Possible feature patch - Excluding with use_true_regexp_matching=1
Matthias Kerk
matthias at tuxlife.de
Thu Jun 26 15:55:31 CEST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I would like to know if it is possible to excluding Hosts, services, groups and so on
excluding with use_true_regex-Option?
I have written a patch, which allow by use_true_regexp_matching=1, Excluding.
- --- nagios-3.0.3.orig/xdata/xodtemplate.c 2008-06-23 23:43:22.000000000 +0200
+++ nagios-3.0.3/xdata/xodtemplate.c 2008-06-26 15:28:24.000000000 +0200
@@ -13345,6 +13345,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this contactgroup should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -13377,7 +13383,7 @@
~ continue;
~ /* add contactgroup members to list */
- - xodtemplate_add_contactgroup_members_to_memberlist(list,temp_contactgroup,_config_file,_start_line);
+ xodtemplate_add_contactgroup_members_to_memberlist((reject_item==TRUE)?reject_list:list,temp_contactgroup,_config_file,_start_line);
~ }
~ /* free memory allocated to compiled regexp */
@@ -13399,19 +13405,13 @@
~ continue;
~ /* add contactgroup to list */
- - xodtemplate_add_contactgroup_members_to_memberlist(list,temp_contactgroup,_config_file,_start_line);
+ xodtemplate_add_contactgroup_members_to_memberlist((reject_item==TRUE)?reject_list:list,temp_contactgroup,_config_file,_start_line);
~ }
~ }
~ /* else this is just a single contactgroup... */
~ else{
- - /* this contactgroup should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the contactgroup */
~ temp_contactgroup=xodtemplate_find_real_contactgroup(temp_ptr);
~ if(temp_contactgroup!=NULL){
@@ -13468,6 +13468,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this contact should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -13498,7 +13504,7 @@
~ continue;
~ /* add contact to list */
- - xodtemplate_add_member_to_memberlist(list,temp_contact->contact_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_contact->contact_name,NULL);
~ }
~ /* free memory allocated to compiled regexp */
@@ -13523,19 +13529,13 @@
~ continue;
~ /* add contact to list */
- - xodtemplate_add_member_to_memberlist(list,temp_contact->contact_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_contact->contact_name,NULL);
~ }
~ }
~ /* else this is just a single contact... */
~ else{
- - /* this contact should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the contact */
~ temp_contact=xodtemplate_find_real_contact(temp_ptr);
~ if(temp_contact!=NULL){
@@ -13696,6 +13696,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this hostgroup should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -13728,7 +13734,7 @@
~ continue;
~ /* add hostgroup members to list */
- - xodtemplate_add_hostgroup_members_to_memberlist(list,temp_hostgroup,_config_file,_start_line);
+ xodtemplate_add_hostgroup_members_to_memberlist((reject_item==TRUE)?reject_list:list,temp_hostgroup,_config_file,_start_line);
~ }
~ /* free memory allocated to compiled regexp */
@@ -13750,19 +13756,13 @@
~ continue;
~ /* add hostgroup to list */
- - xodtemplate_add_hostgroup_members_to_memberlist(list,temp_hostgroup,_config_file,_start_line);
+ xodtemplate_add_hostgroup_members_to_memberlist((reject_item==TRUE)?reject_list:list,temp_hostgroup,_config_file,_start_line);
~ }
~ }
~ /* else this is just a single hostgroup... */
~ else{
- - /* this hostgroup should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the hostgroup */
~ temp_hostgroup=xodtemplate_find_real_hostgroup(temp_ptr);
~ if(temp_hostgroup!=NULL){
@@ -13819,6 +13819,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this host should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -13849,7 +13855,7 @@
~ continue;
~ /* add host to list */
- - xodtemplate_add_member_to_memberlist(list,temp_host->host_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_host->host_name,NULL);
~ }
~ /* free memory allocated to compiled regexp */
@@ -13874,19 +13880,13 @@
~ continue;
~ /* add host to list */
- - xodtemplate_add_member_to_memberlist(list,temp_host->host_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_host->host_name,NULL);
~ }
~ }
~ /* else this is just a single host... */
~ else{
- - /* this host should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the host */
~ temp_host=xodtemplate_find_real_host(temp_ptr);
~ if(temp_host!=NULL){
@@ -14036,6 +14036,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this servicegroup should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -14068,7 +14074,7 @@
~ continue;
~ /* add servicegroup members to list */
- - xodtemplate_add_servicegroup_members_to_memberlist(list,temp_servicegroup,_config_file,_start_line);
+ xodtemplate_add_servicegroup_members_to_memberlist((reject_item==TRUE)?reject_list:list,temp_servicegroup,_config_file,_start_line);
~ }
~ /* free memory allocated to compiled regexp */
@@ -14090,19 +14096,13 @@
~ continue;
~ /* add servicegroup to list */
- - xodtemplate_add_servicegroup_members_to_memberlist(list,temp_servicegroup,_config_file,_start_line);
+ xodtemplate_add_servicegroup_members_to_memberlist((reject_item==TRUE)?reject_list:list,temp_servicegroup,_config_file,_start_line);
~ }
~ }
~ /* else this is just a single servicegroup... */
~ else{
- - /* this servicegroup should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the servicegroup */
~ if((temp_servicegroup=xodtemplate_find_real_servicegroup(temp_ptr))!=NULL){
@@ -14175,6 +14175,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this service should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching for the service description? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp_service=TRUE;
@@ -14227,7 +14233,7 @@
~ continue;
~ /* add service to the list */
- - xodtemplate_add_member_to_memberlist(list,host_name,temp_service->service_description);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,host_name,temp_service->service_description);
~ }
~ /* free memory allocated to compiled regexp */
@@ -14256,19 +14262,13 @@
~ continue;
~ /* add service to the list */
- - xodtemplate_add_member_to_memberlist(list,host_name,temp_service->service_description);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,host_name,temp_service->service_description);
~ }
~ }
~ /* else this is just a single service... */
~ else{
- - /* this service should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the service */
~ if((temp_service=xodtemplate_find_real_service(host_name,temp_ptr))!=NULL){
@@ -14438,6 +14438,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this hostgroup should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -14470,7 +14476,7 @@
~ continue;
~ /* add hostgroup to list */
- - xodtemplate_add_member_to_memberlist(list,temp_hostgroup->hostgroup_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_hostgroup->hostgroup_name,NULL);
~ }
~ /* free memory allocated to compiled regexp */
@@ -14492,19 +14498,13 @@
~ continue;
~ /* add hostgroup to list */
- - xodtemplate_add_member_to_memberlist(list,temp_hostgroup->hostgroup_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_hostgroup->hostgroup_name,NULL);
~ }
~ }
~ /* else this is just a single hostgroup... */
~ else{
- - /* this hostgroup should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the hostgroup */
~ temp_hostgroup=xodtemplate_find_real_hostgroup(temp_ptr);
~ if(temp_hostgroup!=NULL){
@@ -14616,6 +14616,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this contactgroup should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -14648,7 +14654,7 @@
~ continue;
~ /* add contactgroup to list */
- - xodtemplate_add_member_to_memberlist(list,temp_contactgroup->contactgroup_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_contactgroup->contactgroup_name,NULL);
~ }
~ /* free memory allocated to compiled regexp */
@@ -14670,19 +14676,13 @@
~ continue;
~ /* add contactgroup to list */
- - xodtemplate_add_member_to_memberlist(list,temp_contactgroup->contactgroup_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_contactgroup->contactgroup_name,NULL);
~ }
~ }
~ /* else this is just a single contactgroup... */
~ else{
- - /* this contactgroup should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the contactgroup */
~ temp_contactgroup=xodtemplate_find_real_contactgroup(temp_ptr);
~ if(temp_contactgroup!=NULL){
@@ -14794,6 +14794,12 @@
~ /* strip trailing spaces */
~ strip(temp_ptr);
+ /* this servicegroup should be excluded (rejected) */
+ if(temp_ptr[0]=='!'){
+ reject_item=TRUE;
+ temp_ptr++;
+ }
+
~ /* should we use regular expression matching? */
~ if(use_regexp_matches==TRUE && (use_true_regexp_matching==TRUE || strstr(temp_ptr,"*") || strstr(temp_ptr,"?") || strstr(temp_ptr,"+") || strstr(temp_ptr,"\\.")))
~ use_regexp=TRUE;
@@ -14826,7 +14832,7 @@
~ continue;
~ /* add servicegroup to list */
- - xodtemplate_add_member_to_memberlist(list,temp_servicegroup->servicegroup_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_servicegroup->servicegroup_name,NULL);
~ }
~ /* free memory allocated to compiled regexp */
@@ -14848,19 +14854,13 @@
~ continue;
~ /* add servicegroup to list */
- - xodtemplate_add_member_to_memberlist(list,temp_servicegroup->servicegroup_name,NULL);
+ xodtemplate_add_member_to_memberlist((reject_item==TRUE)?reject_list:list,temp_servicegroup->servicegroup_name,NULL);
~ }
~ }
~ /* else this is just a single servicegroup... */
~ else{
- - /* this servicegroup should be excluded (rejected) */
- - if(temp_ptr[0]=='!'){
- - reject_item=TRUE;
- - temp_ptr++;
- - }
- -
~ /* find the servicegroup */
~ temp_servicegroup=xodtemplate_find_real_servicegroup(temp_ptr);
~ if(temp_servicegroup!=NULL){
- --
Matthias
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFIY5/TTG9/zWWjsBsRAh2SAJwILgVMOCKoDMXVqSxhALcNu1rQmgCfVpHN
vKJO9wm9CXzm0ar/vxV/gLc=
=MDAz
-----END PGP SIGNATURE-----
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
More information about the Developers
mailing list