Page 1 of 1

Permission Denied while opening nagios session

Posted: Thu Jul 07, 2016 7:15 pm
by Ayush Jain
Hi,

I have configured one service check using "check_by_ssh_master" plugin . when i am trying to execute the command from nagios server it's giving correct output

./check_by_ssh_master -T psnagios@<hostaddress> -t 60 -m 200 -S /usr/local/nagios/tmp "/users/psnagios/nrpe-agent/nrpe/libexec/tomcat_sora2.sh"

Output :- OK - 1 Tomcat Process running from correct path

But when i have configured same thing in Nagiosxi .. PFA (Service config in nagiosxi)
It's giving error as mentioned below.

cannot open /usr/local/nagios/tmp/psnagios@<hostaddress>.sessions: Permission denied



Permissions given to tmp directory and session file present inside it :

drwxrwxrwx 2 nagios nagios 12288 Jul 8 05:00 tmp

-rw------- 1 apache apache 0 Jul 8 05:00 psnagios@<hostname>.sessions


Note: For other servers same thing i have configured, there it's working fine

Please check and let me know what permissions i need to modify , I am not aware of these sessions in nagiosxi.
Please Let me know if any other information is required.

Thanks and Regards,
Ayush Jain

Re: Permission Denied while opening nagios session

Posted: Thu Jul 07, 2016 8:26 pm
by Box293
There are a couple if things with check_by_ssh_master which will be causing your issues.
Ayush Jain wrote:I have configured one service check using "check_by_ssh_master" plugin . when i am trying to execute the command from nagios server it's giving correct output

./check_by_ssh_master -T psnagios@<hostaddress> -t 60 -m 200 -S /usr/local/nagios/tmp "/users/psnagios/nrpe-agent/nrpe/libexec/tomcat_sora2.sh"

Output :- OK - 1 Tomcat Process running from correct path
When you are testing, are you testing as the nagios user ?
If you are logged into the ssh session as root, the command you are executing stores the ssh keys in it's home directory.
When the nagios user goes to execute the plugin, it doesn't know about those certificates the root user owns.

Do the following:

Code: Select all

su nagios
/usr/local/nagios/libexec/check_by_ssh_master -T psnagios@<hostaddress> -t 60 -m 200 -S /usr/local/nagios/tmp "/users/psnagios/nrpe-agent/nrpe/libexec/tomcat_sora2.sh"
This will confirm the ssh keys have been propely setup and the plugin is correctly executing as the nagios user. If it does not complete, you need to resolve any issues it is complaining about.
Ayush Jain wrote:But when i have configured same thing in Nagiosxi .. PFA (Service config in nagiosxi)
It's giving error as mentioned below.

cannot open /usr/local/nagios/tmp/psnagios@<hostaddress>.sessions: Permission denied

Permissions given to tmp directory and session file present inside it :

drwxrwxrwx 2 nagios nagios 12288 Jul 8 05:00 tmp

-rw------- 1 apache apache 0 Jul 8 05:00 psnagios@<hostname>.sessions


Note: For other servers same thing i have configured, there it's working fine

Please check and let me know what permissions i need to modify , I am not aware of these sessions in nagiosxi.
To directly address the permission denied error I must go back to the first point I made. If you've been running the command in the ssh session as the root user, then the directory referenced here -S /usr/local/nagios/tmp (and any temp files the plugin creates) will have been created by the root user and the nagios user will not have permission. You need to either delete the file and let the plugin create them as the nagios user, or fix the permissions.

One other point to make.
I can see you are running into a couple of problems which can lead to the issues you are having.

Due to how PHP runs as the apache user, the "Test Check Command" does not work in these situations and should be ignored.

So for all further testing of this service you need to:

Make the changes to the service
Save the Service
Apply Configuration
Go back to the home screen and find the Service
When viewing the Service Status Details page click the Schedule a forced immediate check link

Just to re-iterate, for all further testing for this service DO NOT use the "Test Check Command" button, follow the steps above.


Does this help fix your problem?