Multiple Usernames and Passwords in Service Checks

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
aBill
Posts: 1
Joined: Thu Oct 03, 2013 10:34 am

Multiple Usernames and Passwords in Service Checks

Post 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.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Multiple Usernames and Passwords in Service Checks

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked