Skip to content

Commit 316205a

Browse files
committed
QA: Add 2 days and fix chart number of ticks issue
* Attempt to keep the number of samples to approximately 60 regardless of timespan.
1 parent 652d651 commit 316205a

File tree

4 files changed

+33
-25
lines changed

4 files changed

+33
-25
lines changed

panellib/poller.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function poller_info($panel, $user_id) {
123123
'</tr>';
124124

125125
foreach ($sql_pollers as $poller) {
126-
126+
127127
$color = 'green';
128128

129129
if ($poller['status'] == 0 || $poller['status'] == 1 || $poller['status'] == 2 || $poller['status'] == 5) {
@@ -152,13 +152,13 @@ function poller_info($panel, $user_id) {
152152
'<td class="left"><span class="inpa_sq color_' . $color . '"></span>' . $status . '</td>';
153153

154154
$color = 'green';
155-
155+
156156
if (($poller['total_time']/$poller_interval) > 0.9) {
157157
$color = 'red';
158158
} elseif (($poller['total_time']/$poller_interval) > 0.7) {
159159
$color = 'yellow';
160160
}
161-
161+
162162
$details .= '<td class="right"><span class="inpa_sq color_' . $color . '"></span>' . __('%s Secs', round($poller['total_time'], 2), 'intropage') . ' </td></tr>';
163163
}
164164

@@ -252,21 +252,22 @@ function poller_stat($panel, $user_id, $timespan = 0) {
252252
if ($pcount > 0) {
253253
$new_index = 1;
254254
foreach ($pollers as $xpoller) {
255-
255+
$seconds = floor($timespan / 60);
256+
256257
$rows = db_fetch_assoc_prepared("SELECT cur_timestamp AS `date`, AVG(SUBSTRING_INDEX(value, ':', -1)) AS value
257258
FROM plugin_intropage_trends
258259
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
259260
AND name = 'poller'
260261
AND value LIKE ?
261-
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $refresh
262+
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
262263
ORDER BY cur_timestamp ASC",
263264
array($timespan, $xpoller['id'] . ':%'));
264265

265266
if ($pcount < 3) {
266267
$avg = db_fetch_cell_prepared("SELECT (SUBSTRING_INDEX(value, ':', -1)) AS value
267268
FROM plugin_intropage_trends
268269
WHERE cur_timestamp > date_sub(NOW(), INTERVAL 24 HOUR) AND
269-
name = 'poller' AND
270+
name = 'poller' AND
270271
value LIKE ?",
271272
array($xpoller['id'] . ':%'));
272273
}
@@ -315,7 +316,7 @@ function poller_info_detail() {
315316
global $config;
316317

317318
$lines = read_user_setting('intropage_number_of_lines', read_config_option('intropage_number_of_lines'), false, $_SESSION['sess_user_id']);
318-
$poller_interval = read_config_option('poller_interval');
319+
$poller_interval = read_config_option('poller_interval');
319320

320321
$panel = array(
321322
'name' => __('Poller Details', 'intropage'),
@@ -348,9 +349,8 @@ function poller_info_detail() {
348349

349350
if (cacti_sizeof($pollers)) {
350351
foreach ($pollers as $poller) {
351-
352352
$color = 'green';
353-
353+
354354
if ($poller['status'] == 0 || $poller['status'] == 1 || $poller['status'] == 2 || $poller['status'] == 5) {
355355
$ok++;
356356
}
@@ -446,11 +446,13 @@ function poller_output_items($panel, $user_id, $timespan = 0) {
446446
$refresh = $panel['refresh_interval'];
447447
}
448448

449+
$seconds = floor($timespan / 60);
450+
449451
$rows = db_fetch_assoc_prepared("SELECT cur_timestamp AS `date`, value
450452
FROM plugin_intropage_trends
451453
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
452454
AND name = 'poller_output'
453-
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $refresh
455+
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
454456
ORDER BY cur_timestamp ASC",
455457
array($timespan));
456458

panellib/syslog.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ function plugin_syslog($panel, $user_id, $timespan = 0) {
200200
}
201201

202202
if (api_plugin_is_enabled('syslog')) {
203+
$seconds = floor($timespan / 60);
204+
203205
// Get the syslog records
204206
$rows = db_fetch_assoc_prepared("SELECT cur_timestamp AS `date`,
205207
MAX(CASE WHEN name='syslog_total' THEN value ELSE NULL END) AS syslog_total,
@@ -208,7 +210,7 @@ function plugin_syslog($panel, $user_id, $timespan = 0) {
208210
FROM plugin_intropage_trends
209211
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
210212
AND name IN ('syslog_total', 'syslog_incoming', 'syslog_alert')
211-
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $refresh
213+
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
212214
ORDER BY cur_timestamp ASC",
213215
array($timespan));
214216

@@ -321,14 +323,15 @@ function plugin_syslog_levels($panel, $user_id, $timespan = 0) {
321323
}
322324

323325
if (api_plugin_is_enabled('syslog')) {
326+
$seconds = floor($timespan / 60);
324327

325328
$rows = db_fetch_assoc_prepared("SELECT *
326329
FROM plugin_intropage_trends
327330
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
328331
AND name = 'syslog_levels'
329332
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV ?
330333
ORDER BY cur_timestamp ASC",
331-
array($timespan, $refresh));
334+
array($timespan, $seconds));
332335

333336
if (cacti_sizeof($rows)) {
334337

@@ -441,7 +444,7 @@ function plugin_syslog_devices_detail() {
441444
FROM syslog AS s
442445
LEFT JOIN syslog_hosts AS sh
443446
ON s.host_id = sh.host_id
444-
WHERE logtime > (DATE_SUB(NOW(),INTERVAL ? SECOND))
447+
WHERE logtime > (DATE_SUB(NOW(),INTERVAL ? SECOND))
445448
GROUP BY s.host_id
446449
ORDER BY hcount desc
447450
LIMIT 20',

panellib/system.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,13 @@ function cpuload($panel, $user_id, $timespan = 0) {
182182
$panel['data'] = __('This function is not implemented on Windows platforms', 'intropage');
183183
unset($graph);
184184
} else {
185+
$seconds = floor($timespan / 60);
186+
185187
$rows = db_fetch_assoc_prepared("SELECT cur_timestamp AS `date`, AVG(value) AS average, MAX(value) AS max
186188
FROM plugin_intropage_trends
187189
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
188190
AND name = 'cpuload'
189-
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $refresh
191+
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
190192
ORDER BY cur_timestamp ASC",
191193
array($timespan));
192194

@@ -267,7 +269,7 @@ function info($panel, $user_id) {
267269
$panel['data'] .= '<tr><td class="inpa_loglines" title="' . $xdata . '"><br/>' . __('Running on: ', 'intropage') . $xdata . '</td></tr>';
268270

269271
$panel['data'] .= '</table>';
270-
272+
271273
save_panel_result($panel, $user_id);
272274
}
273275

@@ -544,7 +546,7 @@ function extrem_trend() {
544546

545547
foreach ($users as $user) {
546548
if (is_panel_allowed('extrem', $user['id'])) {
547-
549+
548550
$simple_perms = get_simple_device_perms($user['id']);
549551

550552
if (!$simple_perms) {
@@ -608,7 +610,7 @@ function extrem($panel, $user_id) {
608610
} else {
609611
$color = 'green';
610612
}
611-
613+
612614
$fin_data[$key]['poller'] = $row['date'] . ' ' . $row['xvalue'] . 's <span class="inpa_sq color_' . $color . '"></span>';
613615
}
614616
}
@@ -745,7 +747,7 @@ function extrem_detail() {
745747

746748
$lines = read_user_setting('intropage_number_of_lines', read_config_option('intropage_number_of_lines'));
747749
$poller_interval = read_config_option('poller_interval');
748-
750+
749751
$panel = array(
750752
'name' => __('48 Hour Extreme Polling', 'intropage'),
751753
'alarm' => 'grey',

setup.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ function intropage_config_arrays() {
8282
auth_augment_roles(__('System Administration'), array('intropage_admin.php'));
8383

8484
$trend_timespans = array(
85-
3600 => __('Timespan Last 1 Hour', 'intropage'),
86-
7200 => __('Timespan Last %d Hours', 2, 'intropage'),
87-
10800 => __('Timespan Last %d Hours', 3, 'intropage'),
88-
14400 => __('Timespan Last %d Hours', 4, 'intropage'),
89-
21600 => __('Timespan Last %d Hours', 6, 'intropage'),
90-
43200 => __('Timespan Last %d Hours', 12, 'intropage'),
91-
86400 => __('Timespan Last 1 Day', 'intropage')
85+
3600 => __('Timespan Last 1 Hour', 'intropage'),
86+
7200 => __('Timespan Last %d Hours', 2, 'intropage'),
87+
10800 => __('Timespan Last %d Hours', 3, 'intropage'),
88+
14400 => __('Timespan Last %d Hours', 4, 'intropage'),
89+
21600 => __('Timespan Last %d Hours', 6, 'intropage'),
90+
43200 => __('Timespan Last %d Hours', 12, 'intropage'),
91+
86400 => __('Timespan Last 1 Day', 'intropage'),
92+
172800 => __('Timespan Last 2 Days', 'intropage')
9293
);
9394

9495
$poller_interval = read_config_option('poller_interval');

0 commit comments

Comments
 (0)