What user does Nagios run check scripts with? I set up a device to auto log in when I ssh into it in order to run a check script. It works when I ssh into the Nagios server.
[nagios@Juno libexec]$ /usr/local/nagios/libexec/check_3par.pl 10.160.1.32 3paradm check_port_fc
/usr/local/nagios/libexec/check_3par.pl: line 248: /tmp/3par_check_port_fc.10.160.1.32.out1: Permission denied
Could not connect to InServ 10.160.1.32
Do I have to add the nagios user to the sudoers file?
The reason the nagios user cannot write to the file "check_port_fc" is because the check was originally run as root on the command line and the file's owner became root, which the nagios user cannot modify. If you get rid of the file "check_port_fc" and recreate it with the nagios user, your permission problem should be resolved.
or alternatively, you could change the permissions of the plugin,
That fixed that part, thanks. But now I have a different problem. The check needs to have it so that the nagios user can auto login to the device. I can do it with the root user but it doesn't generate the rd_rsa.pub when I do it with the nagios user. Here is the instruction page, on page four it says how to configure the nagios to auto login. http://exchange.nagios.org/components/c ... 0&cf_id=29
Edit.
Alright so I set up auto log in for nagios and ran the check script. It worked! But when I ran it again it failed.
[nagios@Juno .ssh]$ /usr/local/nagios/libexec/check_3par.pl 10.160.1.32 3paradm check_port_fc
OK : All FC ports have normal status (ready or offline)
[nagios@Juno .ssh]$ /usr/local/nagios/libexec/check_3par.pl 10.160.1.32 3paradm check_port_fc
/usr/local/nagios/libexec/check_3par.pl: line 248: /tmp/3par_check_port_fc.10.160.1.32.out1: Permission denied
Could not connect to InServ 10.160.1.32
[nagios@Juno .ssh]$ /usr/local/nagios/libexec/check_3par.pl 10.160.1.32 3paradm check_port_fc
/usr/local/nagios/libexec/check_3par.pl: line 248: /tmp/3par_check_port_fc.10.160.1.32.out1: Permission denied
Could not connect to InServ 10.160.1.32
Edit.
Alright, so I kept testing it and it seems that if I run the script while I'm root user I can run the script as the nagios user. But if I am in Service Management and I click the Test Check Command and type in the Ip address. Then it says
Testing the check with the "Test Check Command" button is an inaccurate way of testing the check as it runs the check as the apache user. Testing from the CLI is the preferred method and will give you much more accurate results of what the check will actually return. If I were you, I would ignore the "Test Check Command" button and check from the CLI only.