Skript-Schnipsel

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 00:45, 4 May 2005 (edit)
217.85.225.183 (Talk)

← Previous diff
Revision as of 00:49, 4 May 2005 (edit) (undo)
217.232.86.128 (Talk)
(ifconfig Traffic Monitor)
Next diff →
Line 168: Line 168:
echo -e "INPUT Speed:\t$input_speed\tBytes/second" echo -e "INPUT Speed:\t$input_speed\tBytes/second"
echo -e "OUTPUT Speed:\t$output_speed\tBytes/second" echo -e "OUTPUT Speed:\t$output_speed\tBytes/second"
 + sleep 60 ;
 + done;
 +</pre>
 +
 +Anstatt sich das ganze auf der Console anzusehen, kann man es natürlich auch in eine html- Seite schicken.<pr>
 +Man muss nur das Echo umleiten und das Verzeichnis /tmp/www anlegen.
 +<pre>
 +mkdir /tmp/www
 +while [ 1 ];
 + do
 + curr_input_bytes=$(ifconfig $(route | grep default | awk '{print$8}') | grep "bytes" | sed -e 's/.*RX bytes:\([0-9]*\).*/\1/');
 + curr_output_bytes=$(ifconfig $(route | grep default | awk '{print$8}') | grep "bytes" | sed -e 's/.*TX bytes:\([0-9]*\).*/\1/');
 + if [ "$old_input_bytes" -eq '' ]; then
 + old_input_bytes=0;
 + fi
 + if [ "$old_output_bytes" -eq '' ]; then
 + old_output_bytes=0;
 + fi
 + let "delta_input_bytes = $curr_input_bytes - $old_input_bytes" ;
 + let "delta_output_bytes = $curr_output_bytes - $old_output_bytes" ;
 + let "input_speed = $delta_input_bytes / 60";
 + let "output_speed = $delta_output_bytes / 60";
 + old_input_bytes=$curr_input_bytes;
 + old_output_bytes=$curr_output_bytes;
 + echo -e '
 + <html><body>
 + <head>
 + <META HTTP-EQUIV='Refresh' CONTENT='60'>
 + </head>
 + <table>
 + <tr bgcolor=#c1c1c1>
 + <td></td>
 + <td>Gesamt<br>[byte]</td>
 + <td>Geschwindigkeit<br>[byte/sek]</td>
 + </tr>
 + <tr>
 + <td bgcolor=#c1c1c1 >Eingehend</td>
 + <td>'$curr_input_bytes'</td>
 + <td>'$input_speed'</td>
 + </tr>
 + </tr>
 + <td bgcolor=#c1c1c1>Ausgehend</td>
 + <td>'$curr_output_bytes'</td>
 + <td>'$output_speed'</td>
 + <tr>
 + </table>
 + <body><html>' > /tmp/www/traffic.htm
sleep 60 ; sleep 60 ;
done; done;
</pre> </pre>

Revision as of 00:49, 4 May 2005