2

Is it possible to pass a different password to the check_nt/check_nrpe command for each windows host I have defined in my icinga configs? For example, I have 3 windows hosts

define host {
    use            windows-server
    host_name      prod
    address        10.0.0.1
}
define host {
    use            windows-server
    host_name      db
    address        10.0.0.2
}
define host {
    use            windows-server
    host_name      test
    address        10.0.0.3
}

and a service set up:

define service{
    use                     generic-service
    host_name               prod,db,test
    service_description     Uptime
    check_command           check_nt!UPTIME
    normal_check_interval   180
    }

which calls

define command {
    command_name    check_nt
    command_line    /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$'
}

This is all working great but I want to be able to set a different password for each host (that isn't viewable from the web interface). I know that the USERn macro's don't appear in the web interface but I don't know how I could use them here. Is there a simple way to do this without creating 3 different services and passing the password as an argument at that stage?

2

Yes, just rewrite the command definition:

define command {
    command_name    check_nt_pwd
    command_line    /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -s '$ARG1$' -v '$ARG2$'
}

Then you can either use three service definitions like so:

define service{
    use                     generic-service
    host_name               prod
    service_description     Uptime
    check_command           check_nt!PWD1!UPTIME
    normal_check_interval   180
    }
define service{
    use                     generic-service
    host_name               db
    service_description     Uptime
    check_command           check_nt!PWD2!UPTIME
    normal_check_interval   180
    }

Or if you have a modern Nagios set host variables (_password) and use a macro ($_HOSTPASSWORD$) like so:

define host {
    use            windows-server
    host_name      prod
    address        10.0.0.1
    _password      PWD1
}
define service{
    use                     generic-service
    host_name               prod,db,test
    service_description     Uptime
    check_command           check_nt!$_HOSTPASSWORD$!UPTIME
    normal_check_interval   180
    }

Or if you want add the macro directly to the command definition in a similar fashion.

1
  • The former violates your "that isn't viewable from the web interface" requirement, FYI. The latter should be okay.
    – Keith
    Sep 8 '14 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.