[Nagios-devel] [PATCH] Add host/service option to control resetting
Posted: Thu Jun 02, 2011 9:13 pm
--=-gyHfA54s41jf8cyz8ym9
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Hello list,
Attached is a patch against 3.2.3 which provides an option to control
whether or not notification counters and suppression should be reset
when transitioning between non-OK states for hosts and services. The
default behavior is to mimic Nagios' current logic where notifications
are always reset on state changes. I've performed internal testing on
this and it works as expected.
If anyone has a better (shorter) name for the setting than
'reset_notifications_on_non_ok_state_change' I'd be very happy to hear
it, since the option is currently by far the longest for either hosts or
services.
Thanks,
--Alex
--
Alex Bame
Sr. Engineer
Stand Sure Systems
"Improving Internet Reliability One Site at a Time"
1077 Independence Ave.
Suite B
Mt. View, CA 94043
www.standsure.com
510.299.2713 CELL
650.967.9070 x2016
650.967.9071 FAX
--=-gyHfA54s41jf8cyz8ym9
Content-Disposition: attachment;
filename="nagios-add-reset-notifications.patch"
Content-Type: text/x-patch; name="nagios-add-reset-notifications.patch";
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
diff -urN nagios-3.2.3.orig/base/checks.c nagios-3.2.3/base/checks.c
--- nagios-3.2.3.orig/base/checks.c 2010-09-21 08:05:31.000000000 -0700
+++ nagios-3.2.3/base/checks.c 2011-05-25 17:41:52.761603203 -0700
@@ -1126,12 +1126,14 @@
/* reschedule the service check */
reschedule_check=3DTRUE;
=20
- /* reset notification times */
- temp_service->last_notification=3D(time_t)0;
- temp_service->next_notification=3D(time_t)0;
+ if(temp_service->reset_notifications_on_non_ok_state_change=3D=3DTRUE ||=
temp_service->current_state=3D=3DSTATE_OK){
+ /* reset notification times */
+ temp_service->last_notification=3D(time_t)0;
+ temp_service->next_notification=3D(time_t)0;
=20
- /* reset notification suppression option */
- temp_service->no_more_notifications=3DFALSE;
+ /* reset notification suppression option */
+ temp_service->no_more_notifications=3DFALSE;
+ }
=20
if(temp_service->acknowledgement_type=3D=3DACKNOWLEDGEMENT_NORMAL){
=20
diff -urN nagios-3.2.3.orig/base/sehandlers.c nagios-3.2.3/base/sehandlers.=
c
--- nagios-3.2.3.orig/base/sehandlers.c 2010-09-21 08:10:19.000000000 -0700
+++ nagios-3.2.3/base/sehandlers.c 2011-05-25 17:42:19.691603219 -0700
@@ -775,12 +775,15 @@
delete_host_acknowledgement_comments(hst);
}
=20
- /* reset the next and last notification times */
- hst->last_host_notification=3D(time_t)0;
- hst->next_host_notification=3D(time_t)0;
+ /* reset notifications if requested */
+ if(hst->reset_notifications_on_non_ok_state_change=3D=3DTRUE || hst->cur=
rent_state=3D=3DHOST_UP){
+ /* reset the next and last notification times */
+ hst->last_host_notification=3D(time_t)0;
+ hst->next_host_notification=3D(time_t)0;
=20
- /* reset notification suppression option */
- hst->no_more_notifications=3DFALSE;
+ /* reset notification suppression option */
+ hst->no_more_notifications=3DFALSE;
+ }
=20
/* write the host state change to the main log file */
if(hst->state_type=3D=3DHARD_STATE || (hst->state_type=3D=3DSOFT_STATE &=
& log_host_retries=3D=3DTRUE))
diff -urN nagios-3.2.3.orig/cgi/config.c nagios-3.2.3/cgi/config.c
--- nagios-3.2.3.orig/cgi/config.c 2010-09-01 07:19:59.000000000 -0700
+++ nagios-3.2.3/cgi/config.c 2011-05-25 17:40:34.561603160 -0700
@@ -480,6 +480,7 @@
printf("Host Check Command");
printf("Check Period");
printf("Obsess Over\n");
+ printf("Reset Notifications On Non-OK State Change\n");
printf("Enable Active Checks\n");
printf("Enable Passive Checks\n");
printf("Check Freshness\n");
@@ -570,6 +571,8 @@
=20
printf("%s\n",bg_class,(temp_host->obsess_over_hos=
t=3D=3DTRUE)?"Yes":"No");
=20
+ printf("%s\n",bg_class,(temp_host->reset_notificat=
ions_on_non_ok_state_change=3D=3DTRUE)?
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]