diff --git a/app/funct.py b/app/funct.py index 1dbf33ee..5a2f2448 100644 --- a/app/funct.py +++ b/app/funct.py @@ -108,10 +108,9 @@ def telegram_send_mess(mess, **kwargs): try: bot = telebot.TeleBot(token=token_bot) bot.send_message(chat_id=channel_name, text=mess) - except: - mess = " Fatal: Can't send message. Add Telegram chanel before use alerting at this servers group" - print(mess) - logging('localhost', mess, haproxywi=1) + except Exception as e: + print(str(e).decode(encoding='UTF-8')) + logging('localhost', str(e).decode(encoding='UTF-8'), haproxywi=1) sys.exit() @@ -213,20 +212,20 @@ def ssh_connect(serv, **kwargs): ssh.connect(hostname = serv, port = ssh_port, username = ssh_user_name, password = ssh_user_password, timeout=11) return ssh except paramiko.AuthenticationException: - return 'Authentication failed, please verify your credentials' + return 'error: Authentication failed, please verify your credentials' pass except paramiko.SSHException as sshException: - return 'Unable to establish SSH connection: %s ' % sshException + return 'error: Unable to establish SSH connection: %s ' % sshException pass except paramiko.BadHostKeyException as badHostKeyException: - return 'Unable to verify server\'s host key: %s ' % badHostKeyException + return 'error: Unable to verify server\'s host key: %s ' % badHostKeyException pass except Exception as e: if e == "No such file or directory": - return '%s. Check ssh key' % e + return 'error: %s. Check ssh key' % e pass elif e == "Invalid argument": - error = 'Check the IP of the server' + error = 'error: Check the IP of the server' pass else: error = e @@ -967,4 +966,4 @@ def check_service(serv, service_name): commands = [ "systemctl status "+service_name+" |grep Active |awk '{print $1}'" ] return ssh_command(serv, commands) - \ No newline at end of file + diff --git a/app/options.py b/app/options.py index c75112da..487af473 100644 --- a/app/options.py +++ b/app/options.py @@ -1379,6 +1379,7 @@ if form.getvalue('newserver') is not None: if form.getvalue('updatehapwiserver') is not None: id = form.getvalue('updatehapwiserver') active = form.getvalue('active') + name = form.getvalue('name') alert = form.getvalue('alert_en') metrics = form.getvalue('metrics') sql.update_hapwi_server(id, alert, metrics, active) @@ -1584,7 +1585,7 @@ if form.getvalue('telegramdel') is not None: if form.getvalue('updatetoken') is not None: token = form.getvalue('updatetoken') channel = form.getvalue('updategchanel') - group = form.getvalue('updategroup') + group = form.getvalue('updatetelegramgroup') id = form.getvalue('id') if token is None or channel is None or group is None: print(error_mess) diff --git a/app/templates/add.html b/app/templates/add.html index 6f39fa32..c1f6e3c7 100644 --- a/app/templates/add.html +++ b/app/templates/add.html @@ -321,7 +321,7 @@ h3 {