Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_squid_ng
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
check_squid is a plugin to nagios for monitoring Squid by using squidclient
Wrote in perl, It require NAGIOS::Plugin to work.
Actualy in version 1.01
Memeory-Patch for squid 3.5.20 (CentOS-7.3)
Wrote in perl, It require NAGIOS::Plugin to work.
Actualy in version 1.01
Memeory-Patch for squid 3.5.20 (CentOS-7.3)
Reviews (2)
byrmtzcx, January 22, 2019
First, thanks for sharing. The script works fine when squid is running fine, however when squid is not running or you send invalid data (-d) the script doesn't return an error.
# Works fine as long as squid is up and running:
~]$ ./check_squid -H myproxy.server.tld -p 3128
SQUID OK - Squid have 12 clients and 0 ICP requests queued | 'HTTP requests'=4735c;; 'sent ICP requests'=0c;; 'received ICP requests'=0c;;
# No errors or messages when you send invalid data (-d):
~]$ ./check_squid -H myproxy.server.tld -p 3128 -d blah
~]$
# Warnings, but no errors if squid is not running:
~]$ sudo systemctl stop squid
~]$ ./check_squid -H myproxy.server.tld -p 3128
ERROR: Cannot connect to 192.168.x.x:3128
ERROR: Cannot connect to 192.168.x.x:3128
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
SQUID OK - Squid have clients and ICP requests queued | 'HTTP requests'=c;; 'sent ICP requests'=c;; 'received ICP requests'=c;;
Apply the patch below to fix both issues above:
1. Download check_squid file
1. Save the patch below as check_squid.patch
2. Apply the patch to check_squid with: patch -i check_squid.patch check_squid
--- check_squid.a 2019-01-22 08:48:59.104963842 -0600
+++ check_squid.b 2019-01-22 08:45:39.348819397 -0600
@@ -122,8 +122,11 @@
@exec = ("-h", "\Q$host", "-p", "\Q$port", "-U", "\Q$user", "-W", "\Q$password", "mgr:info");
-@result = `$squidclient @exec`;
+@result = `$squidclient @exec 2>&1`;
+if ($? != 0) {
+ $np->nagios_exit('CRITICAL', @result);
+}
my $fd_available;
my $fd_used;
@@ -286,6 +289,8 @@
}
+$np->nagios_exit('WARNING', "Invalid data (-d)");
+
# $np->nagios_exit('OK', $output);
# $np->nagios_exit('WARNING', $output);
# Works fine as long as squid is up and running:
~]$ ./check_squid -H myproxy.server.tld -p 3128
SQUID OK - Squid have 12 clients and 0 ICP requests queued | 'HTTP requests'=4735c;; 'sent ICP requests'=0c;; 'received ICP requests'=0c;;
# No errors or messages when you send invalid data (-d):
~]$ ./check_squid -H myproxy.server.tld -p 3128 -d blah
~]$
# Warnings, but no errors if squid is not running:
~]$ sudo systemctl stop squid
~]$ ./check_squid -H myproxy.server.tld -p 3128
ERROR: Cannot connect to 192.168.x.x:3128
ERROR: Cannot connect to 192.168.x.x:3128
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
SQUID OK - Squid have clients and ICP requests queued | 'HTTP requests'=c;; 'sent ICP requests'=c;; 'received ICP requests'=c;;
Apply the patch below to fix both issues above:
1. Download check_squid file
1. Save the patch below as check_squid.patch
2. Apply the patch to check_squid with: patch -i check_squid.patch check_squid
--- check_squid.a 2019-01-22 08:48:59.104963842 -0600
+++ check_squid.b 2019-01-22 08:45:39.348819397 -0600
@@ -122,8 +122,11 @@
@exec = ("-h", "\Q$host", "-p", "\Q$port", "-U", "\Q$user", "-W", "\Q$password", "mgr:info");
-@result = `$squidclient @exec`;
+@result = `$squidclient @exec 2>&1`;
+if ($? != 0) {
+ $np->nagios_exit('CRITICAL', @result);
+}
my $fd_available;
my $fd_used;
@@ -286,6 +289,8 @@
}
+$np->nagios_exit('WARNING', "Invalid data (-d)");
+
# $np->nagios_exit('OK', $output);
# $np->nagios_exit('WARNING', $output);
bymicoots, December 28, 2017
Using the latest squid with CentOS 7.3.1611.
Squid is configured to only allow proxy authenticated users to access it, which includes squidclient.
The Nagios plugin script defines the call to squidclient as:
@exec = ("-h", "\Q$host", "-p", "\Q$port", "-U", "\Q$user", "-W", "\Q$password", "mgr:info");
which is incorrect, since the -U and -W must be -u and -w for squidclient.
So modifying to:
@exec = ("-h", "\Q$host", "-p", "\Q$port", "-u", "\Q$user", "-w", "\Q$password", "mgr:info");
makes the script work.
Note that the error output of:
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
is only there because the script doesn't check whether it has access to the cache manager, so when it's blocked outputs that error. When it has access to the cache manage (when the proxy auth works) then the output will be properly returned.
What this means, is if you are getting the error above, YOU ARE NOT authenticating successfully to the Squid proxy server. You can check this with a squidclient command of:
squidclient -h 10.2.40.78 -p 3128 -u someuser -w somepasword mgr:info
which will confirm whether you have access or not (change someuser and somepassword to whatever you have for the proxy auth).
If the above squidclient command works for you and you don't get an "access denied" output, then the modification of the one line above will also work for you with the output being like:
SQUID_NG OK - Squid have 2 clients and 0 ICP requests queued | 'HTTP requests'=3c;; 'sent ICP requests'=0c;; 'received ICP requests'=0c;;
Squid is configured to only allow proxy authenticated users to access it, which includes squidclient.
The Nagios plugin script defines the call to squidclient as:
@exec = ("-h", "\Q$host", "-p", "\Q$port", "-U", "\Q$user", "-W", "\Q$password", "mgr:info");
which is incorrect, since the -U and -W must be -u and -w for squidclient.
So modifying to:
@exec = ("-h", "\Q$host", "-p", "\Q$port", "-u", "\Q$user", "-w", "\Q$password", "mgr:info");
makes the script work.
Note that the error output of:
Use of uninitialized value in sprintf at /usr/share/perl5/vendor_perl/Nagios/Plugin/Performance.pm line 68.
is only there because the script doesn't check whether it has access to the cache manager, so when it's blocked outputs that error. When it has access to the cache manage (when the proxy auth works) then the output will be properly returned.
What this means, is if you are getting the error above, YOU ARE NOT authenticating successfully to the Squid proxy server. You can check this with a squidclient command of:
squidclient -h 10.2.40.78 -p 3128 -u someuser -w somepasword mgr:info
which will confirm whether you have access or not (change someuser and somepassword to whatever you have for the proxy auth).
If the above squidclient command works for you and you don't get an "access denied" output, then the modification of the one line above will also work for you with the output being like:
SQUID_NG OK - Squid have 2 clients and 0 ICP requests queued | 'HTTP requests'=3c;; 'sent ICP requests'=0c;; 'received ICP requests'=0c;;