0

I am trying to calculate NIC I/O AVG say for eth0 which is a 10GIG Interface during a specific time frame on my Linux server....I need NIC I/O AVG for One hour during a load test to check to see the impact on NIC and its utilization.....I also cannot install utility/tools like - nload- iptraf,iftop vnstat etc etc ... But it would be good to know any good utility that i can use...

Preferably i like to run a script to capture data and then parse it....ie automate

I have tried below

sar -n Dev 1 1 and do see the rxKb/S and txKB/s but cannot make out the Avg NIC I/O utilization in an hour

Same when trying to use netstat -i

Is there a formula that i can use to get AVG NIC I/O Util for an hour with sar -n or netstat -i......

Any thoughts or suggestions would be greatly appreciated.......

Thank you

  • now=$(date +"%b_%d_%Y-%H:%M") sar -n DEV 1 $1 > nicIO_raw.log & 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 – aavam Aug 23 '17 at 22:14
0

I am using my 10 GIG bond0 interface to calculate NIC I/O. You can change ($5+$6)/***10000000 for 10GIG or 1000000 for 1G interface; they are KB in (decimals***)*100

Below is the script that calculates OS Stats ie 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.