First CactiWMI release! (0.0.3)

Yer yer I know it’s not the first actual release but it’s the first one I am posting up publicly.

CactiWMI is the project I have been working on as a method to monitor Windows servers and applications such as Exchange and SQL from a Linux based Cacti install. To do this it uses a combination of some PHP scripting and the WMI client for Linux which just so happens to be available as a Debian package :)

Anyway I’ve posted up some previous examples of what can be done and they were pretty rough. So here are a few examples of what can be done and what templates are available in the package.

Here we can monitor memory usage, this one showing the physical memory usage compared against the commit limit and the current commited bytes.

002-windows-memory

Simple disk space monitor. It also does not suffer from the SNMP remapping problem where when you add a new disk the OID’s are remapped and thus your stats break.

002-windows-diskspace

Pretty straight forward, disk I/O so you can see what is really going on when you have load problems.

002-windows-diskio

CPU usage, available with templates for 1, 2 and 4 core machines. I will do one for an 8 core machine shortly.

002-windows-cpu

SQL performance. Tested against SQL 2005.

002-sql-performance

Domain controller LDAP stats. If you use a lot of query based distribution groups or use LDAP for external authentication this can be invaluable to see when there are performance problems.

002-ntds-ldap-connections

002-ntds-ldap

NT Domain Controller stats. Both authentications per second as well as the read/write/searches against your domain. Good for performance troubleshooting and detecting rogue applications.

002-ntds-ds

002-ntds-auth

Pretty useful no?

So how to set them up… Grab the package attached to this post. It will contain two PHP scripts and a number of templates. Extract the two files to your Cacti scripts folder and then start editing the wmi-logins.php file. In this file are listed the username/password pairs which are referenced by the script. This separates the credential itself from Cacti meaning your Cacti admins don’t actually need to know your WMI user which you are using to pull the stats. In any case add the credential as per the file which should be pretty self explanitory.

Before we go too much further there are some gotcha’s that need to be taken care of regarding the user you have selected to do the WMI queries. This user needs to both have access to remotely query WMI but also to be able to query the subsystems from WMI. What this means in our case is that the user needs have remote access to WMI, be allowed to remote query and then also to be allowed to access perfmon. From my understanding this is due to perfmon being a subsystem which WMI is accessing and thus the credential being used must also have access to the perfmon counters in order to be able to graph anything. For the WMI portion of things you can get most of the information from this MSDN link http://msdn2.microsoft.com/en-us/library/aa393266.aspx. The basics are you grant the user permission to remote WMI as discussed, you then need to grant the user access to the appropriate WMI namespace, in our case this is CIMV2 and then add the user to the perfmon group which by default the 2003 server and up machines should have. This should grant it all the permission it requires, however if you do have problems test with an admin credential and see if you get results. If you do get results as admin but not as your non-admin user then you have a permission issue.

Ok so thats out of the way now you may need to update the wmi.php file to ensure the correct path to your wmic binary so edit that and ensure it is correct. Additionally you can redirect the location of the wmi-logins.php by editing the appropriate variable. Most of the code should be commented to help explain what it is doing, basically its acting as the glue between Cacti and the wmic results. So everything is in place, all that you need to do is import the templates included and attach them to the hosts you want to graph. The slack way I have been doing things is simply adding the graph to the device or the host template which will auto generate the required data sources when you add the graph however your more than welcome to do the the manual way by adding the data source and then the graph and linking the two. Make sure if you used a different credential name to update the data templates as I have not set them to be a per data source credential reference, you will understand once you take a look. It’s up to you if you need the ability to do per data source credentials for different servers but the option is there should it need to be enabled.

So that should cover everything, add your graphs and start monitoring those hosts! If there are any questions feel free to leave a comment or drop me a PM on the Cacti forums :)

  CactiWMI_0.0.3.zip (51.6 KiB, 669 hits)

Monitoring a Speedstream 4200

