Page 1 of 1

URL monitoring with keyword match

Posted: Mon Jul 17, 2017 7:21 am
by Nishath
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

Re: URL monitoring with keyword match

Posted: Mon Jul 17, 2017 9:55 am
by mcapra
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

Re: URL monitoring with keyword match

Posted: Mon Jul 17, 2017 10:12 am
by Nishath
Can you give me one example with the given URL .

Re: URL monitoring with keyword match

Posted: Mon Jul 17, 2017 10:35 am
by mcapra
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

Re: URL monitoring with keyword match

Posted: Mon Jul 17, 2017 3:04 pm
by tmcdonald
Thanks for the assist, @mcapra!

Re: URL monitoring with keyword match

Posted: Mon Jul 17, 2017 4:08 pm
by tacolover101
@mcapra is correct, throwing this out there - another option is passing the -r flag for regex matching.

Re: URL monitoring with keyword match

Posted: Tue Jul 18, 2017 11:50 am
by tmcdonald
@Nishath let us know if you need further assistance, or if we are okay to close this thread.