Linux to Windows WMI Plugin - Beta

Announcements concerning Plugins for Cacti

Moderators: Developers, Moderators

cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Linux to Windows WMI Plugin - Beta

Post by cigamit »

Today I am announcing a plugin that has been a long way coming. This is the first incarnation of the Cacti WMI Plugin. One thing many people have wanted, is the ability to easily query the native WMI client on a Windows box from a Linux box. Well, we are now one step closer.

This plugin currently has no documentation (unless you want to write some!) but I am here to help you as much as I can.

What this plugin does.
---------------------------------------------------------------------------------------------
This plugin adds an integration layer between Cacti and the WMIC Linux binary (GPLv3 License, based upon Samba) , which allows communication directly to the native Windows 2000, XP, 2003 "WMI" client (current source has Vista support, but I can not get it to compile correctly).

Source
---------------------------------------------------------------------------------------------
I provide binaries for 32bit and 64bit CentOS 4.X, but you are free to compile your own from source provided here. I have not modified the source in any way shape or form, so no changes are required from the original.
http://mirror.cactiusers.org/wmi-source.zip
or from the original SVN.
http://dev.zenoss.org/svn/trunk/wmi/

How To
---------------------------------------------------------------------------------------------
Install the plugin the normal PA v1.0 way, by editing the global.php file. I will add v2.0 compatibility shortly. You will need to rename the wmic32 or wmic64 binary to wmic depending on your OS.

This first thing you will notice is a new link under the console, so click it.

Image

The next thing you will need to do is setup an account that has access to the Windows box. So under the Authentication tab, click the Add button. Then fill out the form as so. This information is stored in a semi-encrypted fashion in the database (we have to be able to decrypt it to send it to the Windows box) so be careful about who has access to your database.

Image

Next comes the WMI Query, we will need to build it. Using this builder, we can setup a WMI query to pull the exact information we are needing. To do so you will need to know a bit of information. This is the Class Name, the Keys (Columns), and the Index Key (Unique Column that identifies the item).

I have provided a sample query with the plugin, which I use to pull the number of Exchange emails being sent and received from my Exchange server. I also have one for the SMTP queues if someone wants it.

The Description is the display name for this WMI Query, it holds no other importance. The Query Name is the name that will be used to call this query. It must be unique, and it must contain no spaces. As for the rest, it is taken directly out of the WMI Query you would normally build.

In the example, your WMI query would be like

Code: Select all

SELECT Name, MessagesDelivered, MessagesSent FROM Win32_PerfRawData_MSExchangeIS_MSExchangeISMailbox
From there, you just take the Columns and the Class name out, and put them in their perspective locations. If you do not know what the Index column is (ours is Name), then just manually run the WMI query without it, and Windows adds the Index Column into the results automatically. Just take that extra column name and place it in the appropriate box.

Image

Associating Accounts to Hosts
---------------------------------------------------------------------------------------------
One of the advantages of direct integration, is that we can tell Cacti to use a specific account for a host, and then every WMI query you set will always use that account without you having to do anything. To do this, just goto the Host, and you will find a new drop down listing the Account you previously setup. Just select it, and you are done!

Image

The Data Query, Graph Template, etc....
---------------------------------------------------------------------------------------------
Now that your WMI Query is setup. Now we need to setup a Data Query to properly tell Cacti how to get this information. I currently have some code that will do most of these next parts for you, but they are not ready for prime time just yet, so you will be doing it by hand.

We will be using the script server to do our work, so we will need to first setup a resource XML. I have attached the one used in the example, you can use it as a template to make your own until the plugin does it for you. The important thing to notice is that the script name will never change, nor will you have to write your own script to pull this. The WMI script provided is generic enough to do everything for you.

Then you will need to import the Graph/DataQuery Template provided, or create your own (you can use mine as an example).

You will need to place the wmi-script.php into the /scripts/ directory, and the resource XML (exchange_messages.xml in the example) into the /resource/script_server/ directory.

Missing Exchange Counters
---------------------------------------------------------------------------------------------
Most likely your WMI Exchange Performance counters will not be avaliable (mine were not) until you run the "wmiadap" command from the command line on your Exchange box.


SQL
---------------------------------------------------------------------------------------------
You will need to import the wmi.sql file, but another thing I forgot is that you will need to add a column to your host table. You can do so with this SQL command

ALTER TABLE `host` ADD `wmi_account` INT( 12 ) NOT NULL ;


Download
---------------------------------------------------------------------------------------------
Because of attachment size limits, you can download the plugin here.
http://mirror.cactiusers.org/wmi.zip

