Project

General

Profile

Download (31.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
  Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>
5
  All rights reserved.
6

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

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

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

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

    
28
  */
29

    
30
/*
31
	pfSense_BUILDER_BINARIES:	/bin/rm	/usr/bin/nice	/usr/local/bin/rrdtool	/bin/cd
32
	pfSense_MODULE:	rrd
33
*/
34

    
35
/* include all configuration functions */
36

    
37
function dump_rrd_to_xml($rrddatabase, $xmldumpfile) {
38
	$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
39
	if(file_exists($xmldumpfile))
40
		mwexec("rm {$xmldumpfile}");
41

    
42
	exec("$rrdtool dump {$rrddatabase} {$xmldumpfile} 2>&1", $dumpout, $dumpret);
43
	if ($dumpret <> 0) {
44
		$dumpout = implode(" ", $dumpout);
45
		log_error(sprintf(gettext('RRD dump failed exited with %1$s, the error is: %2$s'), $dumpret, $dumpout));
46
	}
47
	return($dumpret);
48
}
49

    
50
function restore_rrd() {
51
	global $g;
52

    
53
	$rrddbpath = "/var/db/rrd/";
54
	$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
55

    
56
	$rrdrestore = "";
57
	$rrdreturn = "";
58
	if (file_exists("{$g['cf_conf_path']}/rrd.tgz")) {
59
		foreach (glob("{$rrddbpath}/*.xml") as $xml_file) {
60
			unlink($xml_file);
61
		}
62
		exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn);
63
		$rrdrestore = implode(" ", $rrdrestore);
64
		if($rrdreturn != 0) {
65
			log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n");
66
		}
67
		foreach (glob("{$rrddbpath}/*.xml") as $xml_file) {
68
			$rrd_file = preg_replace('/\.xml$/', ".rrd", $xml_file);
69
			if (file_exists("{$rrd_file}")) {
70
				unlink($rrd_file);
71
			}
72
			$output = array();
73
			$status = null;
74
			exec("$rrdtool restore -f '{$xml_file}' '{$rrd_file}'", $output, $status);
75
			if ($status) {
76
				log_error("rrdtool restore -f '{$xml_file}' '{$rrd_file}' failed returning {$status}.");
77
				continue;
78
			}
79
			unlink($xml_file);
80
		}
81
		/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
82
		if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
83
			unlink_if_exists("{$g['cf_conf_path']}/rrd.tgz");
84
		}
85
		return true;
86
	}
87
	return false;
88
}
89

    
90
function create_new_rrd($rrdcreatecmd) {
91
	$rrdcreateoutput = array();
92
	$rrdcreatereturn = 0;
93
	exec("$rrdcreatecmd 2>&1", $rrdcreateoutput, $rrdcreatereturn);
94
	if ($rrdcreatereturn <> 0) {
95
		$rrdcreateoutput = implode(" ", $rrdcreateoutput);
96
		log_error(sprintf(gettext('RRD create failed exited with %1$s, the error is: %2$s'), $rrdcreatereturn, $rrdcreateoutput));
97
	}
98
	return $rrdcreatereturn;
99
}
100

    
101
function migrate_rrd_format($rrdoldxml, $rrdnewxml) {
102
	if(!file_exists("/tmp/rrd_notice_sent.txt")) {
103
		exec("echo 'Converting RRD configuration to new format.  This might take a bit...' | wall");
104
		touch("/tmp/rrd_notice_sent.txt");
105
	}
106
	$numrraold = count($rrdoldxml['rra']);
107
	$numdsold = count($rrdoldxml['ds']);
108
	$numrranew = count($rrdnewxml['rra']);
109
	$numdsnew = count($rrdnewxml['ds']);
110
	log_error(sprintf(gettext('Import RRD has %1$s DS values and %2$s RRA databases, new format RRD has %3$s DS values and %4$s RRA databases'), $numdsold, $numrraold, $numdsnew ,$numrranew));
111

    
112
	/* add data sources not found in the old array from the new array */
113
	$i = 0;
114
	foreach($rrdnewxml['ds'] as $ds) {
115
		if(!is_array($rrdoldxml['ds'][$i])) {
116
			$rrdoldxml['ds'][$i] = $rrdnewxml['ds'][$i];
117
			/* set unknown values to 0 */
118
			$rrdoldxml['ds'][$i]['last_ds'] = " 0.0000000000e+00 ";
119
			$rrdoldxml['ds'][$i]['value'] = " 0.0000000000e+00 ";
120
			$rrdoldxml['ds'][$i]['unknown_sec'] = "0";
121
		}
122
		$i++;
123
	}
124

    
125
	$i = 0;
126
	$rracountold = count($rrdoldxml['rra']);
127
	$rracountnew = count($rrdnewxml['rra']);
128
	/* process each RRA, which contain a database */
129
	foreach($rrdnewxml['rra'] as $rra) {
130
		if(!is_array($rrdoldxml['rra'][$i])) {
131
			$rrdoldxml['rra'][$i] = $rrdnewxml['rra'][$i];
132
		}
133

    
134
		$d = 0;
135
		/* process cdp_prep */
136
		$cdp_prep = $rra['cdp_prep'];
137
		foreach($cdp_prep['ds'] as $ds) {
138
			if(!is_array($rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d])) {
139
				$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d] = $rrdnewxml['rra'][$i]['cdp_prep']['ds'][$d];
140
				$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d]['primary_value'] = " 0.0000000000e+00 ";
141
				$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d]['secondary_value'] = " 0.0000000000e+00 ";
