Bugs
pull/26/head
Aidaho12 2018-07-25 12:28:33 +06:00
parent f16e5f4af7
commit b92b3ea34a
5 changed files with 23 additions and 11 deletions

View File

@ -63,14 +63,12 @@ def logging(serv, action, **kwargs):
print('<center><div class="alert alert-danger">Can\'t read write log. Please chech log_path in config</div></center>') print('<center><div class="alert alert-danger">Can\'t read write log. Please chech log_path in config</div></center>')
pass pass
def telegram_send_mess(mess): def telegram_send_mess(mess, **kwargs):
import telebot import telebot
from telebot import apihelper from telebot import apihelper
import sql import sql
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) telegrams = sql.get_telegram_by_ip(kwargs.get('ip'))
user_id = cookie.get('uuid')
telegrams = sql.get_user_telegram_by_uuid(user_id.value)
for telegram in telegrams: for telegram in telegrams:
token_bot = telegram[1] token_bot = telegram[1]

View File

@ -11,8 +11,13 @@ if [ -f /etc/haproxy/haproxy.cfg ];then
echo -e 'error: Haproxy already installed. You can edit config<a href="/app/config.py" title="Edit HAProxy config">here</a> <br /><br />' echo -e 'error: Haproxy already installed. You can edit config<a href="/app/config.py" title="Edit HAProxy config">here</a> <br /><br />'
exit 1 exit 1
fi fi
sudo wget http://cbs.centos.org/kojifiles/packages/haproxy/1.8.1/5.el7/x86_64/haproxy18-1.8.1-5.el7.x86_64.rpm
sudo yum install haproxy18-1.8.1-5.el7.x86_64.rpm -y if hash apt-get 2>/dev/null; then
sudo apt-get install haproxy socat -y
else
sudo wget http://cbs.centos.org/kojifiles/packages/haproxy/1.8.1/5.el7/x86_64/haproxy18-1.8.1-5.el7.x86_64.rpm
sudo yum install haproxy18-1.8.1-5.el7.x86_64.rpm -y
fi
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
@ -22,7 +27,11 @@ then
fi fi
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
sudo yum install haproxy socat -y > /dev/null if hash apt-get 2>/dev/null; then
sudo apt-get install socat -y
else
sudo yum install haproxy socat -y > /dev/null
fi
fi fi
echo "" > /etc/haproxy/haproxy.cfg echo "" > /etc/haproxy/haproxy.cfg
sudo bash -c cat << EOF > /etc/haproxy/haproxy.cfg sudo bash -c cat << EOF > /etc/haproxy/haproxy.cfg
@ -47,7 +56,7 @@ defaults
option forwardfor except 127.0.0.0/8 option forwardfor except 127.0.0.0/8
option redispatch option redispatch
retries 3 retries 3
timeout http-request 5s timeout http-request 10s
timeout queue 1m timeout queue 1m
timeout connect 10s timeout connect 10s
timeout client 1m timeout client 1m

View File

@ -6,7 +6,12 @@ if [ -f $CONF ];then
exit 1 exit 1
fi fi
sudo yum install keepalived -y > /dev/null if hash apt-get 2>/dev/null; then
sudo apt-get install keepalived -y
else
sudo yum install keepalived -y > /dev/null
fi
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
echo "error: Can't install keepalived <br /><br />" echo "error: Can't install keepalived <br /><br />"

View File

@ -45,7 +45,7 @@ def start_worker(serv):
def kill_worker(serv): def kill_worker(serv):
cmd = "ps ax |grep 'tools/checker_worker.py %s'|grep -v grep |awk '{print $1}' |xargs kill" % serv cmd = "ps ax |grep 'tools/checker_worker.py %s'|grep -v grep |awk '{print $1}' |xargs kill" % serv
output, stderr = funct.subprocess_execute(cmd) output, stderr = funct.subprocess_execute(cmd)
funct.logging("localhost", "Masrer killed worker for: "+serv, alerting=1) funct.logging("localhost", " Masrer killed worker for: "+serv, alerting=1)
if stderr: if stderr:
funct.logging("localhost", stderr, alerting=1) funct.logging("localhost", stderr, alerting=1)

View File

@ -48,7 +48,7 @@ def main(serv, port):
servername = servername.split(",") servername = servername.split(",")
realserver = servername[0] realserver = servername[0]
alert = realserver[2:]+ " has changed status and is now "+ currentstat[i] + " at " + serv alert = realserver[2:]+ " has changed status and is now "+ currentstat[i] + " at " + serv
funct.telegram_send_mess(str(alert)) funct.telegram_send_mess(str(alert), ip=serv)
funct.logging("localhost", " "+alert, alerting=1) funct.logging("localhost", " "+alert, alerting=1)
firstrun = False firstrun = False
oldstat = [] oldstat = []