Skip to content

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, 419 hits)

{ 12 } Comments

  1. Cesar | December 31, 2008 at 8:25 am | Permalink

    Hello, nice work. I tried your scripts and templates.

    I wonder if you know about a Ethernet interface template and a impression queue template.

    Thank you.

  2. claymen | December 31, 2008 at 11:47 am | Permalink

    I’m not sure which metric you are referring to when you say impression queue but ethernet interfaces are relatively easy to do via WMI. The class you are looking for is from memory Win32_PerfRawData_Tcpip_NetworkInterface most of the values are going to be counters to setup the appropriate data input methods and data templates and you should be able to pull the network stats from that. I was looking to write up a data query similar to the SNMP one for network interfaces but have not had the time to do so just yet.

  3. Nik | January 13, 2009 at 2:54 am | Permalink

    I’ve been tryin to find someway to run these graphs, but can’t seem to find the “wmi-client” for fedora so that I can run it. Can you suggest another wmi client and how I can resolve this problem. Thanks.
    P.S. I’m runin fedora Core 10 and the latest cacti

  4. claymen | January 13, 2009 at 7:15 am | Permalink

    Grab the source package from the Debian repository and build it yourself :)

    Here is the original source file (before the Debian guys make any changes)
    http://ftp.debian.org/debian/pool/main/w/wmi/wmi_0.1.13.orig.tar.gz

    Grab that, install any dependencies and then compile it. We had to do the same thing for CentOS and it works fine :)

  5. Nik | January 14, 2009 at 2:53 am | Permalink

    hey thanks for the response so far, but i did everyting except being able to run the autogen.sh. this is the problem I’m getting

    [root@nagios source]# ./autogen.sh
    ./autogen.sh: running script/mkversion.sh
    ./script/mkversion.sh: ‘version.h’ created for Samba(“4.0.0alpha3-GIT-UNKNOWN”)
    ./autogen.sh: running autoheader -I. -Ilib/replace
    build/m4/check_cc.m4:8: error: AC_REQUIRE: circular dependency of AC_AIX
    lib/replace/autoconf-2.60.m4:182: AC_USE_SYSTEM_EXTENSIONS is expanded from…
    ../../lib/autoconf/specific.m4:454: AC_AIX is expanded from…
    lib/replace/autoconf-2.60.m4:182: AC_USE_SYSTEM_EXTENSIONS is expanded from…
    build/m4/check_cc.m4:8: the top level
    autom4te: /usr/bin/m4 failed with exit status: 1
    autoheader: ‘/usr/bin/autom4te’ failed with exit status: 1
    [root@nagios source]#

    I’ve been researching this all day and can’t seem to find a solution, can you assit me me you have any idea.
    Thanks
    Nik

  6. Nik | January 14, 2009 at 5:11 am | Permalink

    Hey,
    I modified the autogen file $IPATH to reflect the real path of the files and now i’m getting the erros below. Basically it is saying it cannot open the files and i know the files are there.

    [root@nagios source]# ./autogen.sh
    ./autogen.sh: running script/mkversion.sh
    ./script/mkversion.sh: ‘version.h’ created for Samba(“4.0.0alpha3-GIT-UNKNOWN”)
    finished clearing autom4te and include config
    running autoheader paths
    ./autogen.sh: running autoheader /usr/src/downloads/wmi/Samba/source/lib/replace
    /usr/bin/m4:lib/replace/libreplace.m4:362: cannot open `libreplace_cc.m4′: No such file or directory
    /usr/bin/m4:lib/replace/libreplace.m4:363: cannot open `libreplace_ld.m4′: No such file or directory
    /usr/bin/m4:lib/replace/libreplace.m4:364: cannot open `libreplace_macros.m4′: No such file or directory
    /usr/bin/m4:lib/replace/libreplace.m4:365: cannot open `autoconf-2.60.m4′: No such file or directory
    /usr/bin/m4:/usr/src/downloads/wmi/Samba/source/lib/replace:1: read error
    autom4te: /usr/bin/m4 failed with exit status: 1

    Thanks
    Nik
    P.S. at least it seems to be making some progress.

  7. Nik | January 15, 2009 at 4:47 am | Permalink

    ok. i manged to get ./autogen.sh to work after tweaking the files a bit then it tells me to run ./configure and make. Now when i run CPPFLAGS=”-I/usr/include/python2.4″ ./configure i’m geting another error. the error this time is

    ./build/smb_build/main.pl: can’t open ‘main.mk’ at build/smb_build/config_mk.pm line 197.
    0
    I’ve been trying all day to resolve this issues but have been unable to get past this. Even though the file exists. if i try to run ./main.pl main.mk it says the command “mkinclude” not found if i try to run ./main.mk I also get the error that command not found. I can’t seem to get around this one.
    Any help appreciated.
    Thanks
    Nik

  8. claymen | January 15, 2009 at 7:17 am | Permalink

    It would look like a dependency issue. I’m not sure about Fedora but is there any way to say apt-get build-dep samba? Effectively under deb what that would do is grab all the dependencies required to build samba and install them so that when you come to compile it’ll have everything it needs?

    Just looking at the errors your having it looks like some build tool or library is missing but not 100% sure what.

  9. voodooo | February 10, 2009 at 9:56 pm | Permalink

    I Nik. Have you managed geting wmic compiled under Fedora ?

    Tks.

  10. claymen | February 11, 2009 at 7:18 am | Permalink

    Not personally as I don’t use Fedora but I have seen a few others manage to get it working on the cacti forums.

  11. Andrey | May 8, 2009 at 5:40 am | Permalink

    Hey, wmi-client is removed from debian. It looks like they are replacing it with Samba4 but I can’t seem to find how to migrate to using samba4 to do WMI queries. Any suggestions?

  12. claymen | May 15, 2009 at 11:15 pm | Permalink

    Grab the latest source from the zenoss project and just build the wmi-client. With that said they are simply maintaining an external Samba4 source tree with their changes so it’s probably about time they merged it into the main tree.

Post a Comment

Your email is never published nor shared. Required fields are marked *