Due to a recent ADSL fault I began monitoring the stats from my Speedstream 4200 DSL modem. I figured the Cacti graphs might be handy for anyone else out there in a similar situation. Example graphs are below :) As you can see there was a pretty bad line fault!

syncrate

upstream

downstream

Attached below are the templates required, all that is really needed is a few Get SNMP data sources and away you go :)

  cacti_graph_template_sync_rate.xml (7.3 KiB, 354 hits)

  cacti_graph_template_snr_attenuation.xml (8.4 KiB, 314 hits)

For reference here are the SNMP OID’s required to pull the stats.

Down
Attenuation    .1.3.6.1.2.1.10.94.1.1.2.1.5.2
Sync        .1.3.6.1.2.1.10.94.1.1.4.1.2.2
SNR        .1.3.6.1.2.1.10.94.1.1.2.1.4.2

Up
Attenuation    .1.3.6.1.2.1.10.94.1.1.3.1.5.2
Sync        .1.3.6.1.2.1.10.94.1.1.5.1.2.2
SNR        .1.3.6.1.2.1.10.94.1.1.3.1.4.2

One last thing… I have attached to this post the latest open version of the firmware. As these modems were always branded when sold you may require the open version to get around the VOIP block and also enable a few of the hidden features that were turned off by some resellers.

  Update_D240_A5Y_106-15_j045_v1r.exe (1.8 MiB, 307 hits)

Improved Cacti Traffic Graphs

Traffic graphs in Cacti are alright to begin with but there are a few modifications you can make to both improve the look and usefulness of them.

Something like this…

sexycactigraph

sexycactigraphzoom

Now this isn’t my idea, a member of the Cacti forums put up a rough guide to get people going. You can view this here http://forums.cacti.net/about25415.html. However to make things simple I have attached a template which should take care of the graph template, CDEF and also includes a few other changes. I have split the graph into positive for inbound and negative for outbound traffic and added a total traffic item to the graph which I use to monitor my ADSL traffic over a period of time.

  cacti_graph_template_interface_-_traffic_bitssec.xml (18.4 KiB, 721 hits)

WMI Monitoring with Cacti

Monitoring machines with Cacti is easy when using SNMP but when you start adding Windows servers into the mix it can become a little more difficult. SNMP is available for Windows but it’s quite limited without the use of the old and unsupported perf2mib or the costly SNMP Informant (at least in regards to SQL and Exchange).

Advantages

  • Built in.
  • Plenty of documentation available.
  • Supports most if not all performance counters (Exchange + SQL etc)
  • Reliable.
  • Possibly more secure.

Disadvantages

  • RPC is required which could cause problems with firewalls.
  • Requires an account with access to read WMI data.

The main problem with SNMP is that without spending a substantial amount of money on SNMP Informant or using the unreliable perf2mib it’s quite hard to get any useful results out of it. With WMI you can pull all sorts of information and monitor most performance counters across the system. And there are plenty of example power shell and vbscripts which can be used to monitor and access WMI information, so it’s relatively straightforward to monitor this data if you’re using a Windows server…

But if you’re not running Cacti on Windows you can’t use these scripts or the more common Perl:OLE. However we can rejoice for there is a WMI client available for Linux/Unix operating systems which can be used to harness the power of WMI and of course use Cacti to monitor these machines.

Now there is a plugin available for Cacti which allows you to query WMI whick looks promising but it does require manual patching of your Cacti install with the plugin architecture which is not always a viable option. Instead I have written up some scripts which will wrap around wmic and allow you to easily graph your windows hosts.

Some example graphs.

Disk I/O

CPU Usage

Disk Usage

As you can see they are quite useful and it can only get better as more scripts are made available. For now the PHP scripts and documentation (what little there is at the moment) can be found on my Subversion repository linked below, if you would like to help and expand this project swing me a message. At this stage there is no packaged release but ideally when they are stable and a lot cleaner packages will be made available.

http://svn.parkingdenied.com/CactiWMI