No output from check command but script works fine

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
UTE-COT
Posts: 18
Joined: Tue Jan 28, 2020 8:29 am

No output from check command but script works fine

Post 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.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: No output from check command but script works fine

Post 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
UTE-COT
Posts: 18
Joined: Tue Jan 28, 2020 8:29 am

Re: No output from check command but script works fine

Post 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.
UTE-COT
Posts: 18
Joined: Tue Jan 28, 2020 8:29 am

Re: No output from check command but script works fine

Post 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.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: No output from check command but script works fine

Post by gsmith »

Awesome!

Have a good one.
Locked