• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4366
  • Last Modified:

nagios Status information (null) issue

I can't figure out why a specific command isn't working and giving me a Null result.

The command in question is check_bl.  The command works fine from the command line when logged in as the Nagios user.  It gives the proper result for the mail server I am testing ("Not Listed") and for my home address which I expect ("Listed at...")

nagios@Nagios:/usr/local/nagios/libexec$ ./check_bl -H {server IP obfuscated} -B zen.spamhaus.org bl.spamcop.net dnsbl.ahbl.org
Not black-listed

I saw a thread somewhere about changing the working directory path from the default for check_bl from "/usr/local/nagios/plugins" to "/usr/local/nagios/libexec", which I did so I have ruled that one out'

Anyone else have any ideas on this one?  Thanks in advance!

Jack


The server is Ubuntu 10.10
Nagios® Core™
Version 3.2.3

Command:
#check to see if mail server is on any public RBLs (real time blackhole lists)
define      command      {
      command_name      check_bl
      command_line      $USER1$/check_bl -H $HOSTADDRESS$ -B zen.spamhaus.org bl.spamcop.net dnsbl.ahbl.org dnsbl.njabl.org dnsbl.sorbs.net virbl.dnsbl.bit.nl rbl.efnet.org phishing.rbl.msrbl.net 0spam.fusionzero.com list.dsbl.org multihop.dsbl.org unconfirmed.dsbl.org will-spam-for-food.eu.org blacklist.spambag.org blackholes.brainerd.net blackholes.uceb.org spamsources.dnsbl.info map.spam-rbl.com ns1.unsubscore.com psbl.surriel.com l2.spews.dnsbl.sorbs.net bl.csma.biz sbl.csma.biz dynablock.njabl.org no-more-funn.moensted.dk  ubl.unsubscore.com dnsbl-1.uceprotect.net dnsbl-2.uceprotect.net dnsbl-3.uceprotect.net spamguard.leadmon.net opm.blitzed.org bl.spamcannibal.org rbl.schulte.org dnsbl.ahbl.org virbl.dnsbl.bit.nl combined.rbl.msrbl.net
      }
Service check:


define service {
      host_name            MailServer
      service_description      BLACKLIST
#      is_volatile            0
      check_command            check_bl!{server IP obfuscated}
      max_check_attempts      3
      normal_check_interval      60
      retry_check_interval      60
      active_checks_enabled      1
      passive_checks_enabled      1
      check_period            24x7
      flap_detection_enabled      1
      failure_prediction_enabled      1
      process_perf_data      1
      retain_status_information      1
      retain_nonstatus_information      1
      contact_groups            admins
      notification_interval      240
      notification_period      24x7
      notification_options      c,r
      notifications_enabled      1
#      register            1
      }

0
freymish
Asked:
freymish
  • 3
  • 3
1 Solution
 
nociSoftware EngineerCommented:
Is your hostname / ip address spelled correctly?

The only place to get an error is when an invalid hostname is supplied with -H.
then it returns this error:
Use of uninitialized value $lookupip in substitution (s///) at /usr/lib/nagios/plugins/contrib//check_bl line 141.

Before Not-Blacklisted...

0
 
freymishAuthor Commented:
I double-checked the spelling or the hostname and it is correct.  I also tried replacing $HOSTADDRESS$ with the FQDN of the server  and replacing $USER1$ with the actual path to the script file but that yielded the same result as well.  I was able to cut and paste the check command from the Command Expansion window directly into the console connection, logged in as the nagios user, and it ran just fine.

Argh...
0
 
nociSoftware EngineerCommented:
BTW, don't put !{ipadress} in your service spec. This is meant to pass an Argument (ARG1) to the check command from the service profile. The Hostaddress is passed using it's own variable.  (this is not your problem though)

appearantly your nagios path is: /usr/local/nagios/libexec
so that should consistently be used, where did you change the nagios path
and does it match the path mentioned inside check_bl, there is a use lib "..."
"use util" after that might CRITICAL error.  (exits status 2, with no output to stdout)
That would explain the message given.

The error in stderr is: (is the path inside check_bl is incorrect).
Can't locate utils.pm in @INC (@INC contains: /usr/lib/nagios/plugins/x /etc/perl /usr/lib/perl5/site_perl/5.12.2/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.12.2 /usr/lib/perl5/vendor_perl/5.12.2/i686-linux-thread-multi /usr/lib/perl5/vendor_perl/5.12.2 /usr/lib/perl5/5.12.2/i686-linux-thread-multi /usr/lib/perl5/5.12.2 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/local/lib/site_perl .) at ../contrib/check_bl line 28.
BEGIN failed--compilation aborted at ../contrib/check_bl line 28.


0
Choose an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

 
freymishAuthor Commented:
the {ipaddress} is just in the post in place of the actual IP which I didn't want to advertise.

I did change the check_bl code to reflect the correct path for the file as I mentioned above.

The path change I mentioned was as below:

from:
define      command      {
      command_name      check_bl
      command_line      $USER1$/check_bl [...]

to:

define      command      {
      command_name      check_bl
      command_line      /usr/local/nagios/libexec/check_bl [...]

0
 
nociSoftware EngineerCommented:
In the service description just use:

check_command     check_bl
(ie without the !...... as you don't use $ARG1$ in the command but $HOSTADDRESS$ (btw hostaddress is the correct way).
The change from $USER1$  to a hardcoded path is unwise and unneeded...

please open the check_bl script in an editor (it's a perl script not a program).
In mine there are the following lines:
---8<---
use strict;
use lib "/usr/lib/nagios/plugins/";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::DNS;
---8<---
please verify the that the path after "use lib" is the same as where all your plugins (and utils.pm) are stored.
That utils.pm is included after the use lib, but perl needs to be able to find it.
The cwd of the server processes is / not the plugins directory, so the path needs to be correct for check_bl to find the utils.pm

0
 
freymishAuthor Commented:
OK, I got it.  Turned out to be a dumb spelling issue.  In the check_bl script the path was enumerated as

"/usr/lib/nagios/libexec"

instead of

"/usr/local/nagios/libexec"

When I edited this I looked past the /lib/ part and just saw the /plugins as the only thing that needed to be changed.

Oh well...  apparently attention to detail matters  ;)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now