Posts tagged: Windows

New release with Exchange Monitoring!

It’s been a little while since I have released anything but after a bit of work I have a new version which now supports monitoring Exchange! Previously I had monitored Exchange myself via WMI using a custom PHP script but now this can all be done with a reasonably straight forward set of templates and the generic wmi.php :)

Aside from just supporting Exchange here are the changes below:

  • Now parses out spaces and replaces with an underscore (needed for anything that has a name with spaces in it)
  • Included new debug mode which logs detailed information to a per host text file
  • Code cleanup, should make it a bit easier to configure
  • General tweaking

The biggest issue with Exchange that I encountered was that the store names could have spaces which would throw off Cacti when it interpreted the data being passed to it. But as you can see from below the changes have fixed this issue and allow for some useful monitoring.

004-exchange-activelogons

004-exchange-messages-per-sec

The templates are included in the attached tar file, please note however that the active client logons will need tweaking to suit your system. For me I created two graphs based on the template then removed the template so that the name of each store could be displayed on the graph. You can do this or alternatively do per store graphs however I found it to be overkill and used two graphs of 5 stores each.

The new debug mode logs by default to /tmp but you can adjust this to wherever you like so long as it has the correct permissions. Effectively what you will end up with is a log file per host of the filename dbug_xx.xx.xx.xx where the x’s are your IP. Inside it will contain basically all the variables being passed in and out as well as the direct output from wmic etc. With this you should be able to track whats going on and debug any issues.

So there you have it everything you need to get started. I will have some additional Exchange templates over the next few weeks so stay tuned! For now if you need help leave a message or drop by the Cacti forums. Also one last note you can browse the latest code and check out any build you like from the web based Subversion repository. Check it out at http://svn.parkingdenied.com/

  CactiWMI-0.0.4.r45.tar.gz (39.7 KiB, 417 hits)

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)

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