W32 CPU (any number of processors) Perl Script via WMI

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Author
Message
shreekarthik
Posts: 13
Joined: Thu Sep 16, 2004 12:32 pm

#16 Post by shreekarthik » Wed Oct 20, 2004 5:52 pm

Thanks for the clarification Devilsun!

anonfoo
Posts: 24
Joined: Thu Nov 18, 2004 12:22 am

#17 Post by anonfoo » Thu Mar 24, 2005 4:38 pm

Would this work if I have cacti installed ona Linux box or does that not matter?

Thomas
Cacti User
Posts: 112
Joined: Thu Dec 09, 2004 1:51 pm
Location: Austria

#18 Post by Thomas » Fri Mar 25, 2005 2:53 am

anonfoo wrote:Would this work if I have cacti installed ona Linux box or does that not matter?
My understanding is that it does matter. Perl doesn't offer Win32::OLE on Linux. But have a look at http://forums.cacti.net/viewtopic.php?t=5842 - there I have summarized all possible ways to get WMI data from windows to CACTI on Linux.

HTH
Thomas Rupp

anonfoo
Posts: 24
Joined: Thu Nov 18, 2004 12:22 am

#19 Post by anonfoo » Fri Mar 25, 2005 9:21 am

cool thanks!

cass
Posts: 2
Joined: Mon Jun 13, 2005 7:11 am
Location: france

#20 Post by cass » Wed Jun 29, 2005 8:57 am

Hi!

I used your scripts to monitor CPUs.I tried this script on my localhost (a WinXP) and it works well, then I tested it on a remote server(a Win2000)...and... no data in my graph...


My config:
Windows XP
apache 2.0.53
cacti 0.8.6d
cactid 0.8.6d
mysql 4.0.24
net-snmp-5.2.1
php-5.0.4
rrdtool-cygwin-1.2.9



When I run php poller.php:


06/29/2005 03:03:23 PM - SYSTEM STATS: Time: 23.1785 s, Method: cmd.php, Processes: 1, Threads: N/A, Hosts: 13, Hosts/Process: 13
06/29/2005 03:03:23 PM - POLLER: Poller[0] CACTI2RRD: c:/rrdtool/rrdtool.exe update C:\Apache2\htdocs\cacti\rra\serveur1_w32_cpu_load_32.rrd --template w32_cpu_load 1120050180:U
06/29/2005 03:03:23 PM - CMDPHP: Poller[0] Time: 22.4457 s, Theads: N/A, Hosts: 12
06/29/2005 03:03:23 PM - PHPSVR: Poller[0] DEBUG: PHP Script Server Shutdown request received, exiting
06/29/2005 03:03:23 PM - CMDPHP: Poller[0] Host[19] CMD: perl C:\Apache2\htdocs\cacti/scripts/w32_query_cpu.pl 192.168.0.14 get LoadPercentage 1, output: U
06/29/2005 03:03:23 PM - CMDPHP: Poller[0] Host[19] WARNING: Result from CMD not valid. Partial Result: Unable to talk to WM
06/29/2005 03:03:18 PM - POLLER: Poller[0] CACTI2RRD: c:/rrdtool/rrdtool.exe update C:\Apache2\htdocs\cacti\rra\serveur2_w32_cpu_load_34.rrd --template w32_cpu_load 1120050180:U
06/29/2005 03:03:17 PM - CMDPHP: Poller[0] Host[19] RECACHE: Processing 3 items in the auto reindex cache for '192.168.0.14'.
06/29/2005 03:03:17 PM - CMDPHP: Poller[0] Host[19] SNMP: Host responded to SNMP
06/29/2005 03:03:17 PM - CMDPHP: Poller[0] Host[16] CMD: perl C:\Apache2\htdocs\cacti/scripts/w32_query_cpu.pl 192.168.0.1 get LoadPercentage 1, output: U
06/29/2005 03:03:17 PM - CMDPHP: Poller[0] Host[16] WARNING: Result from CMD not valid. Partial Result: Unable to talk to WM
06/29/2005 03:03:04 PM - POLLER: Poller[0] CACTI2RRD: c:/rrdtool/rrdtool.exe update C:\Apache2\htdocs\cacti\rra\127_0_0_1_w32_cpu_load_24.rrd --template w32_cpu_load 1120050180:4
06/29/2005 03:03:04 PM - CMDPHP: Poller[0] Host[2] CMD: perl C:\Apache2\htdocs\cacti/scripts/w32_query_cpu.pl 127.0.0.1 get LoadPercentage 1, output: 4

Why for the localhost ouput value it's ok and for remote servers it's done?

Could you help me?!

tman
Cacti User
Posts: 97
Joined: Thu Oct 14, 2004 4:14 pm

#21 Post by tman » Tue Jul 12, 2005 8:21 am

I'm trying to use these scripts to get CPU information from Windows Servers (2000 & 2003), but althought the script is running, when viewing the poller log I get the following errors;

