opinkerfi / adagios

Adagios - Web Based Nagios Configuration
GNU Affero General Public License v3.0
330 stars 75 forks source link

Adagios should care about custom variables #460

Closed giner closed 9 years ago

giner commented 10 years ago

Adagios does not understand custom variables. For example for this:

define host{
    use                         Switch
    host_name                   switch-core-1
    address                     XX.XX.XX.XX
    hostgroups                  Switch-Core
    _ifstatus_exclude_unused    1,2,3,4
}

define service{
    use                         generic-service
    hostgroup_name              Switch-Core
    service_description         check_ifstatus_exclude_unused
    check_command               check_ifstatus_exclude_unused!$_HOSTIFSTATUS_EXCLUDE_UNUSED$
}

define command {
       command_name     check_ifstatus_exclude_unused
       command_line     $USER1$/check_ifstatus -t 30 -H $HOSTADDRESS$ -C COMMUNITY -u $ARG1$
}

Adagios shows this on the information page:

Check command   /usr/lib/nagios/plugins/check_ifstatus -t 30 -H 10.133.63.4 -C Smart-Cards1 -u 

where it should be:

Check command   /usr/lib/nagios/plugins/check_ifstatus -t 30 -H 10.133.63.4 -C Smart-Cards1 -u 1,2,3,4
palli commented 9 years ago

This looks like a pynag problem rather than adagios problem, but it seems like this is a mixture of:

a) using service checks with hostgroups b) Using a custom variable that is injected as $ARG1$

2 quick questions: a) Does Nagios interpret this ok, which variant or version ? b) Does it work if you command line looks like this:

define command {
       command_name     check_ifstatus_exclude_unused
       command_line     $USER1$/check_ifstatus -t 30 -H $HOSTADDRESS$ -C COMMUNITY -u $_HOSTIFSTATUS_EXCLUDE_UNUSED$
}
giner commented 9 years ago

a) Does Nagios interpret this ok, which variant or version ?

Yes, It works in both Nagios 3.2.3 (Ubuntu 12.04) and 3.5.1 (Ubuntu 14.04).

b) Does it work if you command line looks like this

I'll check this tomorrow.

giner commented 9 years ago

Adagios produces the same result for check_ipmi_sensor (command config comes with a package from the official Ubuntu repo):

define command{
        command_name    check_ipmi_sensor
        command_line    /usr/lib/nagios/plugins/check_ipmi_sensor -H $_HOSTIPMI_IP$ -f $ARG1$
}

define service {
        use                             generic-service
        service_description             check_ipmi_sensor
        check_command                   check_ipmi_sensor!/etc/nagios3/custom/plugins-auth/check_ipmi.auth
        hostgroup_name                  IPMI
}

define host{
        use             Server
        host_name       server1
        address         10.0.0.1
        hostgroups      IPMI,...
        _ipmi_ip        10.0.0.2
}
palli commented 9 years ago

Yeah looks like command arguments ($ARG1$) are not being processed correctly when its a service check applied to a hostgroup. I will take a look at it, but the patch will be in pynag, not adagios.

giner commented 9 years ago

In the latest example $ARG1$ is not used and $_HOSTIPMI_IP$ is used instead however it doesn't work either.

palli commented 9 years ago

I will take a look at it, although it could be because in your host definition the _ipmi_ip macro is lowercase, but in the command definition it is uppercase.

giner commented 9 years ago

This is by design http://nagios.sourceforge.net/docs/3_0/customobjectvars.html

palli commented 9 years ago

Ok, there are 2 patches in pynag that are waiting to be merged:

Once these are merged I think we can close this bug.

palli commented 9 years ago

Ok both pull requests have been merged, so I believe finally we are good and the bugs raised in this issue have been fixed.

Can you please download latest pynag (from github if using pip, if using rpm, then ok-testing packages should be ready in 1 hour or so).

I am marking this issue as closed, if there are any further questions or concerns, dont hesitate to reopen it.

ps: Thank you for taking the time to help troubleshoot this.

giner commented 9 years ago

It works perfect now! Thank you.