[2008-12-16]

Nagios plugin for checking Squid

I once needed a way to make sure our Squid proxy cluster operates correctly. So I wrote a rather simple Squid check plugin for the Nagios monitoring software. Andr√© Moura has pimped it further. Feel free to use it. It’s also available from monitoringexchange.org.

16 thoughts on “Nagios plugin for checking Squid

  • 2009-12-09 at 12:40
    Permalink

     

    Hi,

    As you can see I tried many known and unknown URLs, but never received the correct responce. Very odd.

    root@ABC-1234:/usr/local/nagios/libexec# ./check_squid.pl -u http://www.klunky.co.uk -p fredprox -l 8080 -e200
    CRITICAL – Status: 406 Not Acceptable (but expected 200…)
    root@ABC-1234:/usr/local/nagios/libexec# ./check_squid.pl -u http://www.klunky.co.uk/ -p fredprox -l 8080 -e200
    CRITICAL – Status: 406 Not Acceptable (but expected 200…)
    root@ABC-1234:/usr/local/nagios/libexec# ./check_squid.pl -url=http://www.klunky.co.uk/ -p fredprox -l 8080 -e200
    CRITICAL – Status: 400 URL must be absolute (but expected 200…)
    root@ABC-1234:/usr/local/nagios/libexec# ./check_squid.pl -url=http://www.google.com -p fredprox -l 8080 -e200
    CRITICAL – Status: 400 URL must be absolute (but expected 200…)
    root@ABC-1234:/usr/local/nagios/libexec# ./check_squid.pl -url=http://www.google.com/ -p fredprox -l 8080 -e200
    CRITICAL – Status: 400 URL must be absolute (but expected 200…)
    root@ABC-1234:/usr/local/nagios/libexec# ./check_squid.pl -url=http://www.google.com/index.html -p fredprox -l 8080 -e200
    CRITICAL – Status: 400 URL must be absolute (but expected 200…)
      root@ABC-1234:/usr/local/nagios/libexec#./check_squid.pl -url=http://www.simonloewen.com/ -p fredprox-l 8080 -e200
    CRITICAL – Status: 400 URL must be absolute (but expected 200…)

    root@ABC-1234:/usr/local/nagios/libexec#./check_squid.pl -u http://www.simonloewen.com/ -p fredprox-l 8080 -e200
     CRITICAL – Status: 406 Not Acceptable (but expected 200…)

     

    Best regards, me

     

    Reply
    • 2009-12-24 at 09:14
      Permalink

      Your problem is that you give the last parameter wrong. It is "-e 200" not "-e200" (although -h says so).

      Example:

      check_squid.pl -u http://yahoo.com -p proxy.server.com -l 3128 -e 200

      Good luck!

      Reply
      • 2010-04-20 at 12:30
        Permalink

        Hey there,

        thanks for the nice plugin, its definitely helpful.

        My Problem is, that if i let Nagios execute the check it always returns (null).

        I run it as user nagios manualy and had success:

        ./check_squid.pl -u http://www.google.com -p srvproxy -l 3128 -o USER -m PASS -e 200

        OK – Status: 200 OK

         

        But when i created a service and the command ( i hardcoded everything to eleminate the cause of defect) i just get (null) as result.

         

        define service{
                use                             generic-service                  ; Name of service template to use
                host_name                       srvproxy
                service_description             Squid Service
                check_command                   check_squid
                }

         

        # 'check_squid' command definition
        define command{
                command_name    check_squid
                command_line    $USER1$/check_squid.pl -u http://www.google.com -p srvproxy -l 3128 -o USER -m PASS -e 200
        }

        Is there any known issues ?

        Reply
        • 2010-04-26 at 12:23
          Permalink

          hello,

          i got the same error.

          check the path of line 21.where is your utils.pm?

          Reply
          • 2010-06-05 at 16:34
            Permalink

            Hello all..

             

            I have the problem too..

            Its OK now?

          • 2010-06-05 at 20:27
            Permalink

            I founded the problem..

            in the line use lib, the path is another for me..

            its OK now..

            thankss

          • 2011-06-03 at 10:40
            Permalink

            Can you tell me the path?

          • 2012-10-18 at 01:59
            Permalink

            hello

            In my case , NAGIOS PLUGINS PATH in resource.cfg “/usr/local/nagios/libexec”
            and placed check_squid.pl there.
            On the other hand USE LIB PATH in check_squid.pl is “/usr/lib/nagios/plugins”.
            replace USE LIB PATH in check_squid.pl to “/usr/local/nagios/libexec” and restart nagios.
            Is it ok?

          • 2011-06-03 at 10:41
            Permalink

            Caused I am also get the return code as "null"

        • 2012-04-05 at 09:55
          Permalink

          You need install perl-modules

           

          perl -MCPAN -e shell
           
          cpan> install  HTTP::Request::Common
           
          cpan> install  LWP::UserAgent
           
          cpan> install  HTTP::Headers

           

          Reply
          • 2012-04-05 at 10:48
            Permalink

            AND need change:

             

             19 #use lib "/usr/lib/nagios/plugins";
             20 use lib "/usr/local/nagios/libexec";
        • 2012-05-17 at 11:46
          Permalink

          Hello!
          Same thing here, works from a prompt but does nnot work from within nagios.
          YES, I already checked the lib path and YES I also have utils.pm in the same directory. Matter of fact I have both utils.pm as well as util.sh in the same directory /usr/local/nagios/libexec.
          Hmm, I am lost!

          Reply
  • 2010-06-24 at 15:51
    Permalink

    Hi,

     

    I'm trying to use this script to check if squid authentification it's working fine. My SQUID is using ntlm authentification.

    # /usr/lib/nagios/plugins/check_squid.pl -u http://www.google.com -p 10.0.0.20 -l 3128 -e 200 -o test1 -m dunhill
    CRITICAL – Status: 407 Proxy Authentication Required (but expected 200…)

    Reply
    • 2011-09-06 at 03:34
      Permalink

      Does this work against https:// targets?

      Reply
      • 2011-11-28 at 11:04
        Permalink

        Seems so

         

        use output from the –version option of the plugin itself).
        root@SV:/usr/local/nagios/libexec# ./check_squid.pl  -u http://www.google.de -p 10.0.0.13 -l 3128 -e 200
        OK – Status: 200 OK
        root@SV:/usr/local/nagios/libexec# ./check_squid.pl  -u https://www.google.de -p 10.0.0.13 -l 3128 -e 200
        OK – Status: 200 OK
         

        Reply
        • 2011-12-06 at 07:36
          Permalink

          It shows

          CRITICAL – Status: 403 Forbidden (but expected 200…)

          Reply

Leave a Reply

Your email address will not be published. Required fields are marked *