Return variables do not appear in web script bash nagios

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

Return variables do not appear in web script bash nagios

Postby ToyahHodges » Sun Sep 12, 2021 9:35 pm

I have made a small script that takes values ​​from a server, evaluates them and should show them on the nagios website. but it does not report the variables.

The script is:

#!/bin/bash

dat=$(/usr/bin/curl -s http://$1/cgi-bin/Harm.cgi?slot=1|grep -i dbm|awk -v FS="(<Val>|</Val>)" '{print 20}'|bc -l )

echo "OK - Power $dat dbm"
exit 0

But in the nagios web it only shows me "OK - Power dbm" without the variable value.
if I run the script in the environment user nagios the result is correct --> OK - Power 20 dbm

I have set the script permissions to the top -rwxrwxrwx

Any suggestions to make it work

Thank you
ToyahHodges
 
Posts: 1
Joined: Sun Sep 12, 2021 9:33 pm

Re: Return variables do not appear in web script bash nagios

Postby gormank » Mon Sep 13, 2021 12:43 pm

You might want to post the service config file.
Maybe break the pipe into smaller parts and redirect into files to test, while leaving the original pipe unchanged.

/usr/bin/curl -s http://$1/cgi-bin/Harm.cgi?slot=1 > /home/nagios/curl.log
grep -i dbm /home/nagios/curl.log > /home/nagios/grep.log
awk -v FS="(<Val>|</Val>)" '{print 20}' /home/nagios/awk.log | bc -l > /home/nagios/awk.log

Once the issue is found, you can fix the original pipe.
gormank
 
Posts: 901
Joined: Tue Dec 02, 2014 12:00 pm


Return to Community Support

Who is online

Users browsing this forum: No registered users and 26 guests