Quellcode-Programm-1
Version vom 20. Juni 2006, 14:51 Uhr von Carbon4 (Diskussion | Beiträge)
Ziel dieses Programms ist es,ausgehend vom eigenen Default-Gateway alle anderen
Router im Netz per wget auszulesen und eine Menschen/Maschinenlesbare Datei zu erzeugen,die folgendermassen aussieht:
# folgendes Schema: IP,CPU-Last,GPS-X,GPX-Y,Nodename,emails,Telefonnummer,uptime in Tagen 172.16.1.11 = 0.20 = 11.325 50.978 = hegel-11 = harv|at|radiostudio|dot|org = ? = 72 172.16.1.112 = 0.28 = 11.322 50.974 = Humboldt-33 = coco75#gmx+net = ? = 10 172.16.1.118 = 0.47 = ? ? = ? = ? = ? = 43 172.16.1.13 = 0.21 = ? ? = ? = ? = ? = 7 172.16.1.18 = 1.00 = 11.320 50.975 = liszt-18 = lars|pingfm|org = ? = 1 . . . 172.16.7.166 = 0.26 = 11.317 50.987 = Herbst-29 = jens-sieber#web+de = ? = 0 172.16.1.11 - 172.16.1.31 - 172.16.1.19 172.16.1.112 - 172.16.1.24 172.16.1.118 - 172.16.10.2 - 172.16.1.24 - 172.16.1.43 - 172.16.1.18 172.16.1.13 - 172.16.10.2
/* makenodemap2.rexx v0.1a 11.apr.2005 */ wget = 'progs:communication/tcpip/browser/wget17 >nil: -q -t 2 -T 9 -O ' httx = 'progs:text/convert/httx >nil: ' grep = 'progs:text/convert/grep ' stringer = 'progs:text/convert/stringer ' pre = '172.16.' /* auf festeKnoten beschraenken */ ip = '172.16.5.28' /* startadresse = stdgateway */ f0 = 'ram:ausgabe.txt' f1 = 'ram:routen.txt' f2 = 'ram:routen.html' f3 = 'ram:alive-liste'; f3a = 'ram:alive-liste.unsort' f4 = 'ram:routen-UH.txt' f5 = 'ram:routen-eth.txt' f6 = 'ram:kontakt.html' f7 = 'ram:kontakt.txt' f8 = 'ram:status.html' f9 = 'ram:status.txt' fa = 'ram:2paint.txt' address command wget||f2||' "http://'||ip||'/cgi-bin-status.html?post_route=Routen"' address command httx||f2||' '||f1 address command 'echo >'||f3a||' '||ip IF open(x,f1,'R') THEN DO DO until eof(x) z = readln(x) IF substr(z,1,7) = pre & pos(pre||'0.0',z) = 0 THEN DO address command 'echo >>'||f3a||' '||pre||subword(substr(z,8),1,1) END END close(x) END address command 'delete '||f1 address command 'delete '||f2 address command 'progs:text/convert/psort '||f3a||' '||f3 IF open(y,f0,'W') THEN DO IF open(x,f3,'R') THEN DO DO until eof(x) ip = readln(x) say ip address command 'delete '||f5 address command 'delete '||f7 address command 'delete '||f9 address command wget||f2' "http://'||ip||'/cgi-bin-status.html?post_route=Routen"' address command httx||f2||' '||f1 address command grep||'>'||f4||' UH '||f1 address command grep||'>'||f5||' eth '||f4 address command wget||f6||' "http://'||ip||'/cgi-bin-contact.html"' address command httx||f6||' '||f7 address command wget||f8||' "http://'||ip||'/cgi-bin-status.html"' address command httx||f8||' '||f9 name = ?; gpsx = ?; gpsy = ?; cpu = ?; mail = ?; fon = ?; uptime = ? IF open(xx,f7,'R') then do DO until eof(xx) z = TRANSLATE(readln(xx),'.',',') IF pos('E-Mail',z) > 0 THEN mail = COMPRESS(TRANSLATE(substr(z,8),'#+','@.')) IF mail = '' then mail = ? IF pos('Telefon',z) > 0 THEN fon = COMPRESS(substr(z,9)) IF fon = '' THEN fon = ? IF pos('GPS:',upper(z)) >0 then DO gps = substr(z,pos('GPS:',upper(z))+4) gpsx = subword(gps,1,1) gpsy = subword(gps,2,1) END IF DATATYPE(gpsx)~='NUM' | DATATYPE(gpsy)~='NUM' THEN DO gpsx=?; gpsy=? END ELSE IF gpsx > gpsy THEN DO temp = gpsx gpsx = gpsy gpsy = temp END IF pos('NODE:',upper(z)) >0 then name = subword(substr(z,pos('NODE:',upper(z))+5),1,1) END close(xx) END IF open(xx,f9,'R') then do DO until eof(xx) z = readln(xx) IF pos('average:',z) >0 then cpu = subword(substr(z,pos('average:',z)+9),3,1) IF pos('days',z) > 0 then uptime = subword(substr(z,pos(' up ',z)+4),1,1) END close(xx) END out = ip||' = '||cpu||' = '||gpsx||' '||gpsy||' = '||name||' = '||mail||' = '||fon||' = '||uptime say out IF ip~= '' THEN DO WRITELN(y,out) WRITELN(y,ip) END IF open(xx,f5,'R') then do DO until eof(xx) z = readln(xx) IF substr(z,1,7) = pre then DO WRITELN(y,'- '||subword(z,1,1)) say '- '||subword(z,1,1) END END close(xx) END END CLOSE(y) END address command grep||'>'||fa||' = '||f0 address command grep||'>>'||fa||' = '||f0||' -v' EXIT