142
				$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d]['value'] = " 0.0000000000e+00 ";
143
				$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d]['unknown_datapoints'] = "0";
144
			}
145
			$d++;
146
		}
147

    
148
		/* process database */
149
		$rows = $rra['database'];
150
		$k = 0;
151
		$rowcountold = count($rrdoldxml['rra'][$i]['database']['row']);
152
		$rowcountnew = count($rrdnewxml['rra'][$i]['database']['row']);
153
		$rowcountdiff = $rowcountnew - $rowcountold;
154
		/* save old rows for a bit before we put the required empty rows before it */
155
		$rowsdata = $rows;
156
		$rowsempty = array();
157
		$r = 0;
158
		while($r < $rowcountdiff) {
159
			$rowsempty[] = $rrdnewxml['rra'][$i]['database']['row'][$r];
160
			$r++;
161
		}
162
		$rows = $rowsempty + $rowsdata;
163
		/* now foreach the rows in the database */
164
		foreach($rows['row'] as $row) {
165
			if(!is_array($rrdoldxml['rra'][$i]['database']['row'][$k])) {
166
				$rrdoldxml['rra'][$i]['database']['row'][$k] = $rrdnewxml['rra'][$i]['database']['row'][$k];
167
			}
168
			$m = 0;
169
			$vcountold = count($rrdoldxml['rra'][$i]['database']['row'][$k]['v']);
170
			$vcountnew = count($rrdnewxml['rra'][$i]['database']['row'][$k]['v']);
171
			foreach($row['v'] as $value) {
172
				if(empty($rrdoldxml['rra'][$i]['database']['row'][$k]['v'][$m])) {
173
					if(isset($valid)) {
174
						$rrdoldxml['rra'][$i]['database']['row'][$k]['v'][$m] = "0.0000000000e+00 ";
175
					} else {
176
						$rrdoldxml['rra'][$i]['database']['row'][$k]['v'][$m] = $rrdnewxml['rra'][$i]['database']['row'][$k]['v'][$m];
177
					}
178
				} else {
179
					if($value <> " NaN ") {
180
						$valid = true;
181
					} else {
182
						$valid = false;
183
					}
184
				}
185
				$m++;
186
			}
187
			$k++;
188
		}
189
		$i++;
190
	}
191

    
192
	$numrranew = count($rrdoldxml['rra']);
193
	$numdsnew = count($rrdoldxml['ds']);
194
	log_error(sprintf(gettext('The new RRD now has %1$s DS values and %2$s RRA databases'), $numdsnew, $numrranew));
195
	return $rrdoldxml;
