Feature to force contact_groups append instead of overwrite

User / Community contributed content: modifications, patches, extensions, modules, scripts etc.

Feature to force contact_groups append instead of overwrite

Postby Tontonitch » Mon Dec 19, 2011 23:43

Hi,

I needed to have some contact_group inheritances between host-templates / service-templates, which don't overwrite the contact_group defined on the host/service.

For that, I've written a patch that add an option in the nconf.php file:
a new variable FORCE_CONTACTGROUPS_APPEND can be set to globally change the way that contactgroups are added when inherited
  • 0: overwrite existing contact groups. this is the default and actual behaviour
  • 1: append to existing contact groups (add the '+' prefix)
Note that currently the default behaviour changes for host and service depending on the SUPERADMIN_GROUPS definition (if prefixed by a '+' or not).

So, when the FORCE_CONTACTGROUPS_APPEND option is set to 1, a character '+' will be added in front of the contact_groups lists when writing the following classes to nagios cfg files:
  • host
  • service
  • advanced-service
  • host-template
  • service-template
For exemple, it is now possible to have multiple templates on the same host, and contact_groups on that host will be the sum of every contact_groups (every linked templates + host).

Attached the patch:

That would be great to have in future release of NConf something more flexible.
For exemple, a radio button below every contact_group selector. Something similar to what is already implemented when multimodifying contactgroups of some services.
  • selecting 'overwrite' would trigger the actual behaviour.
  • selecting 'append' would add a '+' to the contactgroup list, which indicates that a '+' character will be added in front of the contact_group list when written in the nagios cfg file.
BR,
Yannick
User avatar
Tontonitch
NConf addict
NConf addict
 
Posts: 254
Joined: Fri May 07, 2010 10:14
Location: Thionville, France

Re: Feature to force contact_groups append instead of overwr

Postby jschmoe » Tue Oct 28, 2014 22:46

How do you apply this patch??
jschmoe
starter
starter
 
Posts: 1
Joined: Tue Oct 28, 2014 17:17

Re: Feature to force contact_groups append instead of overwr

Postby Tontonitch » Tue Oct 28, 2014 23:17

Hi,
0. Backup your nconf installation (ex: tar cfz nconf_install.tar.gz /usr/local/nconf or whatever you used)
1. Copy the patch file to this directory
2. Test the patch application: cd <nconf path>; patch --verbose --dry-run -p0 < nconf-1.3.0-0_feature_force_contactgroups_append.patch
3. If no problem reported, apply the patch: patch --verbose -p0 < nconf-1.3.0-0_feature_force_contactgroups_append.patch
Regards,
Yannick
User avatar
Tontonitch
NConf addict
NConf addict
 
Posts: 254
Joined: Fri May 07, 2010 10:14
Location: Thionville, France


Return to Contributions

Who is online

Users browsing this forum: No registered users and 1 guest

cron