Merge branch 'ent-10348-15022-SNMP-Console-no-muestra-Traps-de-1-hora-de-plazo-con-timezone-de-Usuario-1' into 'develop'
fixed snmp traps time See merge request artica/pandorafms!6258
This commit is contained in:
commit
3307b95c54
|
@ -1,5 +1,9 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `ttrap` ADD COLUMN `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0;
|
||||
|
||||
UPDATE ttrap SET utimestamp=UNIX_TIMESTAMP(timestamp);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tgraph_analytics_filter` (
|
||||
`id` INT NOT NULL auto_increment,
|
||||
`filter_name` VARCHAR(45) NULL,
|
||||
|
|
|
@ -549,6 +549,11 @@ class SnmpConsole extends HTML
|
|||
$order = get_datatable_order(true);
|
||||
$filters = get_parameter('filter', []);
|
||||
|
||||
// Build ranges.
|
||||
$now_timestamp = time();
|
||||
$interval_seconds = ($filters['filter_hours_ago'] * 3600);
|
||||
$ago_timestamp = ($now_timestamp - $interval_seconds);
|
||||
|
||||
// Build ranges.
|
||||
$now = new DateTime();
|
||||
$ago = new DateTime();
|
||||
|
@ -688,7 +693,7 @@ class SnmpConsole extends HTML
|
|||
if ($date_from_trap != '') {
|
||||
if ($time_from_trap != '') {
|
||||
$whereSubquery .= '
|
||||
AND (UNIX_TIMESTAMP(timestamp) > UNIX_TIMESTAMP("'.$date_from_trap.' '.$time_from_trap.'"))
|
||||
AND (utimestamp > '.$ago_timestamp.')
|
||||
';
|
||||
} else {
|
||||
$whereSubquery .= '
|
||||
|
@ -700,7 +705,7 @@ class SnmpConsole extends HTML
|
|||
if ($date_to_trap != '') {
|
||||
if ($time_to_trap) {
|
||||
$whereSubquery .= '
|
||||
AND (UNIX_TIMESTAMP(timestamp) < UNIX_TIMESTAMP("'.$date_to_trap.' '.$time_to_trap.'"))
|
||||
AND (utimestamp < '.$now_timestamp.')
|
||||
';
|
||||
} else {
|
||||
$whereSubquery .= '
|
||||
|
|
|
@ -1257,6 +1257,7 @@ CREATE TABLE IF NOT EXISTS `ttrap` (
|
|||
`text` VARCHAR(255) DEFAULT '',
|
||||
`description` VARCHAR(255) DEFAULT '',
|
||||
`severity` TINYINT UNSIGNED NOT NULL DEFAULT 2,
|
||||
`utimestamp` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id_trap`),
|
||||
INDEX timestamp (`timestamp`),
|
||||
INDEX status (`status`),
|
||||
|
|
|
@ -382,8 +382,8 @@ sub pandora_snmptrapd {
|
|||
|
||||
# Insert the trap into the DB
|
||||
if (! defined(enterprise_hook ('snmp_insert_trap', [$pa_config, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type, $timestamp, $server_id, $dbh]))) {
|
||||
my $trap_id = db_insert ($dbh, 'id_trap', 'INSERT INTO ttrap (timestamp, source, oid, type, value, oid_custom, value_custom, type_custom) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
$timestamp, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type);
|
||||
my $trap_id = db_insert ($dbh, 'id_trap', 'INSERT INTO ttrap (timestamp, source, oid, type, value, oid_custom, value_custom, type_custom, utimestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
$timestamp, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type, time());
|
||||
logger ($pa_config, "Received SNMP Trap from $source", 4);
|
||||
|
||||
# Evaluate alerts for this trap
|
||||
|
|
Loading…
Reference in New Issue