Revision 971cc14f
Added by Scott Ullrich over 19 years ago
usr/local/www/status_rrd_graph.php | ||
---|---|---|
91 | 91 |
<div> |
92 | 92 |
<?php |
93 | 93 |
|
94 |
$periods = array("6h", "30h", "10d", "400d"); |
|
94 |
$periods = array("2h", "6h", "48h", "14d", "2m", "18m"); |
|
95 |
$graphs['2h']['seconds'] = 7200; |
|
96 |
$graphs['2h']['average'] = 60; |
|
97 |
$graphs['2h']['scale'] = "MINUTE:5:MINUTE:10:MINUTE:30:0:%H%:%M"; |
|
95 | 98 |
$graphs['6h']['seconds'] = 21600; |
96 | 99 |
$graphs['6h']['average'] = 300; |
97 | 100 |
$graphs['6h']['scale'] = "MINUTE:10:MINUTE:30:MINUTE:30:0:%H%:%M"; |
98 |
$graphs['30h']['seconds'] = 108000; |
|
99 |
$graphs['30h']['average'] = 1200; |
|
100 |
$graphs['30h']['scale'] = "HOUR:1:HOUR:6:HOUR:2:0:%H"; |
|
101 |
$graphs['10d']['seconds'] = 864000; |
|
102 |
$graphs['10d']['average'] = 7200; |
|
103 |
$graphs['10d']['scale'] = "HOUR:6:DAY:1:DAY:1:0:%a"; |
|
104 |
$graphs['400d']['seconds'] = 34560000; |
|
105 |
$graphs['400d']['average'] = 86400; |
|
106 |
$graphs['400d']['scale'] = "MONTH:1:MONTH:1:MONTH:1:0:%b"; |
|
101 |
$graphs['48h']['seconds'] = 108000; |
|
102 |
$graphs['48h']['average'] = 300; |
|
103 |
$graphs['48h']['scale'] = "HOUR:1:HOUR:6:HOUR:2:0:%H"; |
|
104 |
$graphs['14d']['seconds'] = 1209600; |
|
105 |
$graphs['14d']['average'] = 600; |
|
106 |
$graphs['14d']['scale'] = "HOUR:6:DAY:1:DAY:1:0:%a"; |
|
107 |
$graphs['2m']['seconds'] = 5184000; |
|
108 |
$graphs['2m']['average'] = 3600; |
|
109 |
$graphs['2m']['scale'] = "DAY:1:WEEK:1:WEEK:1:0:Week %W"; |
|
110 |
$graphs['18m']['seconds'] = 46656000; |
|
111 |
$graphs['18m']['average'] = 86400; |
|
112 |
$graphs['18m']['scale'] = "MONTH:1:MONTH:1:MONTH:1:0:%b"; |
|
107 | 113 |
|
108 | 114 |
$rrddbpath = "/var/db/rrd/"; |
109 | 115 |
$traffic = "-traffic.rrd"; |
... | ... | |
115 | 121 |
$uptime = "/usr/bin/uptime"; |
116 | 122 |
$sed = "/usr/bin/sed"; |
117 | 123 |
|
124 |
/* FIXME: We need real shaper speeds here, yes i have a 22/2Mbps |
|
125 |
internet connection */ |
|
126 |
/* compare bytes/sec counters, divide bps by 8 */ |
|
127 |
$downstream = (22000000/8); |
|
128 |
$upstream = (2000000/8); |
|
129 |
|
|
130 |
/* FIXME: determine down and up interface, note: case insensitive */ |
|
131 |
$upif = "wan"; |
|
132 |
$downif = "lan"; |
|
133 |
|
|
118 | 134 |
foreach($periods as $period => $interval) { |
119 | 135 |
|
120 | 136 |
/* generate the graphs when we request the page. */ |
... | ... | |
221 | 237 |
$i = 0; |
222 | 238 |
$t = 0; |
223 | 239 |
$colors = array('000000','7B0000','990000','BB0000','CC0000','D90000','EE0000','FF0000','CC0000'); |
224 |
/* compare bytes/sec counters */ |
|
225 |
$downstream = (22000000/8); |
|
226 |
$upstream = (2000000/8); |
|
227 | 240 |
foreach ($a_queues as $queue) { |
228 | 241 |
$name = $queue['name']; |
229 |
if((stristr($name, "wan")) || (stristr($name, "up"))) {
|
|
230 |
$color = $colors[$t];
|
|
242 |
if((stristr($name, "$upif")) || (stristr($name, "up"))) {
|
|
243 |
$color = "$colors[$t]";
|
|
231 | 244 |
if($t > 0) { $stack = ":STACK"; } |
232 | 245 |
$graphcmd .= "DEF:$name=$rrddbpath$curif$queues:$name:AVERAGE \\ |
233 | 246 |
\"CDEF:$name-bytes_out=$name,0,$upstream,LIMIT,UN,0,$name,IF\" \\ |
... | ... | |
235 | 248 |
\"CDEF:$name-bits_out_neg=$name-bits_out,-1,*\" \\ |
236 | 249 |
AREA:$name-bits_out_neg#${color}:$name$stack \\"; |
237 | 250 |
$t++; |
251 |
if($t > 7) { $t = 0; } |
|
238 | 252 |
} |
239 | 253 |
} |
240 | 254 |
$graphcmd .= "COMMENT:\"\\n\" \\"; |
... | ... | |
242 | 256 |
$stack = ""; |
243 | 257 |
foreach ($a_queues as $queue) { |
244 | 258 |
$name = $queue['name']; |
245 |
if((stristr($name, "lan")) || (stristr($name, "down"))) {
|
|
246 |
$color = $colors[$i];
|
|
259 |
if((stristr($name, "$downif")) || (stristr($name, "down"))) {
|
|
260 |
$color = "$colors[$i]";
|
|
247 | 261 |
if($i > 0) { $stack = ":STACK"; } |
248 | 262 |
$graphcmd .= "DEF:$name=$rrddbpath$curif$queues:$name:AVERAGE \\ |
249 | 263 |
\"CDEF:$name-bytes_in=$name,0,$downstream,LIMIT,UN,0,$name,IF\" \\ |
250 | 264 |
\"CDEF:$name-bits_in=$name-bytes_in,8,*\" \\ |
251 | 265 |
AREA:$name-bits_in#${color}:$name$stack \\"; |
252 | 266 |
$i++; |
267 |
if($i > 7) { $i = 0; } |
|
253 | 268 |
} |
254 | 269 |
} |
255 | 270 |
$graphcmd .= "COMMENT:\"\\n\" \\"; |
Also available in: Unified diff
MFC 11475
They asked for something better, perhaps. Important: Wrap colors, when queues > 8 Important: speeds/if variables need filling? Anyone?