1 | #! /usr/bin/perl
|
---|
2 | #
|
---|
3 | #
|
---|
4 | # aug 2002, jasper\@WirelessLeiden.NL
|
---|
5 | #
|
---|
6 |
|
---|
7 |
|
---|
8 | $now=localtime($unow=time());
|
---|
9 |
|
---|
10 | $config='/etc/wl/wleiden.conf';
|
---|
11 | $domain='wLeiden.NET';
|
---|
12 |
|
---|
13 | $ifconfig='/sbin/ifconfig';
|
---|
14 | $iwconfig='/sbin/iwconfig';
|
---|
15 | $ipchains='/sbin/ipchains';
|
---|
16 | $indexmaker='/usr/bin/indexmaker';
|
---|
17 | $sroute='/sbin/route';
|
---|
18 | $OSPFPWD='huppel';
|
---|
19 | $separator=';';
|
---|
20 | $author='feb 2003 jasper@WirelessLeiden.NL';
|
---|
21 | $wicontrol='/usr/sbin/wicontrol';
|
---|
22 |
|
---|
23 | if ($functions_only) {goto functions;}
|
---|
24 | $source='/etc/wl/wleiden.pl';
|
---|
25 |
|
---|
26 | do($config) || die;
|
---|
27 | parse_config();
|
---|
28 |
|
---|
29 |
|
---|
30 | $hostname=`/bin/hostname |cut -d . -f 1`;chomp($hostname);
|
---|
31 | $maxmask= pack("CCCC", 255, 255, 255, 255);
|
---|
32 |
|
---|
33 |
|
---|
34 | if (! $ARGV[0]) {die "use start/stop/startall";}
|
---|
35 |
|
---|
36 | if ($ARGV[1]=~/debug/i) {$DEBUG=1;}
|
---|
37 | if ($ARGV[0]=~/start/i)
|
---|
38 | {
|
---|
39 |
|
---|
40 | ######################################################################
|
---|
41 | do_it();
|
---|
42 |
|
---|
43 | open_files();
|
---|
44 | $nwcfg.="$indexmaker /etc/mrtg/mrtg.cfg> /var/www/html/mrtg/index.html 2> /dev/null\n";
|
---|
45 |
|
---|
46 | print_files();close_files();
|
---|
47 |
|
---|
48 | system("chmod 755 /etc/wl/nwcfg.sh;/etc/wl/nwcfg.sh");
|
---|
49 |
|
---|
50 | if ($DEBUG) {die "DEBUGGING!";}
|
---|
51 |
|
---|
52 | if ($DEBUG) {print "\nDEBUG: making mrtg index.\n";}
|
---|
53 |
|
---|
54 | changeline("/etc/sysconfig/dhcpd","DHCPDARGS","DHCPDARGS=\"$dhcpints\"");
|
---|
55 |
|
---|
56 | #if ($DEBUG) {print "\nDEBUG: reloading firewall.\n";}
|
---|
57 | #$nwcfg.="/usr/local/sbin/firewall\n";
|
---|
58 |
|
---|
59 | if ($DEBUG) {print "\nDEBUG: restarting daemons.\n";}
|
---|
60 |
|
---|
61 | if ($ARGV[0]=~/startall/) {$restart='restart';}
|
---|
62 | else {$restart='condrestart';}
|
---|
63 | $nwcfg.="/etc/init.d/dhcpd $restart\n";
|
---|
64 | $nwcfg.="/etc/init.d/zebra $restart\n";
|
---|
65 | $nwcfg.="/etc/init.d/ospfd $restart\n";
|
---|
66 | $nwcfg.="/etc/init.d/httpd $restart\n";
|
---|
67 | $nwcfg.="/etc/init.d/named $restart\n";
|
---|
68 |
|
---|
69 |
|
---|
70 | ########################################################################
|
---|
71 | } else # geen start -> stop
|
---|
72 | {
|
---|
73 | $nwcfg.="$ifconfig lo:1 down\n";
|
---|
74 |
|
---|
75 | foreach $if (keys %config)
|
---|
76 | {
|
---|
77 | $nwcfg.="$ifconfig $if down\n";
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 |
|
---|
82 | exit;
|
---|
83 |
|
---|
84 | ########################################################################
|
---|
85 |
|
---|
86 | functions:
|
---|
87 |
|
---|
88 | $ahum=1;
|
---|
89 |
|
---|
90 | sub do_it
|
---|
91 | {
|
---|
92 | if ($OS=~/FreeBSD/i) {$FreeBSD=1;}
|
---|
93 | elsif ($OS=~/Linux/i) {$Linux=1;}
|
---|
94 |
|
---|
95 | init_files();
|
---|
96 |
|
---|
97 | #system("/sbin/modprobe ipv6");
|
---|
98 | #system("/sbin/modprobe ipchains");
|
---|
99 |
|
---|
100 | $nwcfg.="$ifconfig lo:1 down\n";
|
---|
101 | #print "ifconfig lo:1 $master_ip\n";
|
---|
102 | #$nwcfg.="$ifconfig lo:1 $master_ip netmask 255.255.255.255\n"; # altijd up!
|
---|
103 |
|
---|
104 | $last='';
|
---|
105 | foreach $if (sort {$b <=> $a} keys %config)
|
---|
106 | {
|
---|
107 | if ($TYPE{$if}=~/wireless/) {$last=$if}
|
---|
108 | } if ($last) {iwconfig("$last &> /dev/null");} # Laatste het eerste...
|
---|
109 |
|
---|
110 | $keys=1;
|
---|
111 | foreach $if (sort keys %config)
|
---|
112 | {
|
---|
113 | if ($if=~/^([^:]+):(\d+)/) {$mymain=$1;$mysub=$2;} else {$mymain='';}
|
---|
114 |
|
---|
115 | if ($functions_only<1) {print "Doing interface: $if IP: $IP{$if}\n";}
|
---|
116 |
|
---|
117 | if ($if!~/:\d+/) {$main=1;} else {$main=0;}
|
---|
118 |
|
---|
119 | ##################### DOWN
|
---|
120 | if ($DOWN{$if}=~/yes/)
|
---|
121 | { print "$if configured DOWN.\n";
|
---|
122 | $nwcfg.="$ifconfig $if 127.0.0.1 down\n";
|
---|
123 |
|
---|
124 | if ($main)
|
---|
125 | {
|
---|
126 | $zebra1.=sprintf <<EOZ3;
|
---|
127 |
|
---|
128 | interface $if
|
---|
129 | description $DESC{$if}
|
---|
130 | ip address 127.0.0.1/0
|
---|
131 | shutdown
|
---|
132 |
|
---|
133 | EOZ3
|
---|
134 | $ospfd2{$if}.=" interface $if\n\n";
|
---|
135 | }
|
---|
136 | next; # Interface down.
|
---|
137 | }
|
---|
138 | ##################### DOWN
|
---|
139 | if ($main)
|
---|
140 | {
|
---|
141 | $if=~/(\d+)/;$ifnum=$1;
|
---|
142 | $nick="${nodename}$ifnum.$domain";
|
---|
143 |
|
---|
144 | if ($TYPE{$if}=~/wireless/)
|
---|
145 | {
|
---|
146 |
|
---|
147 | if ($SDESC{$if}) {$nick="$SDESC{$if}.$nick";}
|
---|
148 | #print "$nick\n";
|
---|
149 | if (iwconfig("$if mode $MODE{$if}"))
|
---|
150 | {
|
---|
151 | if ($DEBUG) {print "\nDEBUG: iwconfig $if mode $MODE{$if} essid $ESSID{$if} nick $nick ap $AP{$if} channel $CHANNEL{$if} sens $SENS{$if} txpower $TXPOWER{$if} rate $RATE{$if}\n";}
|
---|
152 | iwconfig("$if essid $ESSID{$if}");
|
---|
153 | iwconfig("$if nick $nick");
|
---|
154 |
|
---|
155 | $freebsd.=sprintf<<EOFB33;
|
---|
156 | $wicontrol -i $if -s $nick # Nickanem
|
---|
157 | #$wicontrol -i $if -t 7 # TXpower
|
---|
158 | $wicontrol -i $if -P 0 # PowerSave
|
---|
159 | $wicontrol -i $if -Z # Zero SNR cache
|
---|
160 | EOFB33
|
---|
161 | if ($MODE{$if}=~/master/i)
|
---|
162 | {
|
---|
163 | $freebsd.=sprintf<<EOFB3;
|
---|
164 | $wicontrol -i $if -p 6 # hostap mode
|
---|
165 | $wicontrol -i $if -n $ESSID{$if} # network name
|
---|
166 | $wicontrol -i $if -q $ESSID{$if} # ESSID
|
---|
167 | $wicontrol -i $if -c 1 # broadcasting essid on
|
---|
168 | EOFB3
|
---|
169 | } else {
|
---|
170 | $freebsd.=sprintf<<EOFB4;
|
---|
171 | $wicontrol -i $if -p 1 # Client mode (managed)
|
---|
172 | $wicontrol -i $if -n $ESSID{$if} # ESSID
|
---|
173 | EOFB4
|
---|
174 | }
|
---|
175 | if ($AP{$if}) {iwconfig("$if ap $AP{$if}");}
|
---|
176 |
|
---|
177 | if ($MODE{$if}=~/master/) {
|
---|
178 | if ($CHANNEL{$if}) {
|
---|
179 | $freebsd.="$wicontrol -i $if -f $CHANNEL{$if} # Channel\n";
|
---|
180 | } else {
|
---|
181 | $freebsd .= "# WARNING - master but no channel defined.\n";
|
---|
182 | };
|
---|
183 | } else {
|
---|
184 | $freebsd.="# No channel - client follows\n# $wicontrol -i $if -f 0 # Channel\n";
|
---|
185 | }
|
---|
186 |
|
---|
187 | if ($SENS{$if}) {iwconfig("$if sens $SENS{$if}");}
|
---|
188 | if ($TXPOWER{$if}) {iwconfig("$if txpower $TXPOWER{$if}");}
|
---|
189 | if ($RATE{$if}) {iwconfig("$if rate $RATE{$if}");}
|
---|
190 | } #else { print "ERROR: Could not configure interface $if\n";next;}
|
---|
191 |
|
---|
192 | $rcconf.="\nifconfig_$if=\"inet $IP{$if} -promisc\"\n";
|
---|
193 | #$rcconf.="ifconfig_$if=\"inet $IP{$if} -promisc \"\n ssid $ESSID{$if} \\"\n";
|
---|
194 | #if ($CHANNEL{$if}) {$rcconf.=" channel $CHANNEL{$if}";}
|
---|
195 | #$rcconf.="\\\n stationname $nick\"\n";
|
---|
196 | #if ($MODE{$if}=~/master/) {$rcconf.="#mediaopt hostap\n";}
|
---|
197 | #$rcconf.="\n";
|
---|
198 |
|
---|
199 | $freebsd.="\n";
|
---|
200 | } # if wireless
|
---|
201 | mrtg1();
|
---|
202 | if ($OS=~/FreeBSD/)
|
---|
203 | {
|
---|
204 | $ospfd2{$if}.=sprintf <<EOO2;
|
---|
205 |
|
---|
206 | interface $if
|
---|
207 | ip ospf message-digest-key 1 md5 $OSPFPWD
|
---|
208 | ip ospf authentication message-digest
|
---|
209 | EOO2
|
---|
210 |
|
---|
211 | $keys++;
|
---|
212 |
|
---|
213 | $zebra.=sprintf <<EOZ2;
|
---|
214 |
|
---|
215 | interface $if
|
---|
216 | description $DESC{$if}
|
---|
217 | no shutdown
|
---|
218 | EOZ2
|
---|
219 | }
|
---|
220 |
|
---|
221 | } ###################### MAIN
|
---|
222 |
|
---|
223 | if ($OS=~/Linux/)
|
---|
224 | {
|
---|
225 | $ospfd2{$if}.=sprintf <<EOO21;
|
---|
226 |
|
---|
227 | interface $if
|
---|
228 | ip ospf message-digest-key 1 md5 $OSPFPWD
|
---|
229 | ip ospf authentication message-digest
|
---|
230 | EOO21
|
---|
231 | $keys++;
|
---|
232 |
|
---|
233 | $zebra.=sprintf <<EOZ21;
|
---|
234 |
|
---|
235 | interface $if
|
---|
236 | description $DESC{$if}
|
---|
237 | no shutdown
|
---|
238 | EOZ21
|
---|
239 | }
|
---|
240 |
|
---|
241 | if ($IP{$if})
|
---|
242 | {
|
---|
243 | $zebra.=sprintf " ip address $IP{$if}\n";
|
---|
244 | ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if});
|
---|
245 | if ($netmask == '0.0.0.0')
|
---|
246 | {print "Forgot netmask in config $hostname $if: $IP{$if}!\n";
|
---|
247 | die "Forgot netmask in config $hostname $if: $IP{$if}!\n";
|
---|
248 | }
|
---|
249 |
|
---|
250 | # if ($DEBUG) {print("\nDEBUG: $ifconfig $if $ip netmask $netmask broadcast $broadcast up\n");}
|
---|
251 | if ($DEBUG) {print("\nDEBUG: $if $ip $netmask $network $broadcast\n");}
|
---|
252 |
|
---|
253 | if (! $main) {$nwcfg.="$ifconfig $mymain up\n";}
|
---|
254 | $nwcfg.="$ifconfig $if $ip down\n";
|
---|
255 | $nwcfg.="$ifconfig $if $ip netmask $netmask broadcast $broadcast up\n";
|
---|
256 | if ($main)
|
---|
257 | {
|
---|
258 | if ($TYPE{$if}!~/wireless/) {$rcconf.="\nifconfig_$if=\"inet $IP{$if}\"\n";}
|
---|
259 | } else {$rcconf.="ifconfig_${mymain}_alias${mysub}=\"inet $IP{$if}\"\n";}
|
---|
260 | }
|
---|
261 | if (($OS=~/Linux/) || ($main)) {$zebra.= "\n";}
|
---|
262 |
|
---|
263 | if ($ROUTE{$if})
|
---|
264 | {
|
---|
265 | if ($DEBUG) {print "\nDEBUG: ROUTE: $ROUTE{$if}\n";}
|
---|
266 |
|
---|
267 | foreach $r (split(/$separator/,$ROUTE{$if}))
|
---|
268 | {
|
---|
269 | if ($DEBUG) {print "\nDEBUG: ROUTE2: $r\n";}
|
---|
270 |
|
---|
271 | $r=~/([^\/ ]+)\/?(\S+)\s+(\S+)/;
|
---|
272 | $R="$1/$2";$gw=$3;$nm=$2;
|
---|
273 | ($route,$r_netmask,$r_broadcast,$r_network,$r_width)=calc_ip($R);
|
---|
274 | if ($R eq '0.0.0.0/0')
|
---|
275 | { $doit="$sroute add default gw $gw dev $mymain";
|
---|
276 | $rcconf.="\ndefaultrouter=\"$gw\"\n\n";
|
---|
277 | }
|
---|
278 | elsif ($nm eq 32) {$doit="$sroute add $route gw $gw dev $mymain";}
|
---|
279 | else {$doit="$sroute add -net $route netmask $r_netmask gw $gw dev $mymain";}
|
---|
280 |
|
---|
281 | if ($DEBUG) {print "\nROUTE3: $doit\n";}
|
---|
282 | $nwcfg.="$doit\n";
|
---|
283 | if ($R eq '0.0.0.0/0') {$ospfd3.=" default-information originate\n"}
|
---|
284 | else
|
---|
285 | {
|
---|
286 | $area=get_area($R);
|
---|
287 | $ospfd4.="! static route $R\nnetwork $R area $area\n\n";
|
---|
288 | $NW{$area}.="$network/$width ";
|
---|
289 | }
|
---|
290 | $zebra.="ip route $r\n";
|
---|
291 | }
|
---|
292 | }
|
---|
293 |
|
---|
294 | ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if});
|
---|
295 | if (($DHCP{$if}) && ($DHCP{$if}!~/off|no/i))
|
---|
296 | {
|
---|
297 | ($from,$upto)=split(/-/,$DHCP{$if});
|
---|
298 | $ip=~/(^\d+\.\d+\.\d+)\.\d+$/;
|
---|
299 | $dip=$1;
|
---|
300 | $dhcp.=sprintf <<EOD2;
|
---|
301 |
|
---|
302 | #
|
---|
303 | # $if $DESC{$if}
|
---|
304 | #
|
---|
305 | subnet $network netmask $netmask {
|
---|
306 | range $dip.$from $dip.$upto;
|
---|
307 | option broadcast-address $broadcast;
|
---|
308 | option subnet-mask $netmask;
|
---|
309 | option routers $ip;
|
---|
310 | $DHCP_STATIC{$if}
|
---|
311 | }
|
---|
312 |
|
---|
313 | EOD2
|
---|
314 | if ($dhcpints!~/$mymain/) {$dhcpints.=" $mymain";}
|
---|
315 | } # DHCP
|
---|
316 | else
|
---|
317 | {
|
---|
318 | if ( ($main) ) #|| ($DHCP{$mymain}=~/off|no/i))
|
---|
319 | { # niet als main wel dhcp heeft.
|
---|
320 | $dhcp.="subnet $network netmask $netmask {not authoritative; } # $if\n\n";
|
---|
321 | }
|
---|
322 | }
|
---|
323 | if ($OSPF_NEIGHBORS{$if}=~/no/i)
|
---|
324 | {
|
---|
325 | if ($main) {$OSPF_PASSIVE{$if}=1;}
|
---|
326 | }
|
---|
327 |
|
---|
328 | if ($OSPF_AREA{$if}!~/no/i)
|
---|
329 | {
|
---|
330 | ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if});
|
---|
331 |
|
---|
332 | if ($IP{$if})
|
---|
333 | {
|
---|
334 | # if (($OSPF_NEIGHBORS{$if}!~/no/) ||
|
---|
335 | if ($OSPF_AREA{$if} eq '') {$area=get_area($network);}
|
---|
336 | else {$area=int($OSPF_AREA{$if});}
|
---|
337 |
|
---|
338 | $ospfd4.="! $if ($DESC{$if})\nnetwork $network/$width area $area\n\n";
|
---|
339 | $NW{$area}.="$network/$width ";
|
---|
340 | }
|
---|
341 |
|
---|
342 | if ($OSPF_BROADCAST{$if}=~/no/i)
|
---|
343 | {
|
---|
344 | if ($main)
|
---|
345 | {
|
---|
346 | #if ($DEBUG) {print "DEBUG: OSPF_NEIGHBORS{$if}: ($OSPF1_NEIGHBORS{$if})\n";}
|
---|
347 | $OSPFD_NONBROADCAST{$if}=1;
|
---|
348 | }
|
---|
349 | if ($OSPF_NEIGHBORS{$if}!~/no/i)
|
---|
350 | {
|
---|
351 | foreach $n (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if}))
|
---|
352 | {
|
---|
353 | if ($DEBUG) {print "DEBUG: OSPF2_NEIGHBOR{$if}: [$n]\n";}
|
---|
354 | $ospfd5.="! $if link: $SDESC{$if}\n neighbor $n\n\n";
|
---|
355 | }
|
---|
356 | if ($main) {$OSPF_PASSIVE{$if}=0;}
|
---|
357 | else {$OSPF_PASSIVE{$mymain}=0;}
|
---|
358 | } #ospf_neighbors
|
---|
359 | }
|
---|
360 |
|
---|
361 | } # ospf_area
|
---|
362 |
|
---|
363 | if ($POINT_TO_POINT{$if})
|
---|
364 | {
|
---|
365 | foreach $p (split(/$separator/,$POINT_TO_POINT{$if}))
|
---|
366 | {
|
---|
367 | mrtg2();
|
---|
368 | } #foreach $pointtopoint
|
---|
369 | } # pointopoint
|
---|
370 | } # foreach if
|
---|
371 |
|
---|
372 | foreach $if (sort keys %config)
|
---|
373 | {
|
---|
374 | if ($if!~/:\d+/) {$main=1;} else {$main=0;}
|
---|
375 | if ($main)
|
---|
376 | {
|
---|
377 | $ospfd2.=$ospfd2{$if};
|
---|
378 | if ($OSPF_PASSIVE{$if})
|
---|
379 | {
|
---|
380 | $ospfd22.=" passive-interface $if\n";
|
---|
381 | }
|
---|
382 | if ($OSPFD_NONBROADCAST{$if})
|
---|
383 | {
|
---|
384 | $ospfd2.= " ip ospf network non-broadcast\n";
|
---|
385 | }
|
---|
386 | if ($OSPF_COST{$if})
|
---|
387 | {
|
---|
388 | $ospfd2.=" ip ospf cost $OSPF_COST{$if}\n";
|
---|
389 | }
|
---|
390 |
|
---|
391 | }
|
---|
392 | }
|
---|
393 |
|
---|
394 | $zebra.= "\n\nlog file /var/log/zebra.log\n\n";
|
---|
395 |
|
---|
396 | foreach $area (keys %NW)
|
---|
397 | {
|
---|
398 | if ($area eq 0) {next;}
|
---|
399 | $nwa=0xffffffff;
|
---|
400 | foreach $nw (split(/\s+/,$NW{$area}))
|
---|
401 | {
|
---|
402 | ($ip,$width)=split(/\//,$nw);
|
---|
403 | ($a,$b,$c,$d)=split(/\./,$ip);
|
---|
404 | ($II)=($a<<24)+($b<<16)+($c<<8)+$d;
|
---|
405 | if ($width eq 32) {$nm=0xffffffff;}
|
---|
406 | else {$nm=0xffffffff-1<<(31-$width);}
|
---|
407 |
|
---|
408 | $II=$II & $nm;
|
---|
409 | $nwa=$nwa & $II;
|
---|
410 | # $ospfd.=sprintf ("NW-$area: $nw ==> %08x enne %08x\n",$II,$nwa);
|
---|
411 | }
|
---|
412 | $nwa=itoadr($nwa);
|
---|
413 |
|
---|
414 | if ($AGGREGATE) {$agg=$AGGREGATE;}
|
---|
415 | else {$agg=21;}
|
---|
416 |
|
---|
417 | if (($nwa!~/^172\.16\./) && ($area > 0))
|
---|
418 | { $ospfarea.="area $area range $nwa/$agg substitute $nwa/$agg\n"; }
|
---|
419 |
|
---|
420 | $ospf21.="! area $area authentication message-digest\n";
|
---|
421 | }
|
---|
422 |
|
---|
423 |
|
---|
424 | $ospfd.=sprintf <<EOOL;
|
---|
425 |
|
---|
426 | ! ================> interfaces <================
|
---|
427 |
|
---|
428 | $ospfd2
|
---|
429 |
|
---|
430 | ! ================> OSPF router <================
|
---|
431 | router ospf
|
---|
432 | ospf router-id $master_ip
|
---|
433 | $ospfd21
|
---|
434 |
|
---|
435 | passive-interface lo0
|
---|
436 | $ospfd22
|
---|
437 |
|
---|
438 | !default
|
---|
439 | $ospfd3
|
---|
440 |
|
---|
441 | $ospfarea
|
---|
442 |
|
---|
443 | ! ================> networks <================
|
---|
444 | $ospfd4
|
---|
445 |
|
---|
446 | ! ================> neighbors <================
|
---|
447 | $ospfd5
|
---|
448 |
|
---|
449 | log file /var/log/ospf.log
|
---|
450 |
|
---|
451 | EOOL
|
---|
452 | # $rcconf.="\n\n" . $freebsd;
|
---|
453 | }
|
---|
454 |
|
---|
455 | sub get_area
|
---|
456 | {
|
---|
457 | local($IP)=@_;
|
---|
458 | local($range);
|
---|
459 | local($ip,$netmask,$broadcast,$network,$width);
|
---|
460 | local($a,$b,$c,$d)=split(/\./,$IP);
|
---|
461 | local($II)=($a<<24)+($b<<16)+($c<<8)+$d;
|
---|
462 | local($ii,$ip,$nm,$I2);
|
---|
463 |
|
---|
464 | # for ($i=0;$i<=$maxareas;$i++)
|
---|
465 | # {
|
---|
466 | # $ii=$II[$i];
|
---|
467 | # $nm=$NM[$i];
|
---|
468 | # $I2=$II & $nm;
|
---|
469 | ##$ospfd.=sprintf "i=$i\t $RANGE[$i]\t ii=$ii\t nm=$nm\t I2=$I2 $II $IP $a,$b,$c,$d\n";
|
---|
470 | # if ($I2 == $ii) {return($AREA[$i]);}
|
---|
471 | # }
|
---|
472 | # return(12345);
|
---|
473 |
|
---|
474 | if ($b eq 16) {return(0);}
|
---|
475 | if ($c < 128) {return($b * 10)}
|
---|
476 | else {return(1+($b*10));}
|
---|
477 | }
|
---|
478 |
|
---|
479 |
|
---|
480 | sub read_areas
|
---|
481 | {
|
---|
482 | $maxareas=0;
|
---|
483 | open(AC,"$home/areas.conf") || die;
|
---|
484 | while (<AC>)
|
---|
485 | {
|
---|
486 | chomp();
|
---|
487 | s/#.*$//;
|
---|
488 | if (! $_) {next;}
|
---|
489 | ($area,$range,$desc)=split(/\s+/);
|
---|
490 | $AREA[$maxareas]=$area;
|
---|
491 | $RANGE[$maxareas]=$range;
|
---|
492 | $DESC[$maxareas]=$desc;
|
---|
493 |
|
---|
494 | ($ip,$width)=split(/\//,$range);
|
---|
495 | ($a,$b,$c,$d)=split(/\./,$ip);
|
---|
496 | $ii=($a<<24)+($b<<16)+($c<<8)+$d;
|
---|
497 |
|
---|
498 | if ($width eq 32) {$nm=0xffffffff;}
|
---|
499 | else {$nm=0xffffffff-1<<(31-$width);}
|
---|
500 | $II[$maxareas]=$ii;
|
---|
501 | $NM[$maxareas]=$nm;
|
---|
502 |
|
---|
503 | $maxareas++;
|
---|
504 | }
|
---|
505 | close(AC);
|
---|
506 | }
|
---|
507 |
|
---|
508 | sub parse_config
|
---|
509 | {
|
---|
510 | foreach $if (keys %config)
|
---|
511 | {
|
---|
512 | $cfg=$config{$if};
|
---|
513 | if (! $html) {print "Parsing interface: $if\n";}
|
---|
514 | while ($cfg)
|
---|
515 | {
|
---|
516 | $cfg=~s/^([^\n\r]+)[\r\n]*//m;
|
---|
517 | $line=$1;
|
---|
518 | $line=~s/\s*#.*//;
|
---|
519 | if ((($name,$value)=split(/=/,$line)) eq 2)
|
---|
520 | {
|
---|
521 | if ($name eq 'ESSID') {$value=lc($value);}
|
---|
522 | #print "VAL($name)=$value\n";
|
---|
523 | $doit="if (exists(\$$name\{\"$if\"\})) {\$$name\{\"$if\"\}.=\"$separator$value\";} else {\$$name\{\"$if\"\}.=\"$value\";}";
|
---|
524 | #print "DOIT: [$doit]\n";
|
---|
525 | eval($doit);
|
---|
526 | }
|
---|
527 | #print "CFG:[$cfg]\n";
|
---|
528 | $cfg=~s/[\r\n]*$//m;
|
---|
529 | }
|
---|
530 | }
|
---|
531 | if ($functions_only<1) {print "Done parsing config.\n";}
|
---|
532 | }
|
---|
533 |
|
---|
534 | sub iwconfig
|
---|
535 | {
|
---|
536 | local($line)=@_;
|
---|
537 | $nwcfg.="$iwconfig $line\n";
|
---|
538 |
|
---|
539 | }
|
---|
540 |
|
---|
541 | sub ipchains
|
---|
542 | {
|
---|
543 | local($line)=@_;
|
---|
544 | return(system("$ipchains $line"));
|
---|
545 | }
|
---|
546 |
|
---|
547 | #($a,$b,$c,$d) = unpack('C4',$addr[0]);
|
---|
548 |
|
---|
549 | #$IP = pack("CCCC", 152, 2, 128, 184); # create IP address
|
---|
550 | #($var1, $var2, $var3, $var4) = unpack("CCCC", $IP); #inverse of the above
|
---|
551 |
|
---|
552 |
|
---|
553 |
|
---|
554 | sub calc_ip
|
---|
555 | { local($i)=@_;
|
---|
556 | local($a,$b,$c,$d);
|
---|
557 | local($ip,$width)=split(/\//,$i);
|
---|
558 | local($a,$b,$c,$d)=split(/\./,$ip);
|
---|
559 | local($ii)=($a<<24)+($b<<16)+($c<<8)+$d;
|
---|
560 |
|
---|
561 | if ($width eq 32) {$nm=0xffffffff;}
|
---|
562 | else {$nm=0xffffffff-1<<(31-$width);}
|
---|
563 | $nw=($ii & $nm);
|
---|
564 | $br=$nw | (0xffffffff & ~$nm);
|
---|
565 | $netmask=itoadr($nm);;
|
---|
566 | $broadcast=itoadr($br);;
|
---|
567 | $network=itoadr($nw); # $i=itoadr($ii);
|
---|
568 |
|
---|
569 | # printf "ip=$ip|width=$width|nm=%0x|$netmask|br=%0x|$broadcast|$i|\n",$nm,$br;
|
---|
570 |
|
---|
571 | return($ip,$netmask,$broadcast,$network,$width);
|
---|
572 | }
|
---|
573 |
|
---|
574 | sub itoadr
|
---|
575 | {
|
---|
576 | local($ip)=@_;
|
---|
577 | local($a,$b,$c,$d);
|
---|
578 | $a=($ip & 0xff000000) >> 24;
|
---|
579 | $b=($ip & 0x00ff0000) >> 16;
|
---|
580 | $c=($ip & 0x0000ff00) >> 8;
|
---|
581 | $d=($ip & 0x000000ff);
|
---|
582 | return("$a.$b.$c.$d");
|
---|
583 | }
|
---|
584 |
|
---|
585 | sub changeline
|
---|
586 | {
|
---|
587 | local($file,$old,$new)=@_;
|
---|
588 | open(OLD,$file) || die "Could not open old file: $file\n";
|
---|
589 | open(NEW,">$file.genesis.$$") || die "Could not create new file: $file.genesis.$$";
|
---|
590 | while(<OLD>)
|
---|
591 | {
|
---|
592 | if (/$old/) {print NEW "$new\n";}
|
---|
593 | else {print NEW $_;}
|
---|
594 | }
|
---|
595 | close(NEW);
|
---|
596 | close(OLD);
|
---|
597 | rename("$file.genesis.$$",$file) || die "Could not overwrite old file: $file";
|
---|
598 | }
|
---|
599 |
|
---|
600 |
|
---|
601 | sub open_files
|
---|
602 | {
|
---|
603 | open (SH,">/etc/wireless.conf.sh"); # Voor firewall script.
|
---|
604 | open (NWCFG,">/etc/wl/nwcfg.sh"); # Voor network config
|
---|
605 | open (DHCP,">/etc/dhcpd.conf") || die "Could not create dhcpd.conf";
|
---|
606 | open (ZEBRA,">/etc/zebra/zebra.conf") || die "Could not create zebra.conf";
|
---|
607 | open (OSPFD,">/etc/zebra/ospfd.conf") || die "Could not create ospfd.conf";
|
---|
608 | open (MRTG,">/etc/mrtg/mrtg.cfg") || die "Could not create mrtg.cfg";
|
---|
609 | open (RCCONF,">/etc/rc.conf") || die "Could not create rc.conf";
|
---|
610 | open (FREEBSD,">/etc/rc.node.conf") || die "Could not create rc.node.conf";
|
---|
611 | open (RESOLV,">/etc/resolv.conf") || die "Could not create resolv.conf";
|
---|
612 | open (NAMED,">/etc/named.conf") || die "Could not create named.conf";
|
---|
613 | }
|
---|
614 |
|
---|
615 |
|
---|
616 | sub close_files
|
---|
617 | {
|
---|
618 | close (SH);
|
---|
619 | close (NWCFG);
|
---|
620 | close (DHCP);
|
---|
621 | close (ZEBRA);
|
---|
622 | close (OSPFD);
|
---|
623 | close (MRTG);
|
---|
624 | close(RCCONF);
|
---|
625 | close(FREEBSD);
|
---|
626 | close(RESOLV);
|
---|
627 | close(NAMED);
|
---|
628 | }
|
---|
629 |
|
---|
630 | sub print_files
|
---|
631 | {
|
---|
632 | print SH $sh;
|
---|
633 | print NWCFG $nwcfg;
|
---|
634 | print DHCP $dhcp;
|
---|
635 | print ZEBRA $zebra;
|
---|
636 | print OSPFD $ospfd;
|
---|
637 | print MRTG $mrtg;
|
---|
638 | print RCFONG $rcconf;
|
---|
639 | print FREEBSD $freebsd;
|
---|
640 | print RESOLV $resolv;
|
---|
641 | print NAMED $named;
|
---|
642 | }
|
---|
643 |
|
---|
644 |
|
---|
645 | sub init_files
|
---|
646 | {
|
---|
647 | $sh=sprintf <<EOSH;
|
---|
648 | #! /bin/bash
|
---|
649 | #
|
---|
650 | # Generated by $source
|
---|
651 | # on $now
|
---|
652 | #
|
---|
653 | $svn_version
|
---|
654 |
|
---|
655 |
|
---|
656 | gw_open=$gw_open
|
---|
657 | EOSH
|
---|
658 |
|
---|
659 | $nwcfg=sprintf <<EONW;
|
---|
660 | #! /bin/bash
|
---|
661 | #
|
---|
662 | # Generated by $source
|
---|
663 | # on $now
|
---|
664 | #
|
---|
665 | # DO NOT CHANGE!
|
---|
666 | #
|
---|
667 | # $author
|
---|
668 | # home: /etc/wl/nwcfg
|
---|
669 | #
|
---|
670 | $svn_version
|
---|
671 |
|
---|
672 | EONW
|
---|
673 |
|
---|
674 |
|
---|
675 | $dhcp=sprintf <<EOD;
|
---|
676 | # dhcpd.conf
|
---|
677 | #
|
---|
678 | # Generated by $source
|
---|
679 | # on $now
|
---|
680 | #
|
---|
681 | # $author
|
---|
682 | # home: /usr/local/etc/dhcpd.conf
|
---|
683 | #
|
---|
684 | $svn_version
|
---|
685 |
|
---|
686 | option domain-name "$domain";
|
---|
687 |
|
---|
688 | default-lease-time 7200;
|
---|
689 | max-lease-time 2592000;
|
---|
690 |
|
---|
691 | ddns-update-style none;
|
---|
692 |
|
---|
693 | EOD
|
---|
694 | #foreach $ns (split(/\s+/,$NS_forward))
|
---|
695 | # {$dhcp.="option domain-name-servers ${ns};\n";}
|
---|
696 | {$dhcp.="option domain-name-servers ${master_ip};\n";}
|
---|
697 |
|
---|
698 | $dhcp.="\n\n";
|
---|
699 |
|
---|
700 | $zebra= sprintf <<EOZ;
|
---|
701 | ! -*- zebra -*-
|
---|
702 | !
|
---|
703 | ! Zebra configuration for $hostname
|
---|
704 | !
|
---|
705 | ! Generated by $source
|
---|
706 | ! on $now
|
---|
707 | !
|
---|
708 | ! DO NOT CHANGE!
|
---|
709 | !
|
---|
710 | ! $author
|
---|
711 | ! home=/usr/local/etc/zebra/zebra.conf
|
---|
712 | !
|
---|
713 | $svn_version
|
---|
714 |
|
---|
715 | hostname $hostname
|
---|
716 | password getronics
|
---|
717 | enable password getronics
|
---|
718 |
|
---|
719 | ! Interfaces
|
---|
720 |
|
---|
721 | interface lo0
|
---|
722 | description loopback
|
---|
723 | ip address 127.0.0.1/8
|
---|
724 |
|
---|
725 |
|
---|
726 | EOZ
|
---|
727 |
|
---|
728 | $ospfd=init_ospfd();
|
---|
729 |
|
---|
730 | $mrtg=sprintf <<EOM;
|
---|
731 |
|
---|
732 | #
|
---|
733 | # mrtg configuration for $hostname
|
---|
734 | #
|
---|
735 | # Generated by $source
|
---|
736 | # on $now
|
---|
737 | #
|
---|
738 | # DO NOT CHANGE!
|
---|
739 | #
|
---|
740 | # $author
|
---|
741 | # home=/etc/mrtg
|
---|
742 | #
|
---|
743 | $svn_version
|
---|
744 |
|
---|
745 | Workdir: /var/www/html/mrtg
|
---|
746 |
|
---|
747 |
|
---|
748 | #
|
---|
749 | #
|
---|
750 | #
|
---|
751 |
|
---|
752 | Target[${hostname}_load]: `/usr/local/sbin/cpuload.pl`
|
---|
753 | MaxBytes[${hostname}_load]: 1000
|
---|
754 | Title[${hostname}_load]: CPU load on $hostname
|
---|
755 | PageTop[${hostname}_load]: <H1>CPU load on ${hostname}</H1>
|
---|
756 | Options[${hostname}_load]: transparent, gauge, nopercent
|
---|
757 | Legendi[${hostname}_load]: 5min
|
---|
758 | Legendo[${hostname}_load]: 15min
|
---|
759 | ShortLegend[${hostname}_load]: %
|
---|
760 | YLegend[${hostname}_load]: %
|
---|
761 | WithPeak[${hostname}_load]: wmy
|
---|
762 |
|
---|
763 | Target[${hostname}_mem]: `/usr/local/sbin/memusage.pl`
|
---|
764 | MaxBytes[${hostname}_mem]: 256000000
|
---|
765 | Title[${hostname}_mem]: Memory usage on ${hostname}
|
---|
766 | PageTop[${hostname}_mem]: <H1>Memory usage on ${hostname}</H1>
|
---|
767 | Options[${hostname}_mem]: transparent, gauge, nopercent
|
---|
768 | Legendi[${hostname}_mem]: free
|
---|
769 | Legendo[${hostname}_mem]: swap
|
---|
770 | ShortLegend[${hostname}_mem]: Bytes
|
---|
771 | YLegend[${hostname}_mem]: Bytes
|
---|
772 | WithPeak[${hostname}_mem]: wmy
|
---|
773 |
|
---|
774 | Target[${hostname}_up]: `/usr/local/sbin/uptime.pl`
|
---|
775 | MaxBytes[${hostname}_up]: 10000
|
---|
776 | Title[${hostname}_up]: ${hostname} Uptime
|
---|
777 | PageTop[${hostname}_up]: <H1>${hostname} Uptime</H1>
|
---|
778 | Options[${hostname}_up]: transparent, gauge, nopercent
|
---|
779 | Legendi[${hostname}_up]: uptime
|
---|
780 | Legendo[${hostname}_up]:
|
---|
781 | ShortLegend[${hostname}_up]: Days
|
---|
782 | YLegend[${hostname}_up]: Days
|
---|
783 | WithPeak[${hostname}_up]: wmy
|
---|
784 |
|
---|
785 | EOM
|
---|
786 |
|
---|
787 | $rcconf.=sprintf <<EORC1;
|
---|
788 | # This file is read by /etc/rc.conf - and specific to wireless
|
---|
789 | # leiden. Please make all changes in Genesis.
|
---|
790 | #
|
---|
791 | # Generated by $source
|
---|
792 | # on $now
|
---|
793 | #
|
---|
794 | # $author
|
---|
795 | #
|
---|
796 | $svn_version
|
---|
797 |
|
---|
798 | hostname="$hostname.wLeiden.NET"
|
---|
799 | location="$location"
|
---|
800 |
|
---|
801 | #ifconfig_lo0_alias0="inet $master_ip/32"
|
---|
802 | EORC1
|
---|
803 |
|
---|
804 | #$freebsd.=sprintf <<EOFB1;
|
---|
805 | # Wireless Leiden startup script om wireless kaarten te initialiseren
|
---|
806 | #
|
---|
807 | # Generated by $source
|
---|
808 | # on $now
|
---|
809 | #
|
---|
810 | # $author
|
---|
811 | # home=/etc/wl/freebsd.sh
|
---|
812 | #
|
---|
813 | #$svn_version
|
---|
814 | #EOFB1
|
---|
815 |
|
---|
816 | $resolv.=sprintf <<EOR1;
|
---|
817 | search wleiden.net .
|
---|
818 |
|
---|
819 | # Local machine / own nameserver.
|
---|
820 | nameserver 127.0.0.1
|
---|
821 | EOR1
|
---|
822 |
|
---|
823 | #foreach $ns (split(/\s+/,$NS_resolv)) {
|
---|
824 | # $resolv.="nameserver $ns\n";
|
---|
825 | #}
|
---|
826 |
|
---|
827 | foreach $if (sort keys %config) {
|
---|
828 | foreach $ns (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if})) {
|
---|
829 | next unless $ns =~ m/\d+/;
|
---|
830 | $resolv.="# Nameserver on adjacent node - $DESC{$if} over $if\nnameserver $ns\n\n";
|
---|
831 | };
|
---|
832 | };
|
---|
833 |
|
---|
834 |
|
---|
835 |
|
---|
836 | $named.=sprintf <<EON1;
|
---|
837 | # named.conf
|
---|
838 | #
|
---|
839 | # Generated by $source
|
---|
840 | # on $now
|
---|
841 | #
|
---|
842 | # $author
|
---|
843 | # home=/etc/namedb/named.conf
|
---|
844 | #
|
---|
845 | $svn_version
|
---|
846 |
|
---|
847 | options {
|
---|
848 | directory "/var/db/namedb";
|
---|
849 | forward only;
|
---|
850 | forwarders {
|
---|
851 | 172.31.255.1; // Proxy.Demon.wLeiden.NET
|
---|
852 | 172.18.8.66; // Internet GW Jasper
|
---|
853 | // 172.17.32.66; // Internet GW Dirkx
|
---|
854 | EON1
|
---|
855 |
|
---|
856 | %x=();
|
---|
857 | foreach $ns (split(/\s+/,$NS_forward)) {
|
---|
858 | next if $ns eq $master_ip;
|
---|
859 | $named.=" ${ns};\n";
|
---|
860 | $x{ $ns } = 1;
|
---|
861 | }
|
---|
862 |
|
---|
863 | foreach $if (sort keys %config) {
|
---|
864 | foreach $ns (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if})) {
|
---|
865 | next unless $ns =~ m/\d+/;
|
---|
866 | $x{ $ns } = 0;
|
---|
867 | };
|
---|
868 | };
|
---|
869 |
|
---|
870 | #foreach(sort keys(%x)) {
|
---|
871 | # next if $x{$_};
|
---|
872 | # $named.="// $_; // Next door Neighbour..\n";
|
---|
873 | # }
|
---|
874 |
|
---|
875 | $named.=sprintf <<EON2;
|
---|
876 | };
|
---|
877 | };
|
---|
878 |
|
---|
879 | zone "." {
|
---|
880 | type hint;
|
---|
881 | file "/etc/namedb/named.root";
|
---|
882 | };
|
---|
883 |
|
---|
884 | zone "0.0.127.IN-ADDR.ARPA" {
|
---|
885 | type master;
|
---|
886 | file "/etc/namedb/localhost.rev";
|
---|
887 | };
|
---|
888 |
|
---|
889 | zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT" {
|
---|
890 | type master;
|
---|
891 | file "/etc/namedb/localhost-v6.rev";
|
---|
892 | };
|
---|
893 |
|
---|
894 | EON2
|
---|
895 |
|
---|
896 | push (@ZONES,"wLeiden.NET");
|
---|
897 | for ($i=16;$i<32;$i++) {push(@ZONES,"$i.172.in-addr.arpa");}
|
---|
898 | foreach $zone (@ZONES)
|
---|
899 | {
|
---|
900 | $named.=sprintf<<EON3;
|
---|
901 | zone "$zone" {
|
---|
902 | type slave;
|
---|
903 | file "slave-$zone";
|
---|
904 | masters { 172.18.8.66; 212.61.66.38;};
|
---|
905 | };
|
---|
906 |
|
---|
907 | EON3
|
---|
908 | }
|
---|
909 |
|
---|
910 |
|
---|
911 | $snmpd=<<EOM;
|
---|
912 | # /usr/local/share/snmp/snmpd.local.conf
|
---|
913 | # overwrites/augments the data in snmpd.conf
|
---|
914 | # which is identical on each node with data
|
---|
915 | # specific to this node.
|
---|
916 | #
|
---|
917 | EOM
|
---|
918 |
|
---|
919 | $snmpd .= qq|
|
---|
920 | # Location of the physical node.
|
---|
921 | #
|
---|
922 | syslocation "$location"
|
---|
923 |
|
---|
924 | | if defined $location;
|
---|
925 |
|
---|
926 | $snmpd .= qq|
|
---|
927 | # Location of the physical node.
|
---|
928 | #
|
---|
929 | syscontact "$contact"
|
---|
930 |
|
---|
931 | | if defined $contact;
|
---|
932 |
|
---|
933 | $snmpd .=
|
---|
934 | "# Verify that disk is RO\n".
|
---|
935 | "sh diskro /usr/local/sbin/diskro.sh\n\n"
|
---|
936 | if ($DISK eq 'FLASH');
|
---|
937 |
|
---|
938 | $snmpd.=<<EOM;
|
---|
939 | # end of file
|
---|
940 | EOM
|
---|
941 | }
|
---|
942 |
|
---|
943 |
|
---|
944 |
|
---|
945 | sub init_ospfd
|
---|
946 | {
|
---|
947 |
|
---|
948 | local($init)=sprintf <<EOO;
|
---|
949 | ! -*- ospfd -*-
|
---|
950 | !
|
---|
951 | ! osfpd configuration for $hostname
|
---|
952 | !
|
---|
953 | ! Configuration generated by $source
|
---|
954 | ! on $now
|
---|
955 | !
|
---|
956 | ! DO NOT CHANGE!
|
---|
957 | !
|
---|
958 | ! $author
|
---|
959 | ! home=/usr/local/etc/zebra/ospfd.conf
|
---|
960 | !
|
---|
961 | $svn_version
|
---|
962 |
|
---|
963 | hostname $hostname
|
---|
964 | password getronics
|
---|
965 | enable password getronics
|
---|
966 |
|
---|
967 | interface lo0
|
---|
968 | EOO
|
---|
969 | return($init);
|
---|
970 | }
|
---|
971 |
|
---|
972 |
|
---|
973 | sub mrtg1
|
---|
974 | {
|
---|
975 | $mrtg.=sprintf <<EOM2;
|
---|
976 | Target[${if}_traf]: `/usr/local/sbin/ipchains_traf.pl ${if}`
|
---|
977 | MaxBytes[${if}_traf]: $SPEED{$if}
|
---|
978 | Title[${if}_traf]: Traffic Analysis ${if} $SDESC{$if}
|
---|
979 | PageTop[${if}_traf]: <H1>Traffic on $if $DESC{$if}</H1>
|
---|
980 | Options[${if}_traf]: transparent
|
---|
981 | WithPeak[${if}_traf]: wmy
|
---|
982 |
|
---|
983 | EOM2
|
---|
984 |
|
---|
985 | if ($functions_only<1)
|
---|
986 | {
|
---|
987 | ipchains("-N ${if}-i");
|
---|
988 | ipchains("-N ${if}-o");
|
---|
989 | ipchains("-I input -i ${if} -j ${if}-i");
|
---|
990 | ipchains("-I output -i ${if} -j ${if}-o");
|
---|
991 |
|
---|
992 | }
|
---|
993 | if ($TYPE{$if}=~/wireless/i)
|
---|
994 | {
|
---|
995 | $mrtg.=sprintf <<EOM3;
|
---|
996 | Target[${if}_quality]: `/usr/local/sbin/wlan_quality.pl ${if}`
|
---|
997 | MaxBytes1[${if}_quality]: 100
|
---|
998 | MaxBytes2[${if}_quality]: 100
|
---|
999 | Title[${if}_quality]: Quality $if $SDESC{$if}
|
---|
1000 | PageTop[${if}_quality]: <H1>Quality $if $DESC{$if}</H1>
|
---|
1001 | Options[${if}_quality]: transparent, gauge, nopercent
|
---|
1002 | Legendi[${if}_quality]: Quality
|
---|
1003 | Legendo[${if}_quality]: Noise
|
---|
1004 | ShortLegend[${if}_quality]: /100
|
---|
1005 | YLegend[${if}_quality]: /100
|
---|
1006 | WithPeak[${if}_quality]: wmy
|
---|
1007 |
|
---|
1008 | Target[${if}_rate]: `/usr/local/sbin/wlan_bitrate.pl ${if}`
|
---|
1009 | MaxBytes1[${if}_rate]: 11
|
---|
1010 | MaxBytes2[${if}_rate]: 11
|
---|
1011 | Title[${if}_rate]: Bitrate $if $SDESC{$if}
|
---|
1012 | PageTop[${if}_rate]: <H1>Bitrate $if $DESC{$if}</H1>
|
---|
1013 | Options[${if}_rate]: transparent, gauge, nopercent
|
---|
1014 | Legendi[${if}_rate]: Bitrate
|
---|
1015 | ShortLegend[${if}_rate]: Mb/s
|
---|
1016 | YLegend[${if}_rate]: Mb/s
|
---|
1017 | WithPeak[${if}_rate]: wmy
|
---|
1018 |
|
---|
1019 | EOM3
|
---|
1020 | if ($MODE{$if}=~/master/i)
|
---|
1021 | {
|
---|
1022 | $mrtg.=sprintf <<EOM4;
|
---|
1023 | Target[${if}_users]: `/usr/local/sbin/wlan_users.pl ${if}`
|
---|
1024 | MaxBytes[${if}_users]: 100
|
---|
1025 | Title[${if}_users]: Users on $if $SDESC{$if}
|
---|
1026 | PageTop[${if}_users]: <H1>Users on $if $DESC{$if}</H1>
|
---|
1027 | Options[${if}_users]: transparent, gauge, nopercent
|
---|
1028 | Legendi[${if}_users]: Users
|
---|
1029 | ShortLegend[${if}_users]: users
|
---|
1030 | YLegend[${if}_users]: users
|
---|
1031 | WithPeak[${if}_users]: wmy
|
---|
1032 |
|
---|
1033 | EOM4
|
---|
1034 | }
|
---|
1035 | } # wireless
|
---|
1036 |
|
---|
1037 |
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 | sub mrtg2
|
---|
1041 | {
|
---|
1042 | $mrtg.=sprintf <<EOM5;
|
---|
1043 | Target[${if}_lat]: `/usr/local/sbin/latency.pl $p`
|
---|
1044 | MaxBytes1[${if}_lat]: 100
|
---|
1045 | MaxBytes2[${if}_lat]: 200
|
---|
1046 | Title[${if}_lat]: Latency/PktLoss Analysis to $p on $if $SDESC{$if}
|
---|
1047 | PageTop[${if}_lat]: <H1>Latency/PktLoss to $p on $if $DESC{$if}</H1>
|
---|
1048 | Options[${if}_lat]: transparent, gauge, nopercent
|
---|
1049 | Legendi[${if}_lat]: PacketLoss%
|
---|
1050 | Legendo[${if}_lat]: Max Latency (ms)
|
---|
1051 | ShortLegend[${if}_lat]: %/ms
|
---|
1052 | YLegend[${if}_lat]: %/ms
|
---|
1053 | WithPeak[${if}_lat]: wmy
|
---|
1054 |
|
---|
1055 | EOM5
|
---|
1056 |
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | sub ahum
|
---|
1060 | {
|
---|
1061 | print "AHUM!\n";
|
---|
1062 | }
|
---|
1063 |
|
---|
1064 | #return(1);
|
---|
1065 |
|
---|