add a directory for running nagios scale/performance tests
[monitor.git] / nagios / test / run_test.sh
1 #!/bin/bash
2
3 NODES="1280 640 320"
4 TIMES="7 15 30 60 120"
5
6 D=`date +%s`
7
8 # NOTE: we should only need to do this once.  Every restart will inherit the
9 #       last retention file after restarting.
10
11 function block_until_hour ()
12 {
13     d=`date +%s`
14     last_hour=$(( $d - $d % (60 * 60 ) ))
15     next_hour=$(( $last_hour + 60*60 ))
16     while [ $next_hour -gt `date +%s` ] ; do 
17         sleep 10
18     done
19     d=`date +%H:%M`
20     if [ "$d" = "04:00" ] ; then
21         sleep 60 # skip the CRON hour
22         block_until_hour
23     fi
24 }
25
26 #block_until_hour
27 #cp /usr/share/monitor/nagios/retention.dat /var/log/nagios/retention.dat 
28 #echo "Restoring complete retention.dat"
29
30 echo "START time nodes start"
31 for N in $NODES ; do 
32     #cp /var/log/nagios/retention.dat /tmp/retention.dat 
33     #/usr/share/monitor/nagios/filter_nagios_retention.py 7 1280 /tmp/retention.dat > /var/log/nagios/retention.dat
34
35     for T in $TIMES ; do 
36         service nagios stop
37         echo "Removing retention data"
38         rm -f /var/log/nagios/retention.dat
39         echo "Generating plcnodes with $T min intervals & $N nodes"
40         ./plc_test_hosts.py $T $N > /etc/nagios/objects/plcnodes.cfg
41         echo "Sleeping before starting nagios"
42         block_until_hour
43         D=`date +%s`
44         echo "START $T $N" $D $(( $D + 60*120 )) >> stimes.txt
45         service nagios start
46         sleep $(( 105*60 ))
47     done
48 done
49
50
51 service nagios stop
52 rm -f /var/log/nagios/retention.dat
53 sleep $(( 10*60 ))
54 cp /etc/nagios/objects/plc.cfg /etc/nagios/objects/plcnodes.cfg
55 service nagios start
56