Changeset 482

Show
Ignore:
Timestamp:
07/20/08 20:39:33 (4 months ago)
Author:
ChrisPHL
Message:

added simple traffic statistics

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bin/conalarm.sh

    r454 r482  
    7979 Status URL (LAN side)          http://$(ifconfig $lan_ifname 2>/dev/null | grep inet | awk -F'[: ]+' '{print $4}')/cgi-bin/webif/status.sh 
    8080 CALLED_STATION_ID              $( ifconfig wifi0|grep HWaddr|sed -e "s/^.*HWaddr //" |sed -e "s/ //g" ) 
    81  CALLING_STATION_ID             $CALLING_STATION_ID 
     81 CALLING_STATION_ID             $mac 
    8282 FRAMED_IP_ADDRESS              $FRAMED_IP_ADDRESS 
    8383 USER_NAME                      $USER_NAME 
  • trunk/usr/lib/webif/form.awk

    r469 r482  
    163163$1 ~ /^add_label_cell/ { 
    164164        close_field() 
    165         if ($3 != "") print "<td nowrap class=\"tableText\">" $2 "</td><td align=right class=\"tableText\">" $3 "</td>" 
    166         else print "<TD nowrap class=\"tableText\">" $2 "</TD>" 
     165        if ($3 != "") print "<td nowrap class=\"tableText\" valign=top>" $2 "</td><td align=right class=\"tableText\" valign=top>" $3 "</td>" 
     166        else print "<TD nowrap class=\"tableText\" valign=top>" $2 "</TD>" 
    167167} 
    168168$1 ~ /^add_checkbox_cell/ { 
  • trunk/www/cgi-bin/webif/statistics.sh

    r184 r482  
    2929. /usr/lib/webif/webif.sh 
    3030 
     31. /tmp/network-config 
     32 
    3133header "Router Statistics" 
    3234 
     
    5355usagea=$(echo $connecteda | sed 's!> <!><!g') 
    5456 
    55 connectedb= 
    56 for conb in $(cat /tmp/usageb.txt); do 
    57         connectedb="${connectedb:+$connectedb} $conb" 
    58 done 
    59 usageb=$(echo $connectedb | sed 's!> <!><!g') 
     57
     58#connectedb= 
     59#for conb in $(cat /tmp/usageb.txt); do 
     60#       connectedb="${connectedb:+$connectedb} $conb" 
     61#done 
     62#usageb=$(echo $connectedb | sed 's!> <!><!g') 
     63
     64#connectedc= 
     65#for conc in $(cat /tmp/usagec.txt); do 
     66#       connectedc="${connectedc:+$connectedc} $conc" 
     67#done 
     68#usagec=$(echo $connectedc | sed 's!> <!><!g') 
    6069 
    61 connectedc= 
    62 for conc in $(cat /tmp/usagec.txt); do 
    63         connectedc="${connectedc:+$connectedc} $conc" 
    64 done 
    65 usagec=$(echo $connectedc | sed 's!> <!><!g') 
    6670 
    67 uptime="$(uptime)" 
     71# uptime gives a one line display of the following information. 
     72# The current time, how long the system has been running, how many users are currently logged on, 
     73# and the system load averages for the past 1, 5, and 15 minutes. 
     74# (http://linux.die.net/man/1/uptime) 
     75ut="`uptime | awk -F"," '{print $1 $2}'`" 
     76if [ "`echo $ut | awk '{print $4}'`" != "days" ]; then 
     77        uptime="`echo $ut | awk '{print $3}'` @TR<<hours>>" 
     78else 
     79        uptime="`echo $ut | awk '{print $3}'` @TR<<days>>, `echo $ut | awk '{print $5}'` @TR<<hours>>" 
     80fi 
    6881 
    69 cat <<EOF 
    70 <table width="90%"> 
    71         <tr><td><p><strong>@TR<<Router's time, uptime and load average>></strong></p></td></tr> 
    72         <tr><td>$uptime</td></tr> 
    73         <tr><td>$usagea<br /><font size="2">@TR<<One minute based CPU load average>></font><br /><br />$usageb<br /><font size="2">@TR<<5 minutes based CPU load average>></font><br /><br />$usagec<br /><font size="2">@TR<<15 minutes based CPU load average>></font></td></tr> 
    74 </table> 
     82display_form <<EOF 
     83start_table|0|10|5 
     84        add_row 
     85                add_title_cell|@TR<<CPU>> 
     86        end_row 
     87        add_row 
     88                add_label_cell|@TR<<Uptime>> 
     89                add_label_cell|$uptime 
     90        end_row 
     91        add_row 
     92                add_label_cell|@TR<<Average Load>> 
     93                add_label_cell|$usagea <br /><font size="2">(@TR<<One minute based CPU load average>>)</font><br /><br /> 
     94        end_row 
     95end_table 
     96EOF 
     97 
     98lan_rx=$(ifconfig $lan_ifname | grep "RX bytes" | awk -F"(" '{print $2}' | awk -F")" '{print $1}') 
     99lan_tx=$(ifconfig $lan_ifname | grep "RX bytes" | awk -F"(" '{print $3}' | awk -F")" '{print $1}') 
     100wan_rx=$(ifconfig $wan_ifname | grep "RX bytes" | awk -F"(" '{print $2}' | awk -F")" '{print $1}') 
     101wan_tx=$(ifconfig $wan_ifname | grep "RX bytes" | awk -F"(" '{print $3}' | awk -F")" '{print $1}') 
     102hotspot_rx=$(ifconfig tun0 | grep "RX bytes" | awk -F"(" '{print $2}' | awk -F")" '{print $1}') 
     103hotspot_tx=$(ifconfig tun0 | grep "RX bytes" | awk -F"(" '{print $3}' | awk -F")" '{print $1}') 
     104 
     105display_form <<EOF 
     106start_table|0|10|5 
     107        add_row 
     108                add_title_cell|@TR<<Traffic>> 
     109        end_row 
     110        add_row 
     111                add_label_cell|<i>@TR<<LAN>>:</i> 
     112        end_row 
     113        add_row 
     114                add_label_cell|@TR<<transmitted>> 
     115                add_label_cell|$lan_tx 
     116        end_row 
     117        add_row 
     118                add_label_cell|@TR<<received>> 
     119                add_label_cell|$lan_rx 
     120        end_row 
     121        add_row 
     122                add_label_cell|<i>@TR<<WAN>>:</i> 
     123        end_row 
     124        add_row 
     125                add_label_cell|@TR<<transmitted>> 
     126                add_label_cell|$wan_tx 
     127        end_row 
     128        add_row 
     129                add_label_cell|@TR<<received>> 
     130                add_label_cell|$wan_rx 
     131        end_row 
     132                add_row 
     133                add_label_cell|<i>@TR<<Hotspot>>:</i> 
     134        end_row 
     135        add_row 
     136                add_label_cell|@TR<<transmitted>> 
     137                add_label_cell|$hotspot_tx 
     138        end_row 
     139        add_row 
     140                add_label_cell|@TR<<received>> 
     141                add_label_cell|$hotspot_rx 
     142        end_row 
     143end_table 
    75144EOF 
    76145