Monitor Windows via WMI from Cacti on Linux

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

Moderators: Developers, Moderators

Post Reply
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Let me try this from wbemtest
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Or even Ben Coleman's WMI Query tool..

Which gives all the lines if you run this query:


SELECT * FROM Win32_PerfRawData_MSExchangeIS_MSExchangeISMailbox

One line per Mounted DB (+ one for total I think) with a column for each counter....

So if there is a "Count" function in WQL...
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Well this

Code: Select all

<?php 
exec('/var/www/html/plugins/wmi/wmic -U domain/username%password //x.x.x.x "select * FROM Win32_PerfRawData_MSExchangeIS_MSExchangeISMailbox"',$out); 
$count = (count($out)-2); 
echo $count; 
?>
Returns the correct no. of mounted DBs!!

So there should be a way to write a data query to return this data to Cacti, and to set it up as a template, using your wmi stuff.... (particularly the security (username/password) bit of it)....


[EDIT:] Wonders to self if it might be a good idea to include a count with all queries, then realises this would only work on all Select * from queries, where as, atm, each query returns a specific row. To get sensible data from select * query you'd need to use index method to get data... Which must have been what Jimmy did...

So will work on creating a query to get the data into Cacti specifically for Exchange DBs
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Sorted!!!

Thanks for the pointers Claymen, look forwards to your next revision...


If anybody else is interested in this, here's how I did it.

Using Claymen's wmi.php as a template I created a script which returns Count:xx Where xx = no. of rows returned by Query. See attached.

Then I created a Data Template, with three values - hostname, Credentials, and class. Specifying the default values for credentials (in my case cacti, you may want to change this) and class = Win32_PerfRawData_MSExchangeIS_MSExchangeISMailbox

BTW a quick edit of the Class element should give you the ability to count the rows returned by any Query.

And a Data Input Method which took these and queried using the wmi-countrows.php script

Finally created a script graphing the Count value...

These Latter 3 should be in the XML attached, just import this using the Cacti import facility - it should work with any .8.7 version as I'm not doing any CDEF calculations.

Good luck, if you try it out let me know if it works.

I'm not sure if this xml file includes the Data Input Methods/Templates - although it looks as if it does, let me know if you need them separately


I developed this because we occasionally get our Exchange Server dropping Databases - something to do with it being a Virtual Machine, and us using vcbmounter to get a backup...

Now, if Jimmy comes through with the "run script" functionality of thresholds I can script the Exchange Server to remount the DBS if they get dismounted.... (maybe...)



Cheers

Argon0
Attachments
wmi-countrows.rar
Unrar file, and upload to the scripts directory of your Cacti Installation.
(1.85 KiB) Downloaded 194 times
cacti_graph_template_exchange_-_mounted_databases_wmi.xml
Import this using Cacti's import facility
(9.12 KiB) Downloaded 349 times
Example Graph
Example Graph
Exchange Mounted DBs.png (14.89 KiB) Viewed 4829 times
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

..Ignore my previous post if you saw it.

Too hasty.....:( cough, splutter (my fault the error was there in the first place)
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

For everyones reference I have a separate branch which I have hacked in the option to return just the count. I'll have a play around with it to work out how best to implement it long term but it should work out quite nicely.
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

Claymen - is it possible to return the store name and size using the bones of this query ? This is something I'd like to have. (I am talking Exchange)
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

mcutting wrote:Claymen - is it possible to return the store name and size using the bones of this query ? This is something I'd like to have. (I am talking Exchange)
Name is returned by default however I didn't have it set to be stored in the RRD file. I didn't see store size anywhere in the classes but if its there then yer it'd be possible. I'll have a skim over and see if I can spot it.
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Claymen/Mcutting...

I suspect I have brain freeze, but... Is there a way to get this/similar data from a Linux machine?

I've tried the linux and unix templates, but they just give the same data whichever host I point them at (i.e. the same as the local host), I would have thought I could get some, if not all, the data required via SNMP, but....

And I can't believe there are no templates out there...

Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

What do you mean? What exactly were you trying to monitor on your Linux server?

Linux is easy to extend the OID tree :) It makes all this work for Windows just seem that much more difficult...
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

New release 0.0.6-RC1

Post by claymen »

Well the time has come for a new release.

Attached is the 0.0.6-RC1 release. There has been a whole stack of changes but here are the main ones that I can remember (you are welcome to check the SVN logs).

- 0000016: [template] Update templates to suit new input method (claymen) - resolved.
- 0000018: [feature] Backwards compatibility for old argument input method (claymen) - resolved.
- 0000012: [feature] Overhaul how arguments are passed to wmi.php (claymen) - resolved.
- 0000003: [feature] Debug mode via console option (claymen) - resolved.
- 0000013: [feature] Add support for alternate namespaces (claymen) - resolved.
- 0000008: [authentication] Prevent passwords from showing up in process list (claymen) - resolved.
- 0000006: [template] Fix data template MIN & MAX (claymen) - resolved.
- 0000005: [feature] Enterprise Vault Templates (claymen) - resolved.

