Projet

Général

Profil

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

univnautes / usr / local / www / status_rrd_graph_img.php @ 592abfa4

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
        $start = $_GET['start'];
68
} else {
69
        $start = $now - (8 * 3600);
70
}
71

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

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

    
84
$seconds = $end - $start;
85

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

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

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

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

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

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

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

    
139

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
323

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1235
?>
(190-190/246)