Page 1 of 1

No output from check command but script works fine

Posted: Tue Oct 26, 2021 2:54 pm
by UTE-COT
HI, how are you?

I'm having some issues with a new plugin I've just uploaded to my Nagios XI server.

If I run the script from the command line it successfully displays the output data:

Code: Select all

[root@lvwtelcotnagiosprd01 pruebas]# perl /usr/local/nagios/libexec/check_iftraffic64.pl -H 15.0.0.11 -C public -i GigabitEthernet0/0 -B
OK - Average IN: 331.18Kb (0.03%), Average OUT: 316.94Kb (0.03%)Total RX: 1604.18Gbits, Total TX: 1534.42Gbits|inUsage=0.03%;85;98 outUsage=0.03%;85;98 inBandwidth=41397.54B outBandwidth=39616.92B inAbsolut=200522425779c outAbsolut=191802627302c
But running it with "su -c '...command...' nagios" doesn't return anything:

Code: Select all

[root@lvwtelcotnagiosprd01 pruebas]# su -c 'perl /usr/local/nagios/libexec/check_iftraffic64.pl -H 15.0.0.11 -C public -i GigabitEthernet0/0 -B' nagios
[root@lvwtelcotnagiosprd01 pruebas]#
The script has the following permissions:

Code: Select all

[root@lvwtelcotnagiosprd01 pruebas]# ls -l /usr/local/nagios/libexec/check_iftraffic64.pl
-rwxr-xr-x 1 apache apache 38942 Oct 26 15:36 /usr/local/nagios/libexec/check_iftraffic64.pl
Any help is greatly appreciated.

Thanks in advance.

Re: No output from check command but script works fine

Posted: Wed Oct 27, 2021 11:43 am
by gsmith
Hi,

I think it's because initially the plugin cannot create a directory in /usr/local/nagios/libexec.

Please do this from the command line as root:

Code: Select all

cd /usr/local/nagios/libexec
mkdir traffic
chown nagios:nagios traffic
chmod 755 traffic
Then try:

Code: Select all

su -c 'perl /usr/local/nagios/libexec/check_iftraffic64.pl -H 15.0.0.11 -C public -i GigabitEthernet0/0 -B' nagios
Please let me know how it works.

Thanks

Re: No output from check command but script works fine

Posted: Wed Oct 27, 2021 1:02 pm
by UTE-COT
Hi! This line did the trick:

Code: Select all

chown nagios:nagios traffic
The script was creating the folder but with root owner.

Thanks for your help!

Feel free to close this post.

Re: No output from check command but script works fine

Posted: Wed Oct 27, 2021 1:47 pm
by UTE-COT
Hi! This line did the trick:

Code: Select all

chown nagios:nagios traffic
The script was creating the folder but with root owner.

Thanks for your help!

Feel free to close this post.

Re: No output from check command but script works fine

Posted: Wed Oct 27, 2021 1:50 pm
by gsmith
Awesome!

Have a good one.