nice perl script / processor cpu usage script.

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Post Reply
tyrone
Posts: 4
Joined: Fri Apr 25, 2003 12:34 am

nice perl script / processor cpu usage script.

Post by tyrone »

when using cacti i needed an cpu usage utilisation script

luckaly i found one..


and this perl scripts reads the perflib counters on windows . thus being able to read cpu usage on local and remote machine

check it out

http://www.bybyte.de/jmk/showsource.asp ... process.pl

and

http://www.bybyte.de/jmk/docs/perl5/per ... ample.html

handy to pu into as standard for the windows build.
TYrone / Icecrew
MontyP
Posts: 13
Joined: Mon May 12, 2003 9:56 am
Location: Canada
Contact:

Post by MontyP »

How did you configure the Data Input Sorce for the CPU utilitzation perl script for Win2k?

I'm a little confused on how to get it to work in cacti and I'd appreciate some help.

TIA
tyrone re

RE: nice cpu load monitor script for windows

Post by tyrone re »

i modified the processor.pl perl on line 44

from : printf "Instance $p: %.2f\%\n", $proc_time{$p};
to : printf "%.2f\n", $proc_time{$p};

it will now only output a number

then i made a data input source :

name: cpuload etc
input string perl <path_cacti>/scripts/cpuload.pl
or inputstring : perl <path_cacti>/scripts/cpuload.pl \\servername
outputstring :<cpuload>

source configuration

Name : a uniq name
dataname : topdeskcpuload
output
update = yes

Data Source

data source type = Gauge
select data input type
max val = 100

Graph configuration

use ridged boundaries = yes
vertical label = name

GRaph item configuration

select cpuload
select color
graph item type = AREA
Consoludation functoin = AVERAGE
cdef = none


and now you should have an graph . i am also not so experienced with rrdtool graphs but this is working. only for me when i want a line instead of the funtion area the lines are broken and don't get a nice full line.

any help on that would be great too.

TYrone
MontyP
Posts: 13
Joined: Mon May 12, 2003 9:56 am
Location: Canada
Contact:

Post by MontyP »

Thanks for the insight. Got it working fine now. I guess my follow up questions is this: How would this data get captured on a multi-CPU machine? Not that I have any that I monitor, but this issue will probably come up at some point.

I also noticed that if the machine being polled doesn't have the perflib installed then the CPU load script barfs up this error:

Code: Select all

C:\cacti\scripts>perl win-cpu.pl 53.226.177.94
Can't call method "GetObjectList" on an undefined value at win-cpu.pl line 23.
Can this be trapped so it comes up with a friendlier error message?


On another note, using the edits you gave me works just fine at the command line, but I get a decimal number instead of a whole number. I think this is the reason why I'm not getting anything collected when polled:

Code: Select all

perl c:/cacti/scripts/win-cpu.pl 53.226.179.13
c:/rrdtool/rrdtool.exe update c:/cacti/rra/cpu_53_226_179_13.rrd --template cpu_53_226_179_13 N:U
I have my Data Input set up as follows:

Name: Win-cpuLOAD
Input String: perl <path_cacti>/scripts/win-cpu.pl <computerIP>
Output String: <load>

For Data Input Source Fileds:
Name Data Name I/O Update RRA
------------------------------------------------------
ComputerIP computerIP Input No
CPUload load Output YEs

But I am not getting any numbers for some reason; it does work at the command prompt is I run perl c:\cacti\scripts\win-cpu.pl 53.226.177.92

Any help would be welcome!

TIA,
MP[/code]
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests