Monitor IIS Performance Data with Nagios / NSClient

I’ve been working on a script for our customers so we more accurately can measure the load on IIS Websites using Nagios.
Currently the script only gets the performance data and outputs an OK (exitcode 0). In the future I will implement  WARNING and CRITICAL the performance values we need.

Example graph from a labserver.
IIS:Performance Check

Feel free to use and modify this script as you like.

Note: Script is tested on  Windows Server 2008R2, 2012 and 2012R2 servers. Not tested on Windows Server 2008 but I suppose that it may work. Script is developed with Powershell 2.0 support. Don’t ask me why. 🙂

DISCLAIMER: This script is published on “As Is” basis. I will not take any responsibility for any damage this script might do to your production or test server environment. Please ensure that you test this properly in a non-production environment before running or scheduling the script in a production environment.

 

8 thoughts on “Monitor IIS Performance Data with Nagios / NSClient

  1. amit June 26, 2016 / 7:36 am

    Hello,
    I really appreciate your sharing 🙂
    I would like to ask how can i implement this script in my Nagios environment?
    Thanks

    • Gonjer June 27, 2016 / 9:33 am

      Hello Amit,
      You need to add a new Command in Nagios, example
      Name: check_iisperformance_state
      Commandline: $USER1$/check_nrpe -H $HOSTADDRESS$ -t 120 -c check_iisperformance_state -a ‘$ARG1$’

      When that command is added you can either create a Service Template or a new custom Template added to a host. An argument is needed for the script to check a specific site or all sites. To check all sites the argument is “_Total”.

      In the nsclient.ini / NSC.ini file add the following:

      check_iisperformance_state = cmd /c echo scriptsCheck_IISPerformance_State.ps1 -WebSite $ARG1$; exit($lastexitcode) | powershell.exe -command –

      /Philip

      • Vinod January 6, 2017 / 6:51 am

        hi configured it in nagios but am getting all results as Zero in nagios . When chek with power shell in server I can get the status correctly

        • Gonjer January 9, 2017 / 1:58 pm

          Hi Vinod!

          The “check command” in Nagios how is it configured?
          An example of the setup is:
          $USER1$/check_nrpe -u -H $HOSTADDRESS$ -p 5666 -t 120 -c check_iisperformance_state -a ‘$ARG1$’

          In the nsclient.ini file add the following:
          check_iisperformance_state = cmd /c echo scriptsCheck_IISPerformance_State.ps1 -WebSite $ARG1$; exit($lastexitcode) | powershell.exe -command –

          The default input in the Service Template should be “_Total” to monitor all IIS sites.

          Regards
          Philip

  2. david May 4, 2017 / 7:28 pm

    What is the service template look like for the host cfg. I know this is a little old, but am trying to get this to work.

    I think i’m missing something.

    Failed to parse arguments for command using old split string method: unknown escape sequence: cmd /c echo scriptsCheck_IISPerformance_State.ps1 -WebSite $ARG1$; exit($lastexitcode) | powershell.exe -command –

    • Gonjer May 4, 2017 / 9:57 pm

      Hello David

      The check command on your Nagios server (OP5, Centreon, XI etc) should look similar to:
      $USER1$/check_nrpe -u -H $HOSTADDRESS$ -p 5666 -t 60 -c check_iisapplicationpool_state -a ‘$ARG1$’

      The service template model in our environment uses the default “generic-service” with “Check Command” check_iisapplicationpool_state.
      The arguments in the service template is named as “Excludes” and the value for the template is the string “empty”.

      In the Check Command, have you specified any Argument Description (Excludes) or Argument Examples ‘!”empty”‘.

  3. Nicolas June 20, 2017 / 10:18 am

    Hello Gonjer,

    Thanks you for the script, working perfectly! Great work 🙂

    But Im still searching how do you have the graph with all values because on my Nagios interface, i just have a graph on the current connection value and not on all the extended status values information. Do I Have to configure something else or should it be automatic ?

    Regards from Paris

    NB

  4. Mario November 14, 2017 / 4:15 pm

    Hello Gonjer,

    I’m becoming crazy with this script, cause I have regularly followed your instructions, but it works perferctly when I start it with power shell on my server, whereas I’ve received blank graph on my Nagios dashboard.
    Please can you help me?

Leave a Reply

Your email address will not be published. Required fields are marked *