-
Notifications
You must be signed in to change notification settings - Fork 13
/
graph.php
91 lines (75 loc) · 2.3 KB
/
graph.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
include_once('functions.php');
# Set some defaults if they are not specified.
if (isset($_GET['debug']) && is_numeric($_GET['debug'])) {
$debug = $_GET['debug'];
} else {
$debug = 0;
}
if (isset($_GET['duration'])) {
$start = $_GET['duration'];
} else {
$start = isset($default_duration) ? $default_duration : -86400 ;
}
if (isset($_GET['end'])) {
$end = $_GET['end'];
} else {
$end = "-60";
}
if (isset($_GET['height'])) {
$height = $_GET['height'];
} else {
$height = 120;
}
if (isset($_GET['width'])) {
$width = $_GET['width'];
} else {
$width = 500;
}
if (isset($_GET['aggregate_id'])) {
$aggregate_id = $_GET['aggregate_id'];
$data = getAggregateData($aggregate_id);
$graphs_array = $data['graphs_array'];
$meta = $data['meta'];
$rrdtoolcmd = getStackedGraphsCmd($graphs_array, $meta['type'], $meta['stack'], $start, $end, $height, $width, $meta['friendlytitle']);
} else {
$friendlytitle = "";
if (isset($_GET['friendlytitle'])) {
$friendlytitle = $_GET['friendlytitle'];
}
if (isset($_GET['count'])) {
$graph_count = $_GET['count'];
} else {
$graph_count = 1;
}
if (isset($_GET['type'])) {
$type = $_GET['type'];
} else {
$type = "bits";
}
if ($graph_count > 1) {
$graphs_array = getAggregateGraphsArrayFromRequest($_GET);
$stack = !isset($_GET['stack']) || $_GET['stack'] != 'false';
$rrdtoolcmd = getStackedGraphsCmd($graphs_array, $type, $stack, $start, $end, $height, $width, $friendlytitle);
} else {
$rrdname = $_GET['rrdname'];
$rrdfolder = $_GET['host'];
$rrdtoolcmd = getGraphCmd($rrdname, $rrdfolder, $type, $start, $end, $height, $width, $friendlytitle);
}
}
# Anti-caching techniques courtesy of Ganglia
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header ("Content-type: image/png");
if ($debug >= 2) {
header ("Content-type: text/html");
echo $rrdtoolcmd;
}
else {
if ($debug >= 1) {
error_log("rrdtool graph command:" . $rrdtoolcmd);
}
passthru($rrdtoolcmd);
}