Projet

Général

Profil

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

univnautes / usr / local / www / status_rrd_graph_img.php @ 0fab7eb1

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
} else {
48
	$curdatabase = "wan-traffic.rrd";
49
}
50

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

    
57
/* this is used for temp name */
58
if ($_GET['graph']) {
59
	$curgraph = $_GET['graph'];
60
} else {
61
	$curgraph = "custom";
62
}
63

    
64
$now = time();
65

    
66
if (is_numeric($_GET['start'])) {
67
        if($start < ($now - (3600 * 24 * 365 * 5))) {
68
                $start = $now - (8 * 3600);
69
        }
70
        $start = $_GET['start'];
71
} else {
72
        $start = $now - (8 * 3600);
73
}
74

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

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

    
87
$seconds = $end - $start;
88

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

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

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

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

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

    
129
// log_error("start $start, end $end, archivestart $archivestart, average $average, scale $scale, seconds $seconds");
130

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

    
142

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

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

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

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

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

    
202
$speedlimit = ($upstream + $downstream);
203

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
254
/* OpenVPN Users		Online Users */
255
$colorvpnusers		= array('990000');
256

    
257
/* NTPD stats			offset, clk jit,   sys jit,   wander */
258
$colorntpd		= array('0080FF','00E344','FF0000','000000');
259

    
260
/* Captive Portal Total Users	Total Users */
261
/* Captive Portal Concurrent	Concurrent Users */
262
$colorcaptiveportalusers = array('990000');
263

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

    
272
switch ($curstyle) {
273
case "absolute":
274
	$multiplier = 1;
275
	$AREA = "LINE1";
276
	break;
277
default:
278
	$multiplier = -1;
279
	$AREA = "AREA";
280
	break;
281
}
282

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

    
329

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

    
342
	$graphcmd .= "DEF:$curif-in6_bytes_pass=$rrddbpath$curdatabase:inpass6:AVERAGE:step=$step ";
343
	$graphcmd .= "DEF:$curif-out6_bytes_pass=$rrddbpath$curdatabase:outpass6:AVERAGE:step=$step ";
344
	$graphcmd .= "DEF:$curif-in6_bytes_block=$rrddbpath$curdatabase:inblock6:AVERAGE:step=$step ";
345
	$graphcmd .= "DEF:$curif-out6_bytes_block=$rrddbpath$curdatabase:outblock6:AVERAGE:step=$step ";
346

    
347
	$graphcmd .= "CDEF:\"$curif-in_bits_pass=$curif-in_bytes_pass,8,*\" ";
348
	$graphcmd .= "CDEF:\"$curif-out_bits_pass=$curif-out_bytes_pass,8,*\" ";
349
	$graphcmd .= "CDEF:\"$curif-in_bits_block=$curif-in_bytes_block,8,*\" ";
350
	$graphcmd .= "CDEF:\"$curif-out_bits_block=$curif-out_bytes_block,8,*\" ";
351

    
352
	$graphcmd .= "CDEF:\"$curif-in6_bits_pass=$curif-in6_bytes_pass,8,*\" ";
353
	$graphcmd .= "CDEF:\"$curif-out6_bits_pass=$curif-out6_bytes_pass,8,*\" ";
354
	$graphcmd .= "CDEF:\"$curif-in6_bits_block=$curif-in6_bytes_block,8,*\" ";
355
	$graphcmd .= "CDEF:\"$curif-out6_bits_block=$curif-out6_bytes_block,8,*\" ";
356

    
357
	$graphcmd .= "CDEF:\"$curif-in_bytes=$curif-in_bytes_pass,$curif-in_bytes_block,+\" ";
358
	$graphcmd .= "CDEF:\"$curif-out_bytes=$curif-out_bytes_pass,$curif-out_bytes_block,+\" ";
359
	$graphcmd .= "CDEF:\"$curif-in_bits=$curif-in_bits_pass,$curif-in_bits_block,+\" ";
360
	$graphcmd .= "CDEF:\"$curif-out_bits=$curif-out_bits_pass,$curif-out_bits_block,+\" ";
361

    
362
	$graphcmd .= "CDEF:\"$curif-in6_bytes=$curif-in6_bytes_pass,$curif-in6_bytes_block,+\" ";
363
	$graphcmd .= "CDEF:\"$curif-out6_bytes=$curif-out6_bytes_pass,$curif-out6_bytes_block,+\" ";
364
	$graphcmd .= "CDEF:\"$curif-in6_bits=$curif-in6_bits_pass,$curif-in6_bits_block,+\" ";
365
	$graphcmd .= "CDEF:\"$curif-out6_bits=$curif-out6_bits_pass,$curif-out6_bits_block,+\" ";
366

    
367
	$graphcmd .= "CDEF:\"$curif-bits_io=$curif-in_bits,$curif-out_bits,+\" ";
368
	$graphcmd .= "CDEF:\"$curif-out_bits_block_neg=$curif-out_bits_block,$multiplier,*\" ";
369
	$graphcmd .= "CDEF:\"$curif-out_bits_pass_neg=$curif-out_bits_pass,$multiplier,*\" ";
370

    
371
	$graphcmd .= "CDEF:\"$curif-bits6_io=$curif-in6_bits,$curif-out6_bits,+\" ";
372
	$graphcmd .= "CDEF:\"$curif-out6_bits_block_neg=$curif-out6_bits_block,$multiplier,*\" ";
373
	$graphcmd .= "CDEF:\"$curif-out6_bits_pass_neg=$curif-out6_bits_pass,$multiplier,*\" ";
374

    
375
	$graphcmd .= "CDEF:\"$curif-bytes_in_pass=$curif-in_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_pass,IF,$average,*\" ";
376
	$graphcmd .= "CDEF:\"$curif-bytes_out_pass=$curif-out_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_pass,IF,$average,*\" ";
377
	$graphcmd .= "CDEF:\"$curif-bytes_in_block=$curif-in_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_block,IF,$average,*\" ";
378
	$graphcmd .= "CDEF:\"$curif-bytes_out_block=$curif-out_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_block,IF,$average,*\" ";
379

    
380
	$graphcmd .= "CDEF:\"$curif-bytes_in6_pass=$curif-in6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_pass,IF,$average,*\" ";
381
	$graphcmd .= "CDEF:\"$curif-bytes_out6_pass=$curif-out6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_pass,IF,$average,*\" ";
382
	$graphcmd .= "CDEF:\"$curif-bytes_in6_block=$curif-in6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_block,IF,$average,*\" ";
383
	$graphcmd .= "CDEF:\"$curif-bytes_out6_block=$curif-out6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_block,IF,$average,*\" ";
384

    
385
	$graphcmd .= "CDEF:\"$curif-bytes_pass=$curif-bytes_in_pass,$curif-bytes_out_pass,+\" ";
386
	$graphcmd .= "CDEF:\"$curif-bytes_block=$curif-bytes_in_block,$curif-bytes_out_block,+\" ";
387

    
388
	$graphcmd .= "CDEF:\"$curif-bytes_pass6=$curif-bytes_in6_pass,$curif-bytes_out6_pass,+\" ";
389
	$graphcmd .= "CDEF:\"$curif-bytes_block6=$curif-bytes_in6_block,$curif-bytes_out6_block,+\" ";
390

    
391
	$graphcmd .= "CDEF:\"$curif-bytes_in_t_pass=$curif-in_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_pass,IF,$seconds,*\" ";
392
	$graphcmd .= "CDEF:\"$curif-bytes_out_t_pass=$curif-out_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_pass,IF,$seconds,*\" ";
393
	$graphcmd .= "CDEF:\"$curif-bytes_in_t_block=$curif-in_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in_bytes_block,IF,$seconds,*\" ";
394
	$graphcmd .= "CDEF:\"$curif-bytes_out_t_block=$curif-out_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out_bytes_block,IF,$seconds,*\" ";
395

    
396
	$graphcmd .= "CDEF:\"$curif-bytes_in6_t_pass=$curif-in6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_pass,IF,$seconds,*\" ";
397
	$graphcmd .= "CDEF:\"$curif-bytes_out6_t_pass=$curif-out6_bytes_pass,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_pass,IF,$seconds,*\" ";
398
	$graphcmd .= "CDEF:\"$curif-bytes_in6_t_block=$curif-in6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-in6_bytes_block,IF,$seconds,*\" ";
399
	$graphcmd .= "CDEF:\"$curif-bytes_out6_t_block=$curif-out6_bytes_block,0,$speedlimit,LIMIT,UN,0,$curif-out6_bytes_block,IF,$seconds,*\" ";
400

    
401
	$graphcmd .= "CDEF:\"$curif-bytes_t_pass=$curif-bytes_in_t_pass,$curif-bytes_out_t_pass,+\" ";
402
	$graphcmd .= "CDEF:\"$curif-bytes_t_block=$curif-bytes_in_t_block,$curif-bytes_out_t_block,+\" ";
403
	$graphcmd .= "CDEF:\"$curif-bytes_t=$curif-bytes_t_pass,$curif-bytes_t_block,+\" ";
404

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

    
413
	$graphcmd .= "AREA:\"$curif-in_bits_block#{$colortrafficdown[1]}:$curif-in-block\" ";
414
	$graphcmd .= "AREA:\"$curif-in_bits_pass#{$colortrafficdown[0]}:$curif-in-pass:STACK\" ";
415
	$graphcmd .= "AREA:\"$curif-in6_bits_block#{$colortrafficdown[3]}:$curif-in6-block:STACK\" ";
416
	$graphcmd .= "AREA:\"$curif-in6_bits_pass#{$colortrafficdown[2]}:$curif-in6-pass:STACK\" ";
417
	$graphcmd .= "COMMENT:\"\\n\" ";
418

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

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

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

    
515
		$graphcmd .= "CDEF:\"{$ifname}-in_bytes={$ifname}-in_bytes_pass,{$ifname}-in_bytes_block,+\" ";
516
		$graphcmd .= "CDEF:\"{$ifname}-out_bytes={$ifname}-out_bytes_pass,{$ifname}-out_bytes_block,+\" ";
517

    
518
		$graphcmd .= "CDEF:\"{$ifname}-in_bits_pass={$ifname}-in_bytes_pass,8,*\" ";
519
		$graphcmd .= "CDEF:\"{$ifname}-out_bits_pass={$ifname}-out_bytes_pass,8,*\" ";
520
		$graphcmd .= "CDEF:\"{$ifname}-bits_io_pass={$ifname}-in_bits_pass,{$ifname}-out_bits_pass,+\" ";
521

    
522
		$graphcmd .= "CDEF:\"{$ifname}-in_bits_block={$ifname}-in_bytes_block,8,*\" ";
523
		$graphcmd .= "CDEF:\"{$ifname}-out_bits_block={$ifname}-out_bytes_block,8,*\" ";
524
		$graphcmd .= "CDEF:\"{$ifname}-bits_io_block={$ifname}-in_bits_block,{$ifname}-out_bits_block,+\" ";
525

    
526
		$graphcmd .= "CDEF:\"{$ifname}-bytes_in_pass={$ifname}-in_bytes_pass,0,$speedlimit,LIMIT,UN,0,{$ifname}-in_bytes_pass,IF,$average,*\" ";
527
		$graphcmd .= "CDEF:\"{$ifname}-bytes_out_pass={$ifname}-out_bytes_pass,0,$speedlimit,LIMIT,UN,0,{$ifname}-out_bytes_pass,IF,$average,*\" ";
528
		$graphcmd .= "CDEF:\"{$ifname}-bytes_in_block={$ifname}-in_bytes_block,0,$speedlimit,LIMIT,UN,0,{$ifname}-in_bytes_block,IF,$average,*\" ";
529
		$graphcmd .= "CDEF:\"{$ifname}-bytes_out_block={$ifname}-out_bytes_block,0,$speedlimit,LIMIT,UN,0,{$ifname}-out_bytes_block,IF,$average,*\" ";
530
		$graphcmd .= "CDEF:\"{$ifname}-bytes_pass={$ifname}-bytes_in_pass,{$ifname}-bytes_out_pass,+\" ";
531
		$graphcmd .= "CDEF:\"{$ifname}-bytes_block={$ifname}-bytes_in_pass,{$ifname}-bytes_out_block,+\" ";
532

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

    
561
	$graphcmd .= "CDEF:\"tput-in_bits_block={$graphtputbib}{$operand}\" ";
562
	$graphcmd .= "CDEF:\"tput-out_bits_block={$graphtputbob}{$operand}\" "; 
563
	$graphcmd .= "CDEF:\"tput-bits_io_block={$graphtputbtb}{$operand}\" ";
564

    
565
	$graphcmd .= "CDEF:\"tput-out_bits_pass_neg=tput-out_bits_pass,$multiplier,*\" ";
566
	$graphcmd .= "CDEF:\"tput-out_bits_block_neg=tput-out_bits_block,$multiplier,*\" ";
567

    
568
	$graphcmd .= "CDEF:\"tput-bytes_in_t_pass={$graphtputbyip}{$operand}\" ";
569
	$graphcmd .= "CDEF:\"tput-bytes_out_t_pass={$graphtputbyop}{$operand}\" ";
570
	$graphcmd .= "CDEF:\"tput-bytes_t_pass={$graphtputbytp}{$operand}\" ";
571

    
572
	$graphcmd .= "CDEF:\"tput-bytes_in_t_block={$graphtputbyib}{$operand}\" ";
573
	$graphcmd .= "CDEF:\"tput-bytes_out_t_block={$graphtputbyob}{$operand}\" ";
574
	$graphcmd .= "CDEF:\"tput-bytes_t_block={$graphtputbytb}{$operand}\" ";
575

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

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

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

    
623
	$graphcmd .= "DEF:\"$curif-in6_pps_pass=$rrddbpath$curdatabase:inpass6:AVERAGE:step=$step\" ";
624
	$graphcmd .= "DEF:\"$curif-out6_pps_pass=$rrddbpath$curdatabase:outpass6:AVERAGE:step=$step\" ";
625
	$graphcmd .= "DEF:\"$curif-in6_pps_block=$rrddbpath$curdatabase:inblock6:AVERAGE:step=$step\" ";
626
	$graphcmd .= "DEF:\"$curif-out6_pps_block=$rrddbpath$curdatabase:outblock6:AVERAGE:step=$step\" ";
627

    
628
	$graphcmd .= "CDEF:\"$curif-in_pps=$curif-in_pps_pass,$curif-in_pps_block,+\" ";
629
	$graphcmd .= "CDEF:\"$curif-out_pps=$curif-out_pps_pass,$curif-out_pps_block,+\" ";
630
	$graphcmd .= "CDEF:\"$curif-out_pps_pass_neg=$curif-out_pps_pass,$multiplier,*\" ";
631
	$graphcmd .= "CDEF:\"$curif-out_pps_block_neg=$curif-out_pps_block,$multiplier,*\" ";
632

    
633
	$graphcmd .= "CDEF:\"$curif-in6_pps=$curif-in6_pps_pass,$curif-in6_pps_block,+\" ";
634
	$graphcmd .= "CDEF:\"$curif-out6_pps=$curif-out6_pps_pass,$curif-out6_pps_block,+\" ";
635
	$graphcmd .= "CDEF:\"$curif-out6_pps_pass_neg=$curif-out6_pps_pass,$multiplier,*\" ";
636
	$graphcmd .= "CDEF:\"$curif-out6_pps_block_neg=$curif-out6_pps_block,$multiplier,*\" ";
637

    
638
	$graphcmd .= "CDEF:\"$curif-pps_in_pass=$curif-in_pps_pass,0,12500000,LIMIT,UN,0,$curif-in_pps_pass,IF,$average,*\" ";
639
	$graphcmd .= "CDEF:\"$curif-pps_out_pass=$curif-out_pps_pass,0,12500000,LIMIT,UN,0,$curif-out_pps_pass,IF,$average,*\" ";
640
	$graphcmd .= "CDEF:\"$curif-pps_in_block=$curif-in_pps_block,0,12500000,LIMIT,UN,0,$curif-in_pps_block,IF,$average,*\" ";
641
	$graphcmd .= "CDEF:\"$curif-pps_out_block=$curif-out_pps_block,0,12500000,LIMIT,UN,0,$curif-out_pps_block,IF,$average,*\" ";
642

    
643
	$graphcmd .= "CDEF:\"$curif-pps_in6_pass=$curif-in6_pps_pass,0,12500000,LIMIT,UN,0,$curif-in6_pps_pass,IF,$average,*\" ";
644
	$graphcmd .= "CDEF:\"$curif-pps_out6_pass=$curif-out6_pps_pass,0,12500000,LIMIT,UN,0,$curif-out6_pps_pass,IF,$average,*\" ";
645
	$graphcmd .= "CDEF:\"$curif-pps_in6_block=$curif-in6_pps_block,0,12500000,LIMIT,UN,0,$curif-in6_pps_block,IF,$average,*\" ";
646
	$graphcmd .= "CDEF:\"$curif-pps_out6_block=$curif-out6_pps_block,0,12500000,LIMIT,UN,0,$curif-out6_pps_block,IF,$average,*\" ";
647

    
648
	$graphcmd .= "CDEF:\"$curif-pps_io=$curif-in_pps,$curif-out_pps,+\" ";
649
	$graphcmd .= "CDEF:\"$curif-pps_pass=$curif-pps_in_pass,$curif-pps_out_pass,+\" ";
650
	$graphcmd .= "CDEF:\"$curif-pps_block=$curif-pps_in_block,$curif-pps_out_block,+\" ";
651

    
652
	$graphcmd .= "CDEF:\"$curif-pps_io6=$curif-in6_pps,$curif-out6_pps,+\" ";
653
	$graphcmd .= "CDEF:\"$curif-pps_pass6=$curif-pps_in6_pass,$curif-pps_out6_pass,+\" ";
654
	$graphcmd .= "CDEF:\"$curif-pps_block6=$curif-pps_in6_block,$curif-pps_out6_block,+\" ";
655

    
656
	$graphcmd .= "CDEF:\"$curif-pps_in_t_pass=$curif-in_pps_pass,0,12500000,LIMIT,UN,0,$curif-in_pps_pass,IF,$seconds,*\" ";
657
	$graphcmd .= "CDEF:\"$curif-pps_out_t_pass=$curif-out_pps_pass,0,12500000,LIMIT,UN,0,$curif-out_pps_pass,IF,$seconds,*\" ";
658
	$graphcmd .= "CDEF:\"$curif-pps_in_t_block=$curif-in_pps_block,0,12500000,LIMIT,UN,0,$curif-in_pps_block,IF,$seconds,*\" ";
659
	$graphcmd .= "CDEF:\"$curif-pps_out_t_block=$curif-out_pps_block,0,12500000,LIMIT,UN,0,$curif-out_pps_block,IF,$seconds,*\" ";
660

    
661
	$graphcmd .= "CDEF:\"$curif-pps_in6_t_pass=$curif-in6_pps_pass,0,12500000,LIMIT,UN,0,$curif-in6_pps_pass,IF,$seconds,*\" ";
662
	$graphcmd .= "CDEF:\"$curif-pps_out6_t_pass=$curif-out6_pps_pass,0,12500000,LIMIT,UN,0,$curif-out6_pps_pass,IF,$seconds,*\" ";
663
	$graphcmd .= "CDEF:\"$curif-pps_in6_t_block=$curif-in6_pps_block,0,12500000,LIMIT,UN,0,$curif-in6_pps_block,IF,$seconds,*\" ";
664
	$graphcmd .= "CDEF:\"$curif-pps_out6_t_block=$curif-out6_pps_block,0,12500000,LIMIT,UN,0,$curif-out6_pps_block,IF,$seconds,*\" ";
665

    
666
	$graphcmd .= "CDEF:\"$curif-pps_t_pass=$curif-pps_in_t_pass,$curif-pps_out_t_pass,+\" ";
667
	$graphcmd .= "CDEF:\"$curif-pps_t_block=$curif-pps_in_t_block,$curif-pps_out_t_block,+\" ";
668

    
669
	$graphcmd .= "CDEF:\"$curif-pps_t_pass6=$curif-pps_in6_t_pass,$curif-pps_out6_t_pass,+\" ";
670
	$graphcmd .= "CDEF:\"$curif-pps_t_block6=$curif-pps_in6_t_block,$curif-pps_out6_t_block,+\" ";
671

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

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

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

    
1232
/* check modification time to see if we need to generate image */
1233
if (file_exists("$rrdtmppath$curdatabase-$curgraph.png")) {
1234
	if((time() - filemtime("$rrdtmppath$curdatabase-$curgraph.png")) >= 15 ) {
1235
		if($data)
1236
			exec("$graphcmd 2>&1", $graphcmdoutput, $graphcmdreturn);
1237
			$graphcmdoutput = implode(" ", $graphcmdoutput) . $graphcmd;
1238
			flush();
1239
			usleep(500);
1240
	}			
1241
} else {
1242
	if($data)
1243
		exec("$graphcmd 2>&1", $graphcmdoutput, $graphcmdreturn);
1244
		$graphcmdoutput = implode(" ", $graphcmdoutput) . $graphcmd;
1245
		flush();
1246
		usleep(500);
1247
}
1248
if(($graphcmdreturn <> 0) || (! $data)) {
1249
	log_error(sprintf(gettext('Failed to create graph with error code %1$s, the error is: %2$s'),$graphcmdreturn,$graphcmdoutput));
1250
	if(strstr($curdatabase, "queues")) {
1251
		log_error(sprintf(gettext("failed to create graph from %s%s, removing database"),$rrddbpath,$curdatabase));
1252
		exec("/bin/rm -f $rrddbpath$curif$queues");
1253
		flush();
1254
		usleep(500);
1255
		enable_rrd_graphing();
1256
	}
1257
	if(strstr($curdatabase, "queuesdrop")) {
1258
		log_error(sprintf(gettext("failed to create graph from %s%s, removing database"),$rrddbpath,$curdatabase));
1259
		exec("/bin/rm -f $rrddbpath$curdatabase");
1260
		flush();
1261
		usleep(500);
1262
		enable_rrd_graphing();
1263
	}
1264
	header("Content-type: image/png");
1265
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1266
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1267
	header("Cache-Control: no-store, no-cache, must-revalidate");
1268
	header("Cache-Control: post-check=0, pre-check=0", false);
1269
	header("Pragma: no-cache");
1270
	$file= "/usr/local/www/themes/{$g['theme']}/images/misc/rrd_error.png";
1271
	readfile($file);
1272
} else {
1273
	$file = "$rrdtmppath$curdatabase-$curgraph.png";
1274
	if(file_exists("$file")) {
1275
		header("Content-type: image/png");
1276
		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1277
		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1278
		header("Cache-Control: no-store, no-cache, must-revalidate");
1279
		header("Cache-Control: post-check=0, pre-check=0", false);
1280
		header("Pragma: no-cache");
1281
		readfile($file);
1282
	}
1283
}
1284

    
1285
?>
(197-197/254)