Nagios checking Exchange URL (login required)

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
RyanMule
Posts: 57
Joined: Tue Dec 12, 2017 3:14 pm

Nagios checking Exchange URL (login required)

Post by RyanMule »

Hello All,

I have somewhat of an odd request. To begin we are running Nagios XI 5.5.7 and NSClient++ 5.3.

On our Exchange frontend servers I need to monitor this address https://SERVER/ews/exchange.asmx/wssecurity. Browsing to this address prompts for a login and brings you to a XML page. When that happens all is working. If the XWL page does not load I need to restart the MSExchangeServicesAppPool.

So I need a script/plugin that points to that address, inputs logins info and check XML page.

I apologize for the odd request but any help on talking this will be greatly appreciated.

Thank you
Ryan
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios checking Exchange URL (login required)

Post by mcapra »

RyanMule wrote:this address prompts for a login
A very important question; How is it prompting for a login? Is it using basic authentication? Some sort of form based authentication?

The check_http plugin supports basic authentication via the -a argument:

Code: Select all

     -a, --authorization=AUTH_PAIR
        Username:password on sites with basic authentication
In terms of answering the "did the XML page generate" question, hoo boy there's a lot of options starting with checking response codes (200, 400, 503, etc)

Code: Select all

     -e, --expect=STRING
        Comma-delimited list of strings, at least one of them is expected in
        the first (status) line of the server response (default: HTTP/1.)
        If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)
Checking response headers (Content-Type, XSS, etc):

Code: Select all

     -d, --header-string=STRING
        String to expect in the response headers
Checking body contents (specific XML key/value pairs maybe?):

Code: Select all

     -s, --string=STRING
        String to expect in the content

...

     -l, --linespan
        Allow regex to span newlines (must precede -r or -R)
     -r, --regex, --ereg=STRING
        Search page for regex STRING
     -R, --eregi=STRING
        Search page for case-insensitive regex STRING
     --invert-regex
        Return CRITICAL if found, OK if not
Really depends on the specific site, but check_http can cover an awful lot of ground by itself assuming basic auth is the authentication mechanism.

If you're having to navigate forms-based authentication, I'd recommend the following documentation (specifically the bit about the "web transaction" wizard):
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
RyanMule wrote: I apologize for the odd request
Doesn't strike me as odd :) Login checks are super handy for multiple reasons.
Former Nagios employee
https://www.mcapra.com/
RyanMule
Posts: 57
Joined: Tue Dec 12, 2017 3:14 pm

Re: Nagios checking Exchange URL (login required)

Post by RyanMule »

Hello Mcapra,

Thank you for the quick response!
Yes... I missed that key part... It is form based authentication, so it does complicate it a bit.

I am not looking for anything specific in the XML document just as long as is generated.

This is all great information! I have some work to do and I will provide an update asap

Thank you!

mcapra wrote:
RyanMule wrote:this address prompts for a login
A very important question; How is it prompting for a login? Is it using basic authentication? Some sort of form based authentication?

The check_http plugin supports basic authentication via the -a argument:

Code: Select all

     -a, --authorization=AUTH_PAIR
        Username:password on sites with basic authentication
In terms of answering the "did the XML page generate" question, hoo boy there's a lot of options starting with checking response codes (200, 400, 503, etc)

Code: Select all

     -e, --expect=STRING
        Comma-delimited list of strings, at least one of them is expected in
        the first (status) line of the server response (default: HTTP/1.)
        If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)
Checking response headers (Content-Type, XSS, etc):

Code: Select all

     -d, --header-string=STRING
        String to expect in the response headers
Checking body contents (specific XML key/value pairs maybe?):

Code: Select all

     -s, --string=STRING
        String to expect in the content

...

     -l, --linespan
        Allow regex to span newlines (must precede -r or -R)
     -r, --regex, --ereg=STRING
        Search page for regex STRING
     -R, --eregi=STRING
        Search page for case-insensitive regex STRING
     --invert-regex
        Return CRITICAL if found, OK if not
Really depends on the specific site, but check_http can cover an awful lot of ground by itself assuming basic auth is the authentication mechanism.

If you're having to navigate forms-based authentication, I'd recommend the following documentation (specifically the bit about the "web transaction" wizard):
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
RyanMule wrote: I apologize for the odd request
Doesn't strike me as odd :) Login checks are super handy for multiple reasons.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios checking Exchange URL (login required)

Post by ssax »

If it is using form based authentication you will need to use the check_http -P option:

Code: Select all

 -P, --post=STRING
    URL encoded http POST data
You will need to URL encode the data:

https://www.urlencoder.org/

You will need to work with your application developers to determine what POST data you need to submit such as username/pass/etc.

Something like this may work:

Code: Select all

/usr/local/nagios/libexec/check_http -H SERVER -f follow -u '/ews/exchange.asmx/wssecurity' --method=POST -P 'username=USER&password=PASS&loginButton=' -s 'TEXT TO SEARCH FOR' -S -p 443 --sni
optionstechnology
Posts: 234
Joined: Thu Nov 17, 2016 11:26 am

Re: Nagios checking Exchange URL (login required)

Post by optionstechnology »

FYI: I came across a very similar issue and resolved by monitoring the IIS AppPool itself with check_iis -

https://exchange.nagios.org/directory/P ... ol/details
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Nagios checking Exchange URL (login required)

Post by cdienger »

Glad to hear you found another plugin that seems to work. Are we good to lock this one up?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
RyanMule
Posts: 57
Joined: Tue Dec 12, 2017 3:14 pm

Re: Nagios checking Exchange URL (login required)

Post by RyanMule »

Thank you ssax!

I will look into this option as well.
ssax wrote:If it is using form based authentication you will need to use the check_http -P option:

Code: Select all

 -P, --post=STRING
    URL encoded http POST data
You will need to URL encode the data:

https://www.urlencoder.org/

You will need to work with your application developers to determine what POST data you need to submit such as username/pass/etc.

Something like this may work:

Code: Select all

/usr/local/nagios/libexec/check_http -H SERVER -f follow -u '/ews/exchange.asmx/wssecurity' --method=POST -P 'username=USER&password=PASS&loginButton=' -s 'TEXT TO SEARCH FOR' -S -p 443 --sni
RyanMule
Posts: 57
Joined: Tue Dec 12, 2017 3:14 pm

Re: Nagios checking Exchange URL (login required)

Post by RyanMule »

Yes, this can be locked for now.
cdienger wrote:Glad to hear you found another plugin that seems to work. Are we good to lock this one up?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios checking Exchange URL (login required)

Post by scottwilkerson »

RyanMule wrote:Yes, this can be locked for now.
cdienger wrote:Glad to hear you found another plugin that seems to work. Are we good to lock this one up?
Locking
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked