head 1.8; access; symbols; locks; strict; comment @# @; 1.8 date 99.04.28.11.10.45; author alexis; state Exp; branches; next 1.7; 1.7 date 99.02.20.18.11.23; author alexis; state Exp; branches; next 1.6; 1.6 date 99.01.07.13.19.50; author alexis; state Exp; branches; next 1.5; 1.5 date 98.08.29.16.46.41; author alexis; state Exp; branches; next 1.4; 1.4 date 98.08.28.17.41.13; author alexis; state Exp; branches; next 1.3; 1.3 date 98.08.28.13.43.36; author alexis; state Exp; branches; next ; desc @SHPP PORT OF usecnt.in 1.2 @ 1.8 log @included ../../bin/ppplc_msgids.shpp changed explicit message code numbers to shpp variables @ text @#!MARKER_SHELL_CMD PATH=/bin:/usr/bin PROGNAME=`basename $0` ############################################################################### # # # LINK USE COUNTER # # # ############################################################################### ############################################################################### # # Things you should know about this script: # # It is stored under RCS! Keep it that way! If you want a history of # changes made to this script then refer to rlog(1) - don't look here! # ############################################################################### ############################################################################### # # CONFIGURABLE STUFF STARTS HERE # ############################################################################### ############################################################################### # # CONFIGURABLE STUFF ENDS HERE # ############################################################################### VERSION="MARKER_PATCHLEVEL" # $Header: /diskb/home/alexis/dev/supported/ppplc/lib/misc/RCS/usecnt.shpp,v 1.7 1999/02/20 18:11:23 alexis Exp alexis $ #shpp include ../../bin/ppplc_msgids.shpp SNDMSG=MARKER_LCLBINDIR/sndmsg ############################################################################### # # MAIN FUNCTION (called from very bottom of script) # ############################################################################### main() { ########################################################################### # # PROCESS OPTIONS # ########################################################################### while [ "X$1" != X ]; do case "$1" in -V) echo "$PROGNAME version $VERSION" exit 0 ;; -d) [ "X$2" = X ] && usage VERBOSE_LEVEL=$2 shift ;; -v) VERBOSE_LEVEL=3 ;; -*) usage ;; *) break ;; esac shift done # One argument required - the network interface to check [ "X$1" = X -o "X$2" != X ] && usage # Are locks required? No. This script should run very quickly. ########################################################################### # # GET USE COUNT # ########################################################################### info "getting use count for $1" ### # This is a cheat! This program isn't finished, so all we do is ### # generate a changing number and return that! ### USECOUNT=`sed 's/\..*//' < /proc/uptime` # This uses the packet count on the specified interface from /proc. USECOUNT=`cat /proc/net/dev | sed -n "s/^[ ]*$1:[ ]*\([0-9][0-9]*\)[ ][ ]*.*\$/\1/p"` info "use count is $USECOUNT" $SNDMSG MARKER_MSGID_USECNT_RESPONSE $USECOUNT } usage() { { echo "Usage: $PROGNAME [ -d | -v ] " echo " $PROGNAME -V" } >&2 exit 1 } #shpp include utils.sh.shpp #shpp include gep.sh.shpp @ 1.7 log @removed lockfile generator (not used). @ text @d33 2 a34 1 # $Header: /diskb/home/alexis/dev/supported/ppplc/lib/misc/RCS/usecnt.shpp,v 1.6 1999/01/07 13:19:50 alexis Exp alexis $ d87 1 a87 1 $SNDMSG 39 $USECOUNT d100 1 @ 1.6 log @Debian Slink displayed odd characteristic: sed < /proc/net/dev didn't work, but cat /proc/net/dev | sed does! symbol name changes @ text @d33 1 a33 1 # $Header: usecnt.shpp,v 1.5 1998/08/29 16:46:41 alexis Exp alexis $ a86 5 } gen_lock_file_name() { echo MARKER_LOCK_DIR/$PROGNAME.pid @ 1.5 log @corrected regexp which extraced use count from /proc/net/dev (the use count may come *directly* after the colon if it is a sufficiently big number - i.e. leading spaces soaked up) @ text @d1 1 a1 1 #!SCRIPTSHELLCMD_MARKER d32 3 a34 3 VERSION="PATCHLEVEL_MARKER" # $Id: usecnt.shpp,v 1.4 1998/08/28 17:41:13 alexis Exp alexis $ SNDMSG=LCLSBINDIR_MARKER/sndmsg d83 1 a83 1 USECOUNT=`sed -n "s/^[ ]*$1:[ ]*\([0-9][0-9]*\)[ ][ ]*.*\$/\1/p" < /proc/net/dev` d91 1 a91 1 echo LOCK_DIR_MARKER/$PROGNAME.pid d103 1 a103 2 #shpp include utils.sh @ 1.4 log @removed version number tests @ text @d33 1 a33 1 # $Id: usecnt.shpp,v 1.3 1998/08/28 13:43:36 alexis Exp alexis $ d83 1 a83 1 USECOUNT=`sed -n "s/^[ ]*$1:[ ][ ]*\([0-9][0-9]*\)[ ][ ]*.*\$/\1/p" < /proc/net/dev` @ 1.3 log @*** empty log message *** @ text @d33 1 a33 1 # $Id: usecnt.in,v 1.2 1998/08/27 15:38:42 alexis Exp alexis $ d53 2 a54 7 -V) if expr "$VERSION" : 'P.*R$' > /dev/null; then warning "this is a development version; use 'ident' for version information" exit 1 else echo "$PROGNAME version $VERSION" exit 0 fi ;; d91 1 a91 1 echo LOCKDIR_MARKER/$PROGNAME.pid @