aboutsummaryrefslogtreecommitdiff
path: root/heartbeat_hammer.sh
blob: f2d4671408175ea658fe16f0d9f65b6f099fe41f (plain)
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
#!/bin/bash

PRE="ruby -I lib bin/mauveclient localhost"
F=60
S=10
n=$*

_host () { 
  hostname="imaginary-$i.example.com"
  down="n"

  while( true ) ; do

      if [ "$down" == "n" ] ; then
        $PRE -o $hostname -i heartbeat -r +$F -c now -s "heartbeat failed" --detail="<p>The heartbeat wasn't sent for this host</p><p>This indicates that the host might be down</p>"
        sleep $((F - $RANDOM*$S/32768 - $S))
      else
        sleep $((RANDOM*$S/32768 + $F + $S))
      fi

      if [ $RANDOM -gt 30000 ] ; then
        [ "$down" == "n" ] && echo "Host $hostname down"
        down="y"
      else
        [ "$down" == "y" ] && echo "Host $hostname up"
        down="n"
      fi
  done
}

for i in `seq 1 100` ; do
  _host $i &
  sleep 0.2
done