Re: [Nagios-users] Nagios plugin problem using check_nrpe

2010-05-11 Thread Sean McAfee
Antonio Fernando Evangelista wrote:
> [r...@lnxaphmoa04 libexec]# /usr/local/nagios/libexec/check_teste.pl -s4 
> -w80 -c85
> 
> OK: TEMPERATURA ATUAL: 30 C - THRESHOLD: 127 C
> 
> *If I execute the script calling through the check_nrpe command:*
> 
> [r...@lnxaphmoa04 libexec]# /usr/local/nagios/libexec/check_nrpe  -H 
> localhost  -c check_teste
> 
> CRITICAL: TEMPERATURA ATUAL:  C - THRESHOLD:  C

You're running the check as root, but NRPE executes checks as the nagios 
user.

You'll probably be able to replicate the empty variables f you run:
[r...@lnxaphmoa04 libexec]# sudo -H -u nagios 
/usr/local/nagios/libexec/check_teste.pl -s4 -w80 -c85

The solution is:
1. Add permissions in sudoers for the nagios user to exec that script as 
root without a password. The following line would allow the nagios user 
to do passwordless sudo on any plugins:
nagios  ALL=(root) NOPASSWD:/usr/lcoal/nagios/libexec/

2. Change your nrpe.cfg to be:
command[check_teste]=/path/to/sudobinary 
/usr/local/nagios/libexec/check_teste.pl -s 4 -w 80 -c 85

3. Restart npre

-- 
Sean McAfee
Senior Systems Engineer

--

___
Nagios-users mailing list
Nagios-users@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


Re: [Nagios-users] Nagios plugin problem using check_nrpe

