Page 1 of 1

SQLite variables in check script

Posted: Mon Feb 26, 2018 8:32 pm
by dclose
I would like to add some information from a local SQLite data base to the status information shown by Nagios. I have a check script which can access that information and provide it in the required format. In fact, I have two versions of this script, one in bash and one in Perl. Both work perfectly when run on the Nagios server under either the nagios account or the apache account. But when run by Nagios itself, the values returned from the data base are always empty. Does anyone have any idea what I'm doing wrong?

Server is running 64-bit Fedora 27 with Nagios 4.3.4. An abbreviated version of the bash script is below.

Code: Select all

#! /bin/bash
cmd="/usr/bin/sqlite3 /myuser/machines.sqlite"
os=$( $cmd "select os from table where name = \"$1\";" )
echo os = ${os}

Re: SQLite variables in check script

Posted: Tue Feb 27, 2018 2:23 pm
by mcapra
Can you show us exactly how you are running these scripts in Nagios?

As a handler or check command? Can you show us the command definition?

As service/host checks? Can you show us the service/host definitions?

Re: SQLite variables in check script

Posted: Tue Feb 27, 2018 9:15 pm
by dclose
Nevermind. User error. From the command line, I was supplying the simple host name but Nagios is supplying the fully-qualified name. The data base doesn't know the FQDN so it wasn't returning any data.

Re: SQLite variables in check script

Posted: Wed Feb 28, 2018 4:10 pm
by scottwilkerson
GLad you got it sorted. Closing