Hi All!

I must be doing something really stupid or I do not understand
something. I am trying to calculate the %CPU usage on a SuSE Linux 9.0
running net-snmp 5.2.1. I have a script that gets the value once, sleeps
60 seconds, gets the value again, calculates the difference, then
divides this difference by 60 * ticks/second. My assumption is that
ticks/seconds is 100. 

The difference I am calculating is consistantly in the area of
7000-7200. If I divide this by 6000, I have an idle time of just over
1%, thus the CPU usage is 99%. Running top, I see about 60% idle.
Collecting the values locally with snmpget and then doing the math by
hand, I still have a value in the area of 7000. 

In the net-snmp FAQ it talks about problems with multi-processor systems
(which this is), but as I interpret the FAQ the problem is determining
the values for individual CPUs. I am interested in the system idle as a
whole. So this method should work, shouldn't it?

I have included the code that I am using. Maybe the bug is there, but I
can't find it.

Any help would be **greatly** appreaciated. 

Regards,

Jim Mohr


$CPU_OID="UCD-SNMP-MIB::ssCpuRawIdle.0";
$WAIT = 60;
$TICKS = 100;
$first = get_snmp_value($COMMUNITY,$HOST,$CPU_OID);
sleep $WAIT ;
$second = get_snmp_value($COMMUNITY,$HOST,$CPU_OID);
$diff =  $second  - $first;
$cpu_percent0 =  $diff / ($WAIT * $TICKS);
$cpu_percent =  100 - $cpu_percent0 ;


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id5hix
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to