1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
#!/bin/sh
#
# $Id: openserctl.fifo,v 1.1 2006/07/04 17:49:58 miconda Exp $
#
# openser control tool for maintaining openser
#
#===================================================================
##### ----------------------------------------------- #####
### FIFO specific variables and functions
#
##### ----------------------------------------------- #####
### load CTL base
#
if [ -f "$MYLIBDIR/openserctl.ctlbase" ]; then
. "$MYLIBDIR/openserctl.ctlbase"
else
mwarn "Cannot load CTL core functions '$MYLIBDIR/openserctl.ctlbase' ..."
# exit -1
fi
#
##### ----------------------------------------------- #####
### parameters
#
if [ -z "$OSER_FIFO" ]; then
OSER_FIFO=/tmp/openser_fifo
fi
#
##### ----------------------------------------------- #####
### functions
#
usage_fifo() {
echo
mecho " -- command 'fifo'"
echo
cat <<EOF
fifo ............................... send raw FIFO command
EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_fifo"
fifo_cmd()
{
mdbg "entering fifo_cmd $*"
if [ "$#" -lt 1 ]; then
merr "fifo_cmd must take at least command name as parameter"
exit 1
fi
name=openser_receiver_$$
path=/tmp/$name
if [ ! -w $OSER_FIFO ]; then
merr "Error opening openser's FIFO $OSER_FIFO"
merr "Make sure you have line fifo=$OSER_FIFO in your config"
exit 2
fi
mkfifo $path
if [ $? -ne 0 ] ; then
merr "error opening read fifo $path"
exit 3
fi
chmod a+w $path
# construct the command now
CMD=":$1:$name\n";
shift
while [ -n "$1" ] ; do
CMD="${CMD}${1}\n"
shift
done
CMD="${CMD}\n"
trap "rm -f $path; kill 0" 2
# start reader now so that it is ready for replies
# immediately after a request was sent out
cat < $path | filter_fl &
# issue FIFO request (printf taken to deal with \n)
printf "$CMD" > $OSER_FIFO
# wait for the reader to complete
wait
rm $path
mdbg "FIFO command was:\n$CMD"
}
CTLCMD=fifo_cmd
fifo_openser_monitor() {
name=openser_receiver_$$
path=/tmp/$name
if [ ! -w $OSER_FIFO ]; then
merr "Error opening OpenSER's FIFO $OSER_FIFO"
merr "Make sure you have line 'fifo=$OSER_FIFO' in your config"
exit 1
fi
mkfifo $path
if [ $? -ne 0 ] ; then
merr "monitor - error opening read fifo $path"
exit 1
fi
chmod a+w $path
trap "rm $path; clear; echo monitor ^C-ed; exit 1" 2
attempt=0
if [ "$2" = "" ]; then
loops=-1;
else
loops=$2;
fi
clear
while [ $loops -ne $attempt ] ; do
attempt=$(($attempt + 1))
#clear
tput cup 0 0
# print_stats $name $path $attempt
mecho "[cycle #: $attempt; if constant make sure server lives]"
cat < $path | filter_fl &
cat > $OSER_FIFO <<EOF
:version:$name
EOF
wait
cat < $path | filter_fl &
cat > $OSER_FIFO << EOF
:uptime:$name
EOF
wait
echo
mecho "Transaction Statistics: "
cat < $path | filter_fl &
cat > $OSER_FIFO <<EOF
:get_statistics:$name
tm:
EOF
wait
echo
mecho "Stateless Server Statistics: "
cat < $path | filter_fl &
cat > $OSER_FIFO <<EOF
:get_statistics:$name
sl:
EOF
wait
echo
mecho "UsrLoc Stats: "
cat < $path | filter_fl &
cat > $OSER_FIFO <<EOF
:get_statistics:$name
usrloc:
EOF
wait
if [ $loops -ne $attempt ] ; then
sleep $WATCH_PERIOD
fi
done
rm $path
exit 0
}
OPENSER_MONITOR=fifo_openser_monitor
|