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:

Post by anx »

DOH!!!

I was writing that as you figured it out. :-)

Regarding Exchange from wilperi, I don't have an exchange server, should not be too hard, if I had one. However what I plan next is to do MS Sql server, the windows guys have a few of these and have asked me to look in to it.

felimwhiteley, I should be thanking you, if it wasn't for you blog post non of this would have happened. I had a requirement to manage Windows servers from Unix without touching the Windows servers. I found your post, then found that Zenoss uses wmic, found a dude that had done this for Zenoss and the adapted what he had done. Other people did the smart stuff I just put it together.

I hope the Cacti team realize that this is possible and people that are smarter than me can take wmic and make it truly workable with Cacti. For people that don't know the only real hard part is the output from wmic is a bit wonky, it is not consistent. If wmic just returned the value and not some weird | separated list which is in a different order depending on query it would be easy.

As it is now, you need a script that says "if you request value type A, wmic spits the information out like this, if B, then it spits it out like this".

I happy this is working for other people, took me ages to get it done but I am using a lot of scripts that others have published here so it is nice give a bit back.
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

felimwhiteley wrote: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 ?

Your way is much better, I'm just lazy. I am hoping this is just a stop gap until it gets in Cacti proper. Know anything about this Linux WMI beta plugin? If I'd know that exists I might have tried it.

The only time I'd seen the 0s thing is if the time interval was too short between runs. The average ended up less than 1.
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

I might actually be able to cobble together from one of my other bits of code and my Python wrapper a index based one, got a lot on at the moment so not too sure if I'll have time this week. Hey I could find interesting stuff al day, it's building the bloody templates that annoys me :lol:

No I've not heard of that pluging at all. Whereabouts did you hear it from ?

As for Exchange, I do have access to one so what I might do is rather than rewrite your stuff, give it a go converting some of the existing Windows ones using my python to pull the info. I've actually since discovered it's a python script so I can import the functionality (doh) and not have to parse output... not that it's hard on Python anyway.

Ah ok, see what you mean about the timespan.. would make sense, it's not a busy server either. I'll give it a chance to settle down for a while see if it starts to kick in.
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

Ah strange what happens when you Google ;-)

http://forums.cacti.net/about29392.html

Looks interesting, only thing is I can't STAND the PA. Pain to get going, then upgrades trash it on you. Plus I work with multiple domains so if they are using a master account it really wouldn't work for me... this is based on my 30secs looking at the post.. perhaps it allows multiples.
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

Bingo, I did a couple of searches on the box to push disk usage up and I finally got a reading ! :-)

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

Post by anx »

Excellent! Not so excellent is the timing of the WMI Plugin, if I'd known about that I would have used it, no more clear text passwords..... Also Cigamit would have some nice graphs for this plugin.

Always happens. That's the future and I'll convert these templates over to it at some point. I know it uses the PA but I can see everyone else doing things that way.

The dev has taken in to account multiple accounts, an account can be chosen based on host. Its done by Cigamit, a guy who I have a great deal of respect for and is an awesome developer, it will be the way we do WMI in the future for sure.

Just such bad timing, although I was standing on the shoulders of giants doing this, it took sooo long to do all the templates.
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

I've been working on something similar for my workplace and will post up some of the scripts and templates I setup shortly (being they are based off other open source scripts).

Rather than using Perl I opted for PHP and will be looking at using the script servers to improve performance further. The gist of how I was doing things was using the exec command and pulling in the data from wmic into an array of strings and processing that as required. Then dynamically creating a temp file to store the data between runs as to "cook" the data on the next run for counters that require that.

The one advantage I found using PHP was that when compared to the Perl version I was able to do it in much fewer lines of code and could easily serialize the array data out and un-serialize on the next run. This made things a lot easier to do.

I'm in the process of setting up my SVN repository properly but if anyone is interested in my code let me know and I will swing you the details. I'll upload the details for everyone shortly. I want to clean up my code first ;)

With that kept in mind, I have been having some problems with my disk I/O script where on my work cacti install the first run worked fine, but on the second iteration it failed and just wrote out a null array to the temp file. I can't figure it out for the life of me but it only occurs on the work install of cacti whereas my home one using spine also works fine. My debug logging shows wmic returning data both times but something is freaking it out and dumping out null data. Anyone else had similar issues? Keep in mind the script works fine when run from the command line which is also quite odd.
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

SVN Repo is up
http://svn.parkingdenied.com/CactiWMI/

At some stage I will get around to doing a website.
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

anx wrote:Excellent! Not so excellent is the timing of the WMI Plugin, if I'd known about that I would have used it, no more clear text passwords..... Also Cigamit would have some nice graphs for this plugin.

Always happens. That's the future and I'll convert these templates over to it at some point. I know it uses the PA but I can see everyone else doing things that way.

The dev has taken in to account multiple accounts, an account can be chosen based on host. Its done by Cigamit, a guy who I have a great deal of respect for and is an awesome developer, it will be the way we do WMI in the future for sure.

