community strings and passwords

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
MPIvan
Posts: 213
Joined: Thu Nov 22, 2012 6:09 am

community strings and passwords

Post by MPIvan »

Hi
i would like to find some solution about having a different passwords or community strings for a given service that i would like to used in host group. Example: I have multiple host that i like to monitor uptime (for example) but they all have different passwords or community strings and i like to make a group of them, that all that group (host group) have the same UpTime service, and there's the problem, they all have different passwords or community string so how to solve this?

any solution ?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: community strings and passwords

Post by abrist »

Use the $USERn$ macros, specify a different macro for each hostgroup. You will still have to create separate checks for each hostgroup though.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
wezelboy
Posts: 13
Joined: Tue Feb 26, 2013 1:34 pm

Re: community strings and passwords

Post by wezelboy »

You can also use custom data fields- for example:

define host{
host_name foo
alias A host called foo
address foo.bar.baz
_community woopwoop
}

And your snmp command might have this:

define command{
command_name check_snmp_example
command_line /usr/local/nagios/libexec/check_snmp -H $HOSTADDRESS$ -C $_HOSTCOMMUNITY$ <rest of command>
}
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: community strings and passwords

Post by sreinhardt »

I would also suggest wezelboy's usage. This way you can apply the same command to multiple hosts\ a host group and have different community strings defined by the individual hosts. The $USERX$ args as abrist suggests would work but would require multiple commands, and taking up many of the $USER$ args.
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.
MPIvan
Posts: 213
Joined: Thu Nov 22, 2012 6:09 am

Re: community strings and passwords

Post by MPIvan »

Yup, wezelboy is right i already do that and it work ok ... in host you specify _SNMPCOMMUNITY <community_name> and in the command.cgf file in the specify command you add the -C $_HOSTSNMPCOMMUNITY$ and it works ... tnx again to all of you ...
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: community strings and passwords

Post by sreinhardt »

Thanks for letting us know its working!
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