Hi all,
I have created a bash script that checks the status of a backup job by using. If I run the command from the commanline, it works perfectly. Via NAGIOS, it breaks as the variables are not getting created. I’ve run bash -x scrip on the commandline as well as in Nagios. The outputs are pasted below:
Working output:
- . /etc/profile
++ ‘’ -d /etc/profile.d ‘]’
++ for i in ‘/etc/profile.d/.sh’
++ ‘’ -r '/etc/profile.d/.sh’ ‘]’
++ unset i
++ ‘’ ‘’ ‘]’
++ umask 022
++ /usr/bin/head -n 1
++ /bin/nc 1.2.3.4 5678 - export STATUS=0
- STATUS=0
++ /usr/bin/tail -n 1
++ /bin/nc 1.2.3.4 5678 - export DATE=1304658075
- DATE=1304658075
- ‘’ 0 = 0 ‘]’
- /bin/echo 'OK: Data transfered successfully’
OK: Data transfered successfully - exit 0
Output when run in Nagios:
- . /etc/profile
++ ‘’ -d /etc/profile.d ‘]’
++ for i in ‘/etc/profile.d/.sh’
++ ‘’ -r '/etc/profile.d/.sh’ ‘]’
++ unset i
++ ‘’ ‘’ ‘]’
++ umask 022
++ /usr/bin/head -n 1
++ /bin/nc 1.2.3.4 5678 - export STATUS=
- STATUS=
++ /usr/bin/tail -n 1
++ /bin/nc 1.2.3.4 5678 - export DATE=
- DATE=
- ‘’ ‘’ = 0 ‘]’
- ‘’ ‘’ = 1 ‘]’
- ‘’ ‘’ = 2 ‘]’
- ‘’ ‘’ = 4 ‘]’
- /bin/echo 'Not Working’
Not Working - exit 3
Can anyone help here? Been struggling with this for hours now Thanks!