[icinga-checkins] icinga.org: icinga-core/test/core: * idoutils: add max_notifications_age, max_contactnotifications_age, max_contactnotificationmethods_age as housekeeping for notification tables #2051

git at icinga.org git at icinga.org
Tue Nov 15 18:57:40 CET 2011


Module: icinga-core
Branch: test/core
Commit: edb02ba588f51c265d2827f6582903236c270e41
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=edb02ba588f51c265d2827f6582903236c270e41

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Thu Nov 10 15:47:58 2011 +0100

* idoutils: add max_notifications_age, max_contactnotifications_age, max_contactnotificationmethods_age as housekeeping for notification tables #2051

refs #2051

---

 Changelog                                   |    2 ++
 module/idoutils/config/ido2db.cfg-sample.in |    9 +++++++++
 module/idoutils/include/db.h                |    3 +++
 module/idoutils/include/ido2db.h            |    3 +++
 module/idoutils/src/db.c                    |    9 +++++++++
 module/idoutils/src/ido2db.c                |    9 +++++++++
 6 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/Changelog b/Changelog
index 3ef506a..0a7e130 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ ENHANCEMENTS
 * idoutils: added end_time column for acknowledgelemts expiry #770
 * idoutils: add Indices for notification queries for Icinga Web #1964
 * idoutils: add option to format debug log timestamp like locale %c (debug_readable_timestamp) #2033
+* idoutils: add max_notifications_age, max_contactnotifications_age, max_contactnotificationmethods_age as housekeeping for notification tables #2051
 
 * config: add config examples for local monitoring - check_procs for ido2db #1870
 
@@ -72,6 +73,7 @@ CHANGES
 * ido2db.cfg
 	** enable_sla=0
 	** debug_readable_timestamp=0
+	** max_notifications_age, max_contactnotifications_age, max_contactnotificationmethods_age
 
 
 1.5.1 - 09/09/2011
diff --git a/module/idoutils/config/ido2db.cfg-sample.in b/module/idoutils/config/ido2db.cfg-sample.in
index b70743c..ec073dd 100644
--- a/module/idoutils/config/ido2db.cfg-sample.in
+++ b/module/idoutils/config/ido2db.cfg-sample.in
@@ -194,6 +194,15 @@ max_logentries_age=44640
 # Keep acknowledgements for 31 days
 max_acknowledgements_age=44640
 
+# Keep notifications for 31 days
+max_notifications_age=44640
+
+# Keep contactnotifications for 31 days
+max_contactnotifications_age=44640
+
+# Keep contactnotificationmethods for 31 days
+max_contactnotificationmethods_age=44640
+
 
 ## CLEAN REALTIME TABLES AT CORE STARTUP
 # If you don't want to clean all those tables, set this option to 0.
