Nagios and Oracle db

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
JanePisk
Posts: 21
Joined: Wed Nov 06, 2013 9:46 am

Nagios and Oracle db

Post by JanePisk »

hi all!
I installed Nagios on my CentOs virtual Machine.
I downloaded the plugin named 'check_oracle_instant' to control oracle services and for monitor the state of DB.
I copied the script in the path /usr/local/nagios/libexex
and i put 'nagios' like owner for the script.

In the path /usr/local/nagios/etc/object, i modified the file 'commands.cfg' adding

define command {
command_name check_oracle_instant
command_line ...
}

I definied the service in another file and i runned the command
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

No error i received!!!
I restarted nagios, but the script don't works!!!


nagios says :
(Return code of 126 is out of bounds - plugin may be missing)

if i try to run the script with the nagios owner I received
/usr/bin/perl^M bad interpreter: No such file or directory


waiting for your help... :?

uh...
a clarification...
my db is a remote db...
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios and Oracle db

Post by tmcdonald »

JanePisk wrote: I copied the script in the path /usr/local/nagios/libexex
Make sure it is /usr/local/nagios/libexec
JanePisk wrote: (Return code of 126 is out of bounds - plugin may be missing)
That may be related to the above issue
JanePisk wrote: if i try to run the script with the nagios owner I received
/usr/bin/perl^M bad interpreter: No such file or directory
Open up the script, and on the very first line I want you to delete every character and, by hand, type in the following:

Code: Select all

/usr/bin/perl/
The ^M is a meta-character that sometimes gets added when you copy+paste.
Former Nagios employee
JanePisk
Posts: 21
Joined: Wed Nov 06, 2013 9:46 am

Re: Nagios and Oracle db

Post by JanePisk »

first, tnx tmcdonald for your answer,


sorry, the right path is
/usr/local/nagios/libexec (write error)

now the status information is NULL

service status last check duration attempt status information
ORACLE:check_login_health CRITICAL 11-06-2013 17:04:32 0d 0h 2m 17s 2/3 (null)


the plugin's code is :

Code: Select all

/usr/bin/perl/

$host = $ARGV[0];
$port = $ARGV[1];
$sid  = $ARGV[2];
$user  = $ARGV[3];
$pass  = $ARGV[4];

sub trim($);
my @result;
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2);
my @param_array = (
    [90,">","Dictionary Cache Hit Ratio",'SELECT (1 - (Sum(getmisses)/(Sum(gets) + Sum(getmisses)))) * 100 FROM v\$rowcache;'],
    [99,">","Library Cache Hit Ratio",'SELECT (1 -(Sum(reloads)/(Sum(pins) + Sum(reloads)))) * 100  FROM   v\$librarycache;'],
    [89,">","DB Block Buffer Cache Hit Ratio",'SELECT (1 - (phys.value / (db.value + cons.value))) * 100 FROM v\$sysstat phys,v\$sysstat db,v\$sysstat cons WHERE  phys.name  = \'physical reads\' AND db.name = \'db block gets\' AND cons.name  = \'consistent gets\';'],
    [98,">","Latch Hit Ratio",'SELECT (1 - (Sum(misses) / Sum(gets))) * 100  FROM   v\$latch;'],
    [5,"<","Disk Sort Ratio",'SELECT (disk.value/mem.value) * 100 FROM v\$sysstat disk,v\$sysstat mem WHERE  disk.name = \'sorts (disk)\' AND mem.name  = \'sorts (memory)\';'],
    [5,"<","Rollback Segment Waits",'SELECT (Sum(waits) / Sum(gets)) * 100  FROM   v\$rollstat;'],
...skipping...
open (SQL,"sqlplus -s system/mismatch@\\(DESCRIPTION=\\(ADDRESS=\\(PROTOCOL=TCP\\)\\(Host=$host\\)\\(Port=$port\\)\\)\\(CONNECT_DATA=\\(SID=$sid\\)\\)\\)</dev/null
|") or die;
open (SQL,"sqlplus -s system/mismatch@\\(DESCRIPTION=\\(ADDRESS=\\(PROTOCOL=TCP\\)\\(Ho
st=$host\\)\\(Port=$port\\)\\)\\(CONNECT_DATA=\\(SID=$sid\\)\\)\\)</dev/null
|") or die;
  while ( my $res = <SQL> )
             {
           if ($res =~ /^(ORA-\d{5})/) {return $1;}
             }
}

