Projet

Général

Profil

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

univnautes / usr / local / www / status_rrd_graph_img.php @ 65eb0f61

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
/* NTPD stats			offset, clk jit,   sys jit,   wander */
255
$colorntpd		= array('0080FF','00E344','FF0000','000000');
256

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

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

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

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

    
326

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1282
?>
(198-198/255)