W32 System via WMI

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

Moderators: Moderators, Developers

Post Reply
Author
Message
DevilSun
Cacti User
Posts: 166
Joined: Fri Jul 16, 2004 1:59 pm
Location: Oregon

W32 System via WMI

#1 Post by DevilSun » Mon Oct 18, 2004 11:23 am

Gets System Calls/sec, Context Switches/sec, Threads, Processes via WMI...

Usage:

Code: Select all

perl <path_cacti>/scripts/w32_query_system.pl <hostname>
Tested on Windows 2003 Server platforms...
Attachments
cacti_graph_template_w32_system_statistics.xml
Graph template
(17.78 KiB) Downloaded 1608 times
w32_query_system.pl.txt
Perl script
(3.4 KiB) Downloaded 1913 times
screen.gif
Screenshot
screen.gif (7.96 KiB) Viewed 26534 times

User avatar
eddy
Posts: 32
Joined: Wed Apr 03, 2002 8:48 am
Location: Mississauga, Ontario

errors when executing wmi script

#2 Post by eddy » Mon Oct 18, 2004 4:10 pm

DevilSun please excuse a script fools ignorance :o but when I try to run your script on my Win2K Cacti server like so:

\Apache\htdocs\cacti\scripts>perl w32_query_OperatingSystem.pl localhost index

I get the following error message back:

Can't locate loadable object for module Win32::OLE in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .) at w32_query_system.pl line 4
Compilation failed in require at w32_query_system.pl line 4.
BEGIN failed--compilation aborted at w32_query_system.pl line 4.

What am I missing here?

P.S. thanks for the scripts.

DevilSun
Cacti User
Posts: 166
Joined: Fri Jul 16, 2004 1:59 pm
Location: Oregon

#3 Post by DevilSun » Tue Oct 19, 2004 9:48 am

Now that's interesting...to me that seems like a Perl error, such as it doesn't have the OLE libraries or something. Unfortunately I can't help much with that error, being as this is the first time I've ever used Perl in depth in any environment, let alone on a windows platform.

This is my configuration and I haven't had any problems with it as far as that's concerned:
Win2003 w/ IIS6
Cacti 0.8.6
MySQL 4.0.20a
PHP 4.3.7.7
ActivePerl 5.8.4.810

Really sounds like you are missing a Perl library or two. In my C:\Perl\site\lib directory, I have a Win32 subdirectory with an OLE.pm in it, and also within that, a OLE directory. I'd say it's not recognizing them or they're missing.

User avatar
eddy
Posts: 32
Joined: Wed Apr 03, 2002 8:48 am
Location: Mississauga, Ontario

#4 Post by eddy » Tue Oct 19, 2004 10:48 am

Thanks for the prompt reply.
I solved my problem by unistalling and reinstalling ActivePerl-5.8.4.810.

Now however when I run \perl w32_query_system.pl localhost I get this responce:

Check the computer and class name.
No information was found on the specified class!

Any ideas?

BTW if I run \perl w32_query_operatingsystem.pl I get valid data returned.

DevilSun
Cacti User
Posts: 166
Joined: Fri Jul 16, 2004 1:59 pm
Location: Oregon

#5 Post by DevilSun » Tue Oct 19, 2004 4:23 pm

What OS are you querying?

The script I posted I know works on Win2003, but probably not many others. It's specifically looking at the "Win32_PerfFormattedData_PerfOS_System" class in \root\cimv2, and looking for "Threads,Processes,SystemCallsPersec,ContextSwitchesPersec".

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

Re:

#6 Post by shreekarthik » Tue Oct 19, 2004 5:13 pm

Hi Devilsun,
The program runs on the command prompt and gives all the outputs after talking to WMI but when I try to graph it using cacti I am getting the following error in the cacti log file.

10/19/2004 03:12:37 PM - CMDPHP: Poller[0] Host[0] CMD: perl C:\Apache2\htdocs\cacti/scripts/w32_query_system.pl, output: U
10/19/2004 03:12:37 PM - CMDPHP: Poller[0] Host[0] WARNING: Result from CMD not valid. Partial Result: Display information

My OS is Windows XP. Am I missing something?

Thanks,
Jaya.

User avatar
eddy
Posts: 32
Joined: Wed Apr 03, 2002 8:48 am
Location: Mississauga, Ontario

#7 Post by eddy » Tue Oct 19, 2004 5:27 pm

DevilSun I am running the query against a Win2K server and you are correct the WMI query does not work for Win2K.

