Skip to content

Commit

Permalink
Merge pull request #65 from netniV/develop
Browse files Browse the repository at this point in the history
Fix for Issue #64 and #61
  • Loading branch information
cigamit authored Mar 18, 2018
2 parents 03a387a + 1bf1f1a commit 739fc2f
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 58 deletions.
2 changes: 1 addition & 1 deletion INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[info]
name = monitor
version = 2.3.2
version = 2.3.4
longname = Device Monitoring
author = The Cacti Group
email =
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ It would be advisable to view Monitors email notification settings under Setting
Bug and feature enhancements for the webseer plugin are handled in GitHub. If you find a first search the Cacti forums for a solution before creating an issue in GitHub.

## Changelog
--- 2.3.4 ---
* issue#64: Fixed issue with overlapping rows in tree view
* issue#61: Fixed issue where monitor_list was not being used
* feature: Added option to disable inclusion of Threshold alert lists

--- 2.3.3 ---
* issue#60: Fixed issue with themes
* issue#57: Fixed issue with mute not working
Expand Down
6 changes: 2 additions & 4 deletions monitor.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
}

.monitor_frame {
float: left;
display: table-cell;
}

Expand All @@ -48,8 +47,8 @@
}

.monitor_tree_frame {
display: inline-block;
vertical-align: top;
float: left;
position: relative;
padding: 3px;
margin: 4px;
Expand All @@ -61,7 +60,6 @@
display: block;
padding: 3px;
margin: 2px;
float: left;
}

.monitor_device_frame a {
Expand Down Expand Up @@ -109,7 +107,7 @@
}

.monitor_medium {
height: 80px;
height: 60px;
}

.monitor_medium i {
Expand Down
2 changes: 1 addition & 1 deletion monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ function render_tree() {
FROM host AS h
WHERE id IN (" . implode(',', $host_ids) . ")");

$result .= '<div class="monitor_tree_frame ' . $class . '"><table class="odd"><tr class="tableHeader"><th>' . $title . '</th></tr><tr><td class="center"><div>';
$result .= '<div class="monitor_tree_frame"><table class="odd"><tr class="tableHeader"><th>' . $title . '</th></tr><tr><td class="center"><div>';

foreach($hosts as $host) {
$result .= render_host($host, true, $maxlen);
Expand Down
98 changes: 46 additions & 52 deletions poller_monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,23 @@

exit;

function monitor_addemails(&$reboot_emails, $alert_emails, $host_id) {
if (sizeof($alert_emails)) {
foreach($alert_emails as $email) {
$reboot_emails[trim(strtolower($email))][$host_id] = $host_id;
}
}
}

function monitor_addnotificationlist(&$reboot_emails, $notify_list, $host_id, $notification_lists) {
if ($notify_list > 0) {
if (isset($notification_lists[$notify_list])) {
$emails = explode(',', $notification_lists[$notify_list]);
monitor_addemails($reboot_emails, $emails, $host_id);
}
}
}

function monitor_uptime_checker() {
monitor_debug('Checking for Uptime of Devices');

Expand All @@ -165,69 +182,46 @@ function monitor_uptime_checker() {
AND (mu.uptime IS NULL OR mu.uptime > h.snmp_sysUpTimeInstance) AND h.snmp_sysUpTimeInstance > 0');

if (sizeof($rebooted_hosts)) {
$nofitication_lists = array_rekey(
$notification_lists = array_rekey(
db_fetch_assoc('SELECT id, emails
FROM plugin_notification_lists
ORDER BY id'),
'id', 'emails'
);

$monitor_list = read_config_option('monitor_list');
$monitor_thold = read_config_option('monitor_reboot_thold');

foreach($rebooted_hosts as $host) {
db_execute_prepared('INSERT INTO plugin_monitor_reboot_history (host_id, reboot_time) VALUES (?, ?)',
array($host['id'], date('Y-m-d H:i:s', time()-$host['snmp_sysUpTimeInstance'])));

$notify = db_fetch_row_prepared('SELECT thold_send_email, thold_host_email
FROM host
WHERE id = ?',
array($host['id']));

if (sizeof($notify)) {
switch($notify['thold_send_email']) {
case '0': // Disabled

break;
case '1': // Global List
if (sizeof($alert_emails)) {
foreach($alert_emails as $email) {
$reboot_emails[trim($email)][$host['id']] = $host['id'];
}
}

break;
case '2': // Nofitication List
if ($notify['thold_host_email'] > 0) {
if (isset($nofitication_lists[$notify['thold_host_email']])) {
$emails = explode(',', $nofitication_lists[$notify['thold_host_email']]);

if (sizeof($emails)) {
foreach($emails as $email) {
$reboot_emails[trim($email)][$host['id']] = $host['id'];
}
}
}
}

break;
case '3': // Both Global and Nofication list
if (sizeof($alert_emails)) {
foreach($alert_emails as $email) {
$reboot_emails[trim($email)][$host['id']] = $host['id'];
}
}

if ($notify['thold_host_email'] > 0) {
if (isset($nofitication_lists[$notify['thold_host_email']])) {
$emails = explode(',', $nofitication_lists[$notify['thold_host_email']]);

if (sizeof($emails)) {
foreach($emails as $email) {
$reboot_emails[trim($email)][$host['id']] = $host['id'];
}
}
}
monitor_addnotificationlist($reboot_emails, $monitor_list, $host['id'], $notification_lists);

if ($monitor_thold == 'on') {
$notify = db_fetch_row_prepared('SELECT thold_send_email, thold_host_email
FROM host
WHERE id = ?',
array($host['id']));

if (sizeof($notify)) {
switch($notify['thold_send_email']) {
case '0': // Disabled

break;
case '1': // Global List
monitor_addemails($reboot_emails, $alert_emails, $host['id']);
break;
case '2': // Nofitication List
monitor_addnotificationlist($reboot_emails, $notify['thold_host_email'],
$host['id'], $notification_lists);
break;
case '3': // Both Global and Nofication list
monitor_addemails($reboot_emails, $alert_emails, $host['id']);
monitor_addnotificationlist($reboot_emails, $notify['thold_host_email'],
$host['id'], $notification_lists);
break;
}

break;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ function monitor_config_settings() {
'description' => __('Should Device Reboot Notifications be sent to users?', 'monitor'),
'default' => 'on',
),
'monitor_reboot_thold' => array(
'friendly_name' => __('Include Threshold Alert Lists', 'monitor'),
'method' => 'checkbox',
'description' => __('Should Threshold Alert Lists also receive notification', 'monitor'),
'default' => 'on',
),
'monitor_subject' => array(
'friendly_name' => __('Subject', 'monitor'),
'description' => __('Enter a Reboot message subject for the Reboot Nofication.', 'monitor'),
Expand Down

0 comments on commit 739fc2f

Please sign in to comment.