diff --git a/app/configver.py b/app/configver.py
index 2e0be88f..d768696f 100644
--- a/app/configver.py
+++ b/app/configver.py
@@ -31,19 +31,6 @@ try:
except:
pass
-def get_files():
- import glob
- file = set()
- return_files = set()
- for files in glob.glob(os.path.join(hap_configs_dir,'*.cfg')):
- file.add(files.split('/')[6])
- files = sorted(file, reverse=True)
- for file in files:
- ip = file.split("-")
- if serv == ip[0]:
- return_files.add(file)
- return sorted(return_files, reverse=True)
-
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
configver = form.getvalue('configver')
configver = hap_configs_dir + configver
@@ -68,7 +55,7 @@ output_from_parsed_template = template.render(h2 = 1, title = "Old Versions HAPr
user = user,
select_id = "serv",
serv = serv,
- return_files = get_files(),
+ return_files = funct.get_files(),
aftersave = aftersave,
config = config_read,
configver = configver,
diff --git a/app/funct.py b/app/funct.py
index bf448fa9..53f1cdf6 100644
--- a/app/funct.py
+++ b/app/funct.py
@@ -69,7 +69,7 @@ def telegram_send_mess(mess, **kwargs):
import sql
telegrams = sql.get_telegram_by_ip(kwargs.get('ip'))
-
+
for telegram in telegrams:
token_bot = telegram[1]
channel_name = telegram[2]
@@ -78,8 +78,12 @@ def telegram_send_mess(mess, **kwargs):
if proxy is not None:
apihelper.proxy = {'https': proxy}
- bot = telebot.TeleBot(token=token_bot)
- bot.send_message(chat_id=channel_name, text=mess)
+ try:
+ bot = telebot.TeleBot(token=token_bot)
+ bot.send_message(chat_id=channel_name, text=mess)
+ except:
+ print("Fatal: Can't send message. Add Telegram chanel before use alerting at this servers group")
+ sys.exit()
def check_login(**kwargs):
import sql
@@ -130,13 +134,7 @@ def page_for_admin(**kwargs):
print('')
import sys
sys.exit()
-
-def get_button(button, **kwargs):
- value = kwargs.get("value")
- if value is None:
- value = ""
- print('' % (value, value, button))
-
+
def ssh_connect(serv, **kwargs):
import sql
fullpath = get_config_var('main', 'fullpath')
@@ -529,4 +527,5 @@ def get_files():
ip = file.split("-")
if serv == ip[0]:
return_files.add(file)
- return sorted(return_files, reverse=True)
\ No newline at end of file
+ return sorted(return_files, reverse=True)
+
\ No newline at end of file
diff --git a/app/options.py b/app/options.py
index fc069938..167bdf90 100644
--- a/app/options.py
+++ b/app/options.py
@@ -268,9 +268,6 @@ if serv is not None and form.getvalue('right') is not None:
ovw.comapre_show()
if serv is not None and act == "configShow":
- import os
- from datetime import datetime
- from pytz import timezone
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
if form.getvalue('configver') is None:
@@ -296,8 +293,8 @@ if serv is not None and act == "configShow":
print('' % form.getvalue('configver'))
print('')
if form.getvalue('view') is None:
- funct.get_button("Just save", value="save")
- funct.get_button("Upload and restart")
+ print("")
+ print("")
print('')
if form.getvalue('master'):
diff --git a/app/scripts/install_haproxy.sh b/app/scripts/install_haproxy.sh
index fcf39f23..09a99ebb 100644
--- a/app/scripts/install_haproxy.sh
+++ b/app/scripts/install_haproxy.sh
@@ -33,7 +33,8 @@ then
sudo yum install haproxy socat -y > /dev/null
fi
fi
-echo "" > /etc/haproxy/haproxy.cfg
+
+sudo echo "" > /etc/haproxy/haproxy.cfg
sudo bash -c cat << EOF > /etc/haproxy/haproxy.cfg
global
log 127.0.0.1 local2
diff --git a/install.sh b/install.sh
index e6d76741..c4bb6943 100644
--- a/install.sh
+++ b/install.sh
@@ -161,6 +161,10 @@ Type=simple
WorkingDirectory=/var/www/$HOME_HAPROXY_WI
ExecStart=/var/www/$HOME_HAPROXY_WI/tools/checker_master.py
+StandardOutput=syslog
+StandardError=syslog
+SyslogIdentifier=checker
+
RestartSec=2s
Restart=on-failure
TimeoutStopSec=1s
@@ -169,8 +173,29 @@ TimeoutStopSec=1s
WantedBy=multi-user.target
EOF
+cat << EOF > /etc/rsyslog.d/checker.conf
+if $programname startswith 'checker' then /var/www/$HOME_HAPROXY_WI/log/checker-error.log
+& stop
+EOF
+
+cat << EOF > /etc/logrotate.d/checker
+/var/www/$HOME_HAPROXY_WI/log/checker-error.log {
+ daily
+ rotate 10
+ missingok
+ notifempty
+ sharedscripts
+ endscript
+}
+EOF
+
+sed -i 's/#$UDPServerRun 514/$UDPServerRun 514/g' /etc/rsyslog.conf
+sed -i 's/#$ModLoad imudp/$ModLoad imudp/g' /etc/rsyslog.conf
+
systemctl daemon-reload
-systemctl start checker_haproxy.service
+systemctl restart logrotate
+systemctl restart rsyslog
+systemctl restart checker_haproxy.service
systemctl enable checker_haproxy.service
if hash apt-get 2>/dev/null; then
diff --git a/update.sh b/update.sh
index 36d5f350..53b22997 100644
--- a/update.sh
+++ b/update.sh
@@ -9,18 +9,22 @@ mkdir keys
mkdir app/certs
chmod +x app/*py
chmod +x app/tools/*py
-chown -R apache:apache *
-cat << EOF > /etc/systemd/system/multi-user.target.wants/checker_haproxy.service
+
+at << EOF > /etc/systemd/system/multi-user.target.wants/checker_haproxy.service
[Unit]
Description=Haproxy backends state checker
After=syslog.target network.target
[Service]
Type=simple
-WorkingDirectory=/var/www/haproxy-wi/app/
-ExecStart=/var/www/haproxy-wi/app/tools/checker_master.py
+WorkingDirectory=$(pwd)/app
+ExecStart=$(pwd)/app/tools/checker_master.py
+
+StandardOutput=syslog
+StandardError=syslog
+SyslogIdentifier=checker
RestartSec=2s
Restart=on-failure
@@ -30,10 +34,33 @@ TimeoutStopSec=1s
WantedBy=multi-user.target
EOF
+cat << EOF > /etc/rsyslog.d/checker.conf
+if $programname startswith 'checker' then $(pwd)/log/checker-error.log
+& stop
+EOF
+
+cat << EOF > /etc/logrotate.d/checker
+$(pwd)/log/checker-error.log {
+ daily
+ rotate 10
+ missingok
+ notifempty
+ sharedscripts
+ endscript
+}
+EOF
+
+sed -i 's/#$UDPServerRun 514/$UDPServerRun 514/g' /etc/rsyslog.conf
+sed -i 's/#$ModLoad imudp/$ModLoad imudp/g' /etc/rsyslog.conf
+
systemctl daemon-reload
-systemctl start checker_haproxy.service
+systemctl restart logrotate
+systemctl restart rsyslog
+systemctl restart checker_haproxy.service
systemctl enable checker_haproxy.service
+chown -R apache:apache *
+
cd app/
./update_db.py