Skip to content

Instantly share code, notes, and snippets.

@9SQ 9SQ/resource_log.sh
Last active Mar 9, 2016

Embed
What would you like to do?
リソースログ取得スクリプト
#!/bin/sh
if [ $# != 2 ]; then
echo "Usage: $0 FILENAME TIME(sec)" 1>&2
exit 0
fi
echo "Start logging"
DATE=`date +%Y%m%d_%H%M%S`
dmidecode >> $1_dmidecode_${DATE}.txt
vmstat -S m -n 1 $2 | awk 'NR>1{OFS=","; $1 = $1;print strftime("%H:%M:%S"),$0; fflush()}' >> $1_vmstat_${DATE}.csv &
sar -n DEV 1 $2 >> $1_network_${DATE}.txt &
sar -P ALL 1 $2 >> $1_cpu_${DATE}.txt &
iostat 1 $2 >> $1_iostat_${DATE}.txt &
wait
echo "Log saved!"
echo " $1_dmidecode_${DATE}.txt"
echo " $1_vmstat_${DATE}.csv"
echo " $1_network_${DATE}.txt"
echo " $1_iostat_${DATE}.txt"
echo " $1_cpu_${DATE}.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.