More Windows statistics from Linux with WMI

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

Moderators: Developers, Moderators

User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

More Windows statistics from Linux with WMI

Post by anx »

This is a bunch of templates that I have done based on the information in this thread:

http://forums.cacti.net/viewtopic.php?p=143046#143046

I have already done one of these for Active Directory stats and that can be found here:

http://forums.cacti.net/viewtopic.php?p=143047

Basically, I really didn't want to add any tools to the Windows servers so this worked the best for me.

What you need:

wmic (see the information I posted in first thread I linked to).

The wmi_stats.pl script below in your cacti scripts directory and you will need to edit the line:

$cmd = "/var/www/cacti/scripts/wmic

to point to where your wmic is if it is not in your scripts directory.

The Perl script is based on the work that James Dastrup did for Zenoss.
Attachments
wmi_stats.pl
(19.63 KiB) Downloaded 1267 times
cacti_graph_template_w32_-_cpu_statistics.xml
(20.43 KiB) Downloaded 853 times
cpu.png
cpu.png (46.85 KiB) Viewed 29767 times
cacti_graph_template_w32_-_memory_usage.xml
(27.65 KiB) Downloaded 999 times
Mem Useage.png
Mem Useage.png (37.75 KiB) Viewed 29767 times
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

Continued:
Attachments
cacti_graph_template_w32_-_memory_paging.xml
(23.23 KiB) Downloaded 657 times
Mem page.png
Mem page.png (42.93 KiB) Viewed 29765 times
cacti_graph_template_w32_-_terminal_sessions.xml
(16.2 KiB) Downloaded 639 times
Term Sessions.png
Term Sessions.png (24.83 KiB) Viewed 29765 times
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

continued:
Attachments
cacti_graph_template_w32_-_disk_queue.xml
(16.28 KiB) Downloaded 609 times
Disk Queue.png
Disk Queue.png (32.33 KiB) Viewed 29763 times
cacti_graph_template_w32_-_disk_busy.xml
(9.24 KiB) Downloaded 630 times
Disk Busy.png
Disk Busy.png (28.72 KiB) Viewed 29763 times
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

Continued:
Attachments
cacti_graph_template_w32_-_disk_ios.xml
(16.23 KiB) Downloaded 749 times
Disk IO.png
Disk IO.png (47.61 KiB) Viewed 29762 times
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

ANX,
This is exactly what i am looking for. I have a couple of questions for you though. I noticed that the password appears to be stored in Clear Text, is this by design, or are there plans to change this in the future. Also, how can i test that this works. I have imported the XML for the Disk Queue length, which is something that my boss has asked me for for a while now with Cacti, and i am getting an error. I downloaded the wmic from your previous post and put it in the scripts directory, on the Cacti log file, i am getting:

Code: Select all

11/04/2008 06:30:09 AM - SPINE: Poller[0] Host[230] DS[3744] WARNING: Result from SCRIPT not valid. Partial Result: ... 
/

Any assistance would be GREATLY appreciated.

thanks

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]
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

I noticed that the password appears to be stored in Clear Text
So did I but if we don't tell anyone we'll be fine. Seriously I don't know how to get around this, it is either a limit with me or with Cacti, I suspect the former. What I did was create a user in the domain that had no access except to wmi, if I learn of a way to avoid this, I will update the scripts. I plan to update these anyway as I add new graphs. Any requests? Might take me a while to get to it though.

I notice you are using Spine, I have never tried to test this with Spine and I'm on the good old cmd poller, I have to switch one day.

I take it you have downloaded the perl script in to your scripts directory also?

The first step to try is to see if the script runs from the cmd line. Very simple:

./wmi_stats.pl <query> <hostname> <username> <password> <tmp_file>

In your case the query would be diskq, to make sure it is not permission try the administrator password.

./wmi_stats.pl diskq 10.1.1.1 administrator adminpass /tmp/dq.tmp

Funny, my boss wanted the diskq stats as well, likely something to do with a flash new SAN he has bought.
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

Here is what i typed:

Code: Select all

 perl wmi_stats.pl diskq 10.100.70.10 ssv\aperrault XXXXXXXXX /tmp/dq.tmp
and here is what i get:

Code: Select all

sh: /var/www/cacti/scripts/wmic: Permission denied
Unknown|No Response
any thoughts?

app
Last edited by apperrault on Wed Nov 05, 2008 3:06 pm, edited 1 time in total.
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

chmod +x /var/www/cacti/scripts/wmic

Fixed (I hope) :-)

Also, might want to remove that password...... Must admit, it is a fairly strong one (until you posted it here).
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

DOH!!!!!!! :o

Ok, now i am getting a different message:

Code: Select all

/var/www/cacti/scripts/wmic: error while loading shared libraries: requires glibc 2.5 or later dynamic linker
Does this mean i am going to have to compile this myself, or should i just be able to install the glibc and have it work?

app
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

Ah Linux... :D

Perhaps I should have compiled it static but then it would have been large. Seems we are on a different version of Glibc, I did build it on a stock Centos 5, which if you are on RedHat 5 should work fine.

Try and compile it, it is real easy to do, might be the easiest solution, glibc is the C libraries, that almost everything needs, mess with them and your whole system will go wacky. If you are on RedHat 4 this would be a reason.
wilperi
Posts: 12
Joined: Mon Sep 03, 2007 6:55 am

Post by wilperi »

Hi

Puf, its working. awesome graphs. Little bit confusion about user rights to wmi but everything works perfectly (also ad statistics). How about exchange 2003 and 2007 templates. I do search from forum but all exchange scripts is usin wmi and nsclient. If i understand right nsclient is no needed anymore?

I also want to ask can this scirpts use via Linux to Windows WMI Plugin - Beta?

Thanks

-wilperi
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

anx these are mostly working ok, but I've got two servers, one where Diskio and diskq works the other were it doesn't, odd thing is on the command line it's fine, jsut the graph is not reading it. Not sure what's going on.

For instance one gives me:
DiskReadsPerSec:1220 DiskWritesPerSec:447 DiskTransfersPerSec:1667

But in the graph it's either nan or 0. Very weird...
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

AH ! I know why, in your script the temp location is

/usr/share/cacti/site/rra/10.0.22.11_wmi_cpu_data

For one of my hosts, but I'm using an Ubuntu Server and it should be
/var/lib/cacti/rra

For the rra directory... Well sorted now, I put a symlink into /usr/share/cacti/

Happy Days !

Great scripts btw in case I didn't mention before ;-)
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

felimwhiteley wrote:anx these are mostly working ok, but I've got two servers, one where Diskio and diskq works the other were it doesn't, odd thing is on the command line it's fine, jsut the graph is not reading it. Not sure what's going on.

For instance one gives me:
DiskReadsPerSec:1220 DiskWritesPerSec:447 DiskTransfersPerSec:1667

But in the graph it's either nan or 0. Very weird...
Got to be related to the fudge.... On some graphs, like diskio and diskq for example, to make sure these graphs work with any polling interval, it writes a file with the stats in the RRA directory. If the file is not there, it is created. First poll it writes the current value to a file, the next poll, it subtracts the current value minus the value already in the file, divide this value by the time between the two is how many diskq or diskio have happened a second.

Damm, I'm not making much sense. Anyway I have a feeling you issue is to do with this uber kludge, I was hoping this didn't get out in to the open :oops: :lol:

Here's how the script is called for diskIOs as a data input method, the part we are interest in is the last value, value 4:

/usr/bin/perl <path_cacti>/scripts/wmi_stats.pl diskiops <hostname> <user> <pass> <path_cacti>/rra/<hostname>_wmi_diskios_data

This is the file: <hostname>_wmi_diskios_data it will be out in your RRA directory. From the command line, I think you are using what I wrote before:


./wmi_stats.pl diskq 10.1.1.1 administrator adminpass /tmp/dq.tmp

You'll see my file is just in the tmp directory. So if it works from the cmd line, this can be the only difference.
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

Yes I *think* I get how it works.. I'm still wiping up after the initial brain melt :-)

I've done a few things like this but what I did was use an index integer, If the file was old/not_there I'd poll for it, but to avoid say where you have 3 items and it polling 3 times I set in the script that only the first one can pull the data if the index query is another number then wait for X secs then read the file... now do YOU get ME ? :lol:

The worst part is after creating the symlink etc. the diskq data went from

31953527000|3963729000|27989798000|898836817000

to

32018257000|3963729000|28054528000|901258777000

But the script still spat out 0's...

So is that the bit you reckon is the problem in your post or do you suspect something different ?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests