The problem is that ssCpuRawIdle means very little without some context. The other ssCpuRaw* OIDs factor in here too.


The best method I found (which may or may not be the correct method) is to collect ALL the CPU OIDs (especially User and Sys, quite possibly Wait too) in order to average them against each other. The clock-time that you use to wait doesn't actually matter.

So its kinda like (in perl parlance):

$user = $user2 - $user1;
$sys  = $sys2  - $sys1;
$idle = $idle2 - $idle1;

$total = $user + $sys + $idle;

$percent_user = $user / $total;
$percent_sys  = $sys  / $total;
$percent_idle = $idle / $total;

You may need more OIDs than this for an accurate picture tho. I'm not sure which ones add up to "100%" but ssCpuRawWait probably has an effect.


Tho since then, I've abandoned that method. Instead I use a small perl script called by SNMP's "exec" handler. The script runs vmstat for 2 cycles and reaps the percentages listed (from the second line) without any extra math being done. I find this to be more accurate, tho I do get error messages about the "exec" feature being deprecated and an incredibly vague pointer to "NET-SNMP-EXTEND-MIB" that allegedy describes the preferred method of doing what I'm doing.


-frank

P.S. If someone can explain to me how to craft my "alternative" exec call I'd really appreciate it. http://www.net-snmp.org/docs/mibs/netSnmpExtendMIB.html has nothing useful on it, and http://www.net-snmp.org/docs/mibs/NET-SNMP-EXTEND-MIB.txt does even less for me.

"Error: Warning: relocatable 'exec' format will change in a future release - See 
'NET-SNMP-EXTEND-MIB' for an alternative"



On Tue, 26 Apr 2005, Mohr James wrote:

Date: Tue, 26 Apr 2005 22:35:35 +0200
From: Mohr James <[EMAIL PROTECTED]>
To: net-snmp-users@lists.sourceforge.net
Subject: Calculationg CPU usage using ssCpuRawIdle

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 Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users



-------------------------------------------------------
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?id=105hix
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to