Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

Simple HTTP check monitoring plugin on Windows (check_http alternative)
Thursday - Jan 5th 2017 - by - (0 comments)

I was looking for a way to run a monitoring plugin, similar to check_http, on a Windows OS. The plugin itself would be executed through NRPE (using NSClient installation) and result the HTTP connectivity from the point of view of this Windows server.

I came across some scripts, including some tcp port checks (worth to mention: Protocol.vbs), some overblown power shell scripts and also a kind of check_tcp fork for Windows. Unfortunately none of them was really doing what I needed. So I built my own little vbscript put together with the information found on the following pages using the MSXML2.ServerXMLHTTP object :

So at the end the script looks like this:

url = "ENTER_FULL_URL_HERE"
Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.open "GET",url,false
http.send
If http.Status = 200 Then
  wscript.echo "HTTP OK - " & url & " returns " & http.Status
  exitCode = 0
ElseIf http.Status > 400 And http.Status < 500 Then
  wscript.echo "HTTP WARNING - " & url & " returns " & http.Status
  exitCode = 1
Else
  wscript.echo "HTTP CRITICAL - " & url & " returns " & http.Status
  exitCode = 2
End If

WScript.Quit(exitCode)

First define the URL in the first line (e.g. https://www.google.com) and then execute the script using cscript (without cscript you get the script's output as a dialog box):

C:\Users\Claudio\Documents>cscript check_http.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

HTTP OK - https://www.google.com returns 200

Or hitting a page not found error:

C:\Users\Claudio\Documents>cscript check_http.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

HTTP WARNING - https://www.google.com/this-should-not-exist returns 404

There's still much room to improve the script. It would be very nice to use "url" as an argument added in the command line. Maybe I get to that some time.

Finally in the nsclient.ini the script was defined to be called as nrpe command:

; External scripts
[/settings/external scripts]
allow arguments=true
allow nasty characters=true
[/settings/external scripts/scripts]
check_http_google=scripts\\check_http_google.vbs

 

Add a comment

Show form to leave a comment

Comments (newest first):

No comments yet.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

7484 Days
until Death of Computers
Why?