Need setting up service

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Need setting up service

Post by bosecorp »

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.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Need setting up service

Post by mcapra »

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/
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Re: Need setting up service

Post by bosecorp »

[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
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Re: Need setting up service

Post by bosecorp »

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..
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Need setting up service

Post by ssax »

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:

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 $?
Thank you
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Re: Need setting up service

Post by bosecorp »

# 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.
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Re: Need setting up service

Post by bosecorp »

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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Need setting up service

Post by ssax »

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 $?
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Re: Need setting up service

Post by bosecorp »

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

Post by dwhitfield »

It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!
Locked