Skip to content

Commit 739fc2f

Browse files
authored
Merge pull request #65 from netniV/develop
Fix for Issue #64 and #61
2 parents 03a387a + 1bf1f1a commit 739fc2f

File tree

6 files changed

+61
-58
lines changed

6 files changed

+61
-58
lines changed

INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[info]
22
name = monitor
3-
version = 2.3.2
3+
version = 2.3.4
44
longname = Device Monitoring
55
author = The Cacti Group
66
email =

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ It would be advisable to view Monitors email notification settings under Setting
2525
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.
2626

2727
## Changelog
28+
--- 2.3.4 ---
29+
* issue#64: Fixed issue with overlapping rows in tree view
30+
* issue#61: Fixed issue where monitor_list was not being used
31+
* feature: Added option to disable inclusion of Threshold alert lists
32+
2833
--- 2.3.3 ---
2934
* issue#60: Fixed issue with themes
3035
* issue#57: Fixed issue with mute not working

monitor.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
}
3232

3333
.monitor_frame {
34-
float: left;
3534
display: table-cell;
3635
}
3736

@@ -48,8 +47,8 @@
4847
}
4948

5049
.monitor_tree_frame {
50+
display: inline-block;
5151
vertical-align: top;
52-
float: left;
5352
position: relative;
5453
padding: 3px;
5554
margin: 4px;
@@ -61,7 +60,6 @@
6160
display: block;
6261
padding: 3px;
6362
margin: 2px;
64-
float: left;
6563
}
6664

6765
.monitor_device_frame a {
@@ -109,7 +107,7 @@
109107
}
110108

111109
.monitor_medium {
112-
height: 80px;
110+
height: 60px;
113111
}
114112

115113
.monitor_medium i {

monitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ function render_tree() {
956956
FROM host AS h
957957
WHERE id IN (" . implode(',', $host_ids) . ")");
958958

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

961961
foreach($hosts as $host) {
962962
$result .= render_host($host, true, $maxlen);

poller_monitor.php

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@
147147

148148
exit;
149149

150+
function monitor_addemails(&$reboot_emails, $alert_emails, $host_id) {
151+
if (sizeof($alert_emails)) {
152+
foreach($alert_emails as $email) {
153+
$reboot_emails[trim(strtolower($email))][$host_id] = $host_id;
154+
}
155+
}
156+
}
157+
158+
function monitor_addnotificationlist(&$reboot_emails, $notify_list, $host_id, $notification_lists) {
159+
if ($notify_list > 0) {
160+
if (isset($notification_lists[$notify_list])) {
161+
$emails = explode(',', $notification_lists[$notify_list]);
162+
monitor_addemails($reboot_emails, $emails, $host_id);
163+
}
164+
}
165+
}
166+
150167
function monitor_uptime_checker() {
151168
monitor_debug('Checking for Uptime of Devices');
152169

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

167184
if (sizeof($rebooted_hosts)) {
168-
$nofitication_lists = array_rekey(
185+
$notification_lists = array_rekey(
169186
db_fetch_assoc('SELECT id, emails
170187
FROM plugin_notification_lists
171188
ORDER BY id'),
172189
'id', 'emails'
173190
);
174191

192+
$monitor_list = read_config_option('monitor_list');
193+
$monitor_thold = read_config_option('monitor_reboot_thold');
194+
175195
foreach($rebooted_hosts as $host) {
176196
db_execute_prepared('INSERT INTO plugin_monitor_reboot_history (host_id, reboot_time) VALUES (?, ?)',
177197
array($host['id'], date('Y-m-d H:i:s', time()-$host['snmp_sysUpTimeInstance'])));
178198

179-
$notify = db_fetch_row_prepared('SELECT thold_send_email, thold_host_email
180-
FROM host
181-
WHERE id = ?',
182-
array($host['id']));
183-
184-
if (sizeof($notify)) {
185-
switch($notify['thold_send_email']) {
186-
case '0': // Disabled
187-
188-
break;
189-
case '1': // Global List
190-
if (sizeof($alert_emails)) {
191-
foreach($alert_emails as $email) {
192-
$reboot_emails[trim($email)][$host['id']] = $host['id'];
193-
}
194-
}
195-
196-
break;
197-
case '2': // Nofitication List
198-
if ($notify['thold_host_email'] > 0) {
199-
if (isset($nofitication_lists[$notify['thold_host_email']])) {
200-
$emails = explode(',', $nofitication_lists[$notify['thold_host_email']]);
201-
202-
if (sizeof($emails)) {
203-
foreach($emails as $email) {
204-
$reboot_emails[trim($email)][$host['id']] = $host['id'];
205-
}
206-
}
207-
}
208-
}
209-
210-
break;
211-
case '3': // Both Global and Nofication list
212-
if (sizeof($alert_emails)) {
213-
foreach($alert_emails as $email) {
214-
$reboot_emails[trim($email)][$host['id']] = $host['id'];
215-
}
216-
}
217-
218-
if ($notify['thold_host_email'] > 0) {
219-
if (isset($nofitication_lists[$notify['thold_host_email']])) {
220-
$emails = explode(',', $nofitication_lists[$notify['thold_host_email']]);
221-
222-
if (sizeof($emails)) {
223-
foreach($emails as $email) {
224-
$reboot_emails[trim($email)][$host['id']] = $host['id'];
225-
}
226-
}
227-
}
199+
monitor_addnotificationlist($reboot_emails, $monitor_list, $host['id'], $notification_lists);
200+
201+
if ($monitor_thold == 'on') {
202+
$notify = db_fetch_row_prepared('SELECT thold_send_email, thold_host_email
203+
FROM host
204+
WHERE id = ?',
205+
array($host['id']));
206+
207+
if (sizeof($notify)) {
208+
switch($notify['thold_send_email']) {
209+
case '0': // Disabled
210+
211+
break;
212+
case '1': // Global List
213+
monitor_addemails($reboot_emails, $alert_emails, $host['id']);
214+
break;
215+
case '2': // Nofitication List
216+
monitor_addnotificationlist($reboot_emails, $notify['thold_host_email'],
217+
$host['id'], $notification_lists);
218+
break;
219+
case '3': // Both Global and Nofication list
220+
monitor_addemails($reboot_emails, $alert_emails, $host['id']);
221+
monitor_addnotificationlist($reboot_emails, $notify['thold_host_email'],
222+
$host['id'], $notification_lists);
223+
break;
228224
}
229-
230-
break;
231225
}
232226
}
233227
}

setup.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@ function monitor_config_settings() {
503503
'description' => __('Should Device Reboot Notifications be sent to users?', 'monitor'),
504504
'default' => 'on',
505505
),
506+
'monitor_reboot_thold' => array(
507+
'friendly_name' => __('Include Threshold Alert Lists', 'monitor'),
508+
'method' => 'checkbox',
509+
'description' => __('Should Threshold Alert Lists also receive notification', 'monitor'),
510+
'default' => 'on',
511+
),
506512
'monitor_subject' => array(
507513
'friendly_name' => __('Subject', 'monitor'),
508514
'description' => __('Enter a Reboot message subject for the Reboot Nofication.', 'monitor'),

0 commit comments

Comments
 (0)