[Nagiosplug-help] check_squid.pl cannot run in Nagios ; works from the CLI

JKL junk4 at klunky.co.uk
Wed Dec 9 21:35:57 CET 2009



Resent as it bounced as I sent it from the wrong email address. Opps
> Hi Marc,
>
>     Thank-you for the reply:
>
>   
>> Testing as root, with elevated privileges often leads... 
>>     
> I have the same result when run as Nagios.
>
> nagios at abc1234:/usr/local/nagios/libexec$ ./check_squid.pl -u
> http://www.google.com -p fredprox -l 8080 -e200
> OK - Status: 200 OK
>
> Here it is with 2>&1
> nagios at abc1234:/usr/local/nagios/libexec$ ./check_squid.pl -u
> http://www.google.com -p 10.206.2.131 -l 8080 -e200  2>&1
> OK - Status: 200 OK
>
>
> Marc Powell wrote:
>   
>> On Dec 9, 2009, at 7:49 AM, J4 wrote:
>>
>>   
>>     
>>> I have created a command:
>>> # 'check_squid' command definition
>>> define command{
>>>        command_name    check_squid
>>>        command_line    $USER1$/check_squid.pl -u http://www.google.com
>>> -p fredprox -l 8080 -e200
>>>        }
>>>
>>>
>>>
>>> If I run the script from the command line I have:
>>> # ./check_squid.pl -u http://www.google.com -p fredprox -l 8080 -e200
>>> OK - Status: 200 OK
>>>     
>>>       
>> This isn't really a good test. You should test it as the nagios user. Testing as root, with elevated privileges often leads to different results. Another caveat is that the environment seen by the plugin when run by nagios is much reduced than when run from the command line.
>>
>>   
>>     
>>> [1260361433] SERVICE ALERT: demeter;SQUID;CRITICAL;HARD;4;(null)
>>>     
>>>       
>> (null) means that the plugin isn't sending an output to STDOUT. There might be output being sent to STDERR which you may see by testing from the command line as the nagios user or by adding ' 2>&1' to the end of your command_line above. I expect that you'll likely see complaint about the hostname 'fredprox'. You're depending on an automatic translation to a FQDN, then an IP, which likely isn't happening. Try either using the FQDN or the IP in the command_line.
>>
>>   
>>     
>>> I expect that I do not have a clear understanding (or any understanding)
>>> of the plugins, and find the documentation bewildering, to be frank :(
>>>     
>>>       
>> It's a lot to understand; it will come with time and use.
>>
>>   
>>     
>>> Perhaps, it has something to do with the $USER1$ specification in the
>>> command, but I could not find any documentation about this and what it
>>> was used for.
>>>     
>>>       
>> The $USERx$ macros are special macros that are specified in the resource_file (typically resource.cfg). $USER1$ is usually set at install time to be the path to the plugins. You can see/verify this in resource.cfg.
>>
>> resource_file - http://nagios.sourceforge.net/docs/3_0/configmain.html#resource_file
>> general macro documentation - http://nagios.sourceforge.net/docs/3_0/macros.html
>> list of available macros - http://nagios.sourceforge.net/docs/3_0/macrolist.html
>>
>> --




More information about the Help mailing list