URL monitoring with keyword match

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

URL monitoring with keyword match

Postby Nishath » Mon Jul 17, 2017 7:21 am

There is a requirement from our client for URL monitoring.

The URL should be monitored with the keyword for identifying if the URL is as per the customer requirement.

Could you please let us know the possibilities.

URL: https://www.gebiz.gov.sg keyword: GeBIZ
URL: https://www.gebiz.gov.sg/ptn/loginGeBIZID.xhtml keyword: Password
URL: https://www.gebiz.gov.sg/ptn/monitoring/monitor.xhtml keyword: PDB : Ok
URL: https://www.gebiz.gov.sg/ptn/monitoring/monitor.xhtml keyword: NDB : Ok
URL: https://www.gebiz.gov.sg/ptn/monitoring/monitor.xhtml keyword: S:/ : Ok
Nishath
 
Posts: 2
Joined: Mon Jul 17, 2017 6:51 am

Re: URL monitoring with keyword match

Postby mcapra » Mon Jul 17, 2017 9:55 am

The check_http plugin accepts an argument to do a regular expression or simple string match on a given page's content.

From:
https://nagios-plugins.org/doc/man/check_http.html

-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)

...

-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


These articles will get you set up with Nagios Core and the nagios-plugins suite which includes the aforementioned check_http plugin:
https://support.nagios.com/kb/article/n ... ource.html
Last edited by mcapra on Mon Jul 17, 2017 10:34 am, edited 1 time in total.
Former Nagios employee - https://github.com/mcapra/
User avatar
mcapra
 
Posts: 2561
Joined: Thu May 05, 2016 3:54 pm

Re: URL monitoring with keyword match

Postby Nishath » Mon Jul 17, 2017 10:12 am

Can you give me one example with the given URL .
Nishath
 
Posts: 2
Joined: Mon Jul 17, 2017 6:51 am

Re: URL monitoring with keyword match

Postby mcapra » Mon Jul 17, 2017 10:35 am

I'm also using -S to force https. Edited my original post to include the -s argument to match a string in the content, since -e only looks in the header.

Code: Select all
[root@nagios ~]# /usr/local/nagios/libexec/check_http -H www.gebiz.gov.sg -u / -s "GeBIZ" -S
HTTP OK: HTTP/1.1 200 OK - 47718 bytes in 0.909 second response time |time=0.909456s;;;0.000000 size=47718B;;;0

[root@nagios ~]# /usr/local/nagios/libexec/check_http -H www.gebiz.gov.sg -u /ptn/loginGeBIZID.xhtml -s "Password" -S
HTTP OK: HTTP/1.1 200 OK - 27677 bytes in 0.509 second response time |time=0.509107s;;;0.000000 size=27677B;;;0

[root@nagios ~]# /usr/local/nagios/libexec/check_http -H www.gebiz.gov.sg -u /ptn/loginGeBIZID.xhtml -s "Password312544322543" -S
HTTP CRITICAL: HTTP/1.1 200 OK - string 'Password312544322543' not found on 'https://www.gebiz.gov.sg:443/ptn/loginGeBIZID.xhtml' - 27746 bytes in 1.976 second response time |time=1.976145s;;;0.000000 size=27746B;;;0
Former Nagios employee - https://github.com/mcapra/
User avatar
mcapra
 
Posts: 2561
Joined: Thu May 05, 2016 3:54 pm

Re: URL monitoring with keyword match

Postby tmcdonald » Mon Jul 17, 2017 3:04 pm

Thanks for the assist, @mcapra!
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tmcdonald
Support Manager
 
Posts: 8544
Joined: Mon Sep 23, 2013 8:40 am

Re: URL monitoring with keyword match

Postby tacolover101 » Mon Jul 17, 2017 4:08 pm

@mcapra is correct, throwing this out there - another option is passing the -r flag for regex matching.
User avatar
tacolover101
 
Posts: 148
Joined: Mon Apr 10, 2017 11:55 am

Re: URL monitoring with keyword match

Postby tmcdonald » Tue Jul 18, 2017 11:50 am

@Nishath let us know if you need further assistance, or if we are okay to close this thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tmcdonald
Support Manager
 
Posts: 8544
Joined: Mon Sep 23, 2013 8:40 am


Return to Nagios Core

Who is online

Users browsing this forum: Bing [Bot], Nagios_Admin_M and 27 guests