implemented trap history

This commit is contained in:
alejandro.campos@artica.es 2022-09-19 11:15:22 +02:00
parent 3524cdac6c
commit 91194155b0
3 changed files with 37 additions and 3 deletions

View File

@ -76,6 +76,7 @@ if ($generate_trap) {
);
}
$table = new stdClass();
$traps_generator = '<form method="POST" action="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_trap_generator">';
$table->width = '100%';
$table->class = 'databox filters';

View File

@ -1554,6 +1554,10 @@ function config_update_config()
$error_update[] = __('Enable history event');
}
if (config_update_value('history_trap_enabled', get_parameter('history_trap_enabled'), true) === false) {
$error_update[] = __('Enable history trap');
}
if (config_update_value('history_db_user', get_parameter('history_db_user'), true) === false) {
$error_update[] = __('Database user');
}
@ -1578,6 +1582,14 @@ function config_update_config()
$error_update[] = __('Event Days');
}
$history_trap_days = get_parameter('history_trap_days');
if (is_numeric($history_trap_days) === false
|| $history_trap_days <= 0
|| config_update_value('history_trap_days', $history_trap_days) === false
) {
$error_update[] = __('Trap Days');
}
$history_db_step = get_parameter('history_db_step');
if (!is_numeric($history_db_step)
|| $history_db_step <= 0
@ -1642,6 +1654,14 @@ function config_update_config()
$error_update[] = __('Historical database events purge');
}
if ($dbm->setConfigToken(
'trap_purge',
get_parameter('history_dbh_traps_purge')
) !== true
) {
$error_update[] = __('Historical database traps purge');
}
if ($dbm->setConfigToken(
'string_purge',
get_parameter('history_dbh_string_purge')
@ -2476,6 +2496,10 @@ function config_process_config()
config_update_value('history_event_enabled', false);
}
if (!isset($config['history_trap_enabled'])) {
config_update_value('history_trap_enabled', false);
}
if (!isset($config['history_db_host'])) {
config_update_value('history_db_host', '');
}
@ -2504,6 +2528,10 @@ function config_process_config()
config_update_value('history_event_days', 90);
}
if (!isset($config['history_trap_days'])) {
config_update_value('history_trap_days', 90);
}
if (!isset($config['history_db_step'])) {
config_update_value('history_db_step', 0);
}

View File

@ -638,6 +638,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_step_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'step_compact'");
$conf->{'_history_db_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_enabled'");
$conf->{'_history_event_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_enabled'");
$conf->{'_history_trap_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_trap_enabled'");
$conf->{'_history_db_host'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_host'");
$conf->{'_history_db_port'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_port'");
$conf->{'_history_db_name'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_name'");
@ -645,6 +646,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_history_db_pass'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_pass'");
$conf->{'_history_db_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_days'");
$conf->{'_history_event_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_days'");
$conf->{'_history_trap_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_trap_days'");
$conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'");
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
$conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
@ -1128,9 +1130,12 @@ sub pandoradb_main ($$$;$) {
# Move old data to the history DB
if (defined ($history_dbh)) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_historydb', [$dbh, $history_dbh, $conf->{'_history_db_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
if (defined($conf{'_history_event_enabled'}) && $conf->{'_history_event_enabled'} ne "" && $conf->{'_history_event_enabled'} == 1) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_event', [$dbh, $history_dbh, $conf->{'_history_event_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
#undef ($history_dbh) unless defined (enterprise_hook ('pandora_historydb', [$dbh, $history_dbh, $conf->{'_history_db_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
#if (defined($conf{'_history_event_enabled'}) && $conf->{'_history_event_enabled'} ne "" && $conf->{'_history_event_enabled'} == 1) {
# undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_event', [$dbh, $history_dbh, $conf->{'_history_event_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
#}
if (defined($conf{'_history_trap_enabled'}) && $conf->{'_history_trap_enabled'} ne "" && $conf->{'_history_trap_enabled'} == 1) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_trap', [$dbh, $history_dbh, $conf->{'_history_trap_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
}
}