196
}
197

    
198
function enable_rrd_graphing() {
199
	global $config, $g, $altq_list_queues;
200

    
201
	if($g['booting'])
202
		echo gettext("Generating RRD graphs...");
203

    
204
	$rrddbpath = "/var/db/rrd/";
205
	$rrdgraphpath = "/usr/local/www/rrd";
206

    
207
	$traffic = "-traffic.rrd";
208
	$packets = "-packets.rrd";
209
	$states = "-states.rrd";
210
	$wireless = "-wireless.rrd";
211
	$queues = "-queues.rrd";
212
	$queuesdrop = "-queuedrops.rrd";
213
	$spamd = "-spamd.rrd";
214
	$proc = "-processor.rrd";
215
	$mem = "-memory.rrd";
216
	$cellular = "-cellular.rrd";
217
	$vpnusers = "-vpnusers.rrd";
218
	$captiveportalconcurrent = "-concurrent.rrd";
219
	$captiveportalloggedin = "-loggedin.rrd";
220

    
221
	$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
222
	$netstat = "/usr/bin/netstat";
223
	$awk = "/usr/bin/awk";
224
	$tar = "/usr/bin/tar";
225
	$pfctl = "/sbin/pfctl";
226
	$sysctl = "/sbin/sysctl";
227
	$php = "/usr/local/bin/php";
228
	$cpustats = "/usr/local/sbin/cpustats";
229
	$spamd_gather = "/usr/local/bin/spamd_gather_stats.php";
230
	$ifconfig = "/sbin/ifconfig";
231
	$captiveportal_gather = "/usr/local/bin/captiveportal_gather_stats.php";
232

    
233
	$rrdtrafficinterval = 60;
234
	$rrdwirelessinterval = 60;
235
	$rrdqueuesinterval = 60;
236
	$rrdqueuesdropinterval = 60;
237
	$rrdpacketsinterval = 60;
238
	$rrdstatesinterval = 60;
239
	$rrdspamdinterval = 60;
240
	$rrdlbpoolinterval = 60;
241
	$rrdprocinterval = 60;
242
	$rrdmeminterval = 60;
243
	$rrdcellularinterval = 60;
244
	$rrdvpninterval = 60;
245
	$rrdcaptiveportalinterval = 60;
246

    
247
	$trafficvalid = $rrdtrafficinterval * 2;
248
	$wirelessvalid = $rrdwirelessinterval * 2;
249
	$queuesvalid = $rrdqueuesinterval * 2;
250
	$queuesdropvalid = $rrdqueuesdropinterval * 2;
251
	$packetsvalid = $rrdpacketsinterval * 2;
252
	$statesvalid = $rrdstatesinterval*2;
253
	$spamdvalid = $rrdspamdinterval * 2;
254
	$lbpoolvalid = $rrdlbpoolinterval * 2;
255
	$procvalid = $rrdlbpoolinterval * 2;
256
	$memvalid = $rrdmeminterval * 2;
257
	$cellularvalid = $rrdcellularinterval * 2;
258
	$vpnvalid = $rrdvpninterval * 2;
259
	$captiveportalvalid = $rrdcaptiveportalinterval * 2;
260

    
261
	/* Asume GigE for now */
262
	$downstream = 125000000;
263
	$upstream = 125000000;
264

    
265
	/* read the shaper config */
266
	read_altq_config();
267

    
268
	if (isset ($config['rrd']['enable'])) {
269

    
270
		/* create directory if needed */
271
		if (!is_dir($rrddbpath)) {
272
			mkdir($rrddbpath, 0775);
273
		}
274
		chown($rrddbpath, "nobody");
275

    
276
		if ($g['booting']) {
277
			restore_rrd();
278
		}
279

    
280
		/* db update script */
281
		$rrdupdatesh = "#!/bin/sh\n";
282
		$rrdupdatesh .= "\n";
283
		$rrdupdatesh .= "export TERM=dumb\n";
284
		$rrdupdatesh .= "\n";
285
		$rrdupdatesh .= 'echo $$ > ' . $g['varrun_path'] . '/updaterrd.sh.pid';
286
		$rrdupdatesh .= "\n";
287
		$rrdupdatesh .= "counter=1\n";
288
		$rrdupdatesh .= "while [ \"\$counter\" -ne 0 ]\n";
289
		$rrdupdatesh .= "do\n";
290
		$rrdupdatesh .= "";
291

    
292
		$i = 0;
293
		$ifdescrs = get_configured_interface_with_descr();
294
		/* IPsec counters */
295
		$ifdescrs['ipsec'] = "IPsec";
296
		/* OpenVPN server counters */
297
		if(is_array($config['openvpn']['openvpn-server'])) {
298
			foreach($config['openvpn']['openvpn-server'] as $server) {
299
				$serverid = "ovpns" . $server['vpnid'];
300
				$ifdescrs[$serverid] = "{$server['description']}";
301
			}
302
		}
303

    
304
		/* process all real and pseudo interfaces */
305
		foreach ($ifdescrs as $ifname => $ifdescr) {
306
			$temp = get_real_interface($ifname);
307
			if($temp <> "") {
308
				$realif = $temp;
309
			}
310

    
311
			/* TRAFFIC, set up the rrd file */
312
			if (!file_exists("$rrddbpath$ifname$traffic")) {
313
				$rrdcreate = "$rrdtool create $rrddbpath$ifname$traffic --step $rrdtrafficinterval ";
314
				$rrdcreate .= "DS:inpass:COUNTER:$trafficvalid:0:$downstream ";
315
				$rrdcreate .= "DS:outpass:COUNTER:$trafficvalid:0:$upstream ";
316
				$rrdcreate .= "DS:inblock:COUNTER:$trafficvalid:0:$downstream ";
317
				$rrdcreate .= "DS:outblock:COUNTER:$trafficvalid:0:$upstream ";
318
				$rrdcreate .= "DS:inpass6:COUNTER:$trafficvalid:0:$downstream ";
319
				$rrdcreate .= "DS:outpass6:COUNTER:$trafficvalid:0:$upstream ";
320
				$rrdcreate .= "DS:inblock6:COUNTER:$trafficvalid:0:$downstream ";
321
				$rrdcreate .= "DS:outblock6:COUNTER:$trafficvalid:0:$upstream ";
322
				$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
323
				$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
324
				$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
325
				$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
326

    
327
				create_new_rrd($rrdcreate);
328
				unset($rrdcreate);
329
			}
330

    
331
			/* enter UNKNOWN values in the RRD so it knows we rebooted. */
332
			if($g['booting']) {
333
				mwexec("$rrdtool update $rrddbpath$ifname$traffic N:U:U:U:U:U:U:U:U");
334
			}
335

    
336
			$rrdupdatesh .= "\n";
337
			$rrdupdatesh .= "# polling traffic for interface $ifname $realif IPv4/IPv6 counters \n";
338
			$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$traffic N:";
339
			$rrdupdatesh .= "`$pfctl -vvsI -i {$realif} | awk '\\\n";
340
			$rrdupdatesh .= "/In4\/Pass/ { b4pi = \$6 };/Out4\/Pass/ { b4po = \$6 };/In4\/Block/ { b4bi = \$6 };/Out4\/Block/ { b4bo = \$6 };\\\n";
341
			$rrdupdatesh .= "/In6\/Pass/ { b6pi = \$6 };/Out6\/Pass/ { b6po = \$6 };/In6\/Block/ { b6bi = \$6 };/Out6\/Block/ { b6bo = \$6 };\\\n";
342
			$rrdupdatesh .= "END {print b4pi \":\" b4po \":\" b4bi \":\" b4bo \":\" b6pi \":\" b6po \":\" b6bi \":\" b6bo};'`\n";
343

    
344
			/* PACKETS, set up the rrd file */
345
			if (!file_exists("$rrddbpath$ifname$packets")) {
346
				$rrdcreate = "$rrdtool create $rrddbpath$ifname$packets --step $rrdpacketsinterval ";
347
				$rrdcreate .= "DS:inpass:COUNTER:$packetsvalid:0:$downstream ";
348
				$rrdcreate .= "DS:outpass:COUNTER:$packetsvalid:0:$upstream ";
349
				$rrdcreate .= "DS:inblock:COUNTER:$packetsvalid:0:$downstream ";
350
				$rrdcreate .= "DS:outblock:COUNTER:$packetsvalid:0:$upstream ";
351
				$rrdcreate .= "DS:inpass6:COUNTER:$packetsvalid:0:$downstream ";
352
				$rrdcreate .= "DS:outpass6:COUNTER:$packetsvalid:0:$upstream ";
353
				$rrdcreate .= "DS:inblock6:COUNTER:$packetsvalid:0:$downstream ";
354
				$rrdcreate .= "DS:outblock6:COUNTER:$packetsvalid:0:$upstream ";
355
				$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
356
				$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
357
				$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
358
				$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
359

    
360
				create_new_rrd($rrdcreate);
361
				unset($rrdcreate);
362
			}
363

    
364
			/* enter UNKNOWN values in the RRD so it knows we rebooted. */
365
			if($g['booting']) {
366
				mwexec("$rrdtool update $rrddbpath$ifname$packets N:U:U:U:U:U:U:U:U");
367
			}
368

    
369
			$rrdupdatesh .= "\n";
370
			$rrdupdatesh .= "# polling packets for interface $ifname $realif \n";
371
			$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$packets N:";
372
			$rrdupdatesh .= "`$pfctl -vvsI -i {$realif} | awk '\\\n";
373
			$rrdupdatesh .= "/In4\/Pass/ { b4pi = \$4 };/Out4\/Pass/ { b4po = \$4 };/In4\/Block/ { b4bi = \$4 };/Out4\/Block/ { b4bo = \$4 };\\\n";
374
			$rrdupdatesh .= "/In6\/Pass/ { b6pi = \$4 };/Out6\/Pass/ { b6po = \$4 };/In6\/Block/ { b6bi = \$4 };/Out6\/Block/ { b6bo = \$4 };\\\n";
375
			$rrdupdatesh .= "END {print b4pi \":\" b4po \":\" b4bi \":\" b4bo \":\" b6pi \":\" b6po \":\" b6bi \":\" b6bo};'`\n";
376

    
377
			/* WIRELESS, set up the rrd file */
378
			if($config['interfaces'][$ifname]['wireless']['mode'] == "bss") {
379
				if (!file_exists("$rrddbpath$ifname$wireless")) {
380
					$rrdcreate = "$rrdtool create $rrddbpath$ifname$wireless --step $rrdwirelessinterval ";
381
					$rrdcreate .= "DS:snr:GAUGE:$wirelessvalid:0:1000 ";
382
					$rrdcreate .= "DS:rate:GAUGE:$wirelessvalid:0:1000 ";
383
					$rrdcreate .= "DS:channel:GAUGE:$wirelessvalid:0:1000 ";
384
					$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
385
					$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
386
					$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
387
					$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
388

    
389
					create_new_rrd($rrdcreate);
390
					unset($rrdcreate);
391
				}
392

    
393
				/* enter UNKNOWN values in the RRD so it knows we rebooted. */
394
				if($g['booting']) {
395
					mwexec("$rrdtool update $rrddbpath$ifname$wireless N:U:U:U");
396
				}
397

    
398
				$rrdupdatesh .= "\n";
399
				$rrdupdatesh .= "# polling wireless for interface $ifname $realif \n";
400
				$rrdupdatesh .= "WIFI=`$ifconfig {$realif} list sta| $awk 'gsub(\"M\", \"\") {getline 2;print substr(\$5, 0, length(\$5)-2) \":\" $4 \":\" $3}'`\n";
401
				$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$wireless N:\${WIFI}\n";
402
			}
403

    
404
			/* OpenVPN, set up the rrd file */
405
			if(stristr($ifname, "ovpns")) {
406
				if (!file_exists("$rrddbpath$ifname$vpnusers")) {
407
					$rrdcreate = "$rrdtool create $rrddbpath$ifname$vpnusers --step $rrdvpninterval ";
408
					$rrdcreate .= "DS:users:GAUGE:$vpnvalid:0:10000 ";
409
					$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
410
					$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
411
					$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
412
					$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
413

    
414
					create_new_rrd($rrdcreate);
415
					unset($rrdcreate);
416
				}
417

    
418
				/* enter UNKNOWN values in the RRD so it knows we rebooted. */
419
				if($g['booting']) {
420
					mwexec("$rrdtool update $rrddbpath$ifname$vpnusers N:U");
421
				}
422

    
423
				if(is_array($config['openvpn']['openvpn-server'])) {
424
					foreach($config['openvpn']['openvpn-server'] as $server) {
425
						if("ovpns{$server['vpnid']}" == $ifname) {
426
							$port = $server['local_port'];
427
							$vpnid = $server['vpnid'];
428
						}
429
					}
430
				}
431
				$rrdupdatesh .= "\n";
432
				$rrdupdatesh .= "# polling vpn users for interface $ifname $realif port $port\n";
433
				$rrdupdatesh .= "list_current_users() {\n";
434
				$rrdupdatesh .= " sleep 0.2\n";
435
				$rrdupdatesh .= " echo \"status 2\"\n";
436
				$rrdupdatesh .= " sleep 0.2\n";
437
				$rrdupdatesh .= " echo \"quit\"\n";
438
				$rrdupdatesh .= "}\n";
439
				$rrdupdatesh .= "OVPN=`list_current_users | nc -U {$g['varetc_path']}/openvpn/server{$vpnid}.sock | awk -F\",\" '/^CLIENT_LIST/ {print \$2}' | wc -l | awk '{print $1}'`\n";
440
				$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$vpnusers N:\${OVPN}\n";
441
			}
442

    
443
			/* QUEUES, set up the queues databases */
444
			if ($altq_list_queues[$ifname]) {
445
				$altq =& $altq_list_queues[$ifname];
446
				/* NOTE: Is it worth as its own function?! */
447
				switch ($altq->GetBwscale()) {
448
					case "Gb":
449
						$factor = 1024 * 1024 * 1024;
450
							break;
451
					case "Mb":
452
							$factor = 1024 * 1024;
453
							break;
454
					case "Kb":
455
							$factor = 1024;
456
							break;
457
					case "b":
458
					default:
459
							$factor = 1;
460
							break;
461
				}
462
				$qbandwidth = $altq->GetBandwidth() * $factor;
463
				if ($qbandwidth <=0) {
464
					$qbandwidth = 100 * 1000 * 1000; /* 100Mbit */
465
				}
466
				$qlist =& $altq->get_queue_list($notused);
467
				if (!file_exists("$rrddbpath$ifname$queues")) {
468
					$rrdcreate = "$rrdtool create $rrddbpath$ifname$queues --step $rrdqueuesinterval ";
469
					/* loop list of shaper queues */
470
					$q = 0;
471
					foreach ($qlist as $qname => $q) {
472
						$rrdcreate .= "DS:$qname:COUNTER:$queuesvalid:0:$qbandwidth ";
473
					}
474

    
475
					$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
476
					$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
477
					$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
478
					$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
479

    
480
					create_new_rrd($rrdcreate);
481
					unset($rrdcreate);
482
				}
483

    
484
				if (!file_exists("$rrddbpath$ifname$queuesdrop")) {
485
					$rrdcreate = "$rrdtool create $rrddbpath$ifname$queuesdrop --step $rrdqueuesdropinterval ";
486
					/* loop list of shaper queues */
487
					$q = 0;
488
					foreach ($qlist as $qname => $q) {
489
						$rrdcreate .= "DS:$qname:COUNTER:$queuesdropvalid:0:$qbandwidth ";
490
					}
491

    
492
					$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
493
					$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
494
					$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
495
					$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
496

    
497
					create_new_rrd($rrdcreate);
498
					unset($rrdcreate);
499
				}
500

    
501
				if($g['booting']) {
502
					$rrdqcommand = "-t ";
503
					$rrducommand = "N";
504
					$qi = 0;
505
					foreach ($qlist as $qname => $q) {
506
						if($qi == 0) {
507
							$rrdqcommand .= "{$qname}";
508
						} else {
509
							$rrdqcommand .= ":{$qname}";
510
						}
511
						$qi++;
512
						$rrducommand .= ":U";
513
					}
514
					mwexec("$rrdtool update $rrddbpath$ifname$queues $rrdqcommand $rrducommand");
515
					mwexec("$rrdtool update $rrddbpath$ifname$queuesdrop $rrdqcommand $rrducommand");
516
				}
517

    
518
				/* awk function to gather shaper data */
519
				/* yes, it's special */
520
				$rrdupdatesh .= "` pfctl -vsq -i {$realif} | awk 'BEGIN {printf \"$rrdtool update $rrddbpath$ifname$queues \" } ";
521
				$rrdupdatesh .= "{ ";
522
				$rrdupdatesh .= "if ((\$1 == \"queue\") && ( \$2 ~ /^q/ )) { ";
523
				$rrdupdatesh .= " dsname = dsname \":\" \$2 ; ";
524
				$rrdupdatesh .= " q=1; ";
525
				$rrdupdatesh .= "} ";
526
				$rrdupdatesh .= " else if ((\$4 == \"bytes:\") && ( q == 1 ) ) { ";
527
				$rrdupdatesh .= " dsdata = dsdata \":\" \$5 ; ";
528
				$rrdupdatesh .= " q=0; ";
529
				$rrdupdatesh .= "} ";
530
				$rrdupdatesh .= "} END { ";
531
				$rrdupdatesh .= " dsname = substr(dsname,2); ";
532
				$rrdupdatesh .= " dsdata = substr(dsdata,2); ";
533
				$rrdupdatesh .= " printf \"-t \" dsname \" N:\" dsdata }' ";
534
				$rrdupdatesh .= " dsname=\"\" dsdata=\"\"`\n\n";
535

    
536
				$rrdupdatesh .= "` pfctl -vsq -i {$realif} | awk 'BEGIN {printf \"$rrdtool update $rrddbpath$ifname$queuesdrop \" } ";
537
				$rrdupdatesh .= "{ ";
538
				$rrdupdatesh .= "if ((\$1 == \"queue\") && ( \$2 ~ /^q/ )) { ";
539
				$rrdupdatesh .= " dsname = dsname \":\" \$2 ; ";
540
				$rrdupdatesh .= " q=1; ";
541
				$rrdupdatesh .= "} ";
542
				$rrdupdatesh .= " else if ((\$4 == \"bytes:\") && ( q == 1 ) ) { ";
543
				$rrdupdatesh .= " dsdata = dsdata \":\" \$8 ; ";
544
				$rrdupdatesh .= " q=0; ";
545
				$rrdupdatesh .= "} ";
546
				$rrdupdatesh .= "} END { ";
547
				$rrdupdatesh .= " dsname = substr(dsname,2); ";
548
				$rrdupdatesh .= " dsdata = substr(dsdata,2); ";
549
				$rrdupdatesh .= " printf \"-t \" dsname \" N:\" dsdata }' ";
550
				$rrdupdatesh .= " dsname=\"\" dsdata=\"\"`\n\n";
551
			}
552

    
553
			/* 3G interfaces */
554
			if(preg_match("/ppp[0-9]+/i", $realif))	{
555
				if (!file_exists("$rrddbpath$ifname$cellular")) {
556
					$rrdcreate = "$rrdtool create $rrddbpath$ifname$cellular --step $rrdcellularinterval ";
557
					$rrdcreate .= "DS:rssi:GAUGE:$cellularvalid:0:100 ";
558
					$rrdcreate .= "DS:upstream:GAUGE:$cellularvalid:0:100000000 ";
559
					$rrdcreate .= "DS:downstream:GAUGE:$cellularvalid:0:100000000 ";
560
					$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
561
					$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
562
					$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
563
					$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
564
					create_new_rrd($rrdcreate);
565
					unset($rrdcreate);
566
				}
567

    
568
				/* enter UNKNOWN values in the RRD so it knows we rebooted. */
569
				if($g['booting']) {
570
					mwexec("$rrdtool update $rrddbpath$ifname$cellular N:U:U:U");
571
				}
572

    
573
				$rrdupdatesh .= "\n";
574
				$rrdupdatesh .= "# polling 3G\n";
575
				$rrdupdatesh .= "GSTATS=`awk -F, 'getline 2 {print \$2 \":\" \$8 \":\" \$9}' < /tmp/3gstats.$ifname`\n";
576
				$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cellular N:\"\$GSTATS\"";
577
			}
578

    
579
		}
580
		$i++;
581

    
582
		/* System only statistics */
583
		$ifname = "system";
584

    
585
		/* STATES, create pf states database */
586
		if(! file_exists("$rrddbpath$ifname$states")) {
587
			$rrdcreate = "$rrdtool create $rrddbpath$ifname$states --step $rrdstatesinterval ";
588
			$rrdcreate .= "DS:pfrate:GAUGE:$statesvalid:0:10000000 ";
589
			$rrdcreate .= "DS:pfstates:GAUGE:$statesvalid:0:10000000 ";
590
			$rrdcreate .= "DS:pfnat:GAUGE:$statesvalid:0:10000000 ";
591
			$rrdcreate .= "DS:srcip:GAUGE:$statesvalid:0:10000000 ";
592
			$rrdcreate .= "DS:dstip:GAUGE:$statesvalid:0:10000000 ";
593
			$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
594
			$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
595
			$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
596
			$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
597

    
598
			create_new_rrd($rrdcreate);
599
			unset($rrdcreate);
600
		}
601

    
602
		/* enter UNKNOWN values in the RRD so it knows we rebooted. */
603
		if($g['booting']) {
604
			mwexec("$rrdtool update $rrddbpath$ifname$states N:U:U:U:U:U");
605
		}
606

    
607
		/* the pf states gathering function. */
608
		$rrdupdatesh .= "\n";
609
		$rrdupdatesh .= "pfctl_si_out=\"` $pfctl -si > /tmp/pfctl_si_out `\"\n";
610
		$rrdupdatesh .= "pfctl_ss_out=\"` $pfctl -ss > /tmp/pfctl_ss_out`\"\n";
611
		$rrdupdatesh .= "pfrate=\"` cat /tmp/pfctl_si_out | egrep \"inserts|removals\" | awk '{ pfrate = \$3 + pfrate } {print pfrate}'|tail -1 `\"\n";
612
		$rrdupdatesh .= "pfstates=\"` cat /tmp/pfctl_ss_out | egrep -v \"<\\-.*?<\\-|\\->.*?\\->\" | wc -l|sed 's/ //g'`\"\n";
613
		$rrdupdatesh .= "pfnat=\"` cat /tmp/pfctl_ss_out | egrep '<\\-.*?<\\-|\\->.*?\\->' | wc -l|sed 's/ //g' `\"\n";
614
		$rrdupdatesh .= "srcip=\"` cat /tmp/pfctl_ss_out | egrep -v '<\\-.*?<\\-|\\->.*?\\->' | grep '\\->' | awk '{print \$3}' | awk -F: '{print \$1}' | sort -u|wc -l|sed 's/ //g' `\"\n";
615
		$rrdupdatesh .= "dstip=\"` cat /tmp/pfctl_ss_out | egrep -v '<\\-.*?<\\-|\\->.*?\\->' | grep '<\\-' | awk '{print \$3}' | awk -F: '{print \$1}' | sort -u|wc -l|sed 's/ //g' `\"\n";
616
		$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$states N:\$pfrate:\$pfstates:\$pfnat:\$srcip:\$dstip\n\n";
617

    
618
		/* End pf states statistics */
619

    
620
		/* CPU, create CPU statistics database */
621
		if(! file_exists("$rrddbpath$ifname$proc")) {
622
			$rrdcreate = "$rrdtool create $rrddbpath$ifname$proc --step $rrdprocinterval ";
623
			$rrdcreate .= "DS:user:GAUGE:$procvalid:0:10000000 ";
624
			$rrdcreate .= "DS:nice:GAUGE:$procvalid:0:10000000 ";
625
			$rrdcreate .= "DS:system:GAUGE:$procvalid:0:10000000 ";
626
			$rrdcreate .= "DS:interrupt:GAUGE:$procvalid:0:10000000 ";
627
			$rrdcreate .= "DS:processes:GAUGE:$procvalid:0:10000000 ";
628
			$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
629
			$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
630
			$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
631
			$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
632

    
633
			create_new_rrd($rrdcreate);
634
			unset($rrdcreate);
635
		}
636

    
637
		/* enter UNKNOWN values in the RRD so it knows we rebooted. */
638
		if($g['booting']) {
639
			mwexec("$rrdtool update $rrddbpath$ifname$proc N:U:U:U:U:U");
640
		}
641

    
642
		/* the CPU stats gathering function. */
643
		$rrdupdatesh .= "CPU=`$cpustats | cut -f1-4 -d':'`\n";
644
		/* Using ps uxaH will count all processes including system threads. Top was undercounting. */
645
		$rrdupdatesh .= "PROCS=`ps uxaH | wc -l | awk '{print \$1;}'`\n";
646
		$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$proc N:\${CPU}:\${PROCS}\n";
647

    
648
		/* End CPU statistics */
649

    
650
		/* Memory, create Memory statistics database */
651
		if(! file_exists("$rrddbpath$ifname$mem")) {
652
			$rrdcreate = "$rrdtool create $rrddbpath$ifname$mem --step $rrdmeminterval ";
653
			$rrdcreate .= "DS:active:GAUGE:$memvalid:0:10000000 ";
654
			$rrdcreate .= "DS:inactive:GAUGE:$memvalid:0:10000000 ";
655
			$rrdcreate .= "DS:free:GAUGE:$memvalid:0:10000000 ";
656
			$rrdcreate .= "DS:cache:GAUGE:$memvalid:0:10000000 ";
657
			$rrdcreate .= "DS:wire:GAUGE:$memvalid:0:10000000 ";
658
			$rrdcreate .= "RRA:MIN:0.5:1:1000 ";
659
			$rrdcreate .= "RRA:MIN:0.5:5:1000 ";
660
			$rrdcreate .= "RRA:MIN:0.5:60:1000 ";
661
			$rrdcreate .= "RRA:MIN:0.5:720:3000 ";
662
			$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
663
			$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
664
			$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
665
			$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
666
			$rrdcreate .= "RRA:MAX:0.5:1:1000 ";
667
			$rrdcreate .= "RRA:MAX:0.5:5:1000 ";
668
			$rrdcreate .= "RRA:MAX:0.5:60:1000 ";
669
			$rrdcreate .= "RRA:MAX:0.5:720:3000";
670

    
671
			create_new_rrd($rrdcreate);
672
			unset($rrdcreate);
673
		}
674

    
675
		/* enter UNKNOWN values in the RRD so it knows we rebooted. */
676
		if($g['booting']) {
677
			mwexec("$rrdtool update $rrddbpath$ifname$mem N:U:U:U:U:U");
678
		}
679

    
680
		/* the Memory stats gathering function. */
681
		$rrdupdatesh .= "MEM=`$sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_free_count vm.stats.vm.v_cache_count vm.stats.vm.v_wire_count | ";
682
		$rrdupdatesh .= " $awk '{getline active;getline inactive;getline free;getline cache;getline wire;printf ";
683
		$rrdupdatesh .= "((active/$0) * 100)\":\"((inactive/$0) * 100)\":\"((free/$0) * 100)\":\"((cache/$0) * 100)\":\"(wire/$0 * 100)}'`\n";
684
		$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$mem N:\${MEM}\n";
685

    
686
		/* End Memory statistics */
687

    
688
		/* SPAMD, set up the spamd rrd file */
689
		if (isset($config['installedpackages']['spamdsettings']) &&
690
			 $config['installedpackages']['spamdsettings']['config'][0]['enablerrd']) {
691
			/* set up the spamd rrd file */
692
			if (!file_exists("$rrddbpath$ifname$spamd")) {
693
				$rrdcreate = "$rrdtool create $rrddbpath$ifname$spamd --step $rrdspamdinterval ";
694
				$rrdcreate .= "DS:conn:GAUGE:$spamdvalid:0:10000 ";
695
				$rrdcreate .= "DS:time:GAUGE:$spamdvalid:0:86400 ";
696
				$rrdcreate .= "RRA:MIN:0.5:1:1000 ";
697
				$rrdcreate .= "RRA:MIN:0.5:5:1000 ";
698
				$rrdcreate .= "RRA:MIN:0.5:60:1000 ";
699
				$rrdcreate .= "RRA:MIN:0.5:720:3000 ";
700
				$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
701
				$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
702
				$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
703
				$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
704
				$rrdcreate .= "RRA:MAX:0.5:1:1000 ";
705
				$rrdcreate .= "RRA:MAX:0.5:5:1000 ";
706
				$rrdcreate .= "RRA:MAX:0.5:60:1000 ";
707
				$rrdcreate .= "RRA:MAX:0.5:720:3000 ";
708

    
709
				create_new_rrd($rrdcreate);
710
				unset($rrdcreate);
711
			}
712

    
713
			$rrdupdatesh .= "\n";
714
			$rrdupdatesh .= "# polling spamd for connections and tarpitness \n";
715
			$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$spamd \\\n";
716
			$rrdupdatesh .= "`$php -q $spamd_gather`\n";
717

    
718
		}
719
		/* End System statistics */
720

    
721
		/* Captive Portal statistics, set up the rrd file */
722
		if(is_array($config['captiveportal'])) {
723
			foreach ($config['captiveportal'] as $cpkey => $cp) {
724
				if (!isset($cp['enable']))
725
					continue;
726

    
727
				$ifname= "captiveportal";
728
				$concurrent_filename = $rrddbpath . $ifname . '-' . $cpkey . $captiveportalconcurrent;
729
				if (!file_exists("$concurrent_filename")) {
730
					$rrdcreate = "$rrdtool create $concurrent_filename --step $rrdcaptiveportalinterval ";
731
					$rrdcreate .= "DS:concurrentusers:GAUGE:$captiveportalvalid:0:10000 ";
732
					$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
733
					$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
734
					$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
735
					$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
736
					$rrdcreate .= "RRA:MIN:0.5:1:1000 ";
737
					$rrdcreate .= "RRA:MIN:0.5:5:1000 ";
738
					$rrdcreate .= "RRA:MIN:0.5:60:1000 ";
739
					$rrdcreate .= "RRA:MIN:0.5:720:3000 ";
740
					$rrdcreate .= "RRA:MAX:0.5:1:1000 ";
741
					$rrdcreate .= "RRA:MAX:0.5:5:1000 ";
742
					$rrdcreate .= "RRA:MAX:0.5:60:1000 ";
743
					$rrdcreate .= "RRA:MAX:0.5:720:3000 ";
744
					$rrdcreate .= "RRA:LAST:0.5:1:1000 ";
745
					$rrdcreate .= "RRA:LAST:0.5:5:1000 ";
746
					$rrdcreate .= "RRA:LAST:0.5:60:1000 ";
747
					$rrdcreate .= "RRA:LAST:0.5:720:3000 ";
748

    
749
					create_new_rrd($rrdcreate);
750
					unset($rrdcreate);
751
				}
752

    
753
				/* enter UNKNOWN values in the RRD so it knows we rebooted. */
754
				if($g['booting']) {
755
					mwexec("$rrdtool update $concurrent_filename N:U");
756
				}
757

    
758
				/* the Captive Portal stats gathering function. */
759
				$rrdupdatesh .= "\n";
760
				$rrdupdatesh .= "# polling Captive Portal for number of concurrent users\n";
761
				$rrdupdatesh .= "CP=`$php -q $captiveportal_gather '$cpkey' $concurrent`\n";
762
				$rrdupdatesh .= "$rrdtool update $concurrent_filename \${CP}\n";
763

    
764
				$loggedin_filename = $rrddbpath . $ifname . '-' . $cpkey . $captiveportalloggedin;
765
				if (!file_exists("$loggedin_filename")) {
766
					$rrdcreate = "$rrdtool create $loggedin_filename --step $rrdcaptiveportalinterval ";
767
					$rrdcreate .= "DS:loggedinusers:GAUGE:$captiveportalvalid:0:10000 ";
768
					$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
769
					$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
770
					$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
771
					$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
772
					$rrdcreate .= "RRA:MIN:0.5:1:1000 ";
773
					$rrdcreate .= "RRA:MIN:0.5:5:1000 ";
774
					$rrdcreate .= "RRA:MIN:0.5:60:1000 ";
775
					$rrdcreate .= "RRA:MIN:0.5:720:3000 ";
776
					$rrdcreate .= "RRA:MAX:0.5:1:1000 ";
777
					$rrdcreate .= "RRA:MAX:0.5:5:1000 ";
778
					$rrdcreate .= "RRA:MAX:0.5:60:1000 ";
779
					$rrdcreate .= "RRA:MAX:0.5:720:3000 ";
780
					$rrdcreate .= "RRA:LAST:0.5:1:1000 ";
781
					$rrdcreate .= "RRA:LAST:0.5:5:1000 ";
782
					$rrdcreate .= "RRA:LAST:0.5:60:1000 ";
783
					$rrdcreate .= "RRA:LAST:0.5:720:3000 ";
784

    
785
					create_new_rrd($rrdcreate);
786
					unset($rrdcreate);
787
				}
788

    
789
				/* enter UNKNOWN values in the RRD so it knows we rebooted. */
790
				if($g['booting']) {
791
					mwexec("$rrdtool update $loggedin_filename N:U");
792
				}
793

    
794
				/* the Captive Portal stats gathering function. */
795
				$rrdupdatesh .= "\n";
796
				$rrdupdatesh .= "# polling Captive Portal for number of logged in users\n";
797
				$rrdupdatesh .= "CP=`$php -q $captiveportal_gather $cpkey loggedin`\n";
798
				$rrdupdatesh .= "$rrdtool update $loggedin_filename \${CP}\n";
799

    
800
			}
801
		}
802

    
803
		$rrdupdatesh .= "sleep 60\n";
804
		$rrdupdatesh .= "done\n";
805
		log_error(gettext("Creating rrd update script"));
806
		/* write the rrd update script */
807
		$updaterrdscript = "{$g['vardb_path']}/rrd/updaterrd.sh";
808
		$fd = fopen("$updaterrdscript", "w");
809
		fwrite($fd, "$rrdupdatesh");
810
		fclose($fd);
811

    
812
		unset($rrdupdatesh);
813

    
814
		/* kill off traffic collectors */
815
		kill_traffic_collector();
816

    
817
		/* start traffic collector */
818
		mwexec_bg("/usr/bin/nice -n20 /bin/sh $updaterrdscript");
819

    
820
	} else {
821
		/* kill off traffic collectors */
822
		kill_traffic_collector();
823
	}
824

    
825
	$databases = glob("{$rrddbpath}/*.rrd");
826
	foreach($databases as $database) {
827
		chown($database, "nobody");
828
	}
829

    
830
	if($g['booting'])
831
		echo gettext("done.") . "\n";
832

    
833
}
834

    
835
function kill_traffic_collector() {
836
	global $g;
837

    
838
	killbypid("{$g['varrun_path']}/updaterrd.sh.pid");
839
}
840

    
841
?>
(46-46/66)