mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
fixed snmp traps time
This commit is contained in:
parent
83f3928495
commit
c8393ae210
7
pandora_console/extras/mr/66.sql
Normal file
7
pandora_console/extras/mr/66.sql
Normal file
@ -0,0 +1,7 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `ttrap` ADD COLUMN `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0;
|
||||
|
||||
UPDATE ttrap SET utimestamp=UNIX_TIMESTAMP(timestamp);
|
||||
|
||||
COMMIT;
|
@ -547,6 +547,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();
|
||||
@ -686,7 +691,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 .= '
|
||||
@ -698,7 +703,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 .= '
|
||||
|
@ -1226,6 +1226,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…
x
Reference in New Issue
Block a user