A few questions about config and disappearing entries

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
msarro
Posts: 4
Joined: Mon May 16, 2011 7:01 am

A few questions about config and disappearing entries

Post by msarro »

Hey everyone,
First, I'm new, so please be gentle :)

I have made some recent modifications to our nagios3 files. In
resource.cfg I added the following macros: $db_name$, $db_user_name$,
and $db_user_pass$. These seem to be ok.
I added a service like this:
define service {
hostgroup_name mysql-servers
service_description Mysql FSRW
check_command check_mysql_FSRW
use generic-service
notification_interval 0
}


And finally I added a command like this:
define command {
command_name check_mysql_FSRW
command_line $USER1$/check_mysql_query -q "SELECT COUNT(*) FROM
entry WHERE period<DATE_SUB(now(),INTERVAL 2 DAY) AND status_code<2
AND retries=0 AND type=0" -w0:0 -c10 -H $HOSTADDRESS$ -P 3306 -d
$db_name$ -u $db_user_name$ -p $db_user_pass$
}

When I have nagios validate everything, it gives no errors. I then
restart nagios for the config to take effect, and it comes up. In the
event log I see some issues with the service (it appears to be trying
to connect to the mysql servers as user nagios, not the specified
user). When I then log back into the server and look at my
services.cfg file, and my commands.cfg file, the entries I added to
both of them have been removed - like they were never there.

So, I guess I have a few questions.

First, are those entries in the resource.cfg file ok? Does nagios
support the underscores and longer names? Its easier to understand at
a glance than $USER3$ $USER4$ and $USER5$.

Second, does the command_line look ok? I'm trying to figure out why it
isn't using the username and password I'm passing to it.

Finally, why do the command and service keep disappearing out of my
config file? It's making it a pain to troubleshoot.
Any suggestions or advice would be greatly appreciated.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: A few questions about config and disappearing entries

Post by mguthrie »

I'm not sure if this will fix your particular issue, but it's generally recommended to prepend custom variables with an underscore to prevent conflicts with existing macros.

$_DBNAME$
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: A few questions about config and disappearing entries

Post by mguthrie »

Are you using NagiosQL to manage your config files? If you are NagiosQL will overwrite your config definitions with what it has in the database.
msarro
Posts: 4
Joined: Mon May 16, 2011 7:01 am

Re: A few questions about config and disappearing entries

Post by msarro »

Just as a followup, it appears the server was being controlled by a Puppet installation, which was removing my changes. Thanks guys!
Locked