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.
nice perl script / processor cpu usage script.
Moderators: Developers, Moderators
nice perl script / processor cpu usage script.
TYrone / Icecrew
RE: nice cpu load monitor script for windows
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
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
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:
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:
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]
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.
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
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]
Who is online
Users browsing this forum: No registered users and 2 guests