Multiple passwords cause for multiple commands?

Hello,

I’m attempting to find a way to keep from having to create multiple command definitions that are identical except for the community or password. In the site specific commands directories I usually just copy the command from the global/commands directory and change the $USERn$ variable. Is there a way to inherit $USERn$ based on the hostgroup or servicegroup?

I currently have a script that builds most of the configs, so I don’t have to do the command definitions manually. I know nagios just flattens out the whole cfg_dir anyways, so this is just my attempt at cutting down on the number of .cfg files I have. I figured that having command definitions that have only one character difference qualifies for a second look at how I’m doing things. Has anyone else dealt with this issue?

I removed quite a bit of irrelevant info from the layout below, trying to keep it somewhat brief.
My current cfg_dir is like so:
|-- global
| |-- commands
| -- check_something.cfg | |– local
| |-- contacts
| | |-- groups
| | -- users | |-- hostgroups | |-- hosts | |-- servicegroups | |-- services |– templates
-- sites– site1
| |-- commands
| -- check_something_site1.com.cfg | |-- hosts |– services
| |-- host1.site1.com
| -- host2.site1.com– site2
|-- commands
| -- check_something_site2.com.cfg |-- hosts– services
|-- host1.site2.com
`-- host2.site2.com

Thanks!

Gave the docs a good once over and found the “custom object variables”. I can set the pass/comm in the host or service definition and reference it via macro in the command. Awesomeness.