So basically, much cleaner and added support for alternate namespaces. Better input methods which means adding features later on is easier. A bunch of new templates and of course the security updates. And also added the good ol readme.txt and help info when you run wmi.php without arguments.

One thing to keep in mind with this, although backwards compatibility was added you still need to change your credential reference to a path to the credential file. Basically you no longer need wmi-logins.php instead you specify the path to the credential file as per Samba actually... But for reference it is included in the readme and of course below for you.

Code: Select all

Password file format: Plain text file with the following 3 lines replaced with your details.

                      username=<your username>
                      password=<your password>
                      domain=<your domain> (can be WORKGROUP if not using a domain)
You reference that file and lock down the permissions and then you also no longer have details showing up in your process list :)

So give it a go and if there are any issues please log tickets on the bug tracker so that I can follow them up :) Ideally there won't be any and I can mark this as the final 0.0.6 release.
Attachments
CactiWMI-0.0.6-RC1.zip
(168.92 KiB) Downloaded 278 times
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

At a guess you should be able to just change the credentials in templates and get this propogated....

I shall try this later on today, and leave feedback..

Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
st3rling
Posts: 20
Joined: Thu Mar 16, 2006 12:17 pm

Post by st3rling »

Hello,
I couldn't make any previous versions to work, so I just downloaded latest one claymen posted and I'm having this in my cacti log with debug on:
CMDPHP: Poller[0] Host[8] DS[37] CMD: /usr/bin/php -q /var/www/html/scripts/wmi.php -h '10.32.1.110' -u '/etc/cacti/wmi.pw' -w 'Win32_LogicalDisk' -n '' -k 'DeviceID' -v 'C:' -c 'Size,FreeSpace', output: U
CMDPHP: Poller[0] Host[8] DS[37] WARNING: Result from CMD not valid. Partial Result: U
And this if I run it from the command line (wmi.php debug level set to 1):
[root@localhost ~]# /usr/bin/php -q /var/www/html/plugins/wmi/wmic
--namespace='root\CIMV2' --authentication-file=/etc/cacti/wmi.pw
//10.32.1.110 "SELECT Size,FreeSpace, FROM Win32_LogicalDisk WHERE
DeviceID='C:'"
PHP Warning: Unexpected character in input: ' (ASCII=8) state=1 in
/var/www/html/plugins/wmi/wmic on line 31387

Warning: Unexpected character in input: ' (ASCII=8) state=1 in
/var/www/html/plugins/wmi/wmic on line 31387
PHP Parse error: syntax error, unexpected ':' in
/var/www/html/plugins/wmi/wmic on line 31387

Parse error: syntax error, unexpected ':' in
/var/www/html/plugins/wmi/wmic on line 31387
My Hostinfo:
Cacti Version - 0.8.7c
Plugin Architecture - 2.2
Poller Type - CMD.php
Server Info - Linux 2.6.9-78.0.13.plus.c4smp
Web Server - Apache/2.0.63 (CentOS)
PHP - 5.1.6
PHP Extensions - libxml, xml, wddx, tokenizer, sysvshm, sysvsem, sysvmsg, standard, SimpleXML, sockets, SPL, shmop, session, Reflection, pspell, posix, mime_magic, iconv, hash, gmp, gettext, ftp, exif, date, curl, ctype, calendar, bz2, zlib, pcre, openssl, apache2handler, gd, ldap, mysql, mysqli, PDO, pdo_mysql, pdo_sqlite, snmp, eAccelerator
MySQL - 5.0.68
RRDTool - 1.2.23
SNMP - 5.1.2
Plugins
  • Global Plugin Settings (settings - v0.5)
    Large Site Performane Booster for Cacti (boost - v2.2)
    Device Monitoring (monitor - v0.8.2)
    Network Discovery (discovery - v0.8.5)
    Network Tools (tools - v0.3)
    Syslog Monitoring (syslog - v0.5.2)
    Device Tracking (mactrack - v1.1)
    Login Page Mod (loginmod - v1.0)
    Update Checker (update - v0.4)
    FlowView (flowview - v0.6)
    Host Info (hostinfo - v0.2)
    Error Images (errorimage - v0.1)
    PHP Network Weathermap (weathermap - v0.95b)
    docs
    Cacti-ReportIt (reportit - v0.6.1)
    Router Configs (routerconfigs - v0.1)
    WMI Query (wmi - v0.1)
    Realtime for Cacti (realtime - v0.35)
Thank you for any help!
st3rling
Posts: 20
Joined: Thu Mar 16, 2006 12:17 pm

Post by st3rling »

Hmm, I think it's working now. I downloaded wmic from this post (http://forums.cacti.net/about29392.html), replaced the one that was already on the system, and it's working now. Claymen, thank you very much for great plugin!
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Claymen, just wondering if you are planning on upgrading to .8.7d in the near future?

If not, is there any particular reason (beyond the CDEFs) that you are not?

Argon0
No longer a n00by, probably, by now an 0ldby

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

Who is online

Users browsing this forum: No registered users and 6 guests