2010-05-11 Thread Assaf Flatto
Antonio Fernando Evangelista wrote:
>
> Hi.
>
> I’m writing a new Nagios plugin that will be responsible to monitor 
> the server internal components temperature.
>
> I have a Proliant DL380 G5 with the HP Management CLI for Linux 
> installed on it, and I wrote a perl program to check the
>
> Temperature.
>
> When I execute the perl script directly from the command prompt, I 
> receive a message indicating the behavior of the
>
> Temperature. But, when I call this script perl using check_nrpe 
> command, I received the same message, but the information
>
> of the temperature stays in blank.
>
> Following are my nrpe.cfg configuration file and the perl script.
>
> Does anybody know how can I fix this?
>
> *_NRPE.CFG_*
>
> pid_file=/var/run/nrpe.pid
>
> server_port=5666
>
> nrpe_user=nagios
>
> nrpe_group=nagios
>
> allowed_hosts=172.16.4.56,localhost
>
> dont_blame_nrpe=0
>
> debug=1
>
> command_timeout=60
>
> connection_timeout=300
>
> command[check_load]=/usr/local/nagios/libexec/check_load -w 3,3,3 -c 4,4,4
>
> command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/mapper/vg01-lvol1
>
> command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/cciss/c0d0p1
>
> command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/mapper/vg01-lvol6
>
> command[check_sda4]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/mapper/vg01-lvol4
>
> command[check_sda5]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/mapper/vg01-lvol3
>
> command[check_sda6]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/mapper/vg01-lvol2
>
> command[check_sda7]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/sda7
>
> command[check_sda8]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/sda8
>
> command[check_sda9]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% 
> -p /dev/sda9
>
> command[check_sda10]=/usr/local/nagios/libexec/check_disk -w 15% -c 
> 10% -p /dev/sda10
>
> command[check_drbd0]=/usr/local/nagios/libexec/check_disk -w 15% -c 
> 10% -p /dev/drbd0
>
> command[check_drbd1]=/usr/local/nagios/libexec/check_disk -w 15% -c 
> 10% -p /dev/drbd1
>
> command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 2 
> -c 4 -s Z
>
> command[check_informix]=/usr/local/nagios/libexec/check_procs -c 1:50 
> -C oninit
>
> command[check_crond]=/usr/local/nagios/libexec/check_procs -c 1:50 -C 
> crond
>
> command[check_cupsd]=/usr/local/nagios/libexec/check_procs -c 1:50 -C 
> cupsd
>
> command[check_freemem]=/usr/local/nagios/libexec/check_mem.pl -w 10 -c 
> 5 -f
>
> command[check_swap]=/usr/local/nagios/libexec/check_swap -w 90% -c 80%
>
> command[check_bonding]=/usr/local/nagios/libexec/check_linux_bonding
>
> command[check_iozone]=/usr/local/nagios/libexec/check_temperature_hp.pl 
> -s1 -w80 -c85
>
> command[check_ambient]=/usr/local/nagios/libexec/check_temperature_hp.pl 
> -s2 -w80 -c85
>
> command[check_sensor1_cpu1]=/usr/local/nagios/libexec/check_temperature_hp.pl 
> -s3 -w80 -c85
>
> command[check_sensor2_cpu1]=/usr/local/nagios/libexec/check_temperature_hp.pl 
> -s4 -w80 -c85
>
> command[check_teste]=/usr/local/nagios/libexec/check_teste.pl -s 4 -w 
> 80 -c 85
>
> *_The Perl program:_*
>
> #! /usr/bin/perl -w
>
> # $Id: check_teste.pl
>
> use lib "/usr/local/nagios/libexec" ;
>
> # Tell Perl what we need to use
>
> use strict;
>
> use Getopt::Std;
>
> # Predefined exit codes for Nagios
>
> use vars qw($opt_s $opt_c $opt_f $opt_u $opt_w $opt_C $opt_v %exit_codes);
>
> #use vars qw($numero $descricao $tempatual $templimite $sensor);
>
> %exit_codes = ('UNKNOWN' ,-1,
>
> 'OK' , 0,
>
> 'WARNING' , 1,
>
> 'CRITICAL', 2,
>
> );
>
> # Get our variables, do our checking:
>
> init();
>
> get_temperature();
>
> # Show usage
>
> sub usage() {
>
> print "\ncheck_mem.pl v1.0 - Nagios Plugin\n\n";
>
> print "usage:\n";
>
> print " check_mem.pl - -w  -c \n\n";
>
> print "options:\n";
>
> print " -f Check FREE memory\n";
>
> print " -u Check USED memory\n";
>
> print " -C Count OS caches as FREE memory\n";
>
> print " -w PERCENT Percent free/used when to warn\n";
>
> print " -c PERCENT Percent free/used when critical\n";
>
> print "\nCopyright (C) 2000 Dan Larsson \n";
>
> print "check_mem.pl comes with absolutely NO WARRANTY either implied 
> or explicit\n";
>
> print "This program is licensed under the terms of the\n";
>
> print "GNU General Public License (check source code for details)\n";
>
> exit $exit_codes{'UNKNOWN'};
>
> }
>
> #-
>
> # Verifica parametros passados
>
> #-
>
> sub init {
>
> # Get the options
>
> if ($#ARGV le 0) {
>
> &usage;
>
> }
>
> else {
>
> getopts('c:s:w:vh');
>
> }
>
> # Shortcircuit the switches
>
> if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0) {
>
> print "*** You must define WARN and CRITICAL levels!\n";
>
> 

[Nagios-users] Nagios plugin problem using check_nrpe

2010-05-11 Thread Antonio Fernando Evangelista
Hi.

I'm writing a new Nagios plugin  that will be responsible to monitor the server 
internal components temperature.

I have a Proliant DL380 G5 with the HP Management CLI for Linux installed on 
it, and I wrote a perl program to check the
Temperature.

When I execute the perl script directly from the command prompt, I receive a 
message indicating the behavior of the
Temperature. But, when I call this script perl using check_nrpe command, I 
received the same message, but the information
of the temperature stays in blank.

Following are my nrpe.cfg configuration file and the perl script.

Does anybody know how can I fix this?


NRPE.CFG

pid_file=/var/run/nrpe.pid
server_port=5666
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=172.16.4.56,localhost
dont_blame_nrpe=0
debug=1
command_timeout=60
connection_timeout=300
command[check_load]=/usr/local/nagios/libexec/check_load -w 3,3,3 -c 4,4,4
command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/mapper/vg01-lvol1
command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/cciss/c0d0p1
command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/mapper/vg01-lvol6
command[check_sda4]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/mapper/vg01-lvol4
command[check_sda5]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/mapper/vg01-lvol3
command[check_sda6]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/mapper/vg01-lvol2
command[check_sda7]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/sda7
command[check_sda8]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/sda8
command[check_sda9]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/sda9
command[check_sda10]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/sda10
command[check_drbd0]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/drbd0
command[check_drbd1]=/usr/local/nagios/libexec/check_disk -w 15% -c 10% -p 
/dev/drbd1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 2 -c 4 -s Z
command[check_informix]=/usr/local/nagios/libexec/check_procs -c 1:50 -C oninit
command[check_crond]=/usr/local/nagios/libexec/check_procs -c 1:50 -C crond
command[check_cupsd]=/usr/local/nagios/libexec/check_procs -c 1:50 -C cupsd
command[check_freemem]=/usr/local/nagios/libexec/check_mem.pl -w 10 -c 5 -f
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 90% -c 80%
command[check_bonding]=/usr/local/nagios/libexec/check_linux_bonding
command[check_iozone]=/usr/local/nagios/libexec/check_temperature_hp.pl -s1 
-w80 -c85
command[check_ambient]=/usr/local/nagios/libexec/check_temperature_hp.pl -s2 
-w80 -c85
command[check_sensor1_cpu1]=/usr/local/nagios/libexec/check_temperature_hp.pl 
-s3 -w80 -c85
command[check_sensor2_cpu1]=/usr/local/nagios/libexec/check_temperature_hp.pl 
-s4 -w80 -c85
command[check_teste]=/usr/local/nagios/libexec/check_teste.pl -s 4 -w 80 -c 85



The Perl program:

#! /usr/bin/perl -w
# $Id: check_teste.pl


use lib "/usr/local/nagios/libexec"  ;

# Tell Perl what we need to use
use strict;
use Getopt::Std;

# Predefined exit codes for Nagios
use vars qw($opt_s $opt_c $opt_f $opt_u $opt_w $opt_C $opt_v %exit_codes);
#use vars qw($numero $descricao $tempatual $templimite $sensor);

%exit_codes   = ('UNKNOWN' ,-1,
 'OK'  , 0,
 'WARNING' , 1,
 'CRITICAL', 2,
 );

# Get our variables, do our checking:


init();

get_temperature();


# Show usage
sub usage() {
  print "\ncheck_mem.pl v1.0 - Nagios Plugin\n\n";
  print "usage:\n";
  print " check_mem.pl - -w  -c \n\n";
  print "options:\n";
  print " -f   Check FREE memory\n";
  print " -u   Check USED memory\n";
  print " -C   Count OS caches as FREE memory\n";
  print " -w PERCENT   Percent free/used when to warn\n";
  print " -c PERCENT   Percent free/used when critical\n";
  print "\nCopyright (C) 2000 Dan Larsson \n";
  print "check_mem.pl comes with absolutely NO WARRANTY either implied or 
explicit\n";
  print "This program is licensed under the terms of the\n";
  print "GNU General Public License (check source code for details)\n";
  exit $exit_codes{'UNKNOWN'};
}

#-
# Verifica parametros passados
#-
sub init {
# Get the options

if ($#ARGV le 0) {
  &usage;
}
else {
  getopts('c:s:w:vh');
}

# Shortcircuit the switches
if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0) {
  print "*** You must define WARN and CRITICAL levels!\n";
  &usage;
}
elsif (!$opt_s) {
  print "*** You must select the SENSOR number!\n";
  &usage;
}

# Check if levels are sane
if ($opt_w >= $opt_c) {
  print "*** WARN level must not be greather than CRITICAL!\n";
  &