Need setting up service
Need setting up service
I'm trying to run script on remote host and show the output in Nagios, scripts are as per Nagios standards.
So when i run it from Nagios host, it gives me correct results.
[nagios@nagmonus1 ~]$ /usr/bin/sudo /usr/bin/ssh -l root sftp /nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90
Unauthorized access to or use of this system is prohibited. All access and use may be monitored or recorded.
OK- / : Total Space= 1.9G, Used Space= 91M, Available Space= 1.8G i.e. 5% Usage | 'Usage'=5;80;90;0;100
I basically want to show this output in Nagios for the remote host (sftp)
I have configured the command in Command definition already and then i have created a service and associated the appropriate check command to it.
After saving and restarting nagios core, i see below warning message on this host
[sudo: no tty present and no askpass program specified]
Need quick assistance here.
So when i run it from Nagios host, it gives me correct results.
[nagios@nagmonus1 ~]$ /usr/bin/sudo /usr/bin/ssh -l root sftp /nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90
Unauthorized access to or use of this system is prohibited. All access and use may be monitored or recorded.
OK- / : Total Space= 1.9G, Used Space= 91M, Available Space= 1.8G i.e. 5% Usage | 'Usage'=5;80;90;0;100
I basically want to show this output in Nagios for the remote host (sftp)
I have configured the command in Command definition already and then i have created a service and associated the appropriate check command to it.
After saving and restarting nagios core, i see below warning message on this host
[sudo: no tty present and no askpass program specified]
Need quick assistance here.
Re: Need setting up service
Does the sudoers file on your Nagios XI machine grant permissions for /usr/bin/ssh to the nagios user/group? Does the script itself have the appropriate permissions to be executed by the nagios user/group?
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Need setting up service
[nagios@nagmonus1 ~]$ /usr/bin/sudo /usr/bin/ssh -l root sftp /nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90
Unauthorized access to or use of this system is prohibited. All access and use may be monitored or recorded.
OK- / : Total Space= 1.9G, Used Space= 91M, Available Space= 1.8G i.e. 5% Usage | 'Usage'=5;80;90;0;100
[nagios@nagmonus1 ~]$ id
uid=59991(nagios) gid=59991(nagios) groups=59991(nagios),59016(nagcmd)
I'm running this as nagios user
Unauthorized access to or use of this system is prohibited. All access and use may be monitored or recorded.
OK- / : Total Space= 1.9G, Used Space= 91M, Available Space= 1.8G i.e. 5% Usage | 'Usage'=5;80;90;0;100
[nagios@nagmonus1 ~]$ id
uid=59991(nagios) gid=59991(nagios) groups=59991(nagios),59016(nagcmd)
I'm running this as nagios user
Re: Need setting up service
I have checked other posts, and the parameter !requiretty does not exists in sudoers file.
Tried reading https://support.nagios.com/forum/viewto ... 7&start=10
but no luck..
Tried reading https://support.nagios.com/forum/viewto ... 7&start=10
but no luck..
Re: Need setting up service
You'll likely need to use check_by_ssh so that you can get rid of the MOTD, try this and send the full output:
Thank you
Code: Select all
su - nagios
/usr/local/nagios/libexec/check_by_ssh -H sftp -l root -S 1 -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
echo $?
Re: Need setting up service
# su - nagios
[nagios@nagmonus1 ~]$ /usr/local/nagios/libexec/check_by_ssh -H sftp -l root -S 1 -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
Remote command execution failed: Unauthorized access to or use of this system is prohibited. All access and use may be monitored or recorded.
[nagios@nagmonus1 ~]$ echo $?
3
Note: I need to run this command as root, as i have configured password less ssh from nagiosxi server to remote host.
[nagios@nagmonus1 ~]$ /usr/local/nagios/libexec/check_by_ssh -H sftp -l root -S 1 -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
Remote command execution failed: Unauthorized access to or use of this system is prohibited. All access and use may be monitored or recorded.
[nagios@nagmonus1 ~]$ echo $?
3
Note: I need to run this command as root, as i have configured password less ssh from nagiosxi server to remote host.
Re: Need setting up service
When i run the check command from the nagios console, it works fine. PFA
You do not have the required permissions to view the files attached to this post.
Re: Need setting up service
Please run these commands from the CLI and send the entire output (including the commands run):
Code: Select all
su - nagios
/usr/local/nagios/libexec/check_by_ssh -H sftp -l root -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
echo $?
/usr/local/nagios/libexec/check_by_ssh -H sftp -l root -S -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
echo $?
/usr/local/nagios/libexec/check_by_ssh -H sftp -l root -E -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
echo $?
/usr/local/nagios/libexec/check_by_ssh -H sftp -l root -S 2 -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
echo $?
/usr/local/nagios/libexec/check_by_ssh -H sftp -l root -E 1 -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
echo $?
/usr/local/nagios/libexec/check_by_ssh -H sftp -l root -E 2 -C "/nagios-scripts/check_disk_sol.sh -p / -w 80 -c 90"
echo $?Re: Need setting up service
i got a workaround, thanks.
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Need setting up service
It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!