Skip to content

Instantly share code, notes, and snippets.

@9SQ
Last active March 9, 2016 07:09
Show Gist options
  • Save 9SQ/6904fa17bb9b9a4640bd to your computer and use it in GitHub Desktop.
Save 9SQ/6904fa17bb9b9a4640bd to your computer and use it in GitHub Desktop.
リソースログ取得スクリプト
#!/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