Created
December 25, 2013 00:53
-
-
Save parnurzeal/8119225 to your computer and use it in GitHub Desktop.
Bash script for taking wanted average data from sar in wanted format.
It needs a time file with have following format. /var/log/sa/sa20
10:00:00 11:00:00
13:30:20 14:10:00
19:30:00 20:00:00
.
.
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -a words | |
SA_FILE=${words[0]} | |
echo $SA_FILE | |
printf "%9s%9s%9s%9s%9s%10s%10s\n" "Start" "End" "%user" "%system" "%iowait" "RX" "TX" | |
while read -a words; do | |
CPU=`sar -f $SA_FILE -s ${words[0]} -e ${words[1]} | grep Average | awk '{print $3" "$5" "$6}'` | |
NETWORK=`sar -n DEV -f $SA_FILE -s ${words[0]} -e ${words[1]} | grep Average | grep em3 | awk '{print $5" "$6}'` | |
printf "%9s%9s%9s%9s%9s%10s%10s\n" ${words[0]} ${words[1]} ${CPU[0]} ${CPU[1]} ${CPU[2]} ${NETWORK[0]} ${NETWORK[1]} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment