Projet

Général

Profil

Télécharger (62,9 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / status_rrd_graph_img.php @ 2d1e985d

1
<?php
2
/* $Id$ */
3
/*
4
	status_rrd_graph_img.php
5
	Part of pfSense
6
	Copyright (C) 2009 Seth Mos <seth.mos@dds.nl>
7
	All rights reserved.
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11

    
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14

    
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18

    
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*	
31
	pfSense_BUILDER_BINARIES:	/bin/rm	/usr/local/bin/rrdtool
32
	pfSense_MODULE:	system
33
*/
34

    
35
require_once("globals.inc");
36
require_once("guiconfig.inc");
37
require_once("filter.inc");
38
require_once("shaper.inc");
39
require_once("rrd.inc");
40

    
41
global $g;
42

    
43
$pgtitle = array(gettext("System"),gettext("RRD Graphs"),gettext("Image viewer"));
44

    
45
if ($_GET['database']) {
46
	$curdatabase = basename($_GET['database']);
47
	$curdatabase = str_replace(array("<", ">", ";", "&", "'", '"'), "", htmlspecialchars_decode($curdatabase, ENT_QUOTES | ENT_HTML401));
48
} else {
49
	$curdatabase = "wan-traffic.rrd";
50
}
51

    
52
if ($_GET['style']) {
53
	$curstyle = $_GET['style'];
54
} else {
55
	$curstyle = "inverse";
56
}
57

    
58
/* this is used for temp name */
59
if ($_GET['graph']) {
60
	$curgraph = str_replace(array("<", ">", ";", "&", "'", '"'), "", htmlspecialchars_decode($_GET['graph'], ENT_QUOTES | ENT_HTML401));
61
} else {
62
	$curgraph = "custom";
63
}
64

    
65
$now = time();
66

    
67
if (is_numeric($_GET['start'])) {
68
        $start = $_GET['start'];
69
} else {
70
        $start = $now - (8 * 3600);
71
}
72

    
73
if (is_numeric($_GET['end'])) {
74
        $end = $_GET['end'];
75
} else {
76
        $end = $now;
77
}
78

    
79
/* this should never happen */
80
if($end < $start) {
81
	log_error("start $start is smaller than end $end");
82
        $end = $now;
83
}
84

    
85
$seconds = $end - $start;
86

    
87
$scales = array();
88
$scales[14400] = "MINUTE:5:MINUTE:10:MINUTE:30:0:%H%:%M";
89
$scales[57600] = "MINUTE:30:HOUR:1:HOUR:1:0:%H";
90
$scales[172800] = "HOUR:1:HOUR:6:HOUR:2:0:%H";
91
$scales[691200] = "HOUR:2:HOUR:12:DAY:1:0:%D %d";
92
$scales[2764800] = "DAY:1:WEEK:1:WEEK:1:0:Week %W";
93
$scales[16070400] = "WEEK:1:MONTH:1:MONTH:1:0:%b";
94
$scales[42854400] = "MONTH:1:MONTH:1:MONTH:1:0:%b";
95

    
96
$archives = array();
97
$archives[1] = 1200;
98
$archives[5] = 720;
99
$archives[60] = 1860;
100
$archives[1440] = 2284;
101

    
102
$defOptions = array(
103
	'to' => 1,
104
	'parts' => 1,
105
	'precision' => 'minute',
106
	'distance' => FALSE,
107
	'separator' => ', '
108
);
109

    
110
/* always set the average to the highest value as a fallback */
111
$average = 1440 * 60;
112
foreach($archives as $rra => $value) {
113
        $archivestart = $now - ($rra * 60 * $value);
114
        if($archivestart <= $start) {
115
                $average = $rra * 60;
116
                break;
117
        }
118
}
119

    
120
foreach($scales as $scalelength => $value) {
121
        if($scalelength >= $seconds) {
122
                $scale = $value;
123
                break;
124
        }
125
}
126

    
127
// log_error("start $start, end $end, archivestart $archivestart, average $average, scale $scale, seconds $seconds");
128

    
129
/* Deduce a interface if possible and use the description */
130
$curif = explode("-", $curdatabase);
131
$curif = "$curif[0]";
132
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($curif));
133
if($friendly == "") {
134
	$friendly = $curif;
135
}
136
$search = array("-", ".rrd", $curif);
137
$replace = array(" :: ", "", $friendly);
138
$prettydb = ucwords(str_replace($search, $replace, $curdatabase));
139

    
140

    
141
$rrddbpath = "/var/db/rrd/";
142
$rrdtmppath = "/tmp/";
143
$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
144
$uptime = "/usr/bin/uptime";
145
$sed = "/usr/bin/sed";
146

    
147
$havg = timeDiff($average, $defOptions);
148
$hperiod = timeDiff($seconds, $defOptions);
149
$data = true;
150

    
151
/* Don't leave it up to RRD Tool to select the RRA and resolution to use. */
152
/* Specify the RRA and resolution to use per the graph havg value. */
153
switch ($havg) {
154
	case "1 minute":	$step = 60;		break;
155
	case "5 minutes":	$step = 300;	break;
156
	case "1 hour":		$step = 3600;	break;
157
	case "1 day":		$step = 86400;	break;
158
	default:			$step = 0;		break;
159
}
160

    
161
$rrddbpath = "/var/db/rrd/";
162
chdir($rrddbpath);
163
$databases = glob("*.rrd");
164
rsort($databases);
165

    
166
/* compare bytes/sec counters, divide bps by 8 */
167
read_altq_config();
168
if ($altq_list_queues[$curif]) {
169
	$altq =& $altq_list_queues[$curif];
170
	switch ($altq->GetBwscale()) {
171
        case "Gb":
172
                $factor = 1024 * 1024 * 1024;
173
        break;
174
        case "Mb":
175
                $factor = 1024 * 1024;
176
        break;
177
        case "Kb":
178
                $factor = 1024;
179
        break;
180
        case "b":
181
        default:
182
                $factor = 1;
183
        break;
184
        }
185
	$upstream = (($altq->GetBandwidth()*$factor)/8);
186
	if ($upstream != 0)
187
		$downstream = $upstream; /* XXX: Ugly hack */
188
	else
189
		$downstream = $upstream = 12500000;
190
	$upif = $curif;
191
	$downif = "lan"; /* XXX should this be set to something else?! */
192
} else {
193
	$altq = null;
194
	$downstream = 12500000;
195
	$upstream = 12500000;
196
	$upif = "wan";
197
	$downif = "lan";
198
}
199

    
200
$speedlimit = ($upstream + $downstream);
201

    
202
/* Set default colors explicitly, the theme can then override them below.
203
   This prevents missing colors in themes from crashing the graphs. */
