#!/bin/bash
########################################################################
# filename:	coscounter
#
# description:	This script is used to run in the background and will
#               count the number of COS line activations and export
#               the result in $LOCAL/coscount file for use in a script
#               running in the forground.  
#               Mash it with "killall coscounter" when done.
#
# arguments:	always.. but not with me!
#
# history:
# 20090704  V1.00    vk8sj  Original ...
#
#
########################################################################
#
source /home/irlp/custom/my-functions.sh   # test user & load environment
#
cos_num=0                                  # Init variable
echo $cos_num > $LOCAL/coscount            # Init flag file
while [ TRUE ] ; do                        # create endless loop
   if ! $BIN/cosstate ; then               # if COS is active..
     let cos_num+=1                        # crank up the count
     echo $cos_num > $LOCAL/coscount       # write count to flag file
#    echo $cos_num                         # DEBUG only - uncomment to test
     while ! $BIN/cosstate
     do                                    # if COS still active..
       usleep 500                          # take a nap.. (short)
     done                                  # loop till it drops
   fi                                      # outa here..
done                                       # continue endless loop

