URL monitoring with keyword match

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Nishath
Posts: 2
Joined: Mon Jul 17, 2017 6:51 am

URL monitoring with keyword match

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: URL monitoring with keyword match

Post 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
Last edited by mcapra on Mon Jul 17, 2017 10:34 am, edited 1 time in total.
Former Nagios employee
https://www.mcapra.com/
Nishath
Posts: 2
Joined: Mon Jul 17, 2017 6:51 am

Re: URL monitoring with keyword match

Post by Nishath »

Can you give me one example with the given URL .
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: URL monitoring with keyword match

Post 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
Former Nagios employee
https://www.mcapra.com/
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: URL monitoring with keyword match

Post by tmcdonald »

Thanks for the assist, @mcapra!
Former Nagios employee
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: URL monitoring with keyword match

Post by tacolover101 »

@mcapra is correct, throwing this out there - another option is passing the -r flag for regex matching.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: URL monitoring with keyword match

Post by tmcdonald »

@Nishath let us know if you need further assistance, or if we are okay to close this thread.
Former Nagios employee
Locked