Page 1 of 1

Multiple Usernames and Passwords in Service Checks

Posted: Tue May 06, 2014 11:06 am
by aBill
I need to use multiple user names and passwords in order to get data from some of our servers. The resource.cfg file has $USERx$ etc but if I use that then I'll need to have an equal number of commands.cfg set up with those. That would make the commands.cfg file extremely large and a pain to update. How do I use multiple usernames and passwords in the checks?

Below are examples of what is already in place.

resource.cfg
$USER2$=username
$USER4$=password

commands.cfg
# check temperature
define command{
command_name check_esx_temperature
command_line $USER1$/check_vmware.pl -H $HOSTADDRESS$ -u $USER2$ -p $USER4$ -l runtime -s temperature -w $ARG1$ -c $ARG2$
}

hosts.cfg
define host{
use linux_host
host_name esxi_host
alias esxi_host
address 192.168.7.7
contact_groups admins
hostgroups vmware-esxi
}

What do I need to add to allow multiple user names and passwords to use the same commands?

Thank you for your time.

Re: Multiple Usernames and Passwords in Service Checks

Posted: Tue May 06, 2014 11:30 am
by sreinhardt
With some plugins you might be able to specify credentials using a flat file instead. Otherwise arguments and user macros are about the only way to do this. Since you cannot use a macro within a macro (ie: $ARG1$=$USER4$) and get them to expand properly, you're kind of in a tricky situation. I suppose you could make custom macros within the host\service and add credentials there then call $_HOSTUSERNAME$ or something similar. But you still run into having to put lots of credentials in at least every host\hostgroup.