I have been trying to search on google for this problem but nothing I find fixes it.
I am using the check_sql plugin from nagios exchange, when I run it from the command line it returns successfully but from with in nagios the status is Unknown and the status information is (No Output!).
This is what I run from the command line.
./check_sql -H (server) -d Sybase -U (username) -P (password)
and the result is:
CHECK_SQL OK - SQL Server responded in 0.047788 seconds | time=0.047788s;;
This is what I have in the commands.cfg
# ‘check_mssql’ command definition
define command{
command_name check_mssql
command_line $USER1$/check_sql -H (server) -d Sybase -U (username) -P (password)
}
This is the services.cfg #Check Frodo APPLOGS database for FLR stats
define service{
use template-service
host_name (server)
service_description FLR_STATS
check_command check_mssql
max_check_attempts 2
normal_check_interval 1440
retry_check_interval 2
check_period workhours
notification_interval 1440
notification_period workhours
contact_groups nadmin
I have already tried adding the use lib utils.pm path to the check_sql file
I have tried to add /usr/local/perl to the begining of the check command.
The rights to all the check commands are 755 and nagios is the owner and group
Does your database password contain any funky characters like $ or / ? You might have to wrap your check command in your own little shell script then change your checkcommand to $USER1$/my_check_sql.sh etc. etc.
Just to make sure: have you checked your event log (in the nagios web interface) ?
Sometimes, it has very useful infos about this kind of problems (sometimes only :)).
Also, if you’re really stuck, what you could do is:
-rename your check_sql plugin to something else (check_sql.bak ?)
-create a small shell script called check_sql, that takes all the arguments and output them on one line, so that nagios can read them and return them (or write them in a log file).
With that, you’ll see if all the arguments are correctly passed to the plugin and if the plugin is called at all …etc
Have you tried switching to your nagios user and running the command & args? eg:
$ su - nagios
$ /path/to/check_sql -H (server) -d Sybase -U (username) -P (password)
check_sql might be calling other stuff that isn’t runnable by the nagios user
Yes i was running it at the command line as the nagios user. I also ran it using the full path /usr/local/nagios/libexec/check_sql … and it still worked at the command line.
Ok so here is what I have come up with. I was setting the variable as the nagios user and saved them in the nagios user .bash_profile so when i ran at the command line as the nagios user it worked. When I tested as root i set the variables for the root user but didn’t save them. When i was restarting nagios i was doing it from the web interface. I then decided to restart nagios manually, so I shut it down from the web interface and started it up logged in as the nagios user with the /usr/local/nagios… -d … command then everything worked. So to test this i shut it down again logged in as root and started it with the service nagios start command and the check commands no longer worked. I don’t really understand this because if I do a ps -eaf | grep nagios it shows that nagios is the user running the process in both of the above cases. But I have it working no and wanted to thank you both for the help. If you have any thoughts on the above please feel free to share.
Yes, just one thought:
add the variables in your NAGIOS “.profile” file, do a su - nagios and start nagios from there
it should also work when starting as root, because the start command does a “su - nagios” anyway