REDIS = None # Mongo DB initialisation if UserConf.mongo_enabled: MONGO = MongoApi(logger_mongo, UserConf.mongo_db_name, UserConf.mongo_host, UserConf.mongo_port, username=UserConf.mongo_user, password=UserConf.mongo_pass) else: MONGO = None # Alerters initialisation alerter_name = 'PANIC' full_channel_set = get_full_channel_set(alerter_name, logger_general, REDIS, log_file_alerts, MONGO) log_and_print('Enabled alerting channels (general): {}'.format( full_channel_set.enabled_channels_list())) periodic_alive_reminder_channel_set = \ get_periodic_alive_reminder_channel_set(alerter_name, logger_general, REDIS, log_file_alerts, MONGO) log_and_print( 'Enabled alerting channels (periodic alive reminder): {}' ''.format(periodic_alive_reminder_channel_set.enabled_channels_list())) sys.stdout.flush() # Nodes initialisation try: nodes = [node_from_node_config(n) for n in UserConf.filtered_nodes] except InitialisationException as ie: logger_general.error(ie)
from src.alerts.alerts import Alert from src.alerts.alerts import AlertCode from src.utils.alert_utils.get_channel_set import get_full_channel_set from src.utils.config_parsers.internal_parsed import InternalConf from src.utils.config_parsers.user_parsed import UserConf from src.utils.logging import DUMMY_LOGGER from src.store.mongo.mongo_api import MongoApi if __name__ == '__main__': mongo = MongoApi(logger=DUMMY_LOGGER, db_name=UserConf.mongo_db_name, host=UserConf.mongo_host, port=UserConf.mongo_port, username=UserConf.mongo_user, password=UserConf.mongo_pass) channel_set = get_full_channel_set( channel_name='TEST', logger_general=DUMMY_LOGGER, redis=None, alerts_log_file=InternalConf.alerts_log_file, mongo=mongo) channel_set.alert_info( Alert(AlertCode.TestAlert, 'This is a test INFO alert.')) channel_set.alert_warning( Alert(AlertCode.TestAlert, 'This is a test WARNING alert.')) channel_set.alert_critical( Alert(AlertCode.TestAlert, 'This is a test CRITICAL alert.')) channel_set.alert_error( Alert(AlertCode.TestAlert, 'This is a test ERROR alert.'))