1 |
#!/bin/bash |
2 |
#/* |
3 |
# openisis - an open implementation of the CDS/ISIS database |
4 |
# Version 0.8.x (patchlevel see file Version) |
5 |
# Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org |
6 |
# |
7 |
# This library is free software; you can redistribute it and/or |
8 |
# modify it under the terms of the GNU Lesser General Public |
9 |
# License as published by the Free Software Foundation; either |
10 |
# version 2.1 of the License, or (at your option) any later version. |
11 |
# |
12 |
# This library is distributed in the hope that it will be useful, |
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
# Lesser General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU Lesser General Public |
18 |
# License along with this library; if not, write to the Free Software |
19 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
# |
21 |
# see README for more information |
22 |
#EOH */ |
23 |
|
24 |
# $Id: oister,v 1.5 2003/04/08 00:20:53 kripke Exp $ |
25 |
# |
26 |
# OpenIsis server tester -- test oyster |
27 |
# |
28 |
# usage |
29 |
# ./oister [port [host]] # talk to server |
30 |
# time ./oister -trash [requests [clients [port [host]]]] |
31 |
|
32 |
|
33 |
|
34 |
trasher () { |
35 |
id=$1 |
36 |
exec 3<>/dev/tcp/$host/$port |
37 |
local i # running in subshell anyway ... |
38 |
declare -i i |
39 |
i=$requests |
40 |
ses=ses$[id / 4] |
41 |
while [ 0 != $i ]; do |
42 |
if [ 0 -eq $[i % 7] ]; then # add to session |
43 |
echo "-2 $ses |
44 |
$i $id $i foo |
45 |
$i $id $i bar |
46 |
" >&3 |
47 |
else # fetch session info only |
48 |
echo "-2 $ses |
49 |
" >&3 |
50 |
fi |
51 |
while read line; do |
52 |
# echo $line |
53 |
[ -z "$line" ] && break; |
54 |
done <&3 |
55 |
i=i-1 |
56 |
done |
57 |
echo "$id: `date`" |
58 |
} |
59 |
|
60 |
|
61 |
if [ x-trash == "x$1" ]; then |
62 |
requests=${2:-500} |
63 |
clients=${3:-8} |
64 |
port=${4:-8080} |
65 |
host=${5:-localhost} |
66 |
declare -i j |
67 |
echo "starting $clients trashers for $requests requests at `date`" |
68 |
j=$clients; while [ 0 != $j ]; do time trasher $j & j=j-1; done |
69 |
echo "started $clients trashers on $host:$port at `date`" |
70 |
j=$clients; while [ 0 != $j ]; do wait; j=j-1; done |
71 |
echo "collected $clients trashers at `date`" |
72 |
exit |
73 |
fi |
74 |
|
75 |
# default: run manually |
76 |
# |
77 |
|
78 |
exec 3<>/dev/tcp/${2:-localhost}/${1:-8080} |
79 |
|
80 |
cat <&3 & |
81 |
cp=$! |
82 |
|
83 |
cat >&3 |
84 |
kill $cp # copy kill ;/ |