Skip to content

Commit

Permalink
Telk-Alert: Comment Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
erickrr-bd committed Jul 8, 2022
1 parent 7dac083 commit 4001727
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Telk-Alert-Suite/Telk-Alert/modules/Telk_Alert_Class.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from libPyLog import libPyLog
from time import sleep, strftime
from libPyUtils import libPyUtils
from libPyTelegram import libPyTelegram
from .Constants_Class import Constants
from libPyTelegram import libPyTelegram

"""
Class that manages the operation of Telk-Alert.
Expand Down Expand Up @@ -95,8 +95,8 @@ def __startAlertRule(self, conn_es, data_alert_rule):
"""
Method that starts the alert rule's search
:arg conn_es: Object that contains a connection to ElasticSearch.
:arg data_alert_rule: bject that contains the data of the alert rule.
:arg conn_es (object): Object that contains a connection to ElasticSearch.
:arg data_alert_rule (dict): Object that contains the data of the alert rule.
"""
try:
for unit_time in data_alert_rule["time_search"]:
Expand Down Expand Up @@ -160,10 +160,10 @@ def __sendMultipleAlertRule(self, result_search, data_alert_rule, telegram_bot_t
"""
Method that sends an alert for each event found.
:arg result_search: Object that contains the result data of the ElasticSearch search.
:arg data_alert_rule: Object that contains the data of the alert rule.
:arg telegram_bot_token: Telegram Bot Token.
:arg telegram_chat_id: Telegram channel identifier where the alert will be send.
:arg result_search (object): Object that contains the result data of the ElasticSearch search.
:arg data_alert_rule (dict): Object that contains the data of the alert rule.
:arg telegram_bot_token (string): Telegram Bot Token.
:arg telegram_chat_id (string): Telegram channel identifier where the alert will be send.
"""
try:
message_header = u'\u26A0\uFE0F' + " " + data_alert_rule["alert_rule_name"] + " " + u'\u26A0\uFE0F' + '\n\n' + u'\U0001f6a6' + " Alert level: " + data_alert_rule["alert_rule_level"] + "\n\n" + u'\u23F0' + " Alert sent: " + strftime("%c") + "\n\n"
Expand All @@ -181,11 +181,11 @@ def __sendOnlyAlertRule(self, result_search, data_alert_rule, telegram_bot_token
"""
Method that sends only an alert for all events found.
:arg result_search: Object that contains the result data of the ElasticSearch search.
:arg data_alert_rule: Object that contains the data of the alert rule.
:arg telegram_bot_token: Telegram Bot Token.
:arg telegram_chat_id: Telegram channel identifier where the alert will be send.
:arg total_events: Total of events found in the search.
:arg result_search (object): Object that contains the result data of the ElasticSearch search.
:arg data_alert_rule (dict): Object that contains the data of the alert rule.
:arg telegram_bot_token (string): Telegram Bot Token.
:arg telegram_chat_id (string): Telegram channel identifier where the alert will be send.
:arg total_events (integer): Total of events found in the search.
"""
try:
message_header = u'\u26A0\uFE0F' + " " + data_alert_rule["alert_rule_name"] + " " + u'\u26A0\uFE0F' + '\n\n' + u'\U0001f6a6' + " Alert level: " + data_alert_rule["alert_rule_level"] + "\n\n" + u'\u23F0' + " Alert sent: " + strftime("%c") + "\n\n"
Expand All @@ -205,8 +205,8 @@ def __createLogByTelegramCode(self, response_status_code, alert_rule_name):
"""
Method that creates a log based on the HTTP code received as a response.
:arg response_status_code: HTTP code received in the response when sending the alert to Telegram.
:arg alert_rule_name: Name of the alert rule from which the alert was sent.
:arg response_status_code (integer): HTTP code received in the response when sending the alert to Telegram.
:arg alert_rule_name (string): Name of the alert rule from which the alert was sent.
"""
if response_status_code == 200:
self.__logger.generateApplicationLog("Telegram message sent.", 1, "__" + alert_rule_name, use_stream_handler = True, use_file_handler = True, name_file_log = self.__constants.NAME_FILE_LOG, user = self.__constants.USER, group = self.__constants.GROUP)
Expand Down

0 comments on commit 4001727

Please sign in to comment.