Project

General

Profile

Download (31.1 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
		return true;
82
	}
83
	return false;
84
}
85

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

    
97
function migrate_rrd_format($rrdoldxml, $rrdnewxml) {
98
	if(!file_exists("/tmp/rrd_notice_sent.txt")) {
99
		exec("echo 'Converting RRD configuration to new format.  This might take a bit...' | wall");
100
		touch("/tmp/rrd_notice_sent.txt");
101
	}
102
	$numrraold = count($rrdoldxml['rra']);
103
	$numdsold = count($rrdoldxml['ds']);
104
	$numrranew = count($rrdnewxml['rra']);
105
	$numdsnew = count($rrdnewxml['ds']);
106
	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));
107

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

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

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

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

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

    
194
function enable_rrd_graphing() {
195
	global $config, $g, $altq_list_queues;
196

    
197
	if($g['booting'])
198
		echo gettext("Generating RRD graphs...");
199

    
200
	$rrddbpath = "/var/db/rrd/";
201
	$rrdgraphpath = "/usr/local/www/rrd";
202

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

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

    
229
	$rrdtrafficinterval = 60;
230
	$rrdwirelessinterval = 60;
231
	$rrdqueuesinterval = 60;
232
	$rrdqueuesdropinterval = 60;
233
	$rrdpacketsinterval = 60;
234
	$rrdstatesinterval = 60;
235
	$rrdspamdinterval = 60;
236
	$rrdlbpoolinterval = 60;
237
	$rrdprocinterval = 60;
238
	$rrdmeminterval = 60;
239
	$rrdcellularinterval = 60;
240
	$rrdvpninterval = 60;
241
	$rrdcaptiveportalinterval = 60;
242

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

    
257
	/* Asume GigE for now */
258
	$downstream = 125000000;
259
	$upstream = 125000000;
260

    
261
	/* read the shaper config */
262
	read_altq_config();
263

    
264
	if (isset ($config['rrd']['enable'])) {
265

    
266
		/* create directory if needed */
267
		if (!is_dir($rrddbpath)) {
268
			mkdir($rrddbpath, 0775);
269
		}
270
		chown($rrddbpath, "nobody");
271

    
272
		if ($g['booting']) {
273
			if ($g['platform'] != "pfSense") {
274
				restore_rrd();
275
			}
276
		}
277

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

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

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

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

    
325
				create_new_rrd($rrdcreate);
326
				unset($rrdcreate);
327
			}
328

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

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

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

    
358
				create_new_rrd($rrdcreate);
359
				unset($rrdcreate);
360
			}
361

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

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

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

    
387
					create_new_rrd($rrdcreate);
388
					unset($rrdcreate);
389
				}
390

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

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

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

    
412
					create_new_rrd($rrdcreate);
413
					unset($rrdcreate);
414
				}
415

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

    
421
				if(is_array($config['openvpn']['openvpn-server'])) {
422
					foreach($config['openvpn']['openvpn-server'] as $server) {
423
						if("ovpns{$server['vpnid']}" == $ifname) {
424
							$port = $server['local_port'];
425
							$vpnid = $server['vpnid'];
426
						}
427
					}
428
				}
429
				$rrdupdatesh .= "\n";
430
				$rrdupdatesh .= "# polling vpn users for interface $ifname $realif port $port\n";
431
				$rrdupdatesh .= "list_current_users() {\n";
432
				$rrdupdatesh .= " sleep 0.2\n";
433
				$rrdupdatesh .= " echo \"status 2\"\n";
434
				$rrdupdatesh .= " sleep 0.2\n";
435
				$rrdupdatesh .= " echo \"quit\"\n";
436
				$rrdupdatesh .= "}\n";
437
				$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";
438
				$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$vpnusers N:\${OVPN}\n";
439
			}
440

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

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

    
478
					create_new_rrd($rrdcreate);
479
					unset($rrdcreate);
480
				}
481

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

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

    
495
					create_new_rrd($rrdcreate);
496
					unset($rrdcreate);
497
				}
498

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

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

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

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

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

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

    
577
		}
578
		$i++;
579

    
580
		/* System only statistics */
581
		$ifname = "system";
582

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

    
596
			create_new_rrd($rrdcreate);
597
			unset($rrdcreate);
598
		}
599

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

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

    
616
		/* End pf states statistics */
617

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

    
631
			create_new_rrd($rrdcreate);
632
			unset($rrdcreate);
633
		}
634

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

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

    
646
		/* End CPU statistics */
647

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

    
669
			create_new_rrd($rrdcreate);
670
			unset($rrdcreate);
671
		}
672

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

    
678
		/* the Memory stats gathering function. */
679
		$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 | ";
680
		$rrdupdatesh .= " $awk '{getline active;getline inactive;getline free;getline cache;getline wire;printf ";
681
		$rrdupdatesh .= "((active/$0) * 100)\":\"((inactive/$0) * 100)\":\"((free/$0) * 100)\":\"((cache/$0) * 100)\":\"(wire/$0 * 100)}'`\n";
682
		$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$mem N:\${MEM}\n";
683

    
684
		/* End Memory statistics */
685

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

    
707
				create_new_rrd($rrdcreate);
708
				unset($rrdcreate);
709
			}
710

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

    
716
		}
717
		/* End System statistics */
718

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

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

    
747
					create_new_rrd($rrdcreate);
748
					unset($rrdcreate);
749
				}
750

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

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

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

    
783
					create_new_rrd($rrdcreate);
784
					unset($rrdcreate);
785
				}
786

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

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

    
798
			}
799
		}
800

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

    
810
		unset($rrdupdatesh);
811

    
812
		/* kill off traffic collectors */
813
		kill_traffic_collector();
814

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

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

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

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

    
831
}
832

    
833
function kill_traffic_collector() {
834
	global $g;
835

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

    
839
?>
(46-46/67)