SQLite variables in check script

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
dclose
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

SQLite variables in check script

Post 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}
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: SQLite variables in check script

Post 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?
Former Nagios employee
https://www.mcapra.com/
dclose
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

Re: SQLite variables in check script

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: SQLite variables in check script

Post by scottwilkerson »

GLad you got it sorted. Closing
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked