Estou usando minha interface 10 GIG bond0 para calcular a E / S da NIC. Você pode alterar ($5+$6)/***10000000
para 10GIG ou 1000000 para a interface 1G; eles são KB em (decimals***)*100
Abaixo está o script que calcula as estatísticas do SO, ou seja, CPU-RAM-DISK-IO (sda) -NIC-IO (bond0):
#!/bin/bash
echo "Please check Path for log folders"
if [ $# -eq 0 ]
then
echo "Please input time in sec for how long you need to capture the OS Stats:
Ex: os_stats.sh 3600 --> for one hour capture"
else
now=$(date +"%b_%d_%Y-%H:%M")
tail -f /var/log/messages > /tmp/ahsan/messagesd_$now.log 2>&1 &
tailpid1=$!
tail -f /var/log/messages > /tmp/ahsan/messages_$now.log 2>&1 &
tailpid2=$!
sar -u 1 $1 > cpu_raw.log &
sar -r 1 $1 > ram_raw.log &
iostat -x 1 $1 > diskIO_raw.log &
sar -n DEV 1 $1 > nicIO_raw.log &
sleep 5
#****************CPU STATS********************
awk '{print $1,$3,$4,$6,$9}' cpu_raw.log > cpu_parse
cat cpu_parse | head -n -1 |tail -n +4 > cpu_tmp
echo "############ CPU STATS ###########" > os_stats.txt
awk '{ total += $3 } END { print "CPU AVG % = "total/NR }' cpu_tmp >> os_stats.txt
sort -k3 -n cpu_tmp |tail -1 | awk '{print "CPU Max % = " $3}' >> os_stats.txt
rm -rf cpu_tmp cpu_parse
#************MEM STATS*****
echo "############ RAM STATS ###########" >> os_stats.txt
cat ram_raw.log | head -n -1 |tail -n +4 > ram_tmp
awk '{ total += $5 } END { print "RAM AVG % = "total/NR }' ram_tmp >>
os_stats.txt
sort -k3 -n ram_tmp |tail -1 | awk '{print "RAM Max % = " $5}' >> os_stats.txt
rm -rf ram_tmp
#************DISK I/O Stats *****
echo "############ DISK I/O STATS ###########" >> os_stats.txt
cat diskIO_raw.log | grep sda |awk '{print $12}' > diskio_tmp
awk '{ total += $1 } END { print "Disk I/O AVG % = "total/NR }' diskio_tmp >> os_stats.txt
sort -k3 -n diskio_tmp | tail -1 | awk '{print "Disk I/O Max % = " $1}' >> os_stats.txt
rm -rf diskio_tmp
#*********NIC I/O Stats******
echo "############ NIC I/O STATS ###########" >> os_stats.txt
cat nicIO_raw.log | awk '/Average/ && /bond0/' |awk '{print "NIC I/O Avg = " sprintf ("%.8f",(($5+$6)/10000000)*100)}' >> os_stats.txt
mv os_stats.txt os_stats_$now.txt
rm -rf os_stats.txt
kill $tailpid1
kill $tailpid2
fi