check_squid.pl – nagios plugin

Check correct operation of a Squid Web Proxy server

This check command runs a HTTP request through your proxy. You can use it to check the basic proxy operation, authentication and even authentication on a certain web site. You may check for any HTTP error/result code. So this plugin can be useful for checking that certain server do not allow access without authentication, too.

Get the plugin from Nagios Exchange or this site.

Errors and solutions

Error Solution
Can’t locate utils.pm in @INC (…) at check_squid.pl line 21.
BEGIN failed–compilation aborted at check_squid.pl line 21.
Move the script to nagios plugins folder and run it from there
Can’t locate LWP/UserAgent.pm in @INC (…) at ./check_squid.pl line 22.
BEGIN failed–compilation aborted at ./check_squid.pl line 22.
Install perl’s libwww

wget http://www.cpan.org/modules/by-module/LWP/libwww-perl-5.837.tar.gz
tar -zxvf libwww-perl-5.837.tar.gz
cd libwww-perl-5.837
perl Makefile.PL
make
make install

OR

perl -MCPAN -e 'install Bundle::LWP'

OR, on FreeBSD, install it from ports

# portmaster www/p5-libwww

Usage

Check from command line:

# ./check_squid.pl --url=http://www.facebook.com --proxy=proxy.neant.ro --proxyport 3128 --proxyuser=user --proxypass=pass --status=200
OK - Status: 200 OK

Nagios config, command definition:

# 'check_squid' - tries to access an URL through proxy
define command {
        command_name    check_squid
        command_line    $USER1$/check_squid.pl --proxy=$HOSTADDRESS$ --proxyport=$ARG1$ --proxyuser=$ARG2$ --proxypass=$ARG3$ --url=$ARG4$ --status=$ARG5$
        }

Example service check definition:

define service {
        service_description             squid
        use                             generic-service
        host_name                       proxy
        check_command                   check_squid!3128!squid!squid!http://www.facebook.com!200
        contact_groups                  admins_sms
}