def __init__(self,*args, **kwargs):
        super(PlatformMonitorAgent, self).__init__(*args,**kwargs)

        self.agent_id = kwargs['name']
        multinode_data = db_helper.get_multinode_data()
        self.node_name = multinode_data['this_node']
        self.mynode = db_helper.get_node_id()

        self.poll_time = 60
        self.backup_poll_time = 300

        platform_variables['agent_id'] = self.agent_id + '_' + self.node_name
        notification_variables['agent_id'] = self.agent_id

        self.variables = kwargs
        self.db_host = db_host
        self.last_seen_dead = dict()
        self.cassandra_death_time = None #Arbitrary initialization
        self.cassandra_death_date = None
        self.crash_id = dict()
        self.last_event_log_time = None
        self.retry_resurrection = False
        self.setup_complete = False
        self.runPeriodically(self.agentMonitor, self.poll_time)
        self.runPeriodically(self.agentBackupMonitor, self.backup_poll_time,start_immediately=False)
        self.runPeriodically(self.eventMonitor, self.poll_time,start_immediately=False)
        self.run()
Exemple #2
0
    def __init__(self,config_path, **kwargs):
        kwargs['identity'] = 'platformmonitoragent2'
        super(PlatformMonitorAgent, self).__init__(**kwargs)

        # Step1: Agent Code
        config = utils.load_config(config_path)
        def get_config(name):
            try:
                kwargs.pop(name)
            except KeyError:
                return config.get(name, '')

        multinode_data = db_helper.get_multinode_data()
        self.node_name = multinode_data['this_node']
        self.mynode = db_helper.get_node_id()

        self.agent_id = get_config('agent_id')
        self.poll_time = get_config('poll_time')
        self.backup_poll_time = get_config('backup_poll_time')

        platform_variables['agent_id'] = self.agent_id + '_' + self.node_name
        notification_variables['agent_id'] = self.agent_id

        self.variables = kwargs
        self.db_host = db_host
        self.last_seen_dead = dict()
        self.cassandra_death_time = None #Arbitrary initialization
        self.cassandra_death_date = None
        self.crash_id = dict()
        self.last_event_log_time = None
        self.retry_resurrection = False
Exemple #3
0
 def __init__(self, **kwargs):
     super(BEMOSSAgent, self).__init__(**kwargs)
     self.multinode_data = db_helper.get_multinode_data()
     self.node_name = self.multinode_data['this_node']
     if not os.path.isfile(settings.MULTINODE_PARENT_IP_FILE
                           ):  # but parent file doesn't exists
         parent_addr = self.multinode_data['known_nodes'][0]['address']
         parent_ip = self.extract_ip(parent_addr)
         with open(settings.MULTINODE_PARENT_IP_FILE, 'w') as f:
             f.write(parent_ip)
     self.curcon = db_helper.db_connection()
Exemple #4
0
 def __init__(self, *args, **kwargs):
     super(BEMOSSAgent, self).__init__(*args, **kwargs)
     self.agent_id = kwargs['name']
     self.multinode_data = db_helper.get_multinode_data()
     self.node_name = self.multinode_data['this_node']
     if not os.path.isfile(settings.MULTINODE_PARENT_IP_FILE
                           ):  # but parent file doesn't exists
         parent_addr = self.multinode_data['known_nodes'][0]['address']
         parent_ip = self.extract_ip(parent_addr)
         with open(settings.MULTINODE_PARENT_IP_FILE, 'w') as f:
             f.write(parent_ip)
     self.subscription_dict = {}
     self.listenMessages(self.handle_message)
Exemple #5
0
    def getMultinodeData(self):
        self.multinode_data = db_helper.get_multinode_data()

        self.nodelist_dict = {
            node['name']: node
            for node in self.multinode_data['known_nodes']
        }
        self.node_name_list = [
            node['name'] for node in self.multinode_data['known_nodes']
        ]
        self.address_list = [
            node['address'] for node in self.multinode_data['known_nodes']
        ]
        self.server_key_list = [
            node['server_key'] for node in self.multinode_data['known_nodes']
        ]
        self.node_name = self.multinode_data['this_node']

        for index, node in enumerate(self.multinode_data['known_nodes']):
            if node['name'] == self.node_name:
                self.node_index = index
                break
        else:
            raise ValueError(
                '"this_node:" entry on the multinode_data json file is invalid'
            )

        for node_name in self.node_name_list:  #initialize all nodes data
            if node_name not in self.multinode_status:  #initialize new nodes. There could be already the node if this getMultiNode
                # data is being called later
                self.multinode_status[node_name] = dict()
                self.multinode_status[node_name][
                    'health'] = -10  #initialized; never online/offline
                self.multinode_status[node_name]['last_sync_time'] = datetime(
                    1991, 1, 1)
                self.multinode_status[node_name]['last_online_time'] = None
                self.multinode_status[node_name]['last_offline_time'] = None
                self.multinode_status[node_name]['last_scanned_time'] = None
#1.Basic variables initialized

Agents_Launch_DIR = settings.Agents_Launch_DIR

Agents_DIR = settings.Agents_DIR
db_database = settings.DATABASES['default']['NAME']
db_host = settings.DATABASES['default']['HOST']
db_port = settings.DATABASES['default']['PORT']
db_user = settings.DATABASES['default']['USER']
db_password = settings.DATABASES['default']['PASSWORD']
db_table_node_device = settings.DATABASES['default']['TABLE_node_device']
db_table_device_info = settings.DATABASES['default']['TABLE_device_info']
db_table_node_info = settings.DATABASES['default']['TABLE_node_info']

multinode_data = db_helper.get_multinode_data()

node_name = multinode_data['this_node']

myips = find_own_ip.getIPs()
_email_subject = node_name+'@'+str(myips[0])
emailService = EmailService()

#email settings
email_fromaddr = settings.NOTIFICATION['email']['fromaddr']
email_recipients = settings.NOTIFICATION['email']['recipients']
email_username = settings.NOTIFICATION['email']['username']
email_password = settings.NOTIFICATION['email']['password']
email_mailServer = settings.NOTIFICATION['email']['mailServer']