Interesting problem while trying to monitor Oracle RAC services [Solved]

Kumar, Ashish xml.devel at gmail.com
Wed Apr 8 10:14:27 CEST 2009


>> check the environment of the users launching the script. Which user do you
>> "use" to launch the script locally? And which one from remote?
>
> On nagios server I have tried executing it as root user as well as
> nagios user but the problem remains.
>


Hello all,

I made a mistake in the plug-in.  Both Perl script and KSH script were
residing in the same directory.  When executing locally it knew where
to look for external shell script. The code was as follows:

my $PIPED = qx# ksh check_oracle_services.sh $SERVICE #;

But when executed from nagios server, NRPE daemon on monitored host
wouldn't know where to look for the shell script hence the wrong
output.  Adding absolute path to the check_oracle_services.sh fixed
the problem

my $PIPED = qx# ksh /home/nagios/nrpe/libexec/check_oracle_services.sh
$SERVICE #;

The new code is as follows (may be someone would find it useful):

check_oracle_services.pl
------------------------------------

#!/usr/bin/env perl

use strict;
use Getopt::Std;

my %return_value = (
        OK => 0,
        CRIT => 2,
        UNKNOWN => 3
);

my $message = "nagios";
my $exit_status;

my %opt=();
getopts("p:h", \%opt);

sub usage(){
        print "Usage: $0 -p service_name\n";
        exit $return_value{'UNKNOWN'};
}

usage() if defined $opt{'h'};

my $SERVICE = $opt{'p'} if defined $opt{'p'} || usage();

my $PIPED = qx# ksh /home/nagios/nrpe/libexec/check_oracle_services.sh
$SERVICE #;

if ($PIPED =~ /OFFLINE/g) {
        $exit_status = $return_value{'CRIT'};
        $message = "Critical: $SERVICE is not running.";
} else {
        $exit_status = $return_value{'OK'};
        $message = "OK: $SERVICE is running.";
}

print "$message\n";
exit $exit_status;

------------------------------------


check_oracle_services.sh
------------------------------------

#!/usr/bin/ksh

RSC_KEY=$1

/oracle/crs_home/bin/crs_stat -u | awk \
        'BEGIN { FS="="; state = 0; } \
        $1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1}; \
        state == 0 {next;} \
        $1~/TARGET/ && state == 1 {apptarget = $2; state=2;} \
        $1~/STATE/ && state == 2 {appstate = $2; state=3;} \
        state == 3 {printf "%-45s %-18s\n", appname, appstate; state=0;}'



Sorry for the inconvenience caused.

Thanks

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
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