From b92b3ea34a976fd01c4b310d681bd3de74aef466 Mon Sep 17 00:00:00 2001 From: Aidaho12 Date: Wed, 25 Jul 2018 12:28:33 +0600 Subject: [PATCH] v2.7.2 Bugs --- app/funct.py | 6 ++---- app/scripts/install_haproxy.sh | 17 +++++++++++++---- app/scripts/install_keepalived.sh | 7 ++++++- app/tools/checker_master.py | 2 +- app/tools/checker_worker.py | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/funct.py b/app/funct.py index 724d1f87..bf448fa9 100644 --- a/app/funct.py +++ b/app/funct.py @@ -63,14 +63,12 @@ def logging(serv, action, **kwargs): print('
Can\'t read write log. Please chech log_path in config
') pass -def telegram_send_mess(mess): +def telegram_send_mess(mess, **kwargs): import telebot from telebot import apihelper import sql - cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) - user_id = cookie.get('uuid') - telegrams = sql.get_user_telegram_by_uuid(user_id.value) + telegrams = sql.get_telegram_by_ip(kwargs.get('ip')) for telegram in telegrams: token_bot = telegram[1] diff --git a/app/scripts/install_haproxy.sh b/app/scripts/install_haproxy.sh index 12fd6e96..fcf39f23 100644 --- a/app/scripts/install_haproxy.sh +++ b/app/scripts/install_haproxy.sh @@ -11,8 +11,13 @@ if [ -f /etc/haproxy/haproxy.cfg ];then echo -e 'error: Haproxy already installed. You can edit confighere

' exit 1 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 ] then @@ -22,7 +27,11 @@ then fi if [ $? -eq 1 ] 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 echo "" > /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 redispatch retries 3 - timeout http-request 5s + timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m diff --git a/app/scripts/install_keepalived.sh b/app/scripts/install_keepalived.sh index dee3b541..22a46dc1 100644 --- a/app/scripts/install_keepalived.sh +++ b/app/scripts/install_keepalived.sh @@ -6,7 +6,12 @@ if [ -f $CONF ];then exit 1 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 ] then echo "error: Can't install keepalived

" diff --git a/app/tools/checker_master.py b/app/tools/checker_master.py index b6f17cd4..63a5ba0f 100644 --- a/app/tools/checker_master.py +++ b/app/tools/checker_master.py @@ -45,7 +45,7 @@ def start_worker(serv): def kill_worker(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) - funct.logging("localhost", "Masrer killed worker for: "+serv, alerting=1) + funct.logging("localhost", " Masrer killed worker for: "+serv, alerting=1) if stderr: funct.logging("localhost", stderr, alerting=1) diff --git a/app/tools/checker_worker.py b/app/tools/checker_worker.py index 18be0943..4140137d 100644 --- a/app/tools/checker_worker.py +++ b/app/tools/checker_worker.py @@ -48,7 +48,7 @@ def main(serv, port): servername = servername.split(",") realserver = servername[0] 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) firstrun = False oldstat = []