The template is included in the zip.
YoMarK
Cacti User
Posts: 89
Joined: Fri Feb 02, 2007 8:36 am
Location: Eindhoven/The Netherlands

Post by YoMarK »

Great work!
Although I use cacti on Windows, this is really great for the people running it on Linux.
deruut
Posts: 2
Joined: Tue Jun 10, 2008 3:13 pm
Location: Goes Nederland

Post by deruut »

Looks good !!!
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

Does anyone know how i would use this to get the Average Disk Queue Length for a couple of my servers?

This is exactly what we are looking for, but I do not know WMI nor do I 100% understand what i would need to do for this to work.

Any assistance would be greatly appreciated.

I would buy you a beer!!! :D

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]
icewalker
Posts: 42
Joined: Tue Sep 09, 2008 2:18 pm

Post by icewalker »

This is great work. I'm curious though about say the Performance Monitors. For instance, let's say I want to graph the CPU Utilization using the Counters available from:

Code: Select all

Select * from Win32_PerfRawData_PerfOS_Processor where Name='_Total'
Unlike the linux raw counters that have 100 ticks per second per processor, the Windows system polls every 100 nanoseconds, or 10,000,000 times a second!!!! (No wonder I need beefier boxes to run it). Getting a graph from the rawCPU under linux is easy because you just need divide the ticks by the number of processors (I wrote a script for this) and the graph comes out magically with the right number (say 3 for 3%)

I was planning on doing a similar thing for Windows. So I'm curious to know if your plugin adjusts for the slices (by dividing by 100,000 in our case)?
apperrault wrote:Does anyone know how i would use this to get the Average Disk Queue Length for a couple of my servers?

This is exactly what we are looking for, but I do not know WMI nor do I 100% understand what i would need to do for this to work.
I'm sure that it will with a little massaging.

And as a side note, has anybody noticed how PercentIdleTime always equalsPercentProcessorTime, no matter the load the system is under. It makes no Sense!!! Somebody please explain that one to me!!
khufure
Cacti User
Posts: 203
Joined: Wed Oct 24, 2007 5:47 pm
Location: San Francisco, CA
Contact:

Post by khufure »

Looks good!

Are there plans to have more pre-built queries included? E.g., CPU counters, total disk i/o, free memory. Alternatively it would be nice to have a global list of queries somewhere in the package.
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

And to think I *just* spent a week or so creating all my own Data Queries, Data Input Methods, Data Templates and Graph Templates...

Looks good though!
fusionx86
Posts: 4
Joined: Fri Oct 17, 2008 11:40 am

Plugin Management v2.1

Post by fusionx86 »

I'm new to cacti and just got it installed. Went through the plugin how-to and got it all setup, but later realized it was version 2.1.

I have have since installed this new plugin, but it doesn't show up under plugin management. I followed the simple steps to install the plugin and also imported the wmi.sql into my cacti database.

Any idea how to adapt this plugin to version 2.1? I'd rather not have to install an older version of plugin framework now. Thanks.
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

You don't have to install an older framework, it will still work, you just have to install it the old way (in global.php). It will not show up in Plugin Management (PA v2.2 fixes that), but it doesn't need to either.
fusionx86
Posts: 4
Joined: Fri Oct 17, 2008 11:40 am

Post by fusionx86 »

Thanks for the information cigamit. Your comments pointed me away from PA 2.1 as a cause which made me look elsewhere. I found a problem with my global.php file and now a "WMI Settings" link shows up under Configuration in the console.

Now for the fun part of playing with this new plugin...
Neilbo
Posts: 36
Joined: Fri Mar 23, 2007 3:31 pm

Post by Neilbo »

I am having trouble compiling.

I am logged in as root and I get the following.

> cd /tmp
> cd Samba/source
> ./autogen.sh
bash: ./autogen.sh: Permission denied

Does this need to be run under shell?
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Anything you execute on linux has to be set to be allowed to execute

chmod +x autogen.sh
Neilbo
Posts: 36
Joined: Fri Mar 23, 2007 3:31 pm

Post by Neilbo »

Thanks for the reply!

I happen to get this now

[root@cacti source]# ./autogen.sh
: bad interpreter: No such file or directory
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

It means it needs the SH shell
#!/bin/sh

Honestly, if you are having trouble at this point, the dependencies are going to be a nightmare for you to fix. What OS are you running on?
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

Arrgh!!! Cigamit, not good timing, I just spent ages on these:

http://forums.cacti.net/viewtopic.php?t ... sc&start=0

:D

Honestly, great work, just wish I'd know about it before I did it my way. Do you think these templates would be easy to convert to your PA plugin?

Anyway, anyone needs a wmic for Centos 5 32 bit, you'll find my compile if you follow that thread.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests