1 | #!/bin/bash |
---|
2 | |
---|
3 | SHELL=/bin/bash |
---|
4 | PATH=/usr/local/sbin:/usr/local/bin:/opt/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
---|
5 | |
---|
6 | hold() |
---|
7 | { |
---|
8 | /etc/init.d/nginx stop |
---|
9 | killall -9 nginx |
---|
10 | sleep 1 |
---|
11 | killall -9 nginx |
---|
12 | /etc/init.d/php-fpm stop |
---|
13 | /etc/init.d/php53-fpm stop |
---|
14 | killall -9 php-fpm php-cgi |
---|
15 | echo load is $ONEX_LOAD:$FIVX_LOAD while maxload is $CTL_ONEX_LOAD:$CTL_FIVX_LOAD |
---|
16 | } |
---|
17 | |
---|
18 | terminate() |
---|
19 | { |
---|
20 | if [ -e "/var/run/boa_run.pid" ] ; then |
---|
21 | sleep 1 |
---|
22 | else |
---|
23 | killall -9 php drush.php wget |
---|
24 | fi |
---|
25 | } |
---|
26 | |
---|
27 | nginx_high_load_on() |
---|
28 | { |
---|
29 | mv -f /data/conf/nginx_high_load_off.conf /data/conf/nginx_high_load.conf |
---|
30 | /etc/init.d/nginx reload |
---|
31 | } |
---|
32 | |
---|
33 | nginx_high_load_off() |
---|
34 | { |
---|
35 | mv -f /data/conf/nginx_high_load.conf /data/conf/nginx_high_load_off.conf |
---|
36 | /etc/init.d/nginx reload |
---|
37 | } |
---|
38 | |
---|
39 | control() |
---|
40 | { |
---|
41 | ONEX_LOAD=`awk '{print $1*100}' /proc/loadavg` |
---|
42 | FIVX_LOAD=`awk '{print $2*100}' /proc/loadavg` |
---|
43 | CTL_ONEX_SPIDER_LOAD=2716 |
---|
44 | CTL_FIVX_SPIDER_LOAD=2716 |
---|
45 | CTL_ONEX_LOAD=10108 |
---|
46 | CTL_FIVX_LOAD=6216 |
---|
47 | CTL_ONEX_LOAD_CRIT=13216 |
---|
48 | CTL_FIVX_LOAD_CRIT=10885 |
---|
49 | if [ $ONEX_LOAD -ge $CTL_ONEX_SPIDER_LOAD ] && [ $ONEX_LOAD -lt $CTL_ONEX_LOAD ] && [ -e "/data/conf/nginx_high_load_off.conf" ] ; then |
---|
50 | nginx_high_load_on |
---|
51 | elif [ $FIVX_LOAD -ge $CTL_FIVX_SPIDER_LOAD ] && [ $FIVX_LOAD -lt $CTL_FIVX_LOAD ] && [ -e "/data/conf/nginx_high_load_off.conf" ] ; then |
---|
52 | nginx_high_load_on |
---|
53 | elif [ $ONEX_LOAD -lt $CTL_ONEX_SPIDER_LOAD ] && [ $FIVX_LOAD -lt $CTL_FIVX_SPIDER_LOAD ] && [ -e "/data/conf/nginx_high_load.conf" ] ; then |
---|
54 | nginx_high_load_off |
---|
55 | fi |
---|
56 | if [ $ONEX_LOAD -ge $CTL_ONEX_LOAD_CRIT ] ; then |
---|
57 | terminate |
---|
58 | elif [ $FIVX_LOAD -ge $CTL_FIVX_LOAD_CRIT ] ; then |
---|
59 | terminate |
---|
60 | fi |
---|
61 | if [ $ONEX_LOAD -ge $CTL_ONEX_LOAD ] ; then |
---|
62 | hold |
---|
63 | elif [ $FIVX_LOAD -ge $CTL_FIVX_LOAD ] ; then |
---|
64 | hold |
---|
65 | else |
---|
66 | echo load is $ONEX_LOAD:$FIVX_LOAD while maxload is $CTL_ONEX_LOAD:$CTL_FIVX_LOAD |
---|
67 | echo ...OK now doing CTL... |
---|
68 | perl /var/xdrago/proc_num_ctrl.cgi |
---|
69 | touch /var/xdrago/log/proc_num_ctrl.done |
---|
70 | echo CTL done |
---|
71 | fi |
---|
72 | } |
---|
73 | |
---|
74 | control |
---|
75 | sleep 10 |
---|
76 | control |
---|
77 | sleep 10 |
---|
78 | control |
---|
79 | sleep 10 |
---|
80 | control |
---|
81 | sleep 10 |
---|
82 | control |
---|
83 | sleep 10 |
---|
84 | control |
---|
85 | echo Done ! |
---|
86 | ###EOF2013### |
---|