Having Some NRPE issues with specific commands

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Having Some NRPE issues with specific commands

Post by abrist »

Try:

Code: Select all

su - -s /bin/bash nagios '/usr/lib64/nagios/plugins/check_open_files.pl -w 85 -c 95'
echo $?
Or:

Code: Select all

su - nagios -c "/usr/lib64/nagios/plugins/check_open_files.pl -w 85 -c 95"
echo $?
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.
brandon.pal
Posts: 129
Joined: Wed Feb 19, 2014 10:18 pm

Re: Having Some NRPE issues with specific commands

Post by brandon.pal »

Code: Select all

[root@dc01-cache-01 plugins]# ./check_open_files.pl -w 85 -c 95
OK: 928 open files (0% of max 1000000)|opened_files=928;850000;950000

Code: Select all

[root@dc01-cache-01 plugins]# su - -s /bin/bash nagios /usr/lib64/nagios/plugins/check_open_files.pl -w 85 -c 95
su: invalid option -- 'w'
Try `su --help' for more information.

Code: Select all

 su -l -s /bin/bash nagios /usr/lib64/nagios/plugins/check_open_files.pl
/usr/lib64/nagios/plugins/check_open_files.pl: line 3: use: command not found
/usr/lib64/nagios/plugins/check_open_files.pl: line 4: syntax error near unexpected token `('
/usr/lib64/nagios/plugins/check_open_files.pl: line 4: `use vars qw($opt_h $PROGNAME $opt_w $opt_c $opt_t $opt_vi $msg $state);'
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Having Some NRPE issues with specific commands

Post by abrist »

Can nagios see the perl bin and use it?

Code: Select all

su -l -s /bin/bash nagios -c "which perl"
su -l -s /bin/bash nagios -c "perl --version"
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.
brandon.pal
Posts: 129
Joined: Wed Feb 19, 2014 10:18 pm

Re: Having Some NRPE issues with specific commands

Post by brandon.pal »

Code: Select all

[root@dc01-cache-01 ~]# su -l -s /bin/bash nagios -c "which perl"
/usr/bin/perl
[root@dc01-cache-01 ~]# su -l -s /bin/bash nagios -c "perl --version"

This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Having Some NRPE issues with specific commands

Post by lmiltchev »

Run the following commands and show the output.

Code: Select all

usermod -s /bin/bash nagios
su nagios
/usr/lib64/nagios/plugins/check_open_files.pl -w 85 -c 95
echo $?
Be sure to check out our Knowledgebase for helpful articles and solutions!
brandon.pal
Posts: 129
Joined: Wed Feb 19, 2014 10:18 pm

Re: Having Some NRPE issues with specific commands

Post by brandon.pal »

Code: Select all

[root@dc01-cache-01 ~]# usermod -s /bin/bash nagios
[root@dc01-cache-01 ~]# su nagios
bash-4.1$ /usr/lib64/nagios/plugins/check_open_files.pl -w 85 -c 95
Can't locate utils.pm in @INC (@INC contains: /usr/local/nagios/libexec /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/lib64/nagios/plugins/check_open_files.pl line 6.
BEGIN failed--compilation aborted at /usr/lib64/nagios/plugins/check_open_files.pl line 6.
bash-4.1$ echo
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Having Some NRPE issues with specific commands

Post by slansing »

Did you compile the nagios plugins package on this system? It looks like you are missing the Utils perl module. Can you attach your plugin? I'd be interested in seeing it's USE definition, since you have a fairly unstandard directory for your plugins I would not be surprised if it is looking in the wrong location. Does the file "utils.pm" exist in your plugin directory?
brandon.pal
Posts: 129
Joined: Wed Feb 19, 2014 10:18 pm

Re: Having Some NRPE issues with specific commands

Post by brandon.pal »

From what I know our prod sys admin did this:

Code: Select all

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum -y install nagios nagios-plugins-all nrpe 
chkconfig nagios on
slansing wrote:Does the file "utils.pm" exist in your plugin directory?
/usr/lib64/nagios/plugins/utils.pm
slansing wrote:I'd be interested in seeing it's USE definition

Code: Select all

use Getopt::Long;
use vars qw($opt_h $PROGNAME $opt_w $opt_c $opt_t $opt_vi $msg $state);
 use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS &print_revision &support &usage );
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Having Some NRPE issues with specific commands

Post by slansing »

Try changing:

Code: Select all

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

Code: Select all

use lib "/usr/lib64/nagios/plugins/";
Then run the commands lmiltchev posted above, again, thanks!

Yeah yum is a really easy way to install applications, unfortunately on a system to system basis and package to package, the directory structure or contents of the package can change. That's why I usually recommend compiling the plugins by hand.
brandon.pal
Posts: 129
Joined: Wed Feb 19, 2014 10:18 pm

Re: Having Some NRPE issues with specific commands

Post by brandon.pal »

brandon.pal wrote:Then run the commands lmiltchev posted above, again, thanks!

Code: Select all

[root@dc01-cache-01 ~]# su nagios
bash-4.1$ /usr/lib64/nagios/plugins/check_open_files.pl -w 85 -c 95
OK: 1408 open files (0% of max 1000000)|opened_files=1408;850000;950000
bash-4.1$ echo $?
0
brandon.pal wrote:That's why I usually recommend compiling the plugins by hand.
I'll be honest. I have no idea how to do that.
Locked