204
/* Traffic Outbound		Out-P-4,  Out-B-4,  Out-P-6,  Out-B-6 */
205
$colortrafficup		= array('666666', 'CCCCCC', '2217AA', '625AE7');
206

    
207
/* Traffic Inbound		In-P-4,   In-B-4,    In-P-6,  In-B-6 */
208
$colortrafficdown	= array('990000', 'CC0000', 'FFC875', 'FF9900');
209

    
210
/* Packets Outbound		Out-P-4,  Out-B-4,  Out-P-6,  Out-B-6 */
211
$colorpacketsup		= array('666666', 'CCCCCC', '2217AA', '625AE7');
212

    
213
/* Packets Inbound		In-P-4,   In-B-4,    In-P-6,  In-B-6 */
214
$colorpacketsdown	= array('990000', 'CC0000', 'FFC875', 'FF9900');
215

    
216
/* 95th Percentile Lines	Out,      In */
217
$colortraffic95		= array('660000', 'FF0000');
218

    
219
/* State Table			pfrate,  pfstates, pfnat,  srcip,   dstip */
220
$colorstates		= array('00AA00','990000','0000FF','000000','DD9B00');
221

    
222
/* Processor Usage		user,    nice,    system,  int,     processes */
223
$colorprocessor		= array('00AA00','990000','0000FF','DD9B00','000000');
224

    
225
/* Memory Usage			active,  inact,   free,    cache,   wire */
226
$colormemory		= array('00AA00','990000','0000FF','666666','DD9B00');
227

    
228
/* MBUF Usage			current, cache,   total,   max */
229
$colormbuf		= array('0080FF','00E344','FF0000','000000');
230

    
231
/* Traffic Shaper Queues	q1,      q2,      q3,      q4,      q5,      q6,      q7,      q8,      q9 */
232
$colorqueuesup		= array('000000','7B0000','0080FF','00E344','FF0000','2217AA','FFC875','FF9900','CC0000');
233
$colorqueuesdown	= array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
234

    
235
$colorqueuesdropup	= array('000000','7B0000','0080FF','00E344','FF0000','2217AA','FFC875','FF9900','CC0000');
236
$colorqueuesdropdown	= array('000000','7B7B7B','999999','BBBBBB','CCCCCC','D9D9D9','EEEEEE','FFFFFF','CCCCCC');
237

    
238
/* Quality Graph Delay	>420,    180-420, 60-180,  20-60,   <20,     Delay Avg */
239
$colorqualityrtt	= array('990000','a83c3c','b36666','bd9090','cccccc','000000');
240
/* Quality Graph Loss */
241
$colorqualityloss	= 'ee0000';
242

    
243
/* Wireless Graph		SNR,     Rate,    Channel*/
244
/* Cellular Graph		RSSI,     */
245
$colorwireless		= array('333333','a83c3c','999999');
246

    
247
/* SPAMD Times			min area, avg area, max area, Time line */
248
$colorspamdtime		= array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066');
249
/* SPAMD Connections		max area,   min area,   min line,   max line,   avg line */
250
$colorspamdconn		= array('AA00BB', 'FFFFFF', '660088', 'FFFF88', '006600');
251

    
252
/* OpenVPN Users		Online Users */
253
$colorvpnusers		= array('990000');
254

    
255
/* Captive Portal Total Users	Total Users */
256
/* Captive Portal Concurrent	Concurrent Users */
257
$colorcaptiveportalusers = array('990000');
258

    
259
/* select theme colors if the inclusion file exists */
260
$rrdcolors = "{$g['www_path']}/themes/{$g['theme']}/rrdcolors.inc.php";
261
if(file_exists($rrdcolors)) {
262
	include($rrdcolors);
263
} else {
264
	log_error(sprintf(gettext("rrdcolors.inc.php for theme %s does not exist, using defaults!"),$g['theme']));
265
}
266

    
267
switch ($curstyle) {
268
case "absolute":
269
	$multiplier = 1;
270
	$AREA = "LINE1";
271
	break;
272
default:
273
	$multiplier = -1;
274
	$AREA = "AREA";
275
	break;
276
}
277

    
278
function timeDiff($time, $opt = array()) {
279
    // The default values
280
    $defOptions = array(
281
        'to' => 0,
282
        'parts' => 1,
283
        'precision' => 'second',
284
        'distance' => TRUE,
285
        'separator' => ', '
286
    );
287
    $opt = array_merge($defOptions, $opt);
288
    // Default to current time if no to point is given
289
    (!$opt['to']) && ($opt['to'] = time());
290
    // Init an empty string
291
    $str = '';
292
    // To or From computation
293
    $diff = ($opt['to'] > $time) ? $opt['to'] - $time : $time - $opt['to'];
294
    // An array of label => periods of seconds;
295
    $periods = array(
296
        'decade' => 315569260,
297
        'year' => 31539600,
298
        'month' => 2629744,
299
        'week' => 604800,
300
        'day' => 86400,
301
        'hour' => 3600,
302
        'minute' => 60,
303
        'second' => 1
304
    );
305
	// 31539600, 31556926, 31622400
306
    // Round to precision
307
    if ($opt['precision'] != 'second')
308
        $diff = round(($diff / $periods[$opt['precision']])) * $periods[$opt['precision']];
309
    // Report the value is 'less than 1 ' precision period away
310
    (0 == $diff) && ($str = 'less than 1 ' . $opt['precision']);
311
    // Loop over each period
312
    foreach ($periods as $label => $value) {
313
        // Stitch together the time difference string
314
        (($x = round($diff / $value)) && $opt['parts']--) && $str .= ($str ? $opt['separator'] : '') . ($x .' '. $label. ($x > 1 ? 's' : ''));
315
        // Stop processing if no more parts are going to be reported.
316
        if ($opt['parts'] == 0 || $label == $opt['precision']) break;
317
        // Get ready for the next pass
318
        $diff -= $x * $value;
319
    }
320
    $opt['distance'] && $str .= ($str && $opt['to'] >= $time) ? ' ago' : ' away';
321
    return $str;
322
}
323

    
324

    
325
if((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
326
	/* define graphcmd for traffic stats */
327
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
328
	$graphcmd .= "--start $start --end $end --step $step --vertical-label \"bits/sec\" ";
329
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
330
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
331
	$graphcmd .= "--height 200 --width 620 ";
332
	$graphcmd .= "DEF:$curif-in_bytes_pass=$rrddbpath$curdatabase:inpass:AVERAGE:step=$step ";
333
	$graphcmd .= "DEF:$curif-out_bytes_pass=$rrddbpath$curdatabase:outpass:AVERAGE:step=$step ";
334
	$graphcmd .= "DEF:$curif-in_bytes_block=$rrddbpath$curdatabase:inblock:AVERAGE:step=$step ";
335
	$graphcmd .= "DEF:$curif-out_bytes_block=$rrddbpath$curdatabase:outblock:AVERAGE:step=$step ";
336

    
337
	$graphcmd .= "DEF:$curif-in6_bytes_pass=$rrddbpath$curdatabase:inpass6:AVERAGE:step=$step ";
338
	$graphcmd .= "DEF:$curif-out6_bytes_pass=$rrddbpath$curdatabase:outpass6:AVERAGE:step=$step ";
339
	$graphcmd .= "DEF:$curif-in6_bytes_block=$rrddbpath$curdatabase:inblock6:AVERAGE:step=$step ";
340
	$graphcmd .= "DEF:$curif-out6_bytes_block=$rrddbpath$curdatabase:outblock6:AVERAGE:step=$step ";
341

    
342
	$graphcmd .= "CDEF:\"$curif-in_bits_pass=$curif-in_bytes_pass,8,*\" ";
343
	$graphcmd .= "CDEF:\"$curif-out_bits_pass=$curif-out_bytes_pass,8,*\" ";
344
	$graphcmd .= "CDEF:\"$curif-in_bits_block=$curif-in_bytes_block,8,*\" ";
345
	$graphcmd .= "CDEF:\"$curif-out_bits_block=$curif-out_bytes_block,8,*\" ";
346

    
347
	$graphcmd .= "CDEF:\"$curif-in6_bits_pass=$curif-in6_bytes_pass,8,*\" ";
348
	$graphcmd .= "CDEF:\"$curif-out6_bits_pass=$curif-out6_bytes_pass,8,*\" ";
349
	$graphcmd .= "CDEF:\"$curif-in6_bits_block=$curif-in6_bytes_block,8,*\" ";
350
	$graphcmd .= "CDEF:\"$curif-out6_bits_block=$curif-out6_bytes_block,8,*\" ";
351

    
352
	$graphcmd .= "CDEF:\"$curif-in_bytes=$curif-in_bytes_pass,$curif-in_bytes_block,+\" ";
353
	$graphcmd .= "CDEF:\"$curif-out_bytes=$curif-out_bytes_pass,$curif-out_bytes_block,+\" ";
354
	$graphcmd .= "CDEF:\"$curif-in_bits=$curif-in_bits_pass,$curif-in_bits_block,+\" ";
355
	$graphcmd .= "CDEF:\"$curif-out_bits=$curif-out_bits_pass,$curif-out_bits_block,+\" ";
356

    
357
	$graphcmd .= "CDEF:\"$curif-in6_bytes=$curif-in6_bytes_pass,$curif-in6_bytes_block,+\" ";
358
	$graphcmd .= "CDEF:\"$curif-out6_bytes=$curif-out6_bytes_pass,$curif-out6_bytes_block,+\" ";
359
	$graphcmd .= "CDEF:\"$curif-in6_bits=$curif-in6_bits_pass,$curif-in6_bits_block,+\" ";
360
	$graphcmd .= "CDEF:\"$curif-out6_bits=$curif-out6_bits_pass,$curif-out6_bits_block,+\" ";
361

    
362
	$graphcmd .= "CDEF:\"$curif-bits_io=$curif-in_bits,$curif-out_bits,+\" ";
363
	$graphcmd .= "CDEF:\"$curif-out_bits_block_neg=$curif-out_bits_block,$multiplier,*\" ";
364
	$graphcmd .= "CDEF:\"$curif-out_bits_pass_neg=$curif-out_bits_pass,$multiplier,*\" ";
365

    
366
	$graphcmd .= "CDEF:\"$curif-bits6_io=$curif-in6_bits,$curif-out6_bits,+\" ";
367
	$graphcmd .= "CDEF:\"$curif-out6_bits_block_neg=$curif-out6_bits_block,$multiplier,*\" ";
368
	$graphcmd .= "CDEF:\"$curif-out6_bits_pass_neg=$curif-out6_bits_pass,$multiplier,*\" ";
369

    
370
	$graphcmd .= "CDEF:\"$curif-bytes_in_pass=$curif-in_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_pass,IF,$average,*\" ";
371
	$graphcmd .= "CDEF:\"$curif-bytes_out_pass=$curif-out_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_pass,IF,$average,*\" ";
372
	$graphcmd .= "CDEF:\"$curif-bytes_in_block=$curif-in_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_block,IF,$average,*\" ";
373
	$graphcmd .= "CDEF:\"$curif-bytes_out_block=$curif-out_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_block,IF,$average,*\" ";
374

    
375
	$graphcmd .= "CDEF:\"$curif-bytes_in6_pass=$curif-in6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_pass,IF,$average,*\" ";
376
	$graphcmd .= "CDEF:\"$curif-bytes_out6_pass=$curif-out6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_pass,IF,$average,*\" ";
377
	$graphcmd .= "CDEF:\"$curif-bytes_in6_block=$curif-in6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_block,IF,$average,*\" ";
378
	$graphcmd .= "CDEF:\"$curif-bytes_out6_block=$curif-out6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_block,IF,$average,*\" ";
379

    
380
	$graphcmd .= "CDEF:\"$curif-bytes_pass=$curif-bytes_in_pass,$curif-bytes_out_pass,+\" ";
381
	$graphcmd .= "CDEF:\"$curif-bytes_block=$curif-bytes_in_block,$curif-bytes_out_block,+\" ";
382

    
383
	$graphcmd .= "CDEF:\"$curif-bytes_pass6=$curif-bytes_in6_pass,$curif-bytes_out6_pass,+\" ";
384
	$graphcmd .= "CDEF:\"$curif-bytes_block6=$curif-bytes_in6_block,$curif-bytes_out6_block,+\" ";
385

    
386
	$graphcmd .= "CDEF:\"$curif-bytes_in_t_pass=$curif-in_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_pass,IF,$seconds,*\" ";
387
	$graphcmd .= "CDEF:\"$curif-bytes_out_t_pass=$curif-out_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_pass,IF,$seconds,*\" ";
388
	$graphcmd .= "CDEF:\"$curif-bytes_in_t_block=$curif-in_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_block,IF,$seconds,*\" ";
389
	$graphcmd .= "CDEF:\"$curif-bytes_out_t_block=$curif-out_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_block,IF,$seconds,*\" ";
390

    
391
	$graphcmd .= "CDEF:\"$curif-bytes_in6_t_pass=$curif-in6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_pass,IF,$seconds,*\" ";
392
	$graphcmd .= "CDEF:\"$curif-bytes_out6_t_pass=$curif-out6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_pass,IF,$seconds,*\" ";
393
	$graphcmd .= "CDEF:\"$curif-bytes_in6_t_block=$curif-in6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_block,IF,$seconds,*\" ";
394
	$graphcmd .= "CDEF:\"$curif-bytes_out6_t_block=$curif-out6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_block,IF,$seconds,*\" ";
395

    
396
	$graphcmd .= "CDEF:\"$curif-bytes_t_pass=$curif-bytes_in_t_pass,$curif-bytes_out_t_pass,+\" ";
397
	$graphcmd .= "CDEF:\"$curif-bytes_t_block=$curif-bytes_in_t_block,$curif-bytes_out_t_block,+\" ";
398
	$graphcmd .= "CDEF:\"$curif-bytes_t=$curif-bytes_t_pass,$curif-bytes_t_block,+\" ";
399

    
400
	$graphcmd .= "CDEF:\"$curif-bytes_t_pass6=$curif-bytes_in6_t_pass,$curif-bytes_out6_t_pass,+\" ";
401
	$graphcmd .= "CDEF:\"$curif-bytes_t_block6=$curif-bytes_in6_t_block,$curif-bytes_out6_t_block,+\" ";
402
	$graphcmd .= "CDEF:\"$curif-bytes_t6=$curif-bytes_t_pass6,$curif-bytes_t_block6,+\" ";
403
	$graphcmd .= "VDEF:\"$curif-in_bits_95=$curif-in_bits,95,PERCENT\" ";
404
	$graphcmd .= "CDEF:\"$curif-out_bits_mul=$curif-out_bits,$multiplier,*\" ";
405
	$perc = $multiplier > 0 ? "95" : "5";
406
	$graphcmd .= "VDEF:\"$curif-out_bits_95=$curif-out_bits_mul,{$perc},PERCENT\" ";
407

    
408
	$graphcmd .= "AREA:\"$curif-in_bits_block#{$colortrafficdown[1]}:$curif-in-block\" ";
409
	$graphcmd .= "AREA:\"$curif-in_bits_pass#{$colortrafficdown[0]}:$curif-in-pass:STACK\" ";
410
	$graphcmd .= "AREA:\"$curif-in6_bits_block#{$colortrafficdown[3]}:$curif-in6-block:STACK\" ";
411
	$graphcmd .= "AREA:\"$curif-in6_bits_pass#{$colortrafficdown[2]}:$curif-in6-pass:STACK\" ";
412
	$graphcmd .= "COMMENT:\"\\n\" ";
413

    
414
	$graphcmd .= "{$AREA}:\"$curif-out_bits_block_neg#{$colortrafficup[1]}:$curif-out-block\" ";
415
	$graphcmd .= "{$AREA}:\"$curif-out_bits_pass_neg#{$colortrafficup[0]}:$curif-out-pass:STACK\" ";
416
	$graphcmd .= "{$AREA}:\"$curif-out6_bits_block_neg#{$colortrafficup[3]}:$curif-out6-block:STACK\" ";
417
	$graphcmd .= "{$AREA}:\"$curif-out6_bits_pass_neg#{$colortrafficup[2]}:$curif-out6-pass:STACK\" ";
418
	$graphcmd .= "COMMENT:\"\\n\" ";
419
	$graphcmd .= "HRULE:\"$curif-in_bits_95#{$colortraffic95[1]}:$curif-in (95%)\" ";
420
	$graphcmd .= "HRULE:\"$curif-out_bits_95#{$colortraffic95[0]}:$curif-out (95%)\" ";
421
	$graphcmd .= "COMMENT:\"\\n\" ";
422
	$graphcmd .= "COMMENT:\"\t\t\t\t maximum\t    average\t\t current\t    period\t   95th percentile\\n\" ";
423
	$graphcmd .= "COMMENT:\"IPv4 in-pass\t\" ";
424
	$graphcmd .= "GPRINT:\"$curif-in_bits_pass:MAX:%7.2lf %sb/s\" ";
425
	$graphcmd .= "GPRINT:\"$curif-in_bits_pass:AVERAGE:%7.2lf %Sb/s\" ";
426
	$graphcmd .= "GPRINT:\"$curif-in_bits_pass:LAST:%7.2lf %Sb/s\" ";
427
	$graphcmd .= "GPRINT:\"$curif-bytes_in_t_pass:AVERAGE:%7.2lf %sB i\" ";
428
	$graphcmd .= "GPRINT:\"$curif-in_bits_95:%7.2lf %sb/s\" ";
429

    
430
	$graphcmd .= "COMMENT:\"\\n\" ";
431
	$graphcmd .= "COMMENT:\"IPv4 out-pass\t\" ";
432
	$graphcmd .= "GPRINT:\"$curif-out_bits_pass:MAX:%7.2lf %sb/s\" ";
433
	$graphcmd .= "GPRINT:\"$curif-out_bits_pass:AVERAGE:%7.2lf %Sb/s\" ";
434
	$graphcmd .= "GPRINT:\"$curif-out_bits_pass:LAST:%7.2lf %Sb/s\" ";
435
	$graphcmd .= "GPRINT:\"$curif-bytes_out_t_pass:AVERAGE:%7.2lf %sB o\" ";
436
	$graphcmd .= "GPRINT:\"$curif-out_bits_95:%7.2lf %sb/s\" ";
437
	$graphcmd .= "COMMENT:\"\\n\" ";
438
	$graphcmd .= "COMMENT:\"IPv4 in-block\t\" ";
439
	$graphcmd .= "GPRINT:\"$curif-in_bits_block:MAX:%7.2lf %sb/s\" ";
440
	$graphcmd .= "GPRINT:\"$curif-in_bits_block:AVERAGE:%7.2lf %Sb/s\" ";
441
	$graphcmd .= "GPRINT:\"$curif-in_bits_block:LAST:%7.2lf %Sb/s\" ";
442
	$graphcmd .= "GPRINT:\"$curif-bytes_in_t_block:AVERAGE:%7.2lf %sB i\" ";
443
	$graphcmd .= "COMMENT:\"\\n\" ";
444
	$graphcmd .= "COMMENT:\"IPv4 out-block\t\" ";
445
	$graphcmd .= "GPRINT:\"$curif-out_bits_block:MAX:%7.2lf %sb/s\" ";
446
	$graphcmd .= "GPRINT:\"$curif-out_bits_block:AVERAGE:%7.2lf %Sb/s\" ";
447
	$graphcmd .= "GPRINT:\"$curif-out_bits_block:LAST:%7.2lf %Sb/s\" ";
448
	$graphcmd .= "GPRINT:\"$curif-bytes_out_t_block:AVERAGE:%7.2lf %sB o\" ";
449
	$graphcmd .= "COMMENT:\"\\n\" ";
450
	$graphcmd .= "COMMENT:\"\\n\" ";
451
	$graphcmd .= "COMMENT:\"IPv6 in-pass\t\" ";
452
	$graphcmd .= "GPRINT:\"$curif-in6_bits_pass:MAX:%7.2lf %sb/s\" ";
453
	$graphcmd .= "GPRINT:\"$curif-in6_bits_pass:AVERAGE:%7.2lf %Sb/s\" ";
454
	$graphcmd .= "GPRINT:\"$curif-in6_bits_pass:LAST:%7.2lf %Sb/s\" ";
455
	$graphcmd .= "GPRINT:\"$curif-bytes_in6_t_pass:AVERAGE:%7.2lf %sB i\" ";
456
	$graphcmd .= "COMMENT:\"\\n\" ";
457
	$graphcmd .= "COMMENT:\"IPv6 out-pass\t\" ";
458
	$graphcmd .= "GPRINT:\"$curif-out6_bits_pass:MAX:%7.2lf %sb/s\" ";
459
	$graphcmd .= "GPRINT:\"$curif-out6_bits_pass:AVERAGE:%7.2lf %Sb/s\" ";
460
	$graphcmd .= "GPRINT:\"$curif-out6_bits_pass:LAST:%7.2lf %Sb/s\" ";
461
	$graphcmd .= "GPRINT:\"$curif-bytes_out6_t_pass:AVERAGE:%7.2lf %sB o\" ";
462
	$graphcmd .= "COMMENT:\"\\n\" ";
463
	$graphcmd .= "COMMENT:\"IPv6 in-block\t\" ";
464
	$graphcmd .= "GPRINT:\"$curif-in6_bits_block:MAX:%7.2lf %sb/s\" ";
465
	$graphcmd .= "GPRINT:\"$curif-in6_bits_block:AVERAGE:%7.2lf %Sb/s\" ";
466
	$graphcmd .= "GPRINT:\"$curif-in6_bits_block:LAST:%7.2lf %Sb/s\" ";
467
	$graphcmd .= "GPRINT:\"$curif-bytes_in6_t_block:AVERAGE:%7.2lf %sB i\" ";
468
	$graphcmd .= "COMMENT:\"\\n\" ";
469
	$graphcmd .= "COMMENT:\"IPv6 out-block\t\" ";
470
	$graphcmd .= "GPRINT:\"$curif-out6_bits_block:MAX:%7.2lf %sb/s\" ";
471
	$graphcmd .= "GPRINT:\"$curif-out6_bits_block:AVERAGE:%7.2lf %Sb/s\" ";
472
	$graphcmd .= "GPRINT:\"$curif-out6_bits_block:LAST:%7.2lf %Sb/s\" ";
473
	$graphcmd .= "GPRINT:\"$curif-bytes_out6_t_block:AVERAGE:%7.2lf %sB o\" ";
474
	$graphcmd .= "COMMENT:\"\\n\" ";
475
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
476
}
477
elseif(strstr($curdatabase, "-throughput.rrd")) {
478
	/* define graphcmd for throughput stats */
479
	/* this gathers all interface statistics, the database does not actually exist */
480
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
481
	$graphcmd .= "--start $start --end $end --step $step ";
482
	$graphcmd .= "--vertical-label \"bits/sec\" ";
483
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
484
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
485
	$graphcmd .= "--height 200 --width 620 ";
486

    
487
	$iflist = get_configured_interface_list();
488
	$g = 0;
489
	$operand = "";
490
	$comma = "";
491
	$graphtputbip = "";
492
	$graphtputbop = "";
493
	$graphtputbtp = "";
494
	$graphtputbib = "";
495
	$graphtputbob = "";
496
	$graphtputbtb = "";
497
	$graphtputbyip = "";
498
	$graphtputbyop = "";
499
	$graphtputbytp = "";
500
	$graphtputbyib = "";
501
	$graphtputbyob = "";
502
	$graphtputbytb = "";
503
	foreach($iflist as $ifname) {
504
		/* collect all interface stats */
505
		$graphcmd .= "DEF:\"{$ifname}-in_bytes_pass={$rrddbpath}{$ifname}-traffic.rrd:inpass:AVERAGE:step=$step\" ";
506
		$graphcmd .= "DEF:\"{$ifname}-out_bytes_pass={$rrddbpath}{$ifname}-traffic.rrd:outpass:AVERAGE:step=$step\" ";
507
		$graphcmd .= "DEF:\"{$ifname}-in_bytes_block={$rrddbpath}{$ifname}-traffic.rrd:inblock:AVERAGE:step=$step\" ";
508
		$graphcmd .= "DEF:\"{$ifname}-out_bytes_block={$rrddbpath}{$ifname}-traffic.rrd:outblock:AVERAGE:step=$step\" ";
509

    
510
		$graphcmd .= "CDEF:\"{$ifname}-in_bytes={$ifname}-in_bytes_pass,{$ifname}-in_bytes_block,+\" ";
511
		$graphcmd .= "CDEF:\"{$ifname}-out_bytes={$ifname}-out_bytes_pass,{$ifname}-out_bytes_block,+\" ";
512

    
513
		$graphcmd .= "CDEF:\"{$ifname}-in_bits_pass={$ifname}-in_bytes_pass,8,*\" ";
514
		$graphcmd .= "CDEF:\"{$ifname}-out_bits_pass={$ifname}-out_bytes_pass,8,*\" ";
515
		$graphcmd .= "CDEF:\"{$ifname}-bits_io_pass={$ifname}-in_bits_pass,{$ifname}-out_bits_pass,+\" ";
516

    
517
		$graphcmd .= "CDEF:\"{$ifname}-in_bits_block={$ifname}-in_bytes_block,8,*\" ";
518
		$graphcmd .= "CDEF:\"{$ifname}-out_bits_block={$ifname}-out_bytes_block,8,*\" ";
519
		$graphcmd .= "CDEF:\"{$ifname}-bits_io_block={$ifname}-in_bits_block,{$ifname}-out_bits_block,+\" ";
520

    
521
		$graphcmd .= "CDEF:\"{$ifname}-bytes_in_pass={$ifname}-in_bytes_pass,0,$speedlimit,LIMIT,UN,0,{$ifname}-in_bytes_pass,IF,$average,*\" ";
522
		$graphcmd .= "CDEF:\"{$ifname}-bytes_out_pass={$ifname}-out_bytes_pass,0,$speedlimit,LIMIT,UN,0,{$ifname}-out_bytes_pass,IF,$average,*\" ";
523
		$graphcmd .= "CDEF:\"{$ifname}-bytes_in_block={$ifname}-in_bytes_block,0,$speedlimit,LIMIT,UN,0,{$ifname}-in_bytes_block,IF,$average,*\" ";
524
		$graphcmd .= "CDEF:\"{$ifname}-bytes_out_block={$ifname}-out_bytes_block,0,$speedlimit,LIMIT,UN,0,{$ifname}-out_bytes_block,IF,$average,*\" ";
525
		$graphcmd .= "CDEF:\"{$ifname}-bytes_pass={$ifname}-bytes_in_pass,{$ifname}-bytes_out_pass,+\" ";
526
		$graphcmd .= "CDEF:\"{$ifname}-bytes_block={$ifname}-bytes_in_pass,{$ifname}-bytes_out_block,+\" ";
527

    
528
		$graphcmd .= "CDEF:\"{$ifname}-bytes_in_t_pass={$ifname}-in_bytes,0,$speedlimit,LIMIT,UN,0,{$ifname}-in_bytes_pass,IF,$seconds,*\" ";
529
		$graphcmd .= "CDEF:\"{$ifname}-bytes_in_t_block={$ifname}-in_bytes,0,$speedlimit,LIMIT,UN,0,{$ifname}-in_bytes_block,IF,$seconds,*\" ";
530
		$graphcmd .= "CDEF:\"{$ifname}-bytes_out_t_pass={$ifname}-out_bytes,0,$speedlimit,LIMIT,UN,0,{$ifname}-out_bytes_pass,IF,$seconds,*\" ";
531
		$graphcmd .= "CDEF:\"{$ifname}-bytes_out_t_block={$ifname}-out_bytes,0,$speedlimit,LIMIT,UN,0,{$ifname}-out_bytes_block,IF,$seconds,*\" ";
532
		$graphcmd .= "CDEF:\"{$ifname}-bytes_t_pass={$ifname}-bytes_in_t_pass,{$ifname}-bytes_out_t_pass,+\" ";
533
		$graphcmd .= "CDEF:\"{$ifname}-bytes_t_block={$ifname}-bytes_in_t_block,{$ifname}-bytes_out_t_block,+\" ";
534
		if ($g > 0) {
535
			$operand .= ",+";
536
			$comma = ",";
537
		}
538
		$graphtputbip .= "{$comma}{$ifname}-in_bits_pass";
539
		$graphtputbop .= "{$comma}{$ifname}-out_bits_pass";
540
		$graphtputbtp .= "{$comma}{$ifname}-bits_io_pass";
541
		$graphtputbib .= "{$comma}{$ifname}-in_bits_block";
542
		$graphtputbob .= "{$comma}{$ifname}-out_bits_block";
543
		$graphtputbtb .= "{$comma}{$ifname}-bits_io_block";
544
		$graphtputbyip .= "{$comma}{$ifname}-bytes_in_t_pass";
545
		$graphtputbyop .= "{$comma}{$ifname}-bytes_out_t_pass";
546
		$graphtputbyib .= "{$comma}{$ifname}-bytes_in_t_block";
547
		$graphtputbyob .= "{$comma}{$ifname}-bytes_out_t_block";
548
		$graphtputbytp .= "{$comma}{$ifname}-bytes_t_pass";
549
		$graphtputbytb .= "{$comma}{$ifname}-bytes_t_block";
550
		$g++;
551
	}
552
	$graphcmd .= "CDEF:\"tput-in_bits_pass={$graphtputbip}{$operand}\" ";
553
	$graphcmd .= "CDEF:\"tput-out_bits_pass={$graphtputbop}{$operand}\" "; 
554
	$graphcmd .= "CDEF:\"tput-bits_io_pass={$graphtputbtp}{$operand}\" ";
555

    
556
	$graphcmd .= "CDEF:\"tput-in_bits_block={$graphtputbib}{$operand}\" ";
557
	$graphcmd .= "CDEF:\"tput-out_bits_block={$graphtputbob}{$operand}\" "; 
558
	$graphcmd .= "CDEF:\"tput-bits_io_block={$graphtputbtb}{$operand}\" ";
559

    
560
	$graphcmd .= "CDEF:\"tput-out_bits_pass_neg=tput-out_bits_pass,$multiplier,*\" ";
561
	$graphcmd .= "CDEF:\"tput-out_bits_block_neg=tput-out_bits_block,$multiplier,*\" ";
562

    
563
	$graphcmd .= "CDEF:\"tput-bytes_in_t_pass={$graphtputbyip}{$operand}\" ";
564
	$graphcmd .= "CDEF:\"tput-bytes_out_t_pass={$graphtputbyop}{$operand}\" ";
565
	$graphcmd .= "CDEF:\"tput-bytes_t_pass={$graphtputbytp}{$operand}\" ";
566

    
567
	$graphcmd .= "CDEF:\"tput-bytes_in_t_block={$graphtputbyib}{$operand}\" ";
568
	$graphcmd .= "CDEF:\"tput-bytes_out_t_block={$graphtputbyob}{$operand}\" ";
569
	$graphcmd .= "CDEF:\"tput-bytes_t_block={$graphtputbytb}{$operand}\" ";
570

    
571
	$graphcmd .= "AREA:\"tput-in_bits_block#{$colortrafficdown[0]}:in-block \" ";
572
	$graphcmd .= "AREA:\"tput-in_bits_pass#{$colortrafficdown[1]}:in-pass \" ";
573

    
574
	$graphcmd .= "{$AREA}:\"tput-out_bits_block_neg#{$colortrafficup[1]}:out-block \" ";
575
	$graphcmd .= "{$AREA}:\"tput-out_bits_pass_neg#{$colortrafficup[0]}:out-pass \" ";
576

    
577
	$graphcmd .= "COMMENT:\"\\n\" ";
578
	$graphcmd .= "COMMENT:\"\t\t  maximum       average       current        period\\n\" ";
579
	$graphcmd .= "COMMENT:\"in-pass\t\" ";
580
	$graphcmd .= "GPRINT:\"tput-in_bits_pass:MAX:%7.2lf %sb/s\" ";
581
	$graphcmd .= "GPRINT:\"tput-in_bits_pass:AVERAGE:%7.2lf %Sb/s\" ";
582
	$graphcmd .= "GPRINT:\"tput-in_bits_pass:LAST:%7.2lf %Sb/s\" ";
583
	$graphcmd .= "GPRINT:\"tput-bytes_in_t_pass:AVERAGE:%7.2lf %sB i\" ";
584
	$graphcmd .= "COMMENT:\"\\n\" ";
585
	$graphcmd .= "COMMENT:\"out-pass\t\" ";
586
	$graphcmd .= "GPRINT:\"tput-out_bits_pass:MAX:%7.2lf %sb/s\" ";
587
	$graphcmd .= "GPRINT:\"tput-out_bits_pass:AVERAGE:%7.2lf %Sb/s\" ";
588
	$graphcmd .= "GPRINT:\"tput-out_bits_pass:LAST:%7.2lf %Sb/s\" ";
589
	$graphcmd .= "GPRINT:\"tput-bytes_out_t_pass:AVERAGE:%7.2lf %sB o\" ";
590
	$graphcmd .= "COMMENT:\"\\n\" ";
591
	$graphcmd .= "COMMENT:\"in-block\t\" ";
592
	$graphcmd .= "GPRINT:\"tput-in_bits_block:MAX:%7.2lf %sb/s\" ";
593
	$graphcmd .= "GPRINT:\"tput-in_bits_block:AVERAGE:%7.2lf %Sb/s\" ";
594
	$graphcmd .= "GPRINT:\"tput-in_bits_block:LAST:%7.2lf %Sb/s\" ";
595
	$graphcmd .= "GPRINT:\"tput-bytes_in_t_block:AVERAGE:%7.2lf %sB i\" ";
596
	$graphcmd .= "COMMENT:\"\\n\" ";
597
	$graphcmd .= "COMMENT:\"out-block\t\" ";
598
	$graphcmd .= "GPRINT:\"tput-out_bits_block:MAX:%7.2lf %sb/s\" ";
599
	$graphcmd .= "GPRINT:\"tput-out_bits_block:AVERAGE:%7.2lf %Sb/s\" ";
600
	$graphcmd .= "GPRINT:\"tput-out_bits_block:LAST:%7.2lf %Sb/s\" ";
601
	$graphcmd .= "GPRINT:\"tput-bytes_out_t_block:AVERAGE:%7.2lf %sB o\" ";
602
	$graphcmd .= "COMMENT:\"\\n\" ";
603
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
604
}
605
elseif((strstr($curdatabase, "-packets.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
606
	/* define graphcmd for packets stats */
607
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
608
	$graphcmd .= "--start $start --end $end --step $step ";
609
	$graphcmd .= "--vertical-label \"packets/sec\" ";
610
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
611
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
612
	$graphcmd .= "--height 200 --width 620 ";
613
	$graphcmd .= "DEF:\"$curif-in_pps_pass=$rrddbpath$curdatabase:inpass:AVERAGE:step=$step\" ";
614
	$graphcmd .= "DEF:\"$curif-out_pps_pass=$rrddbpath$curdatabase:outpass:AVERAGE:step=$step\" ";
615
	$graphcmd .= "DEF:\"$curif-in_pps_block=$rrddbpath$curdatabase:inblock:AVERAGE:step=$step\" ";
616
	$graphcmd .= "DEF:\"$curif-out_pps_block=$rrddbpath$curdatabase:outblock:AVERAGE:step=$step\" ";
617

    
618
	$graphcmd .= "DEF:\"$curif-in6_pps_pass=$rrddbpath$curdatabase:inpass6:AVERAGE:step=$step\" ";
619
	$graphcmd .= "DEF:\"$curif-out6_pps_pass=$rrddbpath$curdatabase:outpass6:AVERAGE:step=$step\" ";
620
	$graphcmd .= "DEF:\"$curif-in6_pps_block=$rrddbpath$curdatabase:inblock6:AVERAGE:step=$step\" ";
621
	$graphcmd .= "DEF:\"$curif-out6_pps_block=$rrddbpath$curdatabase:outblock6:AVERAGE:step=$step\" ";
622

    
623
	$graphcmd .= "CDEF:\"$curif-in_pps=$curif-in_pps_pass,$curif-in_pps_block,+\" ";
624
	$graphcmd .= "CDEF:\"$curif-out_pps=$curif-out_pps_pass,$curif-out_pps_block,+\" ";
625
	$graphcmd .= "CDEF:\"$curif-out_pps_pass_neg=$curif-out_pps_pass,$multiplier,*\" ";
626
	$graphcmd .= "CDEF:\"$curif-out_pps_block_neg=$curif-out_pps_block,$multiplier,*\" ";
627

    
628
	$graphcmd .= "CDEF:\"$curif-in6_pps=$curif-in6_pps_pass,$curif-in6_pps_block,+\" ";
629
	$graphcmd .= "CDEF:\"$curif-out6_pps=$curif-out6_pps_pass,$curif-out6_pps_block,+\" ";
630
	$graphcmd .= "CDEF:\"$curif-out6_pps_pass_neg=$curif-out6_pps_pass,$multiplier,*\" ";
631
	$graphcmd .= "CDEF:\"$curif-out6_pps_block_neg=$curif-out6_pps_block,$multiplier,*\" ";
632

    
633
	$graphcmd .= "CDEF:\"$curif-pps_in_pass=$curif-in_pps_pass,0,12500000,LIMIT,UN,0,$curif-in_pps_pass,IF,$average,*\" ";
634
	$graphcmd .= "CDEF:\"$curif-pps_out_pass=$curif-out_pps_pass,0,12500000,LIMIT,UN,0,$curif-out_pps_pass,IF,$average,*\" ";
635
	$graphcmd .= "CDEF:\"$curif-pps_in_block=$curif-in_pps_block,0,12500000,LIMIT,UN,0,$curif-in_pps_block,IF,$average,*\" ";
636
	$graphcmd .= "CDEF:\"$curif-pps_out_block=$curif-out_pps_block,0,12500000,LIMIT,UN,0,$curif-out_pps_block,IF,$average,*\" ";
637

    
638
	$graphcmd .= "CDEF:\"$curif-pps_in6_pass=$curif-in6_pps_pass,0,12500000,LIMIT,UN,0,$curif-in6_pps_pass,IF,$average,*\" ";
639
	$graphcmd .= "CDEF:\"$curif-pps_out6_pass=$curif-out6_pps_pass,0,12500000,LIMIT,UN,0,$curif-out6_pps_pass,IF,$average,*\" ";
640
	$graphcmd .= "CDEF:\"$curif-pps_in6_block=$curif-in6_pps_block,0,12500000,LIMIT,UN,0,$curif-in6_pps_block,IF,$average,*\" ";
641
	$graphcmd .= "CDEF:\"$curif-pps_out6_block=$curif-out6_pps_block,0,12500000,LIMIT,UN,0,$curif-out6_pps_block,IF,$average,*\" ";
642

    
643
	$graphcmd .= "CDEF:\"$curif-pps_io=$curif-in_pps,$curif-out_pps,+\" ";
644
	$graphcmd .= "CDEF:\"$curif-pps_pass=$curif-pps_in_pass,$curif-pps_out_pass,+\" ";
645
	$graphcmd .= "CDEF:\"$curif-pps_block=$curif-pps_in_block,$curif-pps_out_block,+\" ";
646

    
647
	$graphcmd .= "CDEF:\"$curif-pps_io6=$curif-in6_pps,$curif-out6_pps,+\" ";
648
	$graphcmd .= "CDEF:\"$curif-pps_pass6=$curif-pps_in6_pass,$curif-pps_out6_pass,+\" ";
649
	$graphcmd .= "CDEF:\"$curif-pps_block6=$curif-pps_in6_block,$curif-pps_out6_block,+\" ";
650

    
651
	$graphcmd .= "CDEF:\"$curif-pps_in_t_pass=$curif-in_pps_pass,0,12500000,LIMIT,UN,0,$curif-in_pps_pass,IF,$seconds,*\" ";
652
	$graphcmd .= "CDEF:\"$curif-pps_out_t_pass=$curif-out_pps_pass,0,12500000,LIMIT,UN,0,$curif-out_pps_pass,IF,$seconds,*\" ";
653
	$graphcmd .= "CDEF:\"$curif-pps_in_t_block=$curif-in_pps_block,0,12500000,LIMIT,UN,0,$curif-in_pps_block,IF,$seconds,*\" ";
654
	$graphcmd .= "CDEF:\"$curif-pps_out_t_block=$curif-out_pps_block,0,12500000,LIMIT,UN,0,$curif-out_pps_block,IF,$seconds,*\" ";
655

    
656
	$graphcmd .= "CDEF:\"$curif-pps_in6_t_pass=$curif-in6_pps_pass,0,12500000,LIMIT,UN,0,$curif-in6_pps_pass,IF,$seconds,*\" ";
657
	$graphcmd .= "CDEF:\"$curif-pps_out6_t_pass=$curif-out6_pps_pass,0,12500000,LIMIT,UN,0,$curif-out6_pps_pass,IF,$seconds,*\" ";
658
	$graphcmd .= "CDEF:\"$curif-pps_in6_t_block=$curif-in6_pps_block,0,12500000,LIMIT,UN,0,$curif-in6_pps_block,IF,$seconds,*\" ";
659
	$graphcmd .= "CDEF:\"$curif-pps_out6_t_block=$curif-out6_pps_block,0,12500000,LIMIT,UN,0,$curif-out6_pps_block,IF,$seconds,*\" ";
660

    
661
	$graphcmd .= "CDEF:\"$curif-pps_t_pass=$curif-pps_in_t_pass,$curif-pps_out_t_pass,+\" ";
662
	$graphcmd .= "CDEF:\"$curif-pps_t_block=$curif-pps_in_t_block,$curif-pps_out_t_block,+\" ";
663

    
664
	$graphcmd .= "CDEF:\"$curif-pps_t_pass6=$curif-pps_in6_t_pass,$curif-pps_out6_t_pass,+\" ";
665
	$graphcmd .= "CDEF:\"$curif-pps_t_block6=$curif-pps_in6_t_block,$curif-pps_out6_t_block,+\" ";
666

    
667
	$graphcmd .= "AREA:\"$curif-in_pps_block#{$colorpacketsdown[1]}:$curif-in-block\" ";
668
	$graphcmd .= "AREA:\"$curif-in_pps_pass#{$colorpacketsdown[0]}:$curif-in-pass:STACK\" ";
669
	$graphcmd .= "AREA:\"$curif-in6_pps_block#{$colorpacketsdown[3]}:$curif-in6-block:STACK\" ";
670
	$graphcmd .= "AREA:\"$curif-in6_pps_pass#{$colorpacketsdown[2]}:$curif-in6-pass:STACK\" ";
671
	$graphcmd .= "COMMENT:\"\\n\" ";
672
	$graphcmd .= "$AREA:\"$curif-out_pps_block_neg#{$colorpacketsup[1]}:$curif-out-block\" ";
673
	$graphcmd .= "$AREA:\"$curif-out_pps_pass_neg#{$colorpacketsup[0]}:$curif-out-pass:STACK\" ";
674
	$graphcmd .= "$AREA:\"$curif-out6_pps_block_neg#{$colorpacketsup[3]}:$curif-out6-block:STACK\" ";
675
	$graphcmd .= "$AREA:\"$curif-out6_pps_pass_neg#{$colorpacketsup[2]}:$curif-out6-pass:STACK\" ";
676

    
677
	$graphcmd .= "COMMENT:\"\\n\" ";
678
	$graphcmd .= "COMMENT:\"\t\t  maximum\t\t average\t     current\t    period\\n\" ";
679
	$graphcmd .= "COMMENT:\"in-pass\t\" ";
680
	$graphcmd .= "GPRINT:\"$curif-in_pps_pass:MAX:%7.2lf %s pps\" ";
681
	$graphcmd .= "GPRINT:\"$curif-in_pps_pass:AVERAGE:%7.2lf %S pps\" ";
682
	$graphcmd .= "GPRINT:\"$curif-in_pps_pass:LAST:%7.2lf %S pps\" ";
683
	$graphcmd .= "GPRINT:\"$curif-pps_in_t_pass:AVERAGE:%7.2lf %s pkts\" ";
684
	$graphcmd .= "COMMENT:\"\\n\" ";
685
	$graphcmd .= "COMMENT:\"out-pass\t\" ";
686
	$graphcmd .= "GPRINT:\"$curif-out_pps_pass:MAX:%7.2lf %s pps\" ";
687
	$graphcmd .= "GPRINT:\"$curif-out_pps_pass:AVERAGE:%7.2lf %S pps\" ";
688
	$graphcmd .= "GPRINT:\"$curif-out_pps_pass:LAST:%7.2lf %S pps\" ";
689
	$graphcmd .= "GPRINT:\"$curif-pps_out_t_pass:AVERAGE:%7.2lf %s pkts\" ";
690
	$graphcmd .= "COMMENT:\"\\n\" ";
691
	$graphcmd .= "COMMENT:\"in-block\t\" ";
692
	$graphcmd .= "GPRINT:\"$curif-in_pps_block:MAX:%7.2lf %s pps\" ";
693
	$graphcmd .= "GPRINT:\"$curif-in_pps_block:AVERAGE:%7.2lf %S pps\" ";
694
	$graphcmd .= "GPRINT:\"$curif-in_pps_block:LAST:%7.2lf %S pps\" ";
695
	$graphcmd .= "GPRINT:\"$curif-pps_in_t_block:AVERAGE:%7.2lf %s pkts\" ";
696
	$graphcmd .= "COMMENT:\"\\n\" ";
697
	$graphcmd .= "COMMENT:\"out-block\t\" ";
698
	$graphcmd .= "GPRINT:\"$curif-out_pps_block:MAX:%7.2lf %s pps\" ";
699
	$graphcmd .= "GPRINT:\"$curif-out_pps_block:AVERAGE:%7.2lf %S pps\" ";
700
	$graphcmd .= "GPRINT:\"$curif-out_pps_block:LAST:%7.2lf %S pps\" ";
701
	$graphcmd .= "GPRINT:\"$curif-pps_out_t_block:AVERAGE:%7.2lf %s pkts\" ";
702
	$graphcmd .= "COMMENT:\"\\n\" ";
703

    
704
	$graphcmd .= "COMMENT:\"\\n\" ";
705
	$graphcmd .= "COMMENT:\"in-pass6\t\" ";
706
	$graphcmd .= "GPRINT:\"$curif-in6_pps_pass:MAX:%7.2lf %s pps\" ";
707
	$graphcmd .= "GPRINT:\"$curif-in6_pps_pass:AVERAGE:%7.2lf %S pps\" ";
708
	$graphcmd .= "GPRINT:\"$curif-in6_pps_pass:LAST:%7.2lf %S pps\" ";
709
	$graphcmd .= "GPRINT:\"$curif-pps_in6_t_pass:AVERAGE:%7.2lf %s pkts\" ";
710
	$graphcmd .= "COMMENT:\"\\n\" ";
711
	$graphcmd .= "COMMENT:\"out-pass6\t\" ";
712
	$graphcmd .= "GPRINT:\"$curif-out6_pps_pass:MAX:%7.2lf %s pps\" ";
713
	$graphcmd .= "GPRINT:\"$curif-out6_pps_pass:AVERAGE:%7.2lf %S pps\" ";
714
	$graphcmd .= "GPRINT:\"$curif-out6_pps_pass:LAST:%7.2lf %S pps\" ";
715
	$graphcmd .= "GPRINT:\"$curif-pps_out6_t_pass:AVERAGE:%7.2lf %s pkts\" ";
716
	$graphcmd .= "COMMENT:\"\\n\" ";
717
	$graphcmd .= "COMMENT:\"in-block6\t\" ";
718
	$graphcmd .= "GPRINT:\"$curif-in6_pps_block:MAX:%7.2lf %s pps\" ";
719
	$graphcmd .= "GPRINT:\"$curif-in6_pps_block:AVERAGE:%7.2lf %S pps\" ";
720
	$graphcmd .= "GPRINT:\"$curif-in6_pps_block:LAST:%7.2lf %S pps\" ";
721
	$graphcmd .= "GPRINT:\"$curif-pps_in6_t_block:AVERAGE:%7.2lf %s pkts\" ";
722
	$graphcmd .= "COMMENT:\"\\n\" ";
723
	$graphcmd .= "COMMENT:\"out-pass6\t\" ";
724
	$graphcmd .= "GPRINT:\"$curif-out6_pps_block:MAX:%7.2lf %s pps\" ";
725
	$graphcmd .= "GPRINT:\"$curif-out6_pps_block:AVERAGE:%7.2lf %S pps\" ";
726
	$graphcmd .= "GPRINT:\"$curif-out6_pps_block:LAST:%7.2lf %S pps\" ";
727
	$graphcmd .= "GPRINT:\"$curif-pps_out6_t_block:AVERAGE:%7.2lf %s pkts\" ";
728
	$graphcmd .= "COMMENT:\"\\n\" ";
729
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
730
}
731
elseif((strstr($curdatabase, "-wireless.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
732
	/* define graphcmd for packets stats */
733
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
734
	$graphcmd .= "--start $start --end $end --step $step ";
735
	$graphcmd .= "--vertical-label \"snr/channel/rate\" ";
736
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
737
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
738
	$graphcmd .= "--height 200 --width 620 ";
739
	$graphcmd .= "DEF:\"$curif-snr=$rrddbpath$curdatabase:snr:AVERAGE:step=$step\" ";
740
	$graphcmd .= "DEF:\"$curif-rate=$rrddbpath$curdatabase:rate:AVERAGE:step=$step\" ";
741
	$graphcmd .= "DEF:\"$curif-channel=$rrddbpath$curdatabase:channel:AVERAGE:step=$step\" ";
742
	$graphcmd .= "LINE2:\"$curif-snr#{$colorwireless[0]}:$curif-snr\" ";
743
	$graphcmd .= "LINE2:\"$curif-rate#{$colorwireless[1]}:$curif-rate\" ";
744
	$graphcmd .= "LINE2:\"$curif-channel#{$colorwireless[2]}:$curif-channel\" ";
745
	$graphcmd .= "COMMENT:\"\\n\" ";
746
	$graphcmd .= "COMMENT:\"\t\t   maximum\t\t average\t     current\\n\" ";
747
	$graphcmd .= "COMMENT:\"SNR\t\t\" ";
748
	$graphcmd .= "GPRINT:\"$curif-snr:MAX:%7.2lf dBi  \" ";
749
	$graphcmd .= "GPRINT:\"$curif-snr:AVERAGE:%7.2lf dBi  \" ";
750
	$graphcmd .= "GPRINT:\"$curif-snr:LAST:%7.2lf dBi\" ";
751
	$graphcmd .= "COMMENT:\"\\n\" ";
752
	$graphcmd .= "COMMENT:\"RATE\t\t\" ";
753
	$graphcmd .= "GPRINT:\"$curif-rate:MAX:%7.2lf Mb   \" ";
754
	$graphcmd .= "GPRINT:\"$curif-rate:AVERAGE:%7.2lf Mb   \" ";
755
	$graphcmd .= "GPRINT:\"$curif-rate:LAST:%7.2lf Mb\" ";
756
	$graphcmd .= "COMMENT:\"\\n\" ";
757
	$graphcmd .= "COMMENT:\"Channel\t\" ";
758
	$graphcmd .= "GPRINT:\"$curif-channel:MAX:%7.2lf      \" ";
759
	$graphcmd .= "GPRINT:\"$curif-channel:AVERAGE:%7.2lf      \" ";
760
	$graphcmd .= "GPRINT:\"$curif-channel:LAST:%7.2lf\" ";
761
	$graphcmd .= "COMMENT:\"\\n\" ";
762
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
763
}
764
elseif((strstr($curdatabase, "-vpnusers.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
765
	/* define graphcmd for vpn users stats */
766
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
767
	$graphcmd .= "--start $start --end $end --step $step ";
768
	$graphcmd .= "--vertical-label \"users\" ";
769
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
770
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
771
	$graphcmd .= "--height 200 --width 620 ";
772
	$graphcmd .= "DEF:\"$curif-users=$rrddbpath$curdatabase:users:AVERAGE:step=$step\" ";
773
	$graphcmd .= "LINE2:\"$curif-users#{$colorvpnusers[0]}:$curif-users\" ";
774
	$graphcmd .= "COMMENT:\"\\n\" ";
775
	$graphcmd .= "COMMENT:\"\t\t\t    maximum\t\t average\t     current\\n\" ";
776
	$graphcmd .= "COMMENT:\"Users Online\t\" ";
777
	$graphcmd .= "GPRINT:\"$curif-users:MAX:%7.2lf     \" ";
778
	$graphcmd .= "GPRINT:\"$curif-users:AVERAGE:%7.2lf      \" ";
779
	$graphcmd .= "GPRINT:\"$curif-users:LAST:%7.2lf \" ";
780
	$graphcmd .= "COMMENT:\"\\n\" ";
781
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
782
}
783
elseif((strstr($curdatabase, "-states.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
784
	/* define graphcmd for states stats */
785
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
786
	$graphcmd .= "--start -$seconds -e -$average --step $step ";
787
	$graphcmd .= "--vertical-label \"states, ip\" ";
788
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
789
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
790
	$graphcmd .= "--height 200 --width 620 ";
791
	$graphcmd .= "DEF:\"$curif-pfrate=$rrddbpath$curdatabase:pfrate:AVERAGE:step=$step\" ";
792
	$graphcmd .= "DEF:\"$curif-pfstates=$rrddbpath$curdatabase:pfstates:AVERAGE:step=$step\" ";
793
	$graphcmd .= "DEF:\"$curif-pfnat=$rrddbpath$curdatabase:pfnat:AVERAGE:step=$step\" ";
794
	$graphcmd .= "DEF:\"$curif-srcip=$rrddbpath$curdatabase:srcip:AVERAGE:step=$step\" ";
795
	$graphcmd .= "DEF:\"$curif-dstip=$rrddbpath$curdatabase:dstip:AVERAGE:step=$step\" ";
796
	$graphcmd .= "CDEF:\"$curif-pfrate_t=$curif-pfrate,0,1000000,LIMIT,UN,0,$curif-pfrate,IF,$seconds,*\" ";
797
	$graphcmd .= "LINE1:\"$curif-pfrate#{$colorstates[0]}:$curif-pfrate\" ";
798
	$graphcmd .= "LINE1:\"$curif-pfstates#{$colorstates[1]}:$curif-pfstates\" ";
799
	$graphcmd .= "LINE1:\"$curif-pfnat#{$colorstates[2]}:$curif-pfnat\" ";
800
	$graphcmd .= "LINE1:\"$curif-srcip#{$colorstates[3]}:$curif-srcip\" ";
801
	$graphcmd .= "LINE1:\"$curif-dstip#{$colorstates[4]}:$curif-dstip\" ";
802
	$graphcmd .= "COMMENT:\"\\n\" ";
803
	$graphcmd .= "COMMENT:\"\t\t      minimum        average        maximum        current         period\\n\" ";
804
	$graphcmd .= "COMMENT:\"state changes\" ";
805
	$graphcmd .= "GPRINT:\"$curif-pfrate:MIN:%7.2lf %s cps\" ";
806
	$graphcmd .= "GPRINT:\"$curif-pfrate:AVERAGE:%7.2lf %s cps\" ";
807
	$graphcmd .= "GPRINT:\"$curif-pfrate:MAX:%7.2lf %s cps\" ";
808
	$graphcmd .= "GPRINT:\"$curif-pfrate:LAST:%7.2lf %S cps\" ";
809
	$graphcmd .= "GPRINT:\"$curif-pfrate_t:AVERAGE:%7.2lf %s chg\" ";
810
	$graphcmd .= "COMMENT:\"\\n\" ";
811
	$graphcmd .= "COMMENT:\"filter states\" ";
812
	$graphcmd .= "GPRINT:\"$curif-pfstates:MIN:%7.2lf %s    \" ";
813
	$graphcmd .= "GPRINT:\"$curif-pfstates:AVERAGE:%7.2lf %s    \" ";
814
	$graphcmd .= "GPRINT:\"$curif-pfstates:MAX:%7.2lf %s    \" ";
815
	$graphcmd .= "GPRINT:\"$curif-pfstates:LAST:%7.2lf %s    \" ";
816
	$graphcmd .= "COMMENT:\"\\n\" ";
817
	$graphcmd .= "COMMENT:\"nat states   \" ";
818
	$graphcmd .= "GPRINT:\"$curif-pfnat:MIN:%7.2lf %s    \" ";
819
	$graphcmd .= "GPRINT:\"$curif-pfnat:AVERAGE:%7.2lf %s    \" ";
820
	$graphcmd .= "GPRINT:\"$curif-pfnat:MAX:%7.2lf %s    \" ";
821
	$graphcmd .= "GPRINT:\"$curif-pfnat:LAST:%7.2lf %s    \" ";
822
	$graphcmd .= "COMMENT:\"\\n\" ";
823
	$graphcmd .= "COMMENT:\"Source addr. \" ";
824
	$graphcmd .= "GPRINT:\"$curif-srcip:MIN:%7.2lf %s    \" ";
825
	$graphcmd .= "GPRINT:\"$curif-srcip:AVERAGE:%7.2lf %s    \" ";
826
	$graphcmd .= "GPRINT:\"$curif-srcip:MAX:%7.2lf %s    \" ";
827
	$graphcmd .= "GPRINT:\"$curif-srcip:LAST:%7.2lf %s    \" ";
828
	$graphcmd .= "COMMENT:\"\\n\" ";
829
	$graphcmd .= "COMMENT:\"Dest. addr.  \" ";
830
	$graphcmd .= "GPRINT:\"$curif-dstip:MIN:%7.2lf %s    \" ";
831
	$graphcmd .= "GPRINT:\"$curif-dstip:AVERAGE:%7.2lf %s    \" ";
832
	$graphcmd .= "GPRINT:\"$curif-dstip:MAX:%7.2lf %s    \" ";
833
	$graphcmd .= "GPRINT:\"$curif-dstip:LAST:%7.2lf %s    \" ";
834
	$graphcmd .= "COMMENT:\"\\n\" ";
835
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
836
}
837
elseif((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
838
	/* define graphcmd for processor stats */
839
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
840
	$graphcmd .= "--start $start --end $end --step $step ";
841
	$graphcmd .= "--vertical-label \"utilization, number\" ";
842
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
843
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
844
	$graphcmd .= "--height 200 --width 620 ";
845
	$graphcmd .= "DEF:\"user=$rrddbpath$curdatabase:user:AVERAGE:step=$step\" ";
846
	$graphcmd .= "DEF:\"nice=$rrddbpath$curdatabase:nice:AVERAGE:step=$step\" ";
847
	$graphcmd .= "DEF:\"system=$rrddbpath$curdatabase:system:AVERAGE:step=$step\" ";
848
	$graphcmd .= "DEF:\"interrupt=$rrddbpath$curdatabase:interrupt:AVERAGE:step=$step\" ";
849
	$graphcmd .= "DEF:\"processes=$rrddbpath$curdatabase:processes:AVERAGE:step=$step\" ";
850
	$graphcmd .= "AREA:\"user#{$colorprocessor[0]}:user\" ";
851
	$graphcmd .= "AREA:\"nice#{$colorprocessor[1]}:nice:STACK\" ";
852
	$graphcmd .= "AREA:\"system#{$colorprocessor[2]}:system:STACK\" ";
853
	$graphcmd .= "AREA:\"interrupt#{$colorprocessor[3]}:interrupt:STACK\" ";
854
	$graphcmd .= "LINE2:\"processes#{$colorprocessor[4]}:processes\" ";
855
	$graphcmd .= "COMMENT:\"\\n\" ";
856
	$graphcmd .= "COMMENT:\"\t\t      minimum        average        maximum        current\\n\" ";
857
	$graphcmd .= "COMMENT:\"User util.   \" ";
858
	$graphcmd .= "GPRINT:\"user:MIN:%7.2lf %s    \" ";
859
	$graphcmd .= "GPRINT:\"user:AVERAGE:%7.2lf %s    \" ";
860
	$graphcmd .= "GPRINT:\"user:MAX:%7.2lf %s    \" ";
861
	$graphcmd .= "GPRINT:\"user:LAST:%7.2lf %S    \" ";
862
	$graphcmd .= "COMMENT:\"\\n\" ";
863
	$graphcmd .= "COMMENT:\"Nice util.   \" ";
864
	$graphcmd .= "GPRINT:\"nice:MIN:%7.2lf %s    \" ";
865
	$graphcmd .= "GPRINT:\"nice:AVERAGE:%7.2lf %s    \" ";
866
	$graphcmd .= "GPRINT:\"nice:MAX:%7.2lf %s    \" ";
867
	$graphcmd .= "GPRINT:\"nice:LAST:%7.2lf %s    \" ";
868
	$graphcmd .= "COMMENT:\"\\n\" ";
869
	$graphcmd .= "COMMENT:\"System util. \" ";
870
	$graphcmd .= "GPRINT:\"system:MIN:%7.2lf %s    \" ";
871
	$graphcmd .= "GPRINT:\"system:AVERAGE:%7.2lf %s    \" ";
872
	$graphcmd .= "GPRINT:\"system:MAX:%7.2lf %s    \" ";
873
	$graphcmd .= "GPRINT:\"system:LAST:%7.2lf %s    \" ";
874
	$graphcmd .= "COMMENT:\"\\n\" ";
875
	$graphcmd .= "COMMENT:\"Interrupt    \" ";
876
	$graphcmd .= "GPRINT:\"interrupt:MIN:%7.2lf %s    \" ";
877
	$graphcmd .= "GPRINT:\"interrupt:AVERAGE:%7.2lf %s    \" ";
878
	$graphcmd .= "GPRINT:\"interrupt:MAX:%7.2lf %s    \" ";
879
	$graphcmd .= "GPRINT:\"interrupt:LAST:%7.2lf %s    \" ";
880
	$graphcmd .= "COMMENT:\"\\n\" ";
881
	$graphcmd .= "COMMENT:\"Processes    \" ";
882
	$graphcmd .= "GPRINT:\"processes:MIN:%7.2lf %s    \" ";
883
	$graphcmd .= "GPRINT:\"processes:AVERAGE:%7.2lf %s    \" ";
884
	$graphcmd .= "GPRINT:\"processes:MAX:%7.2lf %s    \" ";
885
	$graphcmd .= "GPRINT:\"processes:LAST:%7.2lf %s    \" ";
886
	$graphcmd .= "COMMENT:\"\\n\" ";
887
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
888
}
889
elseif((strstr($curdatabase, "-memory.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
890
	/* define graphcmd for memory usage stats */
891
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
892
	$graphcmd .= "--start $start --end $end --step $step ";
893
	$graphcmd .= "--vertical-label \"utilization, percent\" ";
894
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
895
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
896
	$graphcmd .= "--height 200 --width 620 ";
897
	$graphcmd .= "DEF:\"active=$rrddbpath$curdatabase:active:AVERAGE:step=$step\" ";
898
	$graphcmd .= "DEF:\"inactive=$rrddbpath$curdatabase:inactive:AVERAGE:step=$step\" ";
899
	$graphcmd .= "DEF:\"free=$rrddbpath$curdatabase:free:AVERAGE:step=$step\" ";
900
	$graphcmd .= "DEF:\"cache=$rrddbpath$curdatabase:cache:AVERAGE:step=$step\" ";
901
	$graphcmd .= "DEF:\"wire=$rrddbpath$curdatabase:wire:AVERAGE:step=$step\" ";
902
	$graphcmd .= "LINE2:\"active#{$colormemory[0]}:active\" ";
903
	$graphcmd .= "LINE2:\"inactive#{$colormemory[1]}:inactive\" ";
904
	$graphcmd .= "LINE2:\"free#{$colormemory[2]}:free\" ";
905
	$graphcmd .= "LINE2:\"cache#{$colormemory[3]}:cache\" ";
906
	$graphcmd .= "LINE2:\"wire#{$colormemory[4]}:wire\" ";
907
	$graphcmd .= "COMMENT:\"\\n\" ";
908
	$graphcmd .= "COMMENT:\"\t\t      minimum        average        maximum        current\\n\" ";
909
	$graphcmd .= "COMMENT:\"Active.      \" ";
910
	$graphcmd .= "GPRINT:\"active:MIN:%7.2lf %s    \" ";
911
	$graphcmd .= "GPRINT:\"active:AVERAGE:%7.2lf %s    \" ";
912
	$graphcmd .= "GPRINT:\"active:MAX:%7.2lf %s    \" ";
913
	$graphcmd .= "GPRINT:\"active:LAST:%7.2lf %S    \" ";
914
	$graphcmd .= "COMMENT:\"\\n\" ";
915
	$graphcmd .= "COMMENT:\"Inactive.    \" ";
916
	$graphcmd .= "GPRINT:\"inactive:MIN:%7.2lf %s    \" ";
917
	$graphcmd .= "GPRINT:\"inactive:AVERAGE:%7.2lf %s    \" ";
918
	$graphcmd .= "GPRINT:\"inactive:MAX:%7.2lf %s    \" ";
919
	$graphcmd .= "GPRINT:\"inactive:LAST:%7.2lf %S    \" ";
920
	$graphcmd .= "COMMENT:\"\\n\" ";
921
	$graphcmd .= "COMMENT:\"Free.        \" ";
922
	$graphcmd .= "GPRINT:\"free:MIN:%7.2lf %s    \" ";
923
	$graphcmd .= "GPRINT:\"free:AVERAGE:%7.2lf %s    \" ";
924
	$graphcmd .= "GPRINT:\"free:MAX:%7.2lf %s    \" ";
925
	$graphcmd .= "GPRINT:\"free:LAST:%7.2lf %S    \" ";
926
	$graphcmd .= "COMMENT:\"\\n\" ";
927
	$graphcmd .= "COMMENT:\"Cached.      \" ";
928
	$graphcmd .= "GPRINT:\"cache:MIN:%7.2lf %s    \" ";
929
	$graphcmd .= "GPRINT:\"cache:AVERAGE:%7.2lf %s    \" ";
930
	$graphcmd .= "GPRINT:\"cache:MAX:%7.2lf %s    \" ";
931
	$graphcmd .= "GPRINT:\"cache:LAST:%7.2lf %S    \" ";
932
	$graphcmd .= "COMMENT:\"\\n\" ";
933
	$graphcmd .= "COMMENT:\"Wired.       \" ";
934
	$graphcmd .= "GPRINT:\"wire:MIN:%7.2lf %s    \" ";
935
	$graphcmd .= "GPRINT:\"wire:AVERAGE:%7.2lf %s    \" ";
936
	$graphcmd .= "GPRINT:\"wire:MAX:%7.2lf %s    \" ";
937
	$graphcmd .= "GPRINT:\"wire:LAST:%7.2lf %S    \" ";
938
	$graphcmd .= "COMMENT:\"\\n\" ";
939
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
940
}
941
elseif((strstr($curdatabase, "-mbuf.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
942
	/* define graphcmd for mbuf usage stats */
943
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
944
	$graphcmd .= "--start $start --end $end --step $step ";
945
	$graphcmd .= "--vertical-label \"utilization, percent\" ";
946
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
947
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} clusters - {$hperiod} - {$havg} average\" ";
948
	$graphcmd .= "--height 200 --width 620 ";
949
	$graphcmd .= "DEF:\"current=$rrddbpath$curdatabase:current:AVERAGE:step=$step\" ";
950
	$graphcmd .= "DEF:\"cache=$rrddbpath$curdatabase:cache:AVERAGE:step=$step\" ";
951
	$graphcmd .= "DEF:\"total=$rrddbpath$curdatabase:total:AVERAGE:step=$step\" ";
952
	$graphcmd .= "DEF:\"max=$rrddbpath$curdatabase:max:AVERAGE:step=$step\" ";
953
	$graphcmd .= "LINE2:\"current#{$colormbuf[0]}:current\" ";
954
	$graphcmd .= "LINE2:\"cache#{$colormbuf[1]}:cache\" ";
955
	$graphcmd .= "LINE2:\"total#{$colormbuf[2]}:total\" ";
956
	$graphcmd .= "LINE2:\"max#{$colormbuf[3]}:max\" ";
957
	$graphcmd .= "COMMENT:\"\\n\" ";
958
	$graphcmd .= "COMMENT:\"\t\t      minimum        average        maximum        current\\n\" ";
959
	$graphcmd .= "COMMENT:\"Current.      \" ";
960
	$graphcmd .= "GPRINT:\"current:MIN:%7.2lf %s    \" ";
961
	$graphcmd .= "GPRINT:\"current:AVERAGE:%7.2lf %s    \" ";
962
	$graphcmd .= "GPRINT:\"current:MAX:%7.2lf %s    \" ";
963
	$graphcmd .= "GPRINT:\"current:LAST:%7.2lf %S    \" ";
964
	$graphcmd .= "COMMENT:\"\\n\" ";
965
	$graphcmd .= "COMMENT:\"Cache.        \" ";
966
	$graphcmd .= "GPRINT:\"cache:MIN:%7.2lf %s    \" ";
967
	$graphcmd .= "GPRINT:\"cache:AVERAGE:%7.2lf %s    \" ";
968
	$graphcmd .= "GPRINT:\"cache:MAX:%7.2lf %s    \" ";
969
	$graphcmd .= "GPRINT:\"cache:LAST:%7.2lf %S    \" ";
970
	$graphcmd .= "COMMENT:\"\\n\" ";
971
	$graphcmd .= "COMMENT:\"Total.        \" ";
972
	$graphcmd .= "GPRINT:\"total:MIN:%7.2lf %s    \" ";
973
	$graphcmd .= "GPRINT:\"total:AVERAGE:%7.2lf %s    \" ";
974
	$graphcmd .= "GPRINT:\"total:MAX:%7.2lf %s    \" ";
975
	$graphcmd .= "GPRINT:\"total:LAST:%7.2lf %S    \" ";
976
	$graphcmd .= "COMMENT:\"\\n\" ";
977
	$graphcmd .= "COMMENT:\"Max.          \" ";
978
	$graphcmd .= "GPRINT:\"max:MIN:%7.2lf %s    \" ";
979
	$graphcmd .= "GPRINT:\"max:AVERAGE:%7.2lf %s    \" ";
980
	$graphcmd .= "GPRINT:\"max:MAX:%7.2lf %s    \" ";
981
	$graphcmd .= "GPRINT:\"max:LAST:%7.2lf %S    \" ";
982
	$graphcmd .= "COMMENT:\"\\n\" ";
983
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
984
}
985
elseif((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
986
	/* define graphcmd for queue stats */
987
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
988
	$graphcmd .= "--start $start --end $end --step $step ";
989
	$graphcmd .= "--vertical-label \"bits/sec\" ";
990
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
991
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
992
	$graphcmd .= "--height 200 --width 620 ";
993
	if ($altq) {
994
		$a_queues =& $altq->get_queue_list();
995
		$t = 0; 
996
	} else {
997
		$a_queues = array();
998
		$i = 0;
999
		$t = 0;
1000
	}
1001
	foreach ($a_queues as $name => $q) {
1002
		$color = "$colorqueuesup[$t]";
1003
		if($t > 0) { $stack = ":STACK"; }
1004
		$graphcmd .= "DEF:\"$name=$rrddbpath$curdatabase:$name:AVERAGE:step=$step\" ";
1005
		$graphcmd .= "CDEF:\"$name-bytes_out=$name,0,$speedlimit,LIMIT,UN,0,$name,IF\" ";
1006
		$graphcmd .= "CDEF:\"$name-bits_out=$name-bytes_out,8,*\" ";
1007
		$graphcmd .= "$AREA:\"$name-bits_out#${color}:$name$stack\" ";
1008
		$t++;
1009
		if($t > 7) { $t = 0; }
1010
	}
1011
	$graphcmd .= "COMMENT:\"\\n\" ";
1012
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
1013
}
1014
elseif((strstr($curdatabase, "-queuedrops.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
1015
	/* define graphcmd for queuedrop stats */
1016
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
1017
	$graphcmd .= "--start $start --end $end --step $step ";
1018
	$graphcmd .= "--vertical-label \"drops / sec\" ";
1019
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
1020
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
1021
	$graphcmd .= "--height 200 --width 620 ";
1022
	if ($altq) {
1023
		$a_queues =& $altq->get_queue_list();
1024
		$t = 0;
1025
	} else {
1026
        	$a_queues = array();
1027
		$i = 0;
1028
		$t = 0;
1029
	}
1030
	foreach ($a_queues as $name => $q) {
1031
		$color = "$colorqueuesdropup[$t]";
1032
		if($t > 0) { $stack = ":STACK"; }
1033
		$graphcmd .= "DEF:\"$name=$rrddbpath$curdatabase:$name:AVERAGE:step=$step\" ";
1034
		$graphcmd .= "CDEF:\"$name-bytes_out=$name,0,$speedlimit,LIMIT,UN,0,$name,IF\" ";
1035
		$graphcmd .= "CDEF:\"$name-bits_out=$name-bytes_out,8,*\" ";
1036
		$graphcmd .= "CDEF:\"$name-bits_out_neg=$name-bits_out,$multiplier,*\" ";
1037
		$graphcmd .= "$AREA:\"$name-bits_out_neg#${color}:$name$stack\" ";
1038
		$t++;
1039
		if($t > 7) { $t = 0; }
1040
	}
1041
	$graphcmd .= "COMMENT:\"\\n\" ";
1042
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
1043
}
1044
elseif((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
1045
	/* make a link quality graphcmd, we only have WAN for now, others too follow */
1046
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png \\
1047
		--start $start --end $end --step $step  \\
1048
		--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" \\
1049
		--color SHADEA#eeeeee --color SHADEB#eeeeee \\
1050
		--vertical-label \"ms / %\" \\
1051
		--height 200 --width 620 \\
1052
		--lower-limit 0 \\
1053
		DEF:delayraw=$rrddbpath$curdatabase:delay:AVERAGE:step=$step \\
1054
		DEF:loss=$rrddbpath$curdatabase:loss:AVERAGE:step=$step \\
1055
		\"CDEF:delay=delayraw,1000,*\" \\
1056
		\"CDEF:roundavg=delay,PREV(delay),+,2,/\" \\
1057
		\"CDEF:loss10=loss,$multiplier,*\" \\
1058
		\"CDEF:r0=delay,20,MIN\" \\
1059
		\"CDEF:r1=delay,60,MIN\" \\
1060
		\"CDEF:r2=delay,180,MIN\" \\
1061
		\"CDEF:r3=delay,420,MIN\" \\
1062
		COMMENT:\"\t\t\t\t\tDelay\t\t\tPacket loss\\n\" \\
1063
		AREA:delay#$colorqualityrtt[0]:\"> 420      ms\" \\
1064
		GPRINT:delay:MIN:\"\t\tMin\\:  %7.2lf ms\" \\
1065
		GPRINT:loss:MIN:\"\tMin\\: %3.1lf %%\\n\" \\
1066
    		AREA:r3#$colorqualityrtt[1]:\"180-420    ms\" \\
1067
		GPRINT:delay:AVERAGE:\"\t\tAvg\\:  %7.2lf ms\" \\
1068
		GPRINT:loss:AVERAGE:\"\tAvg\\: %3.1lf %%\\n\" \\
1069
		AREA:r2#$colorqualityrtt[2]:\"60-180     ms\" \\
1070
		GPRINT:delay:MAX:\"\t\tMax\\:  %7.2lf ms\" \\
1071
		GPRINT:loss:MAX:\"\tMax\\: %3.1lf %%\\n\" \\
1072
		AREA:r1#$colorqualityrtt[3]:\"20-60      ms\\n\" \\
1073
		AREA:r0#$colorqualityrtt[4]:\"< 20       ms\" \\
1074
		GPRINT:delay:LAST:\"\t\tLast\\: %7.2lf ms\" \\
1075
		GPRINT:loss:LAST:\"\tLast\: %3.1lf %%\\n\" \\
1076
		AREA:loss10#$colorqualityloss:\"Packet loss\\n\" \\
1077
		LINE1:delay#$colorqualityrtt[5]:\"Delay average\\n\" \\
1078
		COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\"";
1079
}
1080
elseif((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
1081
	/* graph a spamd statistics graph */
1082
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png \\
1083
		--start $start --end $end --step $step \\
1084
		--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" \\
1085
		--color SHADEA#eeeeee --color SHADEB#eeeeee \\
1086
		--vertical-label=\"Conn / Time, sec.\" \\
1087
		--height 200 --width 620 --no-gridfit \\
1088
		--lower-limit 0 \\
1089
		DEF:consmin=$rrddbpath$curdatabase:conn:MIN:step=$step \\
1090
		DEF:consavg=$rrddbpath$curdatabase:conn:AVERAGE:step=$step \\
1091
		DEF:consmax=$rrddbpath$curdatabase:conn:MAX:step=$step \\
1092
		DEF:timemin=$rrddbpath$curdatabase:time:MIN:step=$step \\
1093
		DEF:timeavg=$rrddbpath$curdatabase:time:AVERAGE:step=$step \\
1094
		DEF:timemax=$rrddbpath$curdatabase:time:MAX:step=$step \\
1095
		\"CDEF:timeminadj=timemin,0,86400,LIMIT,UN,0,timemin,IF\" \\
1096
		\"CDEF:timeavgadj=timeavg,0,86400,LIMIT,UN,0,timeavg,IF\" \\
1097
		\"CDEF:timemaxadj=timemax,0,86400,LIMIT,UN,0,timemax,IF\" \\
1098
		\"CDEF:t1=timeminadj,timeavgadj,+,2,/,timeminadj,-\" \\
1099
		\"CDEF:t2=timeavgadj,timemaxadj,+,2,/,timeminadj,-,t1,-\" \\
1100
		\"CDEF:t3=timemaxadj,timeminadj,-,t1,-,t2,-\" \\
1101
		AREA:timeminadj \\
1102
		AREA:t1#$colorspamdtime[0]::STACK \\
1103
		AREA:t2#$colorspamdtime[1]::STACK \\
1104
		AREA:t3#$colorspamdtime[2]::STACK \\
1105
		LINE2:timeavgadj#$colorspamdtime[3]:\"Time \" \\
1106
		GPRINT:timeminadj:MIN:\"Min\\:%6.2lf\\t\" \\
1107
		GPRINT:timeavgadj:AVERAGE:\"Avg\\:%6.2lf\\t\" \\
1108
		GPRINT:timemaxadj:MAX:\"Max\\:%6.2lf\\n\" \\
1109
		AREA:consmax#$colorspamdconn[0] \\
1110
		AREA:consmin#$colorspamdconn[1] \\
1111
		LINE1:consmin#$colorspamdconn[2] \\
1112
		LINE1:consmax#$colorspamdconn[3] \\
1113
		LINE1:consavg#$colorspamdconn[4]:\"Cons \" \\
1114
		GPRINT:consmin:MIN:\"Min\\:%6.2lf\\t\" \\
1115
		GPRINT:consavg:AVERAGE:\"Avg\\:%6.2lf\\t\" \\
1116
		GPRINT:consmax:MAX:\"Max\\:%6.2lf\\n\" \\
1117
		COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
1118
}
1119
elseif((strstr($curdatabase, "-cellular.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
1120
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
1121
	$graphcmd .= "--start $start --end $end --step $step ";
1122
	$graphcmd .= "--vertical-label \"signal\" ";
1123
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
1124
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
1125
	$graphcmd .= "--height 200 --width 620 ";
1126
	$graphcmd .= "DEF:\"$curif-rssi=$rrddbpath$curdatabase:rssi:AVERAGE:step=$step\" ";
1127
	$graphcmd .= "LINE2:\"$curif-rssi#{$colorwireless[0]}:$curif-rssi\" ";
1128
	$graphcmd .= "COMMENT:\"\\n\" ";
1129
	$graphcmd .= "COMMENT:\"\t\t   maximum\t\t average\t     current\\n\" ";
1130
	$graphcmd .= "COMMENT:\"RSSI\t\t\" ";
1131
	$graphcmd .= "GPRINT:\"$curif-rssi:MAX:%7.2lf     \" ";
1132
	$graphcmd .= "GPRINT:\"$curif-rssi:AVERAGE:%7.2lf     \" ";
1133
	$graphcmd .= "GPRINT:\"$curif-rssi:LAST:%7.2lf \" ";
1134
	$graphcmd .= "COMMENT:\"\\n\" ";
1135
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";
1136
}
1137
elseif((strstr($curdatabase, "-loggedin.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
1138
	/* define graphcmd for online Captive Portal users stats */
1139
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
1140
	$graphcmd .= "--start $start --end $end --step $step ";
1141
	$graphcmd .= "--vertical-label \"Captive Portal Users\" ";
1142
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
1143
	$graphcmd .= "--base=1000 ";
1144
	$graphcmd .= "--lower-limit=0 ";
1145
	$graphcmd .= "--slope-mode ";
1146
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
1147
	$graphcmd .= "--height 200 --width 620 ";
1148
	$graphcmd .= "DEF:\"$curif-loggedinusers=$rrddbpath$curdatabase:loggedinusers:AVERAGE:step=$step\" ";
1149
	$graphcmd .= "CDEF:\"$curif-totalusers_t=PREV,UN,0,PREV,IF,$curif-loggedinusers,+\" ";
1150
	$graphcmd .= "CDEF:\"$curif-totalusers_d=$curif-totalusers_t,FLOOR\" ";
1151
	$graphcmd .= "AREA:\"$curif-totalusers_d#{$colorcaptiveportalusers[0]}:Total logged in users\" ";
1152
	$graphcmd .= "GPRINT:\"$curif-totalusers_d:MAX:%8.0lf \\n\" ";
1153
	$graphcmd .= "COMMENT:\"\\n\" ";
1154
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";	
1155
}
1156
elseif((strstr($curdatabase, "-concurrent.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
1157
	/* define graphcmd for online Captive Portal users stats */
1158
	$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
1159
	$graphcmd .= "--start $start --end $end --step $step ";
1160
	$graphcmd .= "--vertical-label \"Captive Portal Users\" ";
1161
	$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
1162
	$graphcmd .= "--title \"" . php_uname('n') . " - {$prettydb} - {$hperiod} - {$havg} average\" ";
1163
	$graphcmd .= "--base=1000 ";
1164
	$graphcmd .= "--lower-limit=0 ";
1165
	$graphcmd .= "--slope-mode ";
1166
	$graphcmd .= "--height 200 --width 620 ";
1167
	$graphcmd .= "DEF:\"$curif-concurrentusers=$rrddbpath$curdatabase:concurrentusers:AVERAGE:step=$step\" ";
1168
	$graphcmd .= "AREA:\"$curif-concurrentusers#{$colorcaptiveportalusers[0]}:Concurrent Users\" ";
1169
	$graphcmd .= "COMMENT:\"\\n\" ";
1170
	$graphcmd .= "COMMENT:\"\t\t\t    current\t\t average\t     maximum\\n\" ";
1171
	$graphcmd .= "COMMENT:\"Users Online\t\" ";
1172
	$graphcmd .= "GPRINT:\"$curif-concurrentusers:LAST:%8.0lf     \" ";
1173
	$graphcmd .= "GPRINT:\"$curif-concurrentusers:AVERAGE:%8.0lf      \" ";
1174
	$graphcmd .= "GPRINT:\"$curif-concurrentusers:MAX:%8.0lf \" ";
1175
	$graphcmd .= "COMMENT:\"\\n\" ";
1176
	$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" ";	
1177
}
1178
else {
1179
	$data = false;
1180
	log_error(sprintf(gettext("Sorry we do not have data to graph for %s"),$curdatabase));
1181
} 
1182

    
1183
/* check modification time to see if we need to generate image */
1184
if (file_exists("$rrdtmppath$curdatabase-$curgraph.png")) {
1185
	if((time() - filemtime("$rrdtmppath$curdatabase-$curgraph.png")) >= 15 ) {
1186
		if($data)
1187
			$_gb = exec("$graphcmd 2>&1", $graphcmdoutput, $graphcmdreturn);
1188
			$graphcmdoutput = implode(" ", $graphcmdoutput) . $graphcmd;
1189
			flush();
1190
			usleep(500);
1191
	}			
1192
} else {
1193
	if($data)
1194
		$_gb = exec("$graphcmd 2>&1", $graphcmdoutput, $graphcmdreturn);
1195
		$graphcmdoutput = implode(" ", $graphcmdoutput) . $graphcmd;
1196
		flush();
1197
		usleep(500);
1198
}
1199
if(($graphcmdreturn <> 0) || (! $data)) {
1200
	log_error(sprintf(gettext('Failed to create graph with error code %1$s, the error is: %2$s'),$graphcmdreturn,$graphcmdoutput));
1201
	if(strstr($curdatabase, "queues")) {
1202
		log_error(sprintf(gettext("failed to create graph from %s%s, removing database"),$rrddbpath,$curdatabase));
1203
		unlink_if_exists($rrddbpath . $curif . $queues);
1204
		flush();
1205
		usleep(500);
1206
		enable_rrd_graphing();
1207
	}
1208
	if(strstr($curdatabase, "queuesdrop")) {
1209
		log_error(sprintf(gettext("failed to create graph from %s%s, removing database"),$rrddbpath,$curdatabase));
1210
		unlink_if_exists($rrddbpath . $curdatabase);
1211
		flush();
1212
		usleep(500);
1213
		enable_rrd_graphing();
1214
	}
1215
	header("Content-type: image/png");
1216
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1217
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1218
	header("Cache-Control: no-store, no-cache, must-revalidate");
1219
	header("Cache-Control: post-check=0, pre-check=0", false);
1220
	header("Pragma: no-cache");
1221
	$file= "/usr/local/www/themes/{$g['theme']}/images/misc/rrd_error.png";
1222
	readfile($file);
1223
} else {
1224
	$file = "$rrdtmppath$curdatabase-$curgraph.png";
1225
	if(file_exists("$file")) {
1226
		header("Content-type: image/png");
1227
		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1228
		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1229
		header("Cache-Control: no-store, no-cache, must-revalidate");
1230
		header("Cache-Control: post-check=0, pre-check=0", false);
1231
		header("Pragma: no-cache");
1232
		readfile($file);
1233
	}
1234
}
1235

    
1236
?>
(190-190/246)