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 Data

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.


16 thoughts on “Monitor IIS Performance Data with Nagios / NSClient”

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

    1. 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 –


      1. 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

        1. 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.


  2. 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 –

    1. 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. 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


  4. 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?

  5. Hi, philip.

    Could you share the script mentioned in your post about NSclient?
    it is named “Check_IISPerformance_State.ps1”

    Thank you.

  6. Hi, I have problem with ruuning this script in Nagiox XI

    I have configured

    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 240 -c check_iisperformance_state -a $ARG1$

    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 240 -c check_iisperformance_state -a $ARG1$
    in $ARG1$ field I have _Total

    but when I test
    [nagios@nagios ~]$ /usr/local/nagios/libexec/check_nrpe -H -t 240 -c check_iisperformance_state -a _Total
    Missing expression after unary operator ‘-‘.
    At line:1 char:2
    + – <<<<
    + CategoryInfo : ParserError: (-:String) [], ParentContainsErrorR
    + FullyQualifiedErrorId : MissingExpressionAfterOperator|

    Where is the problem?

    1. Hello Wojtek,

      I have two questions.
      1. Does i work when you run the PowerShell-script directly from the PowerShell host using: .\Check_IISPerformance_State.ps1 -OutPowershell ?

      2. What if you try to omit the argument _Total with quotes? check_nrpe -H -t 240 -c check_iisperformance_state -a “_Total”


      1. Hi Philip,
        I’ve changed monitored server and I have better results 🙂
        Have you got a version with warning or critical alerts?

        Your script is excellent.
        .\Check_IISPerformance_State.ps1 -OutPowershell

        PS C:\Program Files\NSClient++\scripts> .\Check_IISPerformance_State.ps1 -OutPowershell
        OK: Current Connections: 13
        Kilobytes Sent/sec: 0
        Kilobytes Received/sec: 1
        Kilobytes Total/sec: 1
        Connection Attempts/sec: 0
        Get Requests/sec: 0
        Head Requests/sec: 0
        Total Method Requests/sec: 0
        Post Requests/sec: 0
        Search Requests/sec: 0
        Files/sec: 0
        File Cache Hits %: 0
        Kernel: URI Cache Flushes: 0
        Kernel: URI Cache Hits %: 0
        Kernel: URI Cache Misses: 0

        Name Value
        —- —–
        ORDER10_Current Connections 13
        ORDER11_Kilobytes Sent/sec 0
        ORDER12_Kilobytes Received/sec 1
        ORDER13_Kilobytes Total/sec 1
        ORDER14_Connection Attempts… 0
        ORDER15_Get Requests/sec 0
        ORDER16_Head Requests/sec 0
        ORDER17_Total Method Reques… 0
        ORDER18_Post Requests/sec 0
        ORDER19_Search Requests/sec 0
        ORDER20_Files/sec 0
        ORDER21_File Cache Hits % 0
        ORDER22_Kernel: URI Cache F… 0
        ORDER23_Kernel: URI Cache H… 0
        ORDER24_Kernel: URI Cache M… 0
        PS C:\Program Files\NSClient++\scripts>

        1. hi wojtek

          i have the same problem, mm i dont understand that part “I’ve changed monitored server”, im testing in a windows server 2012 r2 datacenter but i dont catch the problem.

          thanks in advance

  7. Hi David,

    I think he means that he monitors another Windows Server instead of his initial one which probably didn’t have any data to begin with.

    What do you mean with “I don’t catch the problem”?


Leave a Comment

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