Page 2 of 4
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 5:12 am
by rajesh.mehra
Please check these values also.
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
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 5:16 am
by aleks1
this is wrong see the answer below
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#
i think because this nagios was implemented ( not by me

) with root user!
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 5:25 am
by aleks1
Ops! my stupid error! i was in the wrong directory!

in the right directory:
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
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 5:33 am
by rajesh.mehra
check nagios user is available in your system ???
Code: Select all
[root@localhost ~]# id nagios
uid=494(nagios) gid=490(nagios) groups=490(nagios)
If available
then
Switch to nagios user and run command by nagios user.
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
else
add nagios user in system
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 5:51 am
by aleks1
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)
is available?
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
i can't switch to nagios user!
i must create a nagios user?
because this nagios (implemented not by me) have a lot of service and hosts to other remote servers.... if i create nagios user... could cause problems to other remote servers?
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 5:59 am
by rajesh.mehra
Hi
You dont need to create nagios user It is already on your system. If you will switch to nagios user it will not effect your system.
because all commands are running by nagios in backend not by root.
Switch to nagios user then run the command I hope it will show exact problem
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 6:12 am
by Stuart Watts
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"
}
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 6:23 am
by rajesh.mehra
Thanks Stuart Watts

Exactly right
Change command definition according to below
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$
}
OR
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"
}
both are correct
Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 7:18 am
by rajesh.mehra
Come to the previous error
Give access to nagios user so that it can login to
[email protected] without password. Still it can login by root.
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
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
ok works!
but when i try to implement this command on servece definition (for control automatically the remote nagios.log)
i got this error:
Code: Select all
backups;Nagios Status;UNKNOWN;SOFT;2;Remote command execution failed: Permission denied, please try again.
where am i wrong?
this is my command 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 service 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
}
this is my host definition:
Code: Select all
define host{
use generic-host ; Name of host template to use
host_name backups
alias Server Nagios
address intranet.xx.xx
}
any help be appreciate!!!

Re: Remote command execution failed: Permission denied,pleas
Posted: Thu Jun 12, 2014 7:29 am
by aleks1
hi everybody and thanks for support!

(
Forums ate my response...
why forums ate your response? hehehe

)
with this service definition:
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"
}
and this command definition:
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$
}
i got this error:
Code: Select all
SERVICE ALERT: backups;Nagios Status;UNKNOWN;SOFT;1;Remote command execution failed: Permission denied, please try again.
with this service definition:
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"
}
and with command definition:
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$
}
i got this errorr:
Code: Select all
SERVICE ALERT: backups;Nagios Status;UNKNOWN;SOFT;2;Remote command execution failed: Permission denied, please try again.
Switch to nagios user then run the command I hope it will show exact problem
but i can't switch to nagios user!!!
Code: Select all
root@maestro:/etc/nagios3# id nagios
uid=121(nagios) gid=124(nagios) groups=124(nagios)
but when i try...su -nagios :
Code: Select all
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
i'm little bit confused! help!