diff --git a/module/idoutils/include/db.h b/module/idoutils/include/db.h
index 7c7e86f..4709e69 100644
--- a/module/idoutils/include/db.h
+++ b/module/idoutils/include/db.h
@@ -30,6 +30,9 @@ typedef struct ido2db_dbconfig_struct{
 	unsigned long max_externalcommands_age;
         unsigned long max_logentries_age;
         unsigned long max_acknowledgements_age;
+        unsigned long max_notifications_age;
+        unsigned long max_contactnotifications_age;
+        unsigned long max_contactnotificationmethods_age;
 	unsigned long trim_db_interval;
 	unsigned long housekeeping_thread_startup_delay;
         unsigned long clean_realtime_tables_on_core_startup;
diff --git a/module/idoutils/include/ido2db.h b/module/idoutils/include/ido2db.h
index b5f4f5d..9e83427 100644
--- a/module/idoutils/include/ido2db.h
+++ b/module/idoutils/include/ido2db.h
@@ -222,6 +222,9 @@ typedef struct ido2db_dbconninfo_struct{
 	unsigned long max_externalcommands_age;
 	unsigned long max_logentries_age;
 	unsigned long max_acknowledgements_age;
+	unsigned long max_notifications_age;
+	unsigned long max_contactnotifications_age;
+	unsigned long max_contactnotificationmethods_age;
 	unsigned long trim_db_interval;
 	unsigned long housekeeping_thread_startup_delay;
 	unsigned long clean_realtime_tables_on_core_startup;
diff --git a/module/idoutils/src/db.c b/module/idoutils/src/db.c
index d98ab97..a4a4b22 100644
--- a/module/idoutils/src/db.c
+++ b/module/idoutils/src/db.c
@@ -288,6 +288,9 @@ int ido2db_db_init(ido2db_idi *idi) {
 	idi->dbinfo.max_externalcommands_age = ido2db_db_settings.max_externalcommands_age;
 	idi->dbinfo.max_logentries_age = ido2db_db_settings.max_logentries_age;
 	idi->dbinfo.max_acknowledgements_age = ido2db_db_settings.max_acknowledgements_age;
+	idi->dbinfo.max_notifications_age = ido2db_db_settings.max_notifications_age;
+	idi->dbinfo.max_contactnotifications_age = ido2db_db_settings.max_contactnotifications_age;
+	idi->dbinfo.max_contactnotificationmethods_age = ido2db_db_settings.max_contactnotificationmethods_age;
 	idi->dbinfo.trim_db_interval = ido2db_db_settings.trim_db_interval;
 	idi->dbinfo.housekeeping_thread_startup_delay = ido2db_db_settings.housekeeping_thread_startup_delay;
 	idi->dbinfo.last_table_trim_time = (time_t) 0L;
@@ -2967,6 +2970,12 @@ int ido2db_db_perform_maintenance(ido2db_idi *idi) {
 			ido2db_db_trim_data_table(idi, ido2db_db_tablenames[IDO2DB_DBTABLE_LOGENTRIES], "logentry_time", (time_t)((unsigned long)current_time - idi->dbinfo.max_logentries_age));
 		if (idi->dbinfo.max_acknowledgements_age > 0L)
 			ido2db_db_trim_data_table(idi, ido2db_db_tablenames[IDO2DB_DBTABLE_ACKNOWLEDGEMENTS], "entry_time", (time_t)((unsigned long)current_time - idi->dbinfo.max_acknowledgements_age));
+		if (idi->dbinfo.max_notifications_age > 0L)
+			ido2db_db_trim_data_table(idi, ido2db_db_tablenames[IDO2DB_DBTABLE_NOTIFICATIONS], "start_time", (time_t)((unsigned long) current_time - idi->dbinfo.max_notifications_age));
+		if (idi->dbinfo.max_contactnotifications_age > 0L)
+			ido2db_db_trim_data_table(idi, ido2db_db_tablenames[IDO2DB_DBTABLE_CONTACTNOTIFICATIONS], "start_time", (time_t)((unsigned long) current_time - idi->dbinfo.max_contactnotifications_age));
+		if (idi->dbinfo.max_contactnotificationmethods_age > 0L)
+			ido2db_db_trim_data_table(idi, ido2db_db_tablenames[IDO2DB_DBTABLE_CONTACTNOTIFICATIONMETHODS], "start_time", (time_t)((unsigned long) current_time - idi->dbinfo.max_contactnotificationmethods_age));
 		idi->dbinfo.last_table_trim_time = current_time;
 	}
 
diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c
index e9f30f8..98f9d5e 100644
--- a/module/idoutils/src/ido2db.c
+++ b/module/idoutils/src/ido2db.c
@@ -541,6 +541,12 @@ int ido2db_process_config_var(char *arg) {
 		ido2db_db_settings.max_logentries_age = strtoul(val, NULL, 0) * 60;
 	else if (!strcmp(var, "max_acknowledgements_age"))
 		ido2db_db_settings.max_acknowledgements_age = strtoul(val, NULL, 0) * 60;
+	else if (!strcmp(var, "max_notifications_age"))
+		ido2db_db_settings.max_notifications_age = strtoul(val, NULL, 0) * 60;
+	else if (!strcmp(var, "max_contactnotifications_age"))
+		ido2db_db_settings.max_contactnotifications_age = strtoul(val, NULL, 0) * 60;
+	else if (!strcmp(var, "max_contactnotificationmethods_age"))
+		ido2db_db_settings.max_contactnotificationmethods_age = strtoul(val, NULL, 0) * 60;
 
 	else if (!strcmp(var, "trim_db_interval"))
 		ido2db_db_settings.trim_db_interval = strtoul(val, NULL, 0);
@@ -619,6 +625,9 @@ int ido2db_initialize_variables(void) {
 	ido2db_db_settings.max_externalcommands_age = 0L;
 	ido2db_db_settings.max_logentries_age = 0L;
 	ido2db_db_settings.max_acknowledgements_age = 0L;
+	ido2db_db_settings.max_notifications_age = 0L;
+	ido2db_db_settings.max_contactnotifications_age = 0L;
+	ido2db_db_settings.max_contactnotificationmethods_age = 0L;
 	ido2db_db_settings.trim_db_interval = (unsigned long)DEFAULT_TRIM_DB_INTERVAL; /* set the default if missing in ido2db.cfg */
 	ido2db_db_settings.housekeeping_thread_startup_delay = (unsigned long)DEFAULT_HOUSEKEEPING_THREAD_STARTUP_DELAY; /* set the default if missing in ido2db.cfg */
 	ido2db_db_settings.clean_realtime_tables_on_core_startup = IDO_TRUE; /* default is cleaning on startup */





More information about the icinga-checkins mailing list