if (logon() eq "ORA-01017"){



 for (my $i=0; $i<array_rows(\@param_array); $i++){
     # print "$param_array[$i][0] -- $param_array[$i][1] -- $param_array[$i][2] -- $param_array[$i][3]\n";

open (SQL,"sqlplus -s $user/$pass@\\(DESCRIPTION=\\(ADDRESS=\\(PROTOCOL=TCP\\)\\(Host=$host\\)\\(Port=$port\\)\\)\\(CONNECT_DATA=\\(SID=$sid\\)\\)\\) << EOF
set pagesize 0
set numformat 999.999
$param_array[$i][3]
EOF |") or die;
  while ( my $res = <SQL> )
             {
 #  print trim($res)."\n";
   if ( $res =~/^\s*\S+/ ) { push(@results,trim($res));}
             }
  }


  for ($i=0;$i<@results;$i++) {
  #   print $i." hodnota je ".$result[$i]." a ma byt ".$param_array[$i][0];
    eval "unless (".$results[$i].$param_array[$i][1].$param_array[$i][0].") { print\"".$param_array[$i][2]." ".$sid." KO \\n\"; exit ".$ERRORS{"WARNING"}.";}";

  }
print "status and health of $sid ORACLE is OK";
exit $ERRORS{"OK"};

} else {print "Unable to connect to $sid ORACLE !!! "; exit $ERRORS{"CRITICAL"};}

command and service definition :


#### CHECK ORACLE ###
define command{
command_name check_oracle_instant
command_line $USER1$/check_oracle_instant $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$ $ARG4$
}



define service{
use generic-service
host_name fox.pisa.exis.it
service_description ORACLE:check_login_health
check_command check_oracle_instant!1521!svildb!sys!***password**
}


?? any ideas ??
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios and Oracle db

Post by tmcdonald »

Can you run the check directly from the command line and show me the output please? Of course be sure to edit out any sensitive information.
Former Nagios employee
JanePisk
Posts: 21
Joined: Wed Nov 06, 2013 9:46 am

Re: Nagios and Oracle db

Post by JanePisk »

ok,
excuse my ignorance
but what command for the run from the command line with the arguments required?


thanks for your patience ;)
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Nagios and Oracle db

Post by slansing »

You would basically take your command definition, and fill in the arguments with what your service definition is defined with like so:

Code: Select all

/usr/local/nagios/libexec/check_oracle_instant -H host.addr.of.oracle.server -p 1521
I believe that you are missing a few crucial things in your command/service definition, for instance you correctly placed the port number in the definition but excluded the flag that is used with it as shown above "-p for port." Now, to verify the flags we need run the following:

Code: Select all

/usr/local/nagios/libexec/check_oracle_instant
This should output some form of help/usage, can you reply with it's output?
JanePisk
Posts: 21
Joined: Wed Nov 06, 2013 9:46 am

Re: Nagios and Oracle db

Post by JanePisk »

good morning!!
if I write the code (/usr/local/nagios/libexec/check_oracle_instant), the output is:

Code: Select all

[nagios@kallisto libexec]$ /usr/local/nagios/libexec/check_oracle_instant 
: Not a directory/libexec/check_oracle_instant: line 1: /usr/bin/perl/
: command not foundibexec/check_oracle_instant: line 2: 
/usr/local/nagios/libexec/check_oracle_instant: line 3: =: command not found
: command not foundibexec/check_oracle_instant: line 3: 
/usr/local/nagios/libexec/check_oracle_instant: line 4: =: command not found
: command not foundibexec/check_oracle_instant: line 4: 
/usr/local/nagios/libexec/check_oracle_instant: line 5: =: command not found
: command not foundibexec/check_oracle_instant: line 5: 
/usr/local/nagios/libexec/check_oracle_instant: line 6: =: command not found
: command not foundibexec/check_oracle_instant: line 6: 
/usr/local/nagios/libexec/check_oracle_instant: line 7: =: command not found
: command not foundibexec/check_oracle_instant: line 7: 
: command not foundibexec/check_oracle_instant: line 8: 
/usr/local/nagios/libexec/check_oracle_instant: line 9: syntax error near unexpected token `('
'usr/local/nagios/libexec/check_oracle_instant: line 9: `sub trim($);
JanePisk
Posts: 21
Joined: Wed Nov 06, 2013 9:46 am

Re: Nagios and Oracle db

Post by JanePisk »

ps: the code of the file ( check_oracle_instant) is a plugin that I downloaded from the website (a plugin created by a user)
JanePisk
Posts: 21
Joined: Wed Nov 06, 2013 9:46 am

Re: Nagios and Oracle db

Post by JanePisk »

but .... sub trim is not something that concerns java? (confused ....) :?: :?: :?:
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios and Oracle db

Post by abrist »

Try:

Code: Select all

/usr/local/nagios/libexec/check_oracle_instant --help
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked