Skip to content

Instantly share code, notes, and snippets.

@masami256
Created January 8, 2013 07:28
Show Gist options
  • Save masami256/4481966 to your computer and use it in GitHub Desktop.
Save masami256/4481966 to your computer and use it in GitHub Desktop.
sarでログ取り用
#!/bin/sh
if [ $# != 4 ]; then
echo "usage: $0 filename hostname start(hh:mm:ss) end(hh:mm:ss)"
exit 0
fi
fname=$1
hname=$2
start=$3
end=$4
cpu_file=`printf "%s_cpu.csv" $hname`
memory_file=`printf "%s_memory.csv" $hname`
net_file=`printf "%s_net.csv" $hname`
load_file=`printf "%s_load.csv" $hname`
sar -u -f $fname -s $start -e $end | sed 's/\s\s*/,/g' > $cpu_file
sar -r -f $fname -s $start -e $end | sed 's/\s\s*/,/g' > $memory_file
sar -q -f $fname -s $start -e $end | sed 's/\s\s*/,/g' > $load_file
sar -n DEV -f $fname -s $start -e $end | sed 's/\s\s*/,/g' > $net_file
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment