From 8a68c91f4f1303c5044a400ce0602ed2b58bdd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Rosiak?= Date: Sun, 12 Apr 2015 01:10:48 +0200 Subject: [PATCH] Basic Alert Stats Page - Diagrams from visjs - Basic Alert Stats Global Page - Basic Alert Stats Device Specific Page Big thanks to lafwood for the help. --- html/includes/print-graph-alerts.inc.php | 100 +++++++++++++++++++++++ html/includes/print-menubar.php | 1 + html/pages/alert-stats.inc.php | 13 +++ html/pages/device.inc.php | 9 ++ html/pages/device/alert-stats.inc.php | 13 +++ 5 files changed, 136 insertions(+) create mode 100644 html/includes/print-graph-alerts.inc.php create mode 100644 html/pages/alert-stats.inc.php create mode 100644 html/pages/device/alert-stats.inc.php diff --git a/html/includes/print-graph-alerts.inc.php b/html/includes/print-graph-alerts.inc.php new file mode 100644 index 000000000..ac4a713f0 --- /dev/null +++ b/html/includes/print-graph-alerts.inc.php @@ -0,0 +1,100 @@ + +* This program is free software: you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation, either version 3 of the License, or (at your +* option) any later version. Please see LICENSE.txt at the top level of +* the source code distribution for details. +*/ +$pagetitle[] = "Alert Stats"; + +if (isset($device['device_id']) && $device['device_id'] > 0) { + $sql = " AND alert_log.device_id=?"; + $param = array( + $device['device_id'] + ); +} + +if ($_SESSION['userlevel'] >= '5') { + $query = "SELECT DATE(time_logged) Date, COUNT(alert_log.device_id) totalCount, alert_rules.severity Severity FROM alert_log,alert_rules WHERE alert_log.rule_id=alert_rules.id $sql GROUP BY DATE(time_logged),alert_rules.severity"; +} + +if ($_SESSION['userlevel'] < '5') { + $query = "SELECT DATE(time_logged) Date, COUNT(alert_log.device_id) totalCount, alert_rules.severity Severity FROM alert_log,alert_rules,devices_perms WHERE alert_log.rule_id=alert_rules.id $sql AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " GROUP BY DATE(time_logged),alert_rules.severity"; +} + +?> + +
+ \ No newline at end of file diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 37e085041..af4177417 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -56,6 +56,7 @@ if (isset($config['site_style']) && ($config['site_style'] == 'dark' || $config[