1 | 1 | simandl | #!/usr/bin/perl |
2 | | | # |
3 | | | # Petr Simandl, www.simandl.cz |
4 | | | # |
5 | | | |
6 | 2 | simandl | $date = `date`; |
7 | 1 | simandl | print "Content-type: text/html\n\n"; |
8 | | | |
9 | | | print "<HTML><HEAD><META HTTP-EQUIV=Pragma CONTENT=no-cache></HEAD><BODY>\n"; |
10 | | | |
11 | | | print "Porovnani obsahu wiki <a href=\"http://czfree.net/wiki/Registrovane_cloudy\">Registrovane_cloudy</a> |
12 | 2 | simandl | s aktualnima <a href=\"/cgi-bin/route.cgi\">routama</a> : $date"; |
13 | 1 | simandl | |
14 | | | print "<pre>"; |
15 | | | |
16 | | | @gl_cloudy=`wget -q -O - http://czfree.net/wiki/Registrovane_cloudy`; |
17 | | | @gl_routy=`ip ro ls | grep ^10 `; |
18 | | | |
19 | 2 | simandl | $gl_pocetonline = 0; |
20 | | | $gl_pocetzastupcu = 0; |
21 | | | $gl_pocethlasu = 0; |
22 | | | $gl_pocetofflinehlasu = 0; |
23 | 1 | simandl | |
24 | | | foreach $gl_line (@gl_cloudy) |
25 | | | { |
26 | | | if ($gl_line =~ /^\<td\> AS6/) |
27 | | | {#print "$gl_pole[4] $gl_pole[5]\n"; |
28 | | | $gl_line =~ s/<td> //; |
29 | | | $gl_line =~ s/<\/td><td>/\t/g; |
30 | | | |
31 | | | @gl_pole=split("\t",$gl_line); |
32 | | | $gl_as = $gl_pole[0]; |
33 | | | $gl_as =~ s/ //g; |
34 | | | $gl_rozsah = $gl_pole[1]; |
35 | | | $gl_rozsah =~ s/ //g; |
36 | | | @gl_rozsah=split("a",$gl_rozsah); |
37 | | | |
38 | | | $gl_zastupce = $gl_pole[2]; |
39 | 2 | simandl | $gl_zastupce =~ s/ //g; |
40 | 1 | simandl | $gl_udaje = $gl_pole[3]; |
41 | | | $gl_online = $gl_pole[4]; |
42 | 2 | simandl | $gl_online =~ s/\n//g; |
43 | | | $gl_online =~ s/ //g; |
44 | | | $gl_hlas = $gl_pole[5]; |
45 | | | $gl_hlas =~ s/\n//g; |
46 | | | $gl_hlas =~ s/ //g; |
47 | 1 | simandl | $gl_pritomno = 0; |
48 | | | $gl_podobne = ""; |
49 | 3 | simandl | $gl_ping = $gl_rozsah[0]; |
50 | | | $gl_ping =~ s/\//xx/g; |
51 | | | $gl_bgp = $gl_as; |
52 | | | $gl_bgp =~ s/AS//g; |
53 | 1 | simandl | |
54 | 2 | simandl | if ("$gl_hlas" eq "ano") {$gl_pocethlasu += 1}; |
55 | | | if ("$gl_online" eq "ano") {$gl_pocetonline += 1}; |
56 | | | if ("$gl_zastupce" ne "ne") {$gl_pocetzastupcu += 1}; |
57 | | | |
58 | 3 | simandl | print "<a href=\"http://ripe.czfree.net/index.php?action=object.search¶mvalue=$gl_rozsah\">$gl_as</a> (historie "; |
59 | | | print "<a href=\"http://sitelka.jablonka.cz/hotsanic/bgp/$gl_bgp.html\">bgp</a> "; |
60 | | | print "<a href=\"http://sitelka.jablonka.cz/hotsanic/ping/$gl_ping.html\">pingu</a>) ma mit $gl_rozsah a nalezeno: "; |
61 | 1 | simandl | |
62 | | | foreach $gl_routa (@gl_rozsah) |
63 | | | { |
64 | | | foreach $gl_iprouta (@gl_routy) |
65 | | | { |
66 | | | @gl_linka=split(" ",$gl_iprouta); |
67 | | | if ("$gl_linka[0]" eq "$gl_routa") |
68 | | | { |
69 | | | $gl_pritomno += 1; |
70 | | | print "$gl_routa "; |
71 | | | } else { |
72 | | | @gl_ipnum=split("\\.",$gl_linka[0]); |
73 | | | @gl_ronum=split("\\.",$gl_routa); |
74 | | | if ("$gl_ipnum[1]" eq "$gl_ronum[1]") |
75 | | | { |
76 | | | $gl_podobne .= "<a href=\"http://ripe.czfree.net/index.php?action=object.search¶mvalue=$gl_linka[0]\">$gl_linka[0]</a> "; |
77 | | | } |
78 | | | } |
79 | | | } |
80 | | | } |
81 | | | if ($gl_pritomno == 0) |
82 | 2 | simandl | { print "nic\t"; |
83 | 1 | simandl | } |
84 | | | if ($gl_podobne) |
85 | | | { |
86 | | | print "\tpodobne routy: $gl_podobne "; |
87 | | | } |
88 | 2 | simandl | if (("$gl_hlas" eq "ano") && ($gl_pritomno == 0) && !($gl_podobne)) |
89 | | | { |
90 | | | print " <blink>!</blink>$gl_zastupce<blink>!</blink> $gl_online $gl_hlas \n"; |
91 | | | $gl_pocetofflinehlasu += 1; |
92 | | | } else { |
93 | | | print " $gl_zastupce $gl_online $gl_hlas \n"; |
94 | 1 | simandl | } |
95 | 2 | simandl | } |
96 | 1 | simandl | } |
97 | | | |
98 | 2 | simandl | print "Shrnuti wiki:\n"; |
99 | | | print "Pocet zastupcu : $gl_pocetzastupcu\n"; |
100 | | | print "Pocet online : $gl_pocetonline\n"; |
101 | | | print "Pocet zastupcu s hlasovacim pravem : $gl_pocethlasu\n"; |
102 | | | print "Pocet zastupcu kteri prave ted maji sit offline : $gl_pocetofflinehlasu\n"; |
103 | 1 | simandl | print "</pre></body></html>"; |