note 33788 added to control-structures.declare

From: Date: Mon, 07 Jul 2003 23:45:59 +0000
Subject: note 33788 added to control-structures.declare
Groups: php.notes 
Request: Send a blank email to php-notes+get-51653@lists.php.net to get a copy of this message
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. =-- ---- Manual Page -- http://www.php.net/manual/en/control-structures.declare.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33788 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33788&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33788&report=yes

« previous php.notes (#51653) next »