[mrtg] Re: Need accurate cpu % info using net-snmp and mrtg
Michael Cunningham
crayola at optonline.net
Fri Mar 14 03:27:57 MET 2003
Okay.. now I am beyond confused.. I used
your script Matt (with slight mods) to query the server and
get all the raw snmp cpu data avaliable for solaris. It seems
that everytime I query the server I get the same results.
I know these servers cpu is all over the map constantly.
I tried many different servers from Solaris 2.6 to 8.
Any idea whats wrong?
Thanks,
Mike
Example data:
[root at stats bin]# ./cpu.pl
Active Usage 29
Idle 71
System 11
User 8
Wait 3
Kernel 8
System raw 4506657.000000
User raw 3343142.000000
Wait raw 1090395.000000
Idle raw 30431811.000000
Kernel raw 3416261.000000
4 days, 10:15:29.95
minnie
And 30 minutes later.. The same data..
[root at stats bin]# ./cpu.pl
Active Usage 29
Idle 71
System 11
User 8
Wait 3
Kernel 8
System raw 4521838.000000
User raw 3351129.000000
Wait raw 1094877.000000
Idle raw 30558873.000000
Kernel raw 3426960.000000
4 days, 10:40:32.27
minnie
Mods I made to the script follow..
Snip ....
# OIDs
my $ssCpuRawUser = '.1.3.6.1.4.1.2021.11.50.0';
my $ssCpuRawSystem = '.1.3.6.1.4.1.2021.11.52.0';
my $ssCpuRawWait = '.1.3.6.1.4.1.2021.11.54.0';
my $ssCpuRawIdle = '.1.3.6.1.4.1.2021.11.53.0';
my $ssCpuRawKernel = '.1.3.6.1.4.1.2021.11.55.0';
my $sysUpTime = '.1.3.6.1.2.1.1.3.0';
Snip ....
# total up all the CPU utilizations and then calculate
# system and user utilzation as a percentage of the total.
my $total = ( $system_cpu->{$ssCpuRawSystem} +
$user_cpu->{$ssCpuRawUser} +
$wait_cpu->{$ssCpuRawWait} +
$idle_cpu->{$ssCpuRawIdle} +
$kernel_cpu->{$ssCpuRawKernel}
);
my $system = ($system_cpu->{$ssCpuRawSystem} / $total ) * 100;
my $user = ($user_cpu->{$ssCpuRawUser} / $total ) * 100;
my $kernel = ($kernel_cpu->{$ssCpuRawKernel} / $total ) * 100;
my $wait = ($wait_cpu->{$ssCpuRawWait} / $total ) * 100;
my $idle = ($idle_cpu->{$ssCpuRawIdle} / $total ) * 100;
my $active = (($system_cpu->{$ssCpuRawSystem} +
$user_cpu->{$ssCpuRawUser}
+ $wait_cpu->{$ssCpuRawWait} +
$kernel_cpu->{$ssCpuRawKernel})
/ $total ) * 100;
my $uptime = ($system_uptime->{$sysUpTime});
# print the results for mrtg
printf ("Active Usage %.0f\n",$active);
printf ("Idle %.0f\n",$idle);
printf ("System %.0f\n",$system);
printf ("User %.0f\n",$user);
printf ("Wait %.0f\n",$wait);
printf ("Kernel %.0f\n",$kernel);
printf ("System raw %f\n",$system_cpu->{$ssCpuRawSystem});
printf ("User raw %f\n",$user_cpu->{$ssCpuRawUser});
printf ("Wait raw %f\n",$wait_cpu->{$ssCpuRawWait});
printf ("Idle raw %f\n",$idle_cpu->{$ssCpuRawIdle});
printf ("Kernel raw %f\n",$kernel_cpu->{$ssCpuRawKernel});
> On Wed, 12 Mar 2003, Michael Cunningham wrote:
> >
> > Thankyou for the script Matt. Unfortunatly it appears you are
> > also being affected by the same accuracy problem I am? As I
> understand
> > it, the
> > raw values you are gathering in your script via snmp are
> not real uasge
> > information, its kernal ticks.. In order to get accurate info
> > we need the total number of ticks or what factor to divide
> by based on
> > the
> > platform.
> >
> > Mike
> >
> I think that I am not quite understanding the issue... the
> output from
> the script is relative, so the period of a kernel tick not really
> relevant. Essentially, the result is a dimensionless number.
>
> Have I missed your point about accuracy?
>
> mm
>
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list