Commit 9f331cbe authored by Afaq Tariq's avatar Afaq Tariq
Browse files

fixes #350 . Thanks, @j75

parent f93af978
#!/bin/bash
numberOfCores=$(/bin/grep -c 'model name' /proc/cpuinfo)
grepCmd=`which grep`
awkCmd=`which awk`
catCmd=`which cat`
numberOfCores=$($grepCmd -c 'processor' /proc/cpuinfo)
if [ $numberOfCores -eq 0 ]; then
numberOfCores=1
fi
result=$(/bin/cat /proc/loadavg | /usr/bin/awk '{print "{ \"1_min_avg\": " ($1*100)/'$numberOfCores' ", \"5_min_avg\": " ($2*100)/'$numberOfCores' ", \"15_min_avg\": " ($3*100)/'$numberOfCores' "}," }')
result=$($catCmd /proc/loadavg | $awkCmd '{print "{ \"1_min_avg\": " ($1*100)/'$numberOfCores' ", \"5_min_avg\": " ($2*100)/'$numberOfCores' ", \"15_min_avg\": " ($3*100)/'$numberOfCores' "}," }')
echo ${result%?}
\ No newline at end of file
echo ${result%?}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment