-1

I am using snmpget to retrieve raw information from:

ssCpuRawIdle.0
ssCpuRawUser.0
ssCpuRawSystem.0

As I understand they are on 32 bit counters. I also use ifOutOctets and ifInOctets to retrieve the information for network statistics over a period of 60 seconds and then run this equation:

value_1 = 1st reading before 60 second sleep
value 2 = 2nd reading after 60 second sleep
PERIOD = 60


value_1=$1
value_2=$2

if (($value_2 < $value_1)); then
    value_2=$(($value_2 + 4294967296))
fi
RATE=$( bc <<< "scale=2; ($value_2 - $value_1)/$PERIOD")
VALUE=$( bc <<< "scale=2; $RATE * 8")

I was wondering if there is a necessity to do this with the cpu statistics and if so, does anyone know the calculation?

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
RussellW
  • 111
  • 2

1 Answers1

0

The answer is to do it via this way, Apologies did not realise i should have said calculate the percentage. CPU_COUNT is the number of cpus on the target server

value_1=$1
value_2=$2
CPU_COUNT=$3

if (($value_2 < $value_1)); then
    value_2=$(($value_2 + 4294967296))
fi
RATE=$( bc <<< "scale=2; ($value_2 - $value_1)/$PERIOD")
VALUE=$( bc <<< "scale=2; $RATE / $CPU_COUNT")
RussellW
  • 111
  • 2