#!/usr/bin/haserl <% echo -en "Content-Type: text/html\r\n\r\n" HOSTNAME="" FFFV4="" FFFGLOBALUNICAST="" FFFTABLE="fff" #lockfile="/tmp/simple.babelweb.lock" ; better nginx proxy cache # #if [ -e $lockfile ];then # if [ 5 -gt $(( $(date +%s) - $(date -r $lockfile +%s) )) ];then # echo "only one access per minute!!" && exit # fi #fi data=$(echo "dump" | nc ::1 33123) #touch $lockfile %> <%= ${HOSTNAME} %>

Simple Babelweb



Babel information

<% if [ -f /bin/opkg ]; then %> <% fi %>
Quellcode Simple Babelweb
<% echo "$data" | head -n 1 %>
<% echo "$data" | head -n 2 | tail -n 1 %>
opkg-version <% opkg list-installed | grep babeld | cut -f 3 -d ' ' %>
<% echo "$data" | head -n 3 | tail -n 1 %>
<% echo "$data" | head -n 4 | tail -n 1 %>

<% if ! [ ${GET_routes} ] && ! [ ${GET_v4table} ] && ! [ ${GET_v6table} ] && ! [ ${GET_weg} ] && ! [ ${GET_lg} ] ; then %>

Interfaces

<% echo "" echo "" echo "$data" | grep interface | while read line ; do tmp=${line##* interface } tmpint=${tmp%% *} newline="" done %>
interfaceupsinceipv6ipv4
$tmpint" tmp=${line##* up } newline="$newline${tmp%% *}" tmp="" if [ -f "/sys/class/net/$tmpint/operstate" ]; then tmp=$(($(date +%s) - $(stat -c %Y /sys/class/net/$tmpint/operstate))) tmp="$((tmp/3600/24))d $((tmp/3600%24)):$((tmp/60%60)):$((tmp%60))" fi newline="$newline$tmp" tmp=${line##* ipv6 } newline="$newline${tmp%% *}" tmp=${line##* ipv4 } echo "$newline${tmp%% *}

Neighbours

<% echo "" echo "$data" | grep neighbour | while read line ; do tmp=${line##*add neighbour } tmp=${tmp%% *} newline="" done %>
idaddressinterfacereachrxcosttxcostrttrttcostcost
${tmp:0:2}:${tmp:2:2}:${tmp:4:2}:${tmp:6:2}:${tmp:8:2}:${tmp:10:2}" tmp=${line##* address } newline="$newline${tmp%% *}" tmp=${line##* if } newline="$newline${tmp%% *}" tmp=${line##* reach } newline="$newline${tmp%% *}" tmp=${line##* rxcost } newline="$newline${tmp%% *}" tmp=${line##* txcost } newline="$newline${tmp%% *}" newline="$newline$(echo "$line" | sed -n '/^.*\srtt\s\+\([0-9.]\+\).*$/s//\1/p')" newline="$newline$(echo "$line" | sed -n '/^.*\srttcost\s\+\([0-9]\+\).*$/s//\1/p')" tmp=${line##* cost } echo "$newline${tmp%% *}

Redistributed routes

<% echo "" echo "$data" | grep xroute | while read line ; do tmp=${line##*add xroute } tmp=${tmp%% *} newline="" done %>
prefixmetric
${tmp%%-*}" tmp=${line##* metric } echo "$newline${tmp%% *}

<% fi echo "" if [ ${GET_routes} ]; then %>

All routes

<% echo ">" echo "$data" | grep -w route | while read line ; do tmp=${line##* prefix } tmp=${tmp%% *} newline="" done %>
targetfrominstalledviadevicemetricdestination id
$tmp" tmp=${line##* from } tmp=${tmp##*/0} newline="$newline${tmp%% *}" tmp=${line##* installed } newline="$newline${tmp%% *}" tmp=${line##* via } newline="$newline${tmp%% *}" tmp=${line##* if } newline="$newline${tmp%% *}" tmp=${line##* metric } newline="$newline${tmp%% *}" tmp=${line##* id } tmp=${tmp%% *} echo "$newline$tmp
<% fi if [ ${GET_v4table} ]; then %>

Show IPv4 Routing Tabele

<% echo "" v4routen=$(ip ro sh tab 10) echo "$v4routen" | while read line ; do tmp=${line%% *} newline="" done %>
targetviadeviceproto
$tmp" tmp=${line##* via } newline="$newline${tmp%% *}" tmp=${line##* dev } newline="$newline${tmp%% *}" tmp=${line##* proto } echo "$newline${tmp%% *}
<% fi if [ ${GET_v6table} ]; then %>

Show IPv6 Routing Tabele

<% echo "" v6routes=$(ip -6 ro sh tab 10) echo "$v6routes" | while read line ; do tmp=${line%% *} newline="" done %>
targetfromviadeviceprotometric
$tmp" tmp="$line"" from " tmp=${tmp#* from } newline="$newline${tmp%% *}" tmp=${line##* via } newline="$newline${tmp%% *}" tmp=${line##* dev } newline="$newline${tmp%% *}" tmp=${line##* proto } newline="$newline${tmp%% *}" tmp=${line##* metric } echo "$newline${tmp%% *}
<% fi if [ ${GET_weg} ]; then %>

Wege zu <% echo "${GET_ip}" %>

<% echo "$data" | grep -w route | grep "${GET_ip}" | while read line ; do tmp=${line##* prefix } tmp=${tmp%% *} newline="" done %>
targetfrominstalledviadevicemetricdestination id
$tmp" tmp=${line##* from } tmp=${tmp##*/0} newline="$newline${tmp%% *}" tmp=${line##* installed } newline="$newline${tmp%% *}" tmp=${line##* via } newline="$newline${tmp%% *}" tmp=${line##* if } newline="$newline${tmp%% *}" tmp=${line##* metric } newline="$newline${tmp%% *}" tmp=${line##* id } tmp=${tmp%% *} echo "$newline$tmp
<% fi if [ ${GET_lg} ]; then %>

Looking Glass

IP or Hostname:
">
<% IPv4=1 if [ -n "$(echo "${GET_lgip}" | sed -e '/^[\.:0-9a-fA-F]\+$/!d')" ]; then if [ "$(ping -4 -c1 -W0.01 "${GET_lgip}" >/dev/null 2>&1; echo "$?")" -ne 2 ]; then IP="${GET_lgip}" IPv4=0 elif [ "$(ping -6 -c1 -W0.01 "${GET_lgip}" >/dev/null 2>&1; echo "$?")" -ne 2 ]; then IP="${GET_lgip}" fi else if [ -n ${GET_lgip} ]; then IP="$(nslookup -q=AAAA "${GET_lgip}" | sed -ne '/^Address: /{s/^Address: *//p;q}')" if [ -z "$IP" ]; then IP="$(nslookup -q=A "${GET_lgip}" | sed -ne '/^Address: /{s/^Address: *//p;q}')" IPv4=0 fi fi fi SourceTR="" SourcePing="" if [ -n "$IP" ]; then if [ $IPv4 -eq 0 ]; then SourceTR="-s""$FFFV4" SourcePing="-I""$FFFV4" elif [ -z "$(ip -6 ro get "$IP" 2>&1 | grep " table ""$FFFTABLE"" \| unreachable")" ]; then SourceTR="-s""$FFFGLOBALUNICAST" SourcePing="-I""$FFFGLOBALUNICAST" fi %>

Ping <% echo -n "$IP" %>

<%	ping -c4 $SourcePing "$IP" 2>&1 | sed -e 's/ from \S\+//g'
%>

Traceroute <% echo -n "$IP" %>

<%	traceroute -w1 -q2 $SourceTR "$IP" 2>&1 | sed -e 's/ from \S\+,/,/g'
	%>
	<%
	fi
fi
%>