Just such bad timing, although I was standing on the shoulders of giants doing this, it took sooo long to do all the templates.
The problem with that is the same issue I have with it, the plugin system and the patches required. It's not suitable for us to start rolling our own whereas custom scripts like this are portable and will work between instalations regardless of cacti version etc. I will admit it looks good and the plugin code is meant to be merged into a later build of cacti but for now its somewhat of a pain.
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

anx noticed something odd. I've been running this script against a Win2k3 server using the IP Address. When I switched to DNS name (Actually it's in my /etc/hosts file so should be no lookup problems) it increased the poller time by about 200seconds ! It's only the one host as well and it's the only thing I've changed, I went form about 70secs complete poller time to 273secs. I switched back and forth to verify between hostname and ip address and each time it jumped up and down correspondingly. Bit strange !

Any ideas !? :-?
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

OK, based on something posted in the thread started by cigamet, i got the login part of this utility to work properly. Apparently for the username i needed to do domain\\USERNAME rather than domain\username. So now i am trying to graph disk queue length. I have the scripts, and i have imported the XML file, but now when i try and graph it i get no graph. When i go to graph debug mode i get the following:

Code: Select all

  RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="SSV-MAILBOXES - Disk Queue" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Avg Queue Length" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/var/www/cacti/rra/ssv-mailboxes_avgdiskwritequeuele_4069.rrd":AvgDiskReadQueueLen:LAST \
DEF:b="/var/www/cacti/rra/ssv-mailboxes_avgdiskwritequeuele_4069.rrd":AvgDiskReadQueueLen:MAX \
DEF:c="/var/www/cacti/rra/ssv-mailboxes_avgdiskwritequeuele_4069.rrd":AvgDiskWriteQueueLe:LAST \
DEF:d="/var/www/cacti/rra/ssv-mailboxes_avgdiskwritequeuele_4069.rrd":AvgDiskWriteQueueLe:MAX \
DEF:e="/var/www/cacti/rra/ssv-mailboxes_avgdiskwritequeuele_4069.rrd":AvgDiskQueueLength:LAST \
DEF:f="/var/www/cacti/rra/ssv-mailboxes_avgdiskwritequeuele_4069.rrd":AvgDiskQueueLength:MAX \
AREA:a#7EE600FF:"Reads"  \
GPRINT:a:LAST:" Current\:%8.2lf %s"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n"  \
AREA:c#005D57FF:"Writes":STACK \
GPRINT:c:LAST:"Current\:%8.2lf %s"  \
GPRINT:d:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:d:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:e#000000FF:"Total"  \
GPRINT:e:LAST:" Current\:%8.2lf %s"  \
GPRINT:f:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:f:MAX:"Maximum\:%8.2lf %s\n" 

RRDTool Says:

ERROR: the RRD does not contain an RRA matching the chosen CF
Can someone help. Also, how do i get these disk queue length's for each individual disk, not the total for all disks?

thanks in advance.

app
gumochlon
Posts: 3
Joined: Thu Aug 07, 2008 11:24 am

More Windows statistics from Linux with WMI

Post by gumochlon »

Hi guys,

I need some help regarding WMI Mapper and teh data I get from it using the wmi_stats.pl script.

I tried it to get disk I/O related stats, by using it like this:

wmi_stats.pl Diskiops server1_hostname username password

and for the first day I was getting some results, and then after the weekend I started getting 0s inetad of any values:

DiskReadsPerSec:0 DiskWritesPerSec:0 DiskTransfersPerSec:0

To make it more funny, if I run it against another server taht is exactly same setup as server1 I actually get some values:

DiskReadsPerSec:2 DiskWritesPerSec:146 DiskTransfersPerSec:148

I also get weird CPU related stats,like:

server1:
PercentPrivilegedTime:0.00 PercentUserTime:0.00 PercentProcessorTime:100.00 ProcessorQueueLength:0

server2:
PercentPrivilegedTime:3.99 PercentUserTime:1.95 PercentProcessorTime:-13507.37 ProcessorQueueLength:0

the value of PercentProcessorTime makes me really confued in this case (negative number) ?

Does anybody knows what might be wrong in such case ?

I will appreciate any sort of hint/help whatsoever.

regards,
Gumochlon
PS. if you have any clues , please send a PM to me.
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

Anx,

I really like this, and am currently using Cigamit's CactiEZCD 6 as a test. I can't seem to get the WMIC working correctly, as it complains

/var/www/html/scripts/wmic: error while loading shared libraries: requires glibc 2.5 or later dynamic linker


Any ideas how I can get this working (Linux newbie) ?

Thanks
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
Zotz
Posts: 2
Joined: Fri Oct 13, 2006 8:34 pm

Post by Zotz »

How do I fix the templates to use with Version 0.8.6i ?

I get Error: XML: Hash version does not exist.
when trying to import.

thanks
Zotz
Posts: 2
Joined: Fri Oct 13, 2006 8:34 pm

Post by Zotz »

Zotz wrote:How do I fix the templates to use with Version 0.8.6i ?

I get Error: XML: Hash version does not exist.
when trying to import.

thanks
Figured it out. Duh. Upgrade cacti. I was on a OLD version. All better.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest