From 5ac9fedd060fa3164cca4a6b0d9260b4a026d4e8 Mon Sep 17 00:00:00 2001 From: Guy Foetz Date: Wed, 13 Mar 2019 14:41:17 +0100 Subject: [PATCH 1/3] adding audit event --- app/dashboard/index.php | 4 ++-- app/json/index.php | 4 ++-- db/SCHEMA.sql | 2 +- functions/classes/class.Notify.php | 5 +++-- functions/classes/class.SNMP.php | 6 +++--- functions/classes/class.Table_print.php | 4 ++-- functions/classes/class.traphandler.php | 5 +++-- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/dashboard/index.php b/app/dashboard/index.php index 583936f..62cbd75 100644 --- a/app/dashboard/index.php +++ b/app/dashboard/index.php @@ -23,7 +23,7 @@ } if(isset($User->user->dash_layout_parsed[2])) { $Trap->reset_print_limit ($User->user->dash_layout_parsed[2]['elements']); - $all_info_traps = $Trap->fetch_traps (array("notice", "informational", "debug")); + $all_info_traps = $Trap->fetch_traps (array("notice", "informational", "debug", "audit")); } if(isset($User->user->dash_layout_parsed[3])) { $Trap->reset_print_limit ($User->user->dash_layout_parsed[3]['elements']); @@ -103,4 +103,4 @@ print ""; } -print ""; \ No newline at end of file +print ""; diff --git a/app/json/index.php b/app/json/index.php index 6f2d403..b4a32c6 100644 --- a/app/json/index.php +++ b/app/json/index.php @@ -51,7 +51,7 @@ if($_GET['type']=="all") { $result = $Trap->fetch_traps ("all"); } elseif($_GET['type']=="major") { $result = $Trap->fetch_traps (array("emergency", "alert", "critical")); } elseif($_GET['type']=="minor") { $result = $Trap->fetch_traps (array("error", "warning")); } - elseif($_GET['type']=="informational") { $result = $Trap->fetch_traps (array("notice", "informational", "debug")); } + elseif($_GET['type']=="informational") { $result = $Trap->fetch_traps (array("notice", "informational", "debug", "audit")); } elseif($_GET['type']=="unknown") { $result = $Trap->fetch_traps (array("unknown")); } } /** @@ -83,4 +83,4 @@ } # return result -print_r(json_encode($result_final)); \ No newline at end of file +print_r(json_encode($result_final)); diff --git a/db/SCHEMA.sql b/db/SCHEMA.sql index a66a7c5..fa6c946 100644 --- a/db/SCHEMA.sql +++ b/db/SCHEMA.sql @@ -38,7 +38,7 @@ DROP TABLE IF EXISTS `severity_definitions`; CREATE TABLE `severity_definitions` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `oid` varchar(128) NOT NULL DEFAULT '', - `severity` set('emergency','alert','critical','error','warning','notice','informational','debug') NOT NULL DEFAULT '', + `severity` set('emergency','alert','critical','error','warning','notice','informational','debug','audit') NOT NULL DEFAULT '', `content` varchar(128) DEFAULT '', `comment` text, PRIMARY KEY (`id`), diff --git a/functions/classes/class.Notify.php b/functions/classes/class.Notify.php index 69fb7ba..950ce7e 100644 --- a/functions/classes/class.Notify.php +++ b/functions/classes/class.Notify.php @@ -528,7 +528,7 @@ public function send ($message_details, $recipients) { # save details $this->message_details = (object) $message_details; # set subject - $subject = "[".$message_details->hostname."] - ".$message_details->msg; + $subject = "[".$message_details->hostname."] - ".$message_details->severity; # set mail body content $body = array(); @@ -787,6 +787,7 @@ private function set_pushover_priority ($severity) { elseif ($severity=="critical") { $this->p_priority = 1; } elseif ($severity=="error") { $this->p_priority = 0; } elseif ($severity=="warning") { $this->p_priority = 0; } + elseif ($severity=="audit") { $this->p_priority = -1; } elseif ($severity=="notice") { $this->p_priority = -1; } elseif ($severity=="informational") { $this->p_priority = -2; } elseif ($severity=="debug") { $this->p_priority = -2; } @@ -954,4 +955,4 @@ private function set_color ($s) { } } -?> \ No newline at end of file +?> diff --git a/functions/classes/class.SNMP.php b/functions/classes/class.SNMP.php index 393af48..4f40deb 100644 --- a/functions/classes/class.SNMP.php +++ b/functions/classes/class.SNMP.php @@ -141,7 +141,7 @@ public function process_oid ($oid) { * @return void */ public function define_severities () { - return array('emergency','alert','critical','error','warning','notice','informational','debug'); + return array('emergency','alert','critical','error','warning','notice','informational','debug', 'audit'); } /** @@ -536,7 +536,7 @@ public function set_permitted_hostnames ($hostnames = "all") { * @return void */ public function define_severities () { - $this->severities = array('emergency','alert','critical','error','warning','notice','informational','debug'); + $this->severities = array('emergency','alert','critical','error','warning','notice','informational','debug','audit'); } @@ -1122,4 +1122,4 @@ private function update_trap_severity ($item = array()) { } -} \ No newline at end of file +} diff --git a/functions/classes/class.Table_print.php b/functions/classes/class.Table_print.php index 3c9dce9..ddb4b38 100644 --- a/functions/classes/class.Table_print.php +++ b/functions/classes/class.Table_print.php @@ -238,7 +238,7 @@ public function set_severity_class ($s, $newClass) { // red if ($s=="emergency" || $s=="alert" || $s=="critical") { $c = "danger"; } elseif ($s=="error" || $s=="warning") { $c = "warning"; } - elseif ($s=="notice"|| $s=="debug" || $s=="informational") { $c = "success"; } + elseif ($s=="notice"|| $s=="debug" || $s=="informational" || $s=="audit") { $c = "success"; } else { $c = "info"; } // newclass ? return $newClass ? $c." new" : $c; @@ -559,7 +559,7 @@ public function prepare_input_item ($field, $value = false, $additional_params = private function prepare_multiple_checkboxes ($field, $value, $additional_params) { // get all possible items if ($field->Field=="notification_severities") { - $options = array('emergency','alert','critical','error','warning','notice','informational','debug', 'unknown'); + $options = array('emergency','alert','critical','error','warning','notice','informational','debug', 'unknown','audit'); } elseif ($field->Field=="notification_types") { include(dirname(__FILE__)."/../../config.php"); diff --git a/functions/classes/class.traphandler.php b/functions/classes/class.traphandler.php index 981665c..3fbb838 100644 --- a/functions/classes/class.traphandler.php +++ b/functions/classes/class.traphandler.php @@ -49,7 +49,8 @@ class Trap { "warning" => "warning", "notice" => "notice", "informational" => "informational", - "debug" => "debug" + "debug" => "debug", + "audit" => "audit" ); /** @@ -774,4 +775,4 @@ public function close_file () { } -?> \ No newline at end of file +?> From 246546a40a4764e6ebbafc49b8356ea953af3042 Mon Sep 17 00:00:00 2001 From: Guy Foetz Date: Wed, 13 Mar 2019 15:09:03 +0100 Subject: [PATCH 2/3] favicon url fix --- app/login/index.php | 4 ++-- index.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/login/index.php b/app/login/index.php index 0e54c9f..bbe26a2 100644 --- a/app/login/index.php +++ b/app/login/index.php @@ -31,7 +31,7 @@ Snmptraps - + @@ -94,4 +94,4 @@ - \ No newline at end of file + diff --git a/index.php b/index.php index 5c86937..e4be27d 100644 --- a/index.php +++ b/index.php @@ -49,7 +49,7 @@ <?php print $title; ?> - + "> @@ -136,4 +136,4 @@ - \ No newline at end of file + From da64ac6170fbaa691ad8ea3777f36fcba9a1c970 Mon Sep 17 00:00:00 2001 From: Guy Foetz Date: Wed, 13 Mar 2019 15:31:52 +0100 Subject: [PATCH 3/3] fixes issue #23 --- functions/classes/class.Notify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/classes/class.Notify.php b/functions/classes/class.Notify.php index 950ce7e..cb3fece 100644 --- a/functions/classes/class.Notify.php +++ b/functions/classes/class.Notify.php @@ -548,7 +548,7 @@ public function send ($message_details, $recipients) { # get content $mail_content_html = $this->generate_message (implode("\r\n", $body)); - $mail_content_plain = $this->generate_message_plain (implode("\r\n", strip_tags(str_replace("
","\n",$body)))); + $mail_content_plain = $this->generate_message_plain (strip_tags(implode("\r\n", str_replace("
","\n",$body)))); # try to send try {