Zeile 12: |
Zeile 12: |
| | | |
| ===Lösung Programm=== | | ===Lösung Programm=== |
| + | Hier schonmal ein alpha-release 8-) |
| + | Einfach ausschneiden & auf den Router kopieren...(naja,fast...) |
| <pre> | | <pre> |
| #!/bin/sh | | #!/bin/sh |
− | echo "Content-type: text/html";echo;cat<<EOF | + | # |
− | $(wl scan)<HTML><TITLE>$(nvram get wifi_ipaddr)/$(nvram get lan_ipaddr)</TITLE><BODY><PRE><b>WLAN</b> | + | # version.......: infopage_05-jan-2005 |
− | $(a=$(wl noise | awk '{ print $3 }');b=$(wl rssi | awk '{ print $3 }');let c=b-a;echo SIGNALRAUSCHABSTAND: $c) | + | # author........: bastian bittorf |
− | SSID: $(nvram get wl0_ssid) | + | # contact.......: infopage.20.bastian@spamgourmet.org |
− | $(echo KANAL/_real/mW/_real: $(nvram get wl0_channel)/$(wl assoc | grep Channel | awk '{ print $11 }')/$(
| + | # licence.......: GPL |
− | nvram get ff_txpwr)/$(wl txpwr | awk '{ print $3 }')) | + | # requirements..: 600kb runtime-memory |
− | $(g="2";if [ "$(nvram get wl0_antdiv)" = "0" ];then g="L";fi
| + | # tested........: fff v1.0.7 |
− | if [ "$(nvram get wl0_antdiv)" = "1" ];then g="R";fi
| + | # |
− | h="2";if [ "$(nvram get ff_txant)" = "0" ];then h="L";fi
| + | # This script generates helpful infos about your fff-openwrt-router |
− | if [ "$(nvram get ff_txant)" = "1" ];then h="R";fi
| + | # Its main purpose was to avoid loading hundreds of kilobytes from |
− | echo Empf/SendANT: $g/$h)
| + | # slow longrange wireless-links only to know some unmuch infos |
− | $(h="BG";if [ "$(nvram get wl0_gmode)" = "0" ];then h="B";fi;if [ "$(nvram get wl0_gmode)" = "2" ];then h="G";fi
| + | # Output should be HTML,but human AND machine-readable. |
− | echo MODE/_real: $h/$(if [ "$(wl assoc | grep "Supported" | awk '{ printf $15 }')" = "54" ]; then echo "G";else echo "B";fi))
| + | # Total data-output should not be around 1000 bytes. |
− | BASERATE: $(nvram get wl0_rateset) | + | # |
− | RATE/_real: $(nvram get wl0_rate)/$(wl rate | awk '{ print $3 }') | + | # Which programs are needed to un this? |
− | CTS/BURST: $(nvram get wl0_gmode_protection)/$(nvram get wl0_frameburst) | + | # ash,wl,busybox (awk,cat,echo,grep,ipcalc,wget) |
− | FRAG/RTS/MTU: $(nvram get wl0_frag)/$(nvram get wl0_rts)/$(nvram get ff_mtu) | + | # |
− | WEP/_real: $(nvram get wl0_wep)/$(if [ "$(wl assoc | grep WEP | awk '{ print $5 }')" = "WEP" ]; then echo "on";else echo "off";fi) | + | # ----------------------------------------------------------------- |
− | <b>KONTAKT</b> | + | # |
− | MAIL: $(nvram get ff_adm_mail) | + | # |
− | FON: $(nvram get ff_adm_tel) | + | # Introducing HTMLoutput for client-browser |
− | ORT/GPSX/Y: $(nvram get ff_adm_loc)/$(nvram get gpsx)/$(nvram get gpsy) | + | # Sadly we have to use text/html rather than text/plain,because |
− | <b>SYSTEM</b> | + | # i want to use <b> for some bold-text = better humanreadable |
− | UP: $(cat /proc/uptime | awk '{ printf "%1.1f",$1/3600 }')h | + | # |
− | vFFF/OLSRd: $(ipkg status | awk '{ if(index($0,"webadmin")>1) a++; if (a>0) {b++;if (b==4) print $2;break} }')/$( | + | |
− | ipkg status | awk '{ if(index($0,"olsrd")>1) a++; if (a>0) {b++;if (b==5) print $2;break} }') | + | echo "Content-type: text/html";echo |
− | $(cat /tmp/dmesg.txt|awk '{ if($1=="CPU:"){printf $0;exit}}')$(cat /proc/loadavg|awk '{printf "/";printf "%3.0f",$3*100}'; | + | |
− | cat /proc/cpuinfo|awk '{ if($1=="cpu")printf "%% / "$4"-"$5;if($1=="BogoMIPS"){print " / "$3"bmips";exit}}')
| + | # |
− | BOARDrev/type/num/flags/2: $(nvram get boardrev|awk '{printf $0"/"}'; | + | # Evaluation query-string |
− | nvram get boardtype|awk '{printf $0"/"}'; | + | # For faster access the hole infopage will be silently generated |
− | nvram get boardnum|awk '{printf $0"/"}'; | + | # trough crond every 15mins. Only if you specify an url+"?l" |
− | nvram get boardflags|awk '{printf $0"/"}'; | + | # you get livedata, but you have to wait some seconds. |
| + | # |
| + | |
| + | if [ "$QUERY_STRING" = "l" ]; then echo "live daten...";fi |
| + | |
| + | # |
| + | # Evaluation query-string |
| + | # If the clientbrowsers query is not "l" get lifedata. |
| + | # |
| + | |
| + | if [ "$QUERY_STRING" != "l" ]; then echo "generierte page...";fi |
| + | |
| + | # |
| + | # WIFI-scan |
| + | # Starting wifiscan. We check out the results later |
| + | # to give the wireless-device some time for the job. |
| + | # |
| + | |
| + | wl scan |
| + | |
| + | # |
| + | # IPs and netmasks in HTML-Title |
| + | # For better orientation with multiple tabs i prefer to |
| + | # read the wifi/lan-IPs and "short" netmasks in title. |
| + | # |
| + | |
| + | echo "<HTML><TITLE>"$( |
| + | nvram get wifi_ipaddr)/$( |
| + | ipcalc -p $(nvram get wifi_netmask)| |
| + | awk -F= '{print $2}'),$( |
| + | nvram get lan_ipaddr)/$( |
| + | ipcalc -p $(nvram get lan_netmask)| |
| + | awk -F= '{print $2}')"</TITLE><BODY><PRE>" |
| + | |
| + | # |
| + | # Calculating signal-noise-difference |
| + | # ash cant handle adding negative numbers, |
| + | # so i make them positve with "number*-1" |
| + | # does anyone know a simpler/faster/better way? |
| + | # |
| + | |
| + | echo "<b>WLAN</b>" |
| + | echo "SIGNALRAUSCHABSTAND: "$( |
| + | echo $(($((($(wl noise|awk '{print $3}'))*-1))-$(($(wl rssi|awk '{print $3}')*-1))))) |
| + | |
| + | # |
| + | # SSID. |
| + | # I never heard of associated routers with different SSID, |
| + | # so i think its enough to print the configured SSID. |
| + | # |
| + | |
| + | echo "SSID: "$(nvram get wl0_ssid) |
| + | |
| + | # |
| + | # Channel und transmit/output-power. |
| + | # In fact we know the beavior of routers which |
| + | # have different real and conifgured values. |
| + | # Here we can track this. |
| + | # |
| + | |
| + | echo "KANAL/_real/mW/_real: "$( |
| + | nvram get wl0_channel)/$( |
| + | wl assoc|grep Channel|awk '{print $11}')/$( |
| + | nvram get ff_txpwr)/$( |
| + | wl txpwr|awk '{print $3}') |
| + | |
| + | # |
| + | # Used Antenna / diversity |
| + | # Here we track the configured |
| + | # transmit and receive-antennas. |
| + | # To save time we take defaults ("2"). |
| + | # |
| + | |
| + | g=2 |
| + | if [ "$(nvram get wl0_antdiv)" = "0" ];then g=L;fi |
| + | if [ "$(nvram get wl0_antdiv)" = "1" ];then g=R;fi |
| + | h=2 |
| + | if [ "$(nvram get ff_txant)" = "0" ];then h=L;fi |
| + | if [ "$(nvram get ff_txant)" = "1" ];then h=R;fi |
| + | echo "Empf/SendANT: "$g/$h |
| + | |
| + | # |
| + | # Use of B-mode or G-mode (801.11b/g 11/54mbit) |
| + | # We know the beavior of broadcom-adhoc-mode. |
| + | # After some time a big ad-hoc network falls into |
| + | # B-mode and normally never raises into G. |
| + | # Here we track configured and real mode. |
| + | # |
| + | |
| + | h=BG |
| + | if [ "$(nvram get wl0_gmode)" = "0" ];then h=B;fi |
| + | if [ "$(nvram get wl0_gmode)" = "2" ];then h=G;fi |
| + | echo "MODE/_real: "$h/$( |
| + | if [ "$(wl assoc|grep "Supported"|awk '{printf $15}')" = "54" ] |
| + | then echo G |
| + | else echo B |
| + | fi) |
| + | |
| + | # |
| + | # Baserate. |
| + | # Nothing to say. |
| + | # |
| + | |
| + | echo "BASERATE: "$( |
| + | nvram get wl0_rateset) |
| + | |
| + | # |
| + | # Transmit-rate. |
| + | # Here we can see the configured max-rate |
| + | # and the real,actual rate. i.e. 0/5.5 |
| + | |
| + | echo "RATE/_real: "$( |
| + | nvram get wl0_rate)/$( |
| + | wl rate|awk '{print $3}') |
| + | |
| + | # |
| + | # CTS & Frameburst |
| + | # Configured values. |
| + | # |
| + | |
| + | echo "CTS/BURST: "$( |
| + | nvram get wl0_gmode_protection)/$( |
| + | nvram get wl0_frameburst) |
| + | |
| + | # |
| + | # FragmentationHold, RTS , MTU |
| + | # Configrued values. |
| + | # |
| + | |
| + | echo "FRAG/RTS/MTU: "$( |
| + | nvram get wl0_frag)/$( |
| + | nvram get wl0_rts)/$( |
| + | nvram get ff_mtu) |
| + | |
| + | # |
| + | # WEP-crypto on/off |
| + | # We know the behavior of routers which |
| + | # have configured wep but running uncrypted, |
| + | # and the opposite. Here we track this. |
| + | |
| + | echo "WEP/_real: "$( |
| + | nvram get wl0_wep)/$( |
| + | if [ "$(wl assoc|grep WEP|awk '{print $5}')" = "WEP" ] |
| + | then echo on |
| + | else echo off |
| + | fi) |
| + | |
| + | # |
| + | # Contact-infos |
| + | # Configured values. In our contact-page we |
| + | # included 2 fields for gpsdata. They can easy |
| + | # obtained through www.maporama.com |
| + | # |
| + | |
| + | echo "<b>KONTAKT</b>" |
| + | echo "MAIL: "$( |
| + | nvram get ff_adm_mail) |
| + | echo "FON: "$( |
| + | nvram get ff_adm_tel) |
| + | echo "ORT/GPSX/Y: "$( |
| + | nvram get ff_adm_loc)/$( |
| + | nvram get gpsx)/$( |
| + | nvram get gpsy) |
| + | |
| + | # |
| + | # uptime |
| + | # Time since last reboot, calculated in hours. |
| + | # |
| + | |
| + | echo "<b>SYSTEM</b>" |
| + | echo "UP: "$( |
| + | cat /proc/uptime|awk '{printf "%1.1f",$1/3600}')h |
| + | |
| + | # |
| + | # Free memory, free diskspace |
| + | # Something special. Here we add some offset-kilobytes |
| + | # to the actual value,to have the "real" amount |
| + | # when not running the script. |
| + | # The method to show diskspace is not optimal. |
| + | # Anyone knows a better way? |
| + | # |
| + | |
| + | OFFSET=860 |
| + | echo "FREEMEM/DISK: "$( |
| + | cat /proc/meminfo|awk '{if($1=="Mem:"){print ($4/1024)+$OFFSET;exit}}')kb/$( |
| + | df|awk '{if($1=="/dev/mtdblock/4"){print$4;exit}}')kb |
| + | |
| + | # |
| + | # Version FFF,OLSRd, this infopage and excution time. |
| + | # Not that elegant,but the most reliable way i think. |
| + | # On another day i will make this in one loop. |
| + | # |
| + | |
| + | echo "vFFF/OLSRd/THIS/TIME: "$( |
| + | ipkg status|awk '{ |
| + | if(index($0,"webadmin")>1) a++ |
| + | if (a>0) {b++ |
| + | if (b==4) print $2 |
| + | break} }')/$( |
| + | ipkg status|awk '{ |
| + | if(index($0,"olsrd")>1) a++ |
| + | if (a>0) {b++ |
| + | if (b==5) print $2 |
| + | break} }')/$( |
| + | ipkg status|awk '{ |
| + | if(index($0,"infopage")>1) a++ |
| + | if (a>0) {b++ |
| + | if (b==5) print $2 |
| + | break} }')/$( |
| + | date) |
| + | |
| + | # |
| + | # CPU-infos. |
| + | # At router-startup runs an script in "/etc/init.d/S..saveklog" |
| + | # We need this to save the kernel-log, because later this log |
| + | # is filled with (for this skript) useless infos. |
| + | # CPU-load is given in percent. Its wrong but nicer 8-) |
| + | # |
| + | |
| + | cat /tmp/dmesg.txt|awk '{ |
| + | if($1=="CPU")a=$4 |
| + | if($1=="CPU:"){printf $0;printf " / Rev. "a |
| + | exit}}' |
| + | cat /proc/loadavg|awk '{ |
| + | printf " /";printf "%3.0f",$3*100}' |
| + | cat /proc/cpuinfo|awk '{ |
| + | if($1=="cpu")printf "%% / "$4"-"$5 |
| + | if($1=="BogoMIPS"){print " / "$3"bmips" |
| + | exit}}' |
| + | |
| + | # |
| + | # Board-values |
| + | # Nothing to say. |
| + | # Maybe later I write a routine to |
| + | # determine from CPU/board-values the |
| + | # machine behind. ("WRT54g v1.0","Siemens SE505" etc.) |
| + | # |
| + | |
| + | echo "BOARDrev/type/num/flags/2: "$( |
| + | nvram get boardrev|awk '{printf $0"/"}' |
| + | nvram get boardtype|awk '{printf $0"/"}' |
| + | nvram get boardnum|awk '{printf $0"/"}' |
| + | nvram get boardflags|awk '{printf $0"/"}' |
| nvram get boardflags2|awk '{printf $0}') | | nvram get boardflags2|awk '{printf $0}') |
− | <b>OLSR</b> | + | |
− | $(cat /etc/olsrd.conf | awk '{ if($1=="LinkQualityWinSize") a=$2; if($1=="HelloInterval") b=$2 | + | # |
− | if($1=="HelloValidityTime") {c=$2;d="!=";if (c-(a*b)==0) d="=";print "HEIn*WSize=HEVal?:",b" x "a,d,c;exit} }') | + | # OLSR-uptime |
− | FILTER: $(nvram get ff_ign) | + | # Maybe interesting to know. |
− | DHCP: $(nvram get ff_wldhcp) | + | # Hint: for all OLSR-infos should be |
− | HNA4: $(nvram get ff_hna4) | + | # the httpinfo-plugin enabled. |
− | LQ: $(nvram get ff_lqmult) | + | # |
− | PLUGIN: $(cat /etc/olsrd.conf | awk '{ if($1=="LoadPlugin") printf $2"/" }') | + | |
− | <b>CLIENTS</b> | + | echo "<b>OLSR</b>" |
− | $(cat /etc/resolv.conf | awk '{if($1=="nameserver")printf "DNSSERVER: "$2"/"}')$(
| + | echo "UP: "$( |
− | cat /etc/dnsmasq.conf|awk -F "=" '{if(index($0,"server=")>0){print $2;exit}}')
| + | wget -O - http://127.0.0.1:8080|awk -F "i>" '{ |
− | $(cat /var/run/dhcp.leases | awk '{print $2,$3,$4}')
| + | if($1=="Olsrd uptime: <"){ |
− | <b>INETGATES</b> | + | print substr($2,1,length($2)-8) |
− | $(wget -O - http://127.0.0.1:8080/nodes|awk -F "<" '{if(substr($0,1,40)=="<tr><td>0.0.0.0</td><td>0.0.0.0</td><td>")print substr($7,4)}')
| + | exit}}') |
− | <b>ETX/NACHBARN</b> | + | |
− | $(wget -O - http://127.0.0.1:8080/nodes|awk '{if($0=="</table>")exit;a++;if(a>21){split($0,b,"</td><td>");
| + | # |
− | c=substr(b[8],1,length(b[8])-10);if(c>99)c="99.99";printf "%5.2f ",c;print "-",b[2]}}'|sort)
| + | # OLSR-Timing |
− | <b>SIGNALRAUSCHABSTAND/SSID/KANAL</b> | + | # Does this often misunderstood expression work? |
− | $(wl scanresults|awk '{if($1=="SSID:")d=$2;a=index($0,"RSSI:");if(a>0){b=substr($0,a+6,3);c=substr($0,a+21,3);e=b-c;
| + | # |
− | if(e<0)e=0;printf"%2.0f ",e;print d,substr($0,a+38)} }'|sort) | + | |
− | </HTML>
| + | cat /etc/olsrd.conf|awk '{ |
− | EOF
| + | if($1=="LinkQualityWinSize")a=$2 |
| + | if($1=="HelloInterval")b=$2 |
| + | if($1=="HelloValidityTime"){ |
| + | c=$2;d="!=" |
| + | if (c-(a*b)==0)d="=" |
| + | print "HEIn*WSize=HEVal?:",b" x "a,d,c |
| + | exit} }' |
| + | |
| + | # |
| + | # Filter, OLSR-dhcp, HNA4, LQ |
| + | # Configured values. |
| + | # Maybe we should better parse olsrd.conf? |
| + | # |
| + | |
| + | echo "FILTER: "$( |
| + | nvram get ff_ign) |
| + | echo "DHCP: "$( |
| + | nvram get ff_wldhcp) |
| + | echo "HNA4: "$( |
| + | nvram get ff_hna4) |
| + | echo "LQ: "$( |
| + | nvram get ff_lqmult) |
| + | |
| + | # |
| + | # OLSRd-PlugIns |
| + | # All configured plugins from olsrd.conf |
| + | # Version information included. |
| + | # |
| + | |
| + | echo "PLUGIN: "$( |
| + | cat /etc/olsrd.conf|awk '{ |
| + | if($1=="LoadPlugin") printf $2"/" }') |
| + | |
| + | # |
| + | # DNS-server |
| + | # Search-order for name-servers. Normally the router |
| + | # itself (127.0.0.1) and then the dnsmasq-entry |
| + | # |
| + | |
| + | echo "<b>CLIENTS</b>" |
| + | cat /etc/resolv.conf|awk '{ |
| + | if($1=="nameserver")printf "DNSSERVER: "$2"/"}' |
| + | cat /etc/dnsmasq.conf|awk -F "=" '{ |
| + | if(index($0,"server=")>0){ |
| + | print $2 |
| + | exit}}' |
| + | |
| + | # |
| + | # DHCP-clients |
| + | # All dhcp-leases. Maybe we should for |
| + | # private reasons delete the mac-addresses. |
| + | # |
| + | |
| + | cat /var/run/dhcp.leases|awk '{ |
| + | print $2,$3,$4}' |
| + | |
| + | # |
| + | # INET-gateways |
| + | # All 0.0.0.0/0-HNA4-Announced inet-gateways. |
| + | # Later I want to include tracerout-outputs to every IP |
| + | # and the affiliated and summarized ETX-values |
| + | # traceroute 10.11.12.3 -w 3 -n 2>/dev/null | awk '{if($2=="*"){print "error";exit} else printf $2" -> " }') |
| + | # |
| + | |
| + | echo "<b>INETGATES</b>" |
| + | wget -O - http://127.0.0.1:8080/nodes|awk -F "<" '{ |
| + | if(substr($0,1,40)=="<tr><td>0.0.0.0</td><td>0.0.0.0</td><td>") |
| + | print substr($7,4)}' |
| + | |
| + | # |
| + | # Neighborhood |
| + | # All direct neighbors, sorted. |
| + | # Best ETX-values are bottom. |
| + | # ETX > 99 will be "translated" to 99. |
| + | # This means "senseless". |
| + | # Maybe i should also filter ETX 0.00 |
| + | # Maybe i should make hyperlinks for faster |
| + | # exploring some nodes. (more output!) |
| + | # |
| + | |
| + | echo "<b>ETX/NACHBARN</b>" |
| + | wget -O - http://127.0.0.1:8080/nodes|awk '{ |
| + | if($0=="</table>")exit |
| + | a++ |
| + | if(a>21){ |
| + | split($0,b,"</td><td>") |
| + | c=substr(b[8],1,4) |
| + | if(c>99)c="99.99" |
| + | printf "%5.2f ",c |
| + | print "- "b[2]}}'| |
| + | sort |
| + | |
| + | # |
| + | # Wifi-scan |
| + | # The now hopefully ready wifi-scan (see on top) |
| + | # will be formatted. Its only purpose is the have |
| + | # an overview of channel-density. Therefore no |
| + | # crypto-infos etc. |
| + | # Sorted by signal-noise-difference. |
| + | # |
| + | |
| + | echo "<b>SIGNALRAUSCHABSTAND/SSID/KANAL</b>" |
| + | wl scanresults|awk '{ |
| + | if($1=="SSID:")d=$2;a=index($0,"RSSI:") |
| + | if(a>0){b=substr($0,a+6,3);c=substr($0,a+21,3);e=b-c; |
| + | if(e<0)e=0;printf"%2.0f ",e;print d,substr($0,a+38)} }'|sort |
| + | |
| + | # |
| + | # End! Because of saving output-filesize |
| + | # HTML-endtag is not needed 8-) |
| + | # |
| + | # |
| + | |
| </pre> | | </pre> |
| | | |