I have found another script:w32_query_operatingsystem.pl that will run and I can get memory information when I run the script from the command prompt, but it fails to update the rrd thus no data in the graph.

:o

Thanks for the help I'll keep plugging away and maybe I'll get lucky and find a solution that works.

Guest

#8 Post by Guest » Wed Oct 20, 2004 8:48 am

I have tried to import this script into cacti v8.6b and nothing happens when i select save the page refreshes and there is no text stating what has been imported etc. This is also the case with the SQl server script in an earlier post, but havent had any problems importing any other scripts

Any ideas?

DevilSun
Cacti User
Posts: 166
Joined: Fri Jul 16, 2004 1:59 pm
Location: Oregon

#9 Post by DevilSun » Wed Oct 20, 2004 10:09 am

I haven't been able to use the import file feature for a few versions...it doesn't do anything it seems; however pasting the contents of the file into the text box and importing seems to have always worked for me. Little more work, but at least it works -- I believe it's a cacti 0.8.6x problem that should be fixed soon but am not sure.

otherguy
Posts: 8
Joined: Sat Apr 28, 2007 7:24 pm

#10 Post by otherguy » Mon May 14, 2007 4:22 pm

I am randomly getting cactid failures and gaps on my graphs after adding this script to about 60 hosts. It seems to runs fine if from the command line, but every few polling cycles I get something like this in my logs:

05/14/2007 10:18:09 AM - CACTID: Poller[0] Host[21] DS[963] WARNING: Result from SCRIPT not valid. Partial Result: ...
05/14/2007 10:18:09 AM - CACTID: Poller[0] Host[21] ERROR: The POPEN timed out
05/14/2007 10:18:09 AM - CACTID: Poller[0] Host[21] ERROR: One or more of the file descriptor sets specified a file descriptor that is not a valid open file descriptor.

Occasionally cactid hangs completely and I have to kill the process. Because the failures are so intermittent I am not sure if the problem is with the script or something else.

Where I can look to get more information about what is happening? I've been trying to find out what the "file descriptor" error means but I haven't had any luck so far.

I'm running Cacti 0.8.6j on Windows with Perl 5 and mysql 5.0.37

apperrault
Cacti User
Posts: 372
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

#11 Post by apperrault » Mon May 14, 2007 5:05 pm

Hey OtherGuy, how did you get this graph template to import? I have tried two different times, and I keep getting XML Parse Errors.

Any assistance would be greatly appreciated.

app
[b]Cacti Version[/b] - 0.8.7b
[b]Plugin Architecture[/b] - 2.2 Beta
[b]Poller Type[/b] - CMD.php
[b]Server Info[/b] - Linux 2.6.9-78.0.1.ELsmp
[b]Web Server[/b] - Apache/2.0.52 (Red Hat)
[b]PHP[/b] - 4.3.9
[b]MySQL[/b] - 4.1.22
[b]RRDTool[/b] - 1.2.23
[b]SNMP[/b] - 5.1.2
[b]Plugins[/b][list]Global Plugin Settings (settings - v0.5)
SuperLinks (superlinks - v0.72)
Host Info (hostinfo - v0.2)
Report Creator (reports - v0.3)
Update Checker (update - v0.4)
Realtime for Cacti (realtime - v0.35)
Cacti Log View (clog - v1.1)
RRD File Cleaner (rrdclean - v0.36)
Network Discovery (discovery - v0.9)
Uptime (uptime - v0.4)[/list]

otherguy
Posts: 8
Joined: Sat Apr 28, 2007 7:24 pm

#12 Post by otherguy » Mon May 14, 2007 6:26 pm

I don't know much about the xml errors, but from reading other people's comments I gather that they could happen when you try to import a template that has been created from a newer version. What version of cacti are you running?

FYI- I started noticing more weird issues after I had this script running for a while. In addition to the errors I already posted, MySQL stopped working after another hour or so, reporting "Too many connections" and all sorts of other nasty errors. I had to restart the server and wait about 30 minutes for it to begin working again. I have disabled this script until I have more time to look at it.

dainiookas
Posts: 34
Joined: Fri Dec 05, 2008 5:49 am
Location: Vilnius, Lithuania

CISCO SCE 1000 CPU (3) load template

#13 Post by dainiookas » Fri Mar 20, 2009 5:34 am

Today I had a need of that and couldn't find anywhere else so created it mysql.
Attachments
cacti_graph_template_cisco_sce_-_cpu_usage.xml
(26.11 KiB) Downloaded 696 times

Post Reply