Code: Select all
[root@localhost etc]# cat nagios.cfg | grep nagios_user
nagios_user=nagios
[root@localhost etc]# cat nagios.cfg | grep nagios_group
nagios_group=nagios
Code: Select all
[root@localhost etc]# cat nagios.cfg | grep nagios_user
nagios_user=nagios
[root@localhost etc]# cat nagios.cfg | grep nagios_group
nagios_group=nagios
i think because this nagios was implemented ( not by me ) with root user!Code: Select all
root@maestro:/usr/lib/nagios/plugins# cat nagios.cfg | grep nagios_user cat: nagios.cfg: No such file or directory root@maestro:/usr/lib/nagios/plugins# cat nagios.cfg | grep nagios_group cat: nagios.cfg: No such file or directory root@maestro:/usr/lib/nagios/plugins#
Code: Select all
root@maestro:/etc/nagios3# cat nagios.cfg | grep nagios_user
nagios_user=nagios
root@maestro:/etc/nagios3# cat nagios.cfg | grep nagios_group
nagios_group=nagios
Code: Select all
[root@localhost ~]# id nagios
uid=494(nagios) gid=490(nagios) groups=490(nagios)
Code: Select all
[root@localhost ~]# su - nagios
[nagios@localhost]$ /usr/lib/nagios/plugins/check_by_ssh -4 -H remote address -l root -p 2022 -C "/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios" -vvvvvvvvvvvvvvvvvvvvv
check nagios user is available in your system ???
Code: Select all
root@maestro:/etc/nagios3# id nagios
uid=121(nagios) gid=124(nagios) groups=124(nagios)
Switch to nagios user and run command by nagios user.
Code: Select all
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
Code: Select all
define service {
use generic-service
host_name backups
service_description Nagios Status
check_command check_nagios_ssh!$HOSTADDRESS$!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios"
}
Code: Select all
define command{
command_name check_nagios_ssh
command_line /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -p $ARG1$ -l $ARG2$ -C $ARG3$
}
Stuart Watts wrote:Forums ate my response...
The clue is in the error message "Port must be a positive integer"
The problem is the service definition - $ARG1$ is passing "2022" to the command, which is used as the value for the option -H, which should be the host address or name. You're passing "root" as $ARG2$ which is sent to the plugin as the value for -p, hence the error message.
Update your service definition to:Code: Select all
define service { use generic-service host_name backups service_description Nagios Status check_command check_nagios_ssh!$HOSTADDRESS$!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios" }
aleks1 wrote:Hi everybody!
I'm trying to implement a remote command from a nagios (let's call it for convenience nagios A ) to the new nagios on ubuntu server 12.04 lts (nagios B) (this nagios on ubuntu server , was done , with the precious help of this forum )
anyway i want to implement a simple command that control my nagios.log (on remote server nagios B)
i have just put the public key in authorized_keys.... and the access without password... works! the nagiosA access to the nagiosB only with a specific port:then i have tried the command from the command line:Code: Select all
ssh -p 2022 root@intranet.xx.xx
ok works!Code: Select all
root@maestro: root@maestro:/etc/nagios-plugins/config# /usr/lib/nagios/plugins/check_by_ssh -H 'intranet.xx.xx' -p '2022' -C "/usr/local/nagios/libexec/check_nagios -F '/usr/local/nagios/var/nagios.log' -e '5' -C '/usr/local/nagios/bin/nagios'" NAGIOS OK: 40 processes, status log updated 47 seconds ago
but when i try to implement this command on servece definition (for control automatically the remote nagios.log)
i got this error:where am i wrong?Code: Select all
backups;Nagios Status;UNKNOWN;SOFT;2;Remote command execution failed: Permission denied, please try again.
this is my command definition:
this is my service definition:Code: Select all
define command{ command_name check_nagios_ssh command_line /usr/lib/nagios/plugins/check_by_ssh -H '$HOSTADDRESS$' -p '$ARG4$' -C "/usr/local/nagios/libexec/check_nagios -F '$ARG1$' -e '$ARG2$' -C '$ARG3$'" }
this is my host definition:Code: Select all
define service { use generic-service host_name backups service_description Nagios Status check_command check_nagios_ssh!/usr/local/nagios/var/nagios.log!5!/usr/local/nagios/bin/nagios!2022 }
any help be appreciate!!!Code: Select all
define host{ use generic-host ; Name of host template to use host_name backups alias Server Nagios address intranet.xx.xx }
why forums ate your response? hehehe )Forums ate my response...
Code: Select all
define service {
use generic-service
host_name backups
service_description Nagios Status
check_command check_nagios_ssh!$HOSTADDRESS$!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios"
}
Code: Select all
define command{
command_name check_nagios_ssh
command_line /usr/lib/nagios/plugins/check_by_ssh -H $ARG1$ -p $ARG2$ -l $ARG3$ -C $ARG4$
}
Code: Select all
SERVICE ALERT: backups;Nagios Status;UNKNOWN;SOFT;1;Remote command execution failed: Permission denied, please try again.
Code: Select all
define service {
use generic-service
host_name backups
service_description Nagios Status
check_command check_nagios_ssh!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios"
}
Code: Select all
define command{
command_name check_nagios_ssh
command_line /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -p $ARG1$ -l $ARG2$ -C $ARG3$
}
Code: Select all
SERVICE ALERT: backups;Nagios Status;UNKNOWN;SOFT;2;Remote command execution failed: Permission denied, please try again.
but i can't switch to nagios user!!!Switch to nagios user then run the command I hope it will show exact problem
Code: Select all
root@maestro:/etc/nagios3# id nagios
uid=121(nagios) gid=124(nagios) groups=124(nagios)
Code: Select all
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios