forked from Cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspikekill.php
74 lines (65 loc) · 3.12 KB
/
spikekill.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2016 The Cacti Group |
| |
| 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 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
include('./include/auth.php');
$debug = false;
switch(get_nfilter_request_var('method')) {
case 'stddev':
case 'variance':
break;
default:
echo __("FATAL: SpikeKill method '%s' is Invalid\n", get_nfilter_request_var('method'));
exit(1);
break;
}
if (is_realm_allowed(1043)) {
$local_data_ids = db_fetch_assoc('SELECT DISTINCT
data_template_rrd.local_data_id
FROM graph_templates_item
LEFT JOIN data_template_rrd
ON (graph_templates_item.task_item_id=data_template_rrd.id)
WHERE graph_templates_item.local_graph_id=' . get_filter_request_var('local_graph_id'));
$results = '';
if (sizeof($local_data_ids)) {
foreach($local_data_ids as $local_data_id) {
$data_source_path = get_data_source_path($local_data_id['local_data_id'], true);
if (strlen($data_source_path)) {
if ($debug) {
cacti_log(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/cli/removespikes.php ' .
' -R=' . $data_source_path . (isset_request_var('dryrun') ? ' --dryrun' : '') .
' -M=' . get_nfilter_request_var('method') .
' -U=' . $_SESSION['sess_user_id'] .
' --html', false);
}
$results .= shell_exec(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/cli/removespikes.php ' .
' -R=' . $data_source_path . (isset_request_var('dryrun') ? ' --dryrun' : '') .
' -M=' . get_nfilter_request_var('method') .
' -U=' . $_SESSION['sess_user_id'] .
' --html');
}
}
}
print json_encode(array('local_graph_id' => get_request_var('local_graph_id'), 'results' => $results));
}else{
echo __("FATAL: SpikeKill Not Allowed\n");
}