[icinga-checkins] icinga.org: icinga-core/next: idoutils: add a table trimming option for ' downtime history'

git at icinga.org git at icinga.org
Sat Jun 22 19:33:52 CEST 2013


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Sat Jun 22 19:32:59 2013 +0200

idoutils: add a table trimming option for 'downtime history'

fixes #3989

---

 Changelog                                          |    5 +++++
 module/idoutils/config/ido2db.cfg-sample.in        |    3 +++
 .../updates/ido2db.cfg_added_1.9_to_1.10.cfg       |   13 +++++++++++++
 module/idoutils/include/db.h                       |    1 +
 module/idoutils/include/ido2db.h                   |    1 +
 module/idoutils/src/db.c                           |    4 ++++
 module/idoutils/src/ido2db.c                       |    3 +++
 7 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/Changelog b/Changelog
index ed276c2..d777cd6 100644
--- a/Changelog
+++ b/Changelog
@@ -19,6 +19,8 @@ ENHANCEMENTS
 
 * classic ui: add display filter modification for status.cgi #852 - RB
 
+* idoutils: add a table trimming option for 'downtime history' #3989 - MF
+
 * install: allow enable perfdata config switch via configure #3996 - MF
 
 * contrib: add vim highlight script for Icinga syntax #4150 - LE
@@ -37,6 +39,9 @@ CHANGES
 * core: multiple neb modules from same bin are copied to tmp with random name (again) #4199
 	** trick dlopen() to register callbacks for every neb module with different instance_name
 	** no need to manually copy binaries around
+
+* idoutils: add max_downtimhistory_age to ido2db.cfg #3989
+
 * install: configure --enable-perfdata sets icinga.cfg:process_performance_data #3996
 
 
diff --git a/module/idoutils/config/ido2db.cfg-sample.in b/module/idoutils/config/ido2db.cfg-sample.in
index c644fdf..f32cd8f 100644
--- a/module/idoutils/config/ido2db.cfg-sample.in
+++ b/module/idoutils/config/ido2db.cfg-sample.in
@@ -224,6 +224,9 @@ max_contactnotifications_age=44640
 # Keep contactnotificationmethods for 31 days
 max_contactnotificationmethods_age=44640
 
+# Keep downtimehistory for 31 days
+max_downtimehistory_age=44640
+
 
 ## CLEAN REALTIME TABLES AT CORE STARTUP !!!EXPERIMENTAL!!!
 # If you don't want to clean all those tables, set this option to 0.
diff --git a/module/idoutils/config/updates/ido2db.cfg_added_1.9_to_1.10.cfg b/module/idoutils/config/updates/ido2db.cfg_added_1.9_to_1.10.cfg
new file mode 100644
index 0000000..3552511
--- /dev/null
+++ b/module/idoutils/config/updates/ido2db.cfg_added_1.9_to_1.10.cfg
@@ -0,0 +1,13 @@
+#################################################################
+# These are newly ADDED config options for IDO2DB.CFG only.
+#
+# NOTE: Update your existing configuration with those new ones,
+#	if needed. You are advised to do so, in order to get the
+#	full Icinga experience!
+#################################################################
+
+# Keep downtimehistory for 31 days
+max_downtimehistory_age=44640
+
+
+
diff --git a/module/idoutils/include/db.h b/module/idoutils/include/db.h
index 1f71344..90ecc27 100644
--- a/module/idoutils/include/db.h
+++ b/module/idoutils/include/db.h
@@ -33,6 +33,7 @@ typedef struct ido2db_dbconfig_struct{
         unsigned long max_notifications_age;
         unsigned long max_contactnotifications_age;
         unsigned long max_contactnotificationmethods_age;
+	unsigned long max_downtimehistory_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 40c38ea..1ef160a 100644
--- a/module/idoutils/include/ido2db.h
+++ b/module/idoutils/include/ido2db.h
@@ -220,6 +220,7 @@ typedef struct ido2db_dbconninfo_struct{
 	unsigned long max_notifications_age;
 	unsigned long max_contactnotifications_age;
 	unsigned long max_contactnotificationmethods_age;
+	unsigned long max_downtimehistory_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 670128c..8fbdf23 100644
--- a/module/idoutils/src/db.c
+++ b/module/idoutils/src/db.c
@@ -291,6 +291,7 @@ int ido2db_db_init(ido2db_idi *idi) {
 	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.max_downtimehistory_age = ido2db_db_settings.max_downtimehistory_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;
@@ -2899,6 +2900,9 @@ int ido2db_db_perform_maintenance(ido2db_idi *idi) {
 			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));
+		if (idi->dbinfo.max_downtimehistory_age > 0L)
+			ido2db_db_trim_data_table(idi, ido2db_db_tablenames[IDO2DB_DBTABLE_DOWNTIMEHISTORY], "entry_time", (time_t)((unsigned long) current_time - idi->dbinfo.max_downtimehistory_age));
+
 		idi->dbinfo.last_table_trim_time = current_time;
 	}
 
diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c
index c0d67bc..8afdb93 100644
--- a/module/idoutils/src/ido2db.c
+++ b/module/idoutils/src/ido2db.c
@@ -564,6 +564,8 @@ int ido2db_process_config_var(char *arg) {
 		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, "max_downtimehistory_age"))
+		ido2db_db_settings.max_downtimehistory_age = strtoul(val, NULL, 0) * 60;
 
 	else if (!strcmp(var, "trim_db_interval"))
 		ido2db_db_settings.trim_db_interval = strtoul(val, NULL, 0);
@@ -650,6 +652,7 @@ int ido2db_initialize_variables(void) {
 	ido2db_db_settings.max_notifications_age = 0L;
 	ido2db_db_settings.max_contactnotifications_age = 0L;
 	ido2db_db_settings.max_contactnotificationmethods_age = 0L;
+	ido2db_db_settings.max_downtimehistory_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