Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
* idoutils: add max_notifications_age, max_contactnotifications_age, …
Browse files Browse the repository at this point in the history
…max_contactnotificationmethods_age as housekeeping for notification tables #2051

refs #2051
  • Loading branch information
Michael Friedrich committed Nov 10, 2011
1 parent c970c46 commit edb02ba
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changelog
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions module/idoutils/config/ido2db.cfg-sample.in
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions module/idoutils/include/db.h
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions module/idoutils/include/ido2db.h
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions module/idoutils/src/db.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 9 additions & 0 deletions module/idoutils/src/ido2db.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit edb02ba

Please sign in to comment.