This is a very simple example using ticks to execute a external script to show rx/tx data from the server
<?php
function traf(){
passthru( './traf.sh' );
echo "<br />\n";
flush(); // keeps it flowing to the browser...
sleep( 1 );
}
register_tick_function( "traf" );
declare( ticks=1 ){
while( true ){} // to keep it running...
}
?>
contents of traf.sh:
# Shows TX/RX for eth0 over 1sec
#!/bin/bash
TX1=`cat /proc/net/dev | grep "eth0" | cut -d: -f2 | awk '{print $9}'`
RX1=`cat /proc/net/dev | grep "eth0" | cut -d: -f2 | awk '{print $1}'`
sleep 1
TX2=`cat /proc/net/dev | grep "eth0" | cut -d: -f2 | awk '{print $9}'`
RX2=`cat /proc/net/dev | grep "eth0" | cut -d: -f2 | awk '{print $1}'`
echo -e "TX: $[ $TX2 - $TX1 ] bytes/s \t RX: $[ $RX2 - $RX1 ] bytes/s"
#--= the end. =--