NRPE: Unable to read output

Matthew Litwin mlitwin at stubhub.com
Thu Sep 3 22:30:21 CEST 2009


I guess I should include the plugin script:

#!/usr/bin/perl -w

#check for item count in ListingCatlogue URL

use POSIX;
use strict;
use File::Basename;
use Getopt::Long;


use vars qw(
            $opt_critical
            $opt_warning
            $opt_username
            $opt_password
            $opt_instance
            $opt_help
            $opt_usage
            $opt_version
           );

sub print_usage();
sub print_help();

#
# Version and Author info
my $author = "Matthew Litwin";
my $datemod = "September 2, 2009";
my $version = "0.1.0";
# 0.1.0 - initial cannibalization from check_lcs_update.pl

my $progname = basename($0);

my %ERRORS = ('UNKNOWN'  => '-1',
              'OK'       => '0',
              'WARNING'  => '1',
              'CRITICAL' => '2');

my $sqlplus = '/opt/oracle/product/10gRac/bin/sqlplus';
my $sqlfile = '/usr/local/nagios/libexec/check_scrub_backlog.sql';

Getopt::Long::Configure('bundling');
GetOptions
  (
   "c=s" => \$opt_critical, "critical=s" => \$opt_critical,
   "w=s" => \$opt_warning,  "warning=s"  => \$opt_warning,
   "u=s" => \$opt_username, "username=s" => \$opt_username,
   "p=s" => \$opt_password, "password=s" => \$opt_password,
   "i=s" => \$opt_instance, "instance=s" => \$opt_instance,
   "h"   => \$opt_help,     "help"       => \$opt_help,
                            "usage"      => \$opt_usage,
   "V"   => \$opt_version,"version"    => \$opt_version
  ) || die "Try `$progname --help' for more information.\n";

sub print_usage() {
  print "Usage: $progname -w WARNING -c CRITICAL -u username -p password -i
instance\n";
  print "       $progname --help\n";
  print "       $progname --version\n";
}

sub print_help() {
  print "$progname - check item count in ListingCatlogue URL\n";
  print "Options are:\n";
  print "  -c, --critical\n";
  print "  -w, --warning\n";
  print "  -u, --username\n";
  print "  -p, --password\n";
  print "  -i, --instance\n";
  print "  -h, --help                      display this help and exit\n";
  print "      --usage                     display a short usage
instruction\n";
  print "  -V, --version                   output version information and
exit\n";
}

if ($opt_help) {
  print_help();
  exit $ERRORS{'UNKNOWN'};
}

if ($opt_usage || !($opt_critical && $opt_warning && $opt_username &&
$opt_password && $opt_instance && $opt_instance))  {
  print_usage();
  exit $ERRORS{'UNKNOWN'};
}

if ($opt_version) {
  print "$progname $version\n";
  print "$author, $datemod\n";
  exit $ERRORS{'UNKNOWN'};
}

if (!-x $sqlplus) {
  print "sqlplus not found or not executable at: $sqlplus\n";
  exit $ERRORS{'UNKNOWN'};
}

if (!-r $sqlfile) {
  print "sql command file not found or not readable at: $sqlfile\n";
  exit $ERRORS{'UNKNOWN'};
}
 
# This SQL request returns a row count.
my $scrubcount=`$sqlplus -S $opt_username/$opt_password\@$opt_instance
\@$sqlfile`;

if ($? == 0) {
  chomp($scrubcount);
  $scrubcount =~ s/^\s+//;
  if ($scrubcount =~ m/^\d+$/) {
    print "Scrub Backlog Count: $scrubcount\n";
    my $state;
    $state="OK";
    if ($scrubcount >= $opt_warning) {$state="WARNING";}
    if ($scrubcount >= $opt_critical) {$state="CRITICAL";}
    exit $ERRORS{$state};
  } else {
    print "Output not a numeric value\n";
    exit $ERRORS{'UNKNOWN'};
  }
} else {
  print "sqlplus error: $?\n";
  exit $ERRORS{'UNKNOWN'};
}


On 9/3/09 12:48 PM, "Matthew Litwin" <mlitwin at stubhub.com> wrote:

> I wrote a perl plugin that seems to work fine when I run it locally on the
> remote host as the nagios user, however when I try to execute it via NRPE I
> get the old familiar nebulous ³NRPE: Unable to read output². I have debugging
> on for NRPE logging and it doesn¹t tell much more. (Note this is in reverse
> order is it is out of splunk. IPs are obfuscated)
> 
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 903583
> daemon.debug] Connection from X.X.X.X closed.
> host=sjvp00dbs001.XX.com Options sourcetype=syslog Options source=udp:514
> Options
> 589/3/09 7:27:01.000 PM
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 869297
> daemon.debug] Return Code: 1, Output: NRPE: Unable to read output
> host=sjvp00dbs001.XX.com Options sourcetype=syslog Options source=udp:514
> Options
> 599/3/09 7:27:01.000 PM
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 757686
> daemon.debug] Command completed with return code 1 and output:
> host=sjvp00dbs001.XX.com Options sourcetype=syslog Options source=udp:514
> Options
> 609/3/09 7:27:01.000 PM
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 462736
> daemon.debug] Running command: /usr/loca/nagios/libexec/check_scrub_backlog.pl
> -w 1000 -c 2000 -u XXXX -p XXXX -i XXXX
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 881351
> daemon.debug] Host is asking for command 'check_scrub_backlog' to be run...
> host=sjvp00dbs001.XX.com Options sourcetype=syslog Options source=udp:514
> Options
> 629/3/09 7:27:01.000 PM
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 385967
> daemon.debug] Host address is in allowed_hosts
> host=sjvp00dbs001.XX.com Options sourcetype=syslog Options source=udp:514
> Options
> 639/3/09 7:27:01.000 PM
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 654915
> daemon.debug] Connection from X.X.X.X port 34549
> host=sjvp00dbs001.XX.com Options sourcetype=syslog Options source=udp:514
> Options
> 649/3/09 7:27:01.000 PM
> Sep  3 19:27:01 sjvp00dbs001.XX.com Sep  3 19:27:01 nrpe[12434]: [ID 879649
> daemon.debug] Handling the connection...
> 
> The command that is trying to run looks corrected- arguments are being sent
> correctly. I have tested the command using the same user that NRPE is running
> as, nagios. I did build in output for error messages in case there were
> problems like issues with ENV, but obviously they are not making it to NRPE. I
> confirmed my output text has EOLs. What is especially weird is that the return
> code makes it back correctly but the output is just ³NRPE: Unable to read
> output² even as logged by nrpe.
> 
> The output should look like this, which is what it gets locally when ran:
> Scrub Backlog Count: 1083
> 
> Nothing unusually with that, right?
> 
> Any help appreciated, thanks.
> 
> 
> 
> Does anyone have any other suggestions on how I might debug this? Since NRPE
> is working for all my other plugins

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20090903/09e03646/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list