07/12/2005 02:11:04 PM - CACTID: Poller[0] Host[3] DS[33] WARNING: Result from SCRIPT not valid. Partial Result: ...
07/12/2005 02:11:04 PM - CACTID: Poller[0] Host[3] ERROR: Empty result [server1.comm.ad.roke.co.uk]: 'perl C:\Inetpub\wwwroot\cacti/scripts/w32_query_cpu.pl server1 get LoadPercentage 2'

The RRD files are not updated, and the graphs show 'NaN'. If I run this script from the command line, I get the correct results, e.g;

CPU0:1 CPU1:2 etc.

I am running Cacti 0.8.6f on Windows 2000 server.

argon0
Cacti User
Posts: 443
Joined: Fri Mar 12, 2004 1:22 pm

#22 Post by argon0 » Tue Jan 31, 2006 7:31 am

Ah, and here I am trying to duplicate your work.... <groan>...

Except I'm trying to do it without ANY knowledge of how to use WMI along with SNMP.

Just trying to use the standard Host_MIB stuff... (Which should work too).

Argon0
[size=50]No longer a n00by but[/size] not yet an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....

argon0
Cacti User
Posts: 443
Joined: Fri Mar 12, 2004 1:22 pm

#23 Post by argon0 » Tue Jan 31, 2006 8:41 am

ah... no wonder its not graphing - the script uses the win32/OLE.pm ...
[size=50]No longer a n00by but[/size] not yet an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....

ioiioi
Cacti User
Posts: 52
Joined: Mon Mar 28, 2005 8:57 am

#24 Post by ioiioi » Sun Feb 05, 2006 10:12 am

I got a problem with this template.
the perl script works fine when I manually run it:
c:\perl c:/apache2/htdocs/cacti/scripts/w32_query_cpu.pl 192.168.100.26 LoadPercentage 4
CPU0:0 CPU1:1 CPU2:1 CPU3:0
and the debug log as this:
02/05/2006 11:12:23 PM - CMDPHP: Poller[0] Host[18] DS[171] CMD: perl C:/Apache2/htdocs/cacti/scripts/w32_query_cpu.pl 192.168.100.26 get LoadPercentage 4, output: U
so the graphic could not update.
any clue?

ioiioi
Cacti User
Posts: 52
Joined: Mon Mar 28, 2005 8:57 am

#25 Post by ioiioi » Sun Feb 05, 2006 10:20 am

acturally, all WMI scripts are failed to work within cacti, but the single perl scripts could work by manually while cmd.php utilize them, they failed. any body could give me a clue?b

ioiioi
Cacti User
Posts: 52
Joined: Mon Mar 28, 2005 8:57 am

#26 Post by ioiioi » Sun Feb 05, 2006 11:17 pm

I have figured out the problem, the reason is the account's permission, It could not talk to WMI.

chewy009
Posts: 38
Joined: Wed Jun 15, 2005 1:18 pm
Location: Washington State, USA

Does this work with 2k and 2k3

#27 Post by chewy009 » Thu Apr 27, 2006 3:44 pm

I am trying to run this against a 2k server and get no results. Do i need to change the script?

jengstro
Cacti User
Posts: 156
Joined: Tue Nov 15, 2005 12:14 pm

#28 Post by jengstro » Thu May 11, 2006 12:27 pm

Any tips on how to deal with 8 hyperthreaded procs? Each physical processor shows up as two seperate procs as far as the template is concerned. Any help is greatly apprieciated.
[size=75]Cacti - 0.8.6h + patches
PHP - 5.1.2
ZendOptimizer - 2.6.2
FastCGI - 0.6
MySQL - 4.1.15
Cactid - 0.8.6g
rrdtool - 1.2.x
IIS6[/size]

User avatar
rcaston
Cacti User
Posts: 204
Joined: Tue Jan 06, 2004 7:47 pm
Location: US-Dallas, TX
Contact:

#29 Post by rcaston » Thu Jul 13, 2006 11:53 am

ioiioi wrote:I have figured out the problem, the reason is the account's permission, It could not talk to WMI.
what did you do to fix this for yourself?

I'm having the same problem.

law
Posts: 9
Joined: Mon Jul 24, 2006 8:25 pm

#30 Post by law » Mon Jul 31, 2006 9:53 pm

ioiioi wrote:I have figured out the problem, the reason is the account's permission, It could not talk to WMI.
I have similar error but not sure whether its similar cause.
May i know what is your solution.

08/01/2006 10:45:05 AM - CACTID: Poller[0] Host[5] SNMP Result: Host responded to SNMP
08/01/2006 10:45:05 AM - CACTID: Poller[0] Host[4] DS[77] SCRIPT: perl C:/Inetpub/wwwroot/cacti/scripts/w32_query_cpu.pl get LoadPercentage 4, output: U
08/01/2006 10:45:05 AM - CACTID: Poller[0] Host[4] DS[77] WARNING: Result from SCRIPT not valid. Partial Result: ...
08/01/2006 10:45:05 AM - CACTID: Poller[0] Host[4] ERROR: Empty result [sgk-kp2]: 'perl C:/Inetpub/wwwroot/cacti/scripts/w32_query_cpu.pl get LoadPercentage 4'
08/01/2006 10:45:05 AM - CACTID: Poller[0] Host[4] SNMP Result: Host responded to SNMP

Post Reply