check_pycurl
INTRODUCTION
A nagios / icinga / shinken plugin to check HTTP requests
Written in python. Licensed under GPL v3
Copyright James Powell 2013
DEPENDENCIES
python 2.x with modules:
- pycurl
- yaml
- dnspython
INSTALLATION
Just install the dependencies & copy the binary to your standard path for nagios plugins and configure in nagios (see NAGIOS CONFIGURATION).
USAGE
Usage: check_pycurl [options]
Options:
-h, --help show this help message and exit
-u URL, --url=URL
-f RUNFILE, --runfile=RUNFILE
--test=TEST [code:HTTPCODE|regex:REGEX]
--connect-timeout=CONNECTTIMEOUT
--timeout=TIMEOUT
--proxy=PROXY
--location Follow redirects
--insecure
check_pycurl can run in one of two ways, a simple one-off http check (specify the url with -u) or with a runfile which is written in yaml and can be used to specify multi-stage url checks (eg logging in then checking for success).
By default check_pycurl will test for HTTP 200 code (--test code:200)
An alternate test is for presence of regex in the output (--test regex:t.st)
EXAMPLE RUNFILE
cookiejar: no
urls:
- url: http://jamespo.org.uk
test: code:200
- url: http://yahoo.com
test: code:301
NAGIOS CONFIGURATION
# simple configuration just for HTTP 200 check
define command {
command_name check_pycurl
command_line /usr/local/nagios/plugins/check_pycurl --url $ARG1$
}
# configuration to use runfiles
define command {
command_name check_pycurl_rf
command_line /usr/local/nagios/plugins/check_pycurl -f $ARG1$
}
# host check
define service {
use generic-service
host_name local2
service_description BBC web check
check_command check_pycurl!http://www.bbc.co.uk
}
# runfile check
define service {
use generic-service
host_name local2
service_description Roundcube Login Check
check_command check_pycurl_rf!/opt/nagios/pyc_rf/rc.yml
}