0

I have setup Nagios and Nconf to check our network but I have a problem that I have not yet been able to solve. How do I add custom object variables (_var-name) to a host? I have a number of custom checks that requires custom variables.

eg: output would be

define host{
    use                     generic-host            
    host_name               my-host-name
    alias                   my-host-name-alias
    address                 my-host-name.com
    _SSHUSER                ausername                               <- How do I add this i NConf
    _CONNECTIONSTRING       "jdbc:mysql://my-host-name.com/db_name" <- And this?
    hostgroups              Linux
    }

2 Answers2

1

You can add extra attributes to host definition and then instruct NConf to write these to generated config or not.

See in NConf Administration/Attributes - Add

Nagios-specific attribute name: _SSHUSER
Friendly name: ssh user on host
Attribute belongs to class: host
attribute is visible?: yes
write attribute to configuration?: yes

Submit

After this procedure edit your defined host and you should find "ssh user" attribute. Fill it with relevant data and Generate Nagios config. The new attribute will included in it.

ZsZs
  • 11
  • 1
0

Nconf won't do this without some rather major modifications. I typically enter options on the check_command as arguments. Of course, this only works if your NRPE server is set up to allow the passing of args to the monitored hosts.

When you define a check_command in Nagios, you do not have to use only the short name of the command. You can pass arguments to it - some are already passed, like $HOSTNAME$. These do not have to be Nagios 'macros'. These are passed via $ARG1$, $ARG2$, etc.

For instance, in your service.cfg file(s):

check_ping!myhost.mydomain.com!5.0

See (example 2) @ http://nagios.sourceforge.net/docs/3_0/macros.html

In your example above, those option don't seem appropriate inside a 'host' definition. They appear more like server check options, mysql being a 'service' running on a 'host'.

Jim Black
  • 1,422
  • 1
  • 13
  • 26