[Nagiosplug-help] NRPE and check_oracle

Ralph.Grothe at itdz-berlin.de Ralph.Grothe at itdz-berlin.de
Wed Jul 13 03:40:43 CEST 2005


Hi Andreas,

of course you were right, it's as simple as providing a wrapper
script.

I was a blind not to have noticed that even check_oracle is a
mere Bourne shell script.

So instead of additionally wrapping yet another script around
this I only needed to slightly
modify check_oracle.

These are my changes.

$ ll check_oracle*
-rwxr-xr-x   1 root       sys           8778 Jul 13 12:26
check_oracle
-rwxr-xr-x   1 root       sys           8293 Jul 12 10:58
check_oracle.dist

$ diff check_oracle*
26d25
<   echo "  $PROGNAME --env VAR1=val1[,VAR2=val2[,...VARN=valN]]
{--opt_from_above [opt_arg]}"
57,58d55
<   echo "--env VAR=val"
<   echo "   Define environment for check_oracle proc such as
ORACLE_HOME, ORACLE_SID etc."
71,83d67
< 
< if [ $# -gt 2 -a $1 = --env ]; then
<     shift
<     ENV="`echo $1|tr \, \ `"
<     shift
<     # argh, non-posix Bourne compatible shells require this
ugly looping
<     if [ -n "$ENV" ]; then
<       for var in $ENV; do
<           eval $var
<           eval export `echo $var|cut -d= -f1`
<       done
<     fi
< fi


This yields this new help screen

$ ./check_oracle

./check_oracle[72]: test: Specify a parameter with this command.
Usage:
  check_oracle --tns <Oracle Sid or Hostname/IP address>
  check_oracle --db <ORACLE_SID>
  check_oracle --login <ORACLE_SID>
  check_oracle --cache <ORACLE_SID> <USER> <PASS> <CRITICAL>
<WARNING>
  check_oracle --tablespace <ORACLE_SID> <USER> <PASS>
<TABLESPACE> <CRITICAL> <WARNING>
  check_oracle --oranames <Hostname>
  check_oracle --help
  check_oracle --version
  check_oracle --env VAR1=val1[,VAR2=val2[,...VARN=valN]]
{--opt_from_above [opt_arg]}


$ ./check_oracle --help|sed -n '/^--env/,$p'
--env VAR=val
   Define environment for check_oracle proc such as ORACLE_HOME,
ORACLE_SID etc.

If the plugin doesn't work, check that the ORACLE_HOME
environment
variable is set, that ORACLE_HOME/bin is in your PATH, and the
tnsnames.ora file is locatable and is properly configured.

When checking local database status your ORACLE_SID is case
sensitive.

If you want to use a default Oracle home, add in your oratab
file:
*:/opt/app/oracle/product/7.3.4:N

Send email to nagios-users at lists.sourceforge.net if you have
questions
regarding use of this software. To submit patches or suggest
improvements,
send email to nagiosplug-devel at lists.sourceforge.net.
Please include version information with all correspondence (when
possible,
use output from the --version option of the plugin itself).


And invocation is as simple as


$ ./check_oracle --env
ORACLE_HOME=/app/oracle/product/9.2.0,PATH=/usr/bin:\$ORACLE_HOME
/bin --tns FREMD
OK - reply time 20 msec from FREMD


Regards
Ralph



> -----Original Message-----
> From: nagiosplug-help-admin at lists.sourceforge.net
> [mailto:nagiosplug-help-admin at lists.sourceforge.net]On Behalf 
> Of Andreas
> Ericsson
> Sent: Tuesday, July 12, 2005 5:25 PM
> To: nagiosplug-help at lists.sourceforge.net
> Subject: Re: [Nagiosplug-help] NRPE and check_oracle
> 
> 
> Ralph.Grothe at itdz-berlin.de wrote:
> > Hi,
> > 
> > after having managed to build the plugins from the sources on
> > HPUX 11.00 I am about to configure nrpe.cfg
> > 
> > As you can see, this box is not the Nagios server but a
monitored
> > (managed) node whose nrpe daemon (spawned through inetd)
shall
> > transmit the return codes of plugins run on this node via
NRPE.
> > 
> > Thus I don't have a nagios.cfg or the like on this node.
> > 
> > Starting with the check_oracle plugin (as this node is a DB
> > server) I now tripped over the minor problem of how to setup
the
> > ORACLE environment for this plugin.
> > 
> > Unfortunately the "documentation" of the plugin (unless you
are
> > into sifting through the source code) is quite sparse, and so
I'm
> > left with what the --help screen displays
> > 
> >>From it I found that the plugin requires a minimal ORACLE
> > environment.
> > OK this is straight forward as long as I invoke it on the
command
> > line
> > 
> > e.g.
> > 
> > $ uname -srv
> > HP-UX B.11.00 U
> > 
> > $ id -u
> > 101
> > 
> > $ ORACLE_HOME=/app/oracle/product/9.2.0
> > PATH=/usr/bin:$ORACLE_HOME/bin
/usr/local/nagios/libexec/chec>
> > OK - reply time 30 msec from FREMD
> > 
> > 
> > However, how is the nrpe daemon getting its environment.
> > I don't want to set up a specicific Oracle (or whatever the
next
> > plugin calls for) environment for the user as indicated in
> > inetd.conf for nrpe
> > 
> 
> Use a wrapper script to run the check where you set up the
proper 
> environment first.
> 
> > $ grep ^nrpe /etc/inetd.conf
> > nrpe    stream tcp nowait nagios /opt/nrpe/bin/nrpe nrpe -c
> > /opt/nrpe/etc/nrpe.cfg --inetd
> > 
> > Aprops, as I'm on the subject, the README of nrpe didn't
specify
> > the daemon's name as ARGV[0] but started right
> > with -c ...
> > However, the HPUX inetd expects the program name of the
daemon it
> > spawns in arg position 0,
> > as the manpage points out (which seems to me in accordance to
C
> > programming conventions)
> > 
> > 
> > Can I simply define environment vars in nrpe.cfg?
> > Or should one setup a resources.cfg wherein one would define
> > $USER#$ macros?
> > 
> > I know that I could define the environment simply in the
user's
> > $HOME/.profile for instance.
> > But I don't want this as it could happen that such a user
even
> > doesn't posses a $HOME (aka 6th field in /etc/passwd) for
obvious
> > reasons (even though this might breach Unix conventions).
> > 
> > $ awk -F: '$1=="nagios"{print$6}' /etc/passwd
> > 
> > 
> > Thanx
> > 
> > 
> > 
> > 
> > --
> > Ralph Grothe (GBII1Gr)
> > IT Dienstleistungszentrum Berlin 
> > Berliner Strasse 112-115
> > D-10713 Berlin
> > Phone:   +49 30 9012 6481
> > Fax:     +49 30 9012 3151
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email is sponsored by the 'Do More With Dual!' 
> webinar happening
> > July 14 at 8am PDT/11am EDT. We invite you to explore the 
> latest in dual
> > core and dual graphics technology at this free one hour 
> event hosted by HP, 
> > AMD, and NVIDIA.  To register visit
http://www.hp.com/go/dualwebinar
> > _______________________________________________
> > Nagiosplug-help mailing list
> > Nagiosplug-help at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
> > ::: Please include plugins version (-v) and OS when 
> reporting any issue. 
> > ::: Messages without supporting info will risk being sent 
> to /dev/null
> > 
> 
> -- 
> Andreas Ericsson                   andreas.ericsson at op5.se
> OP5 AB                             www.op5.se
> Lead Developer
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' 
> webinar happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the 
> latest in dual
> core and dual graphics technology at this free one hour event 
> hosted by HP, 
> AMD, and NVIDIA.  To register visit
http://www.hp.com/go/dualwebinar
> _______________________________________________
> Nagiosplug-help mailing list
> Nagiosplug-help at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
> ::: Please include plugins version (-v) and OS when reporting 
> any issue. 
> ::: Messages without supporting info will risk being sent to
/dev/null
> 




More information about the Help mailing list