Exemple #1
0
def get_support_info (system_id, ticket):
    args = {}
    args['output_type'] = 'support'
    args['output_raw'] = 'True'
    args['output_file_prefix'] = ticket

    (success, ip) = get_system_ip_from_system_id(system_id)
    if not success:
        return (False, "Bad system_id '%s'" % system_id)

    if not ticket.isdigit() or len(ticket) != 8:
        return (False, "Bad ticket id format: %s" % ticket)

    file_uploaded = False
    file_name = ''

    data = get_doctor_data ([ip], args)
    if ip in data['dark']:
        return (False, data['dark'][ip]['msg'])

    if data['contacted'][ip]['rc'] == 0:
        file_uploaded = True
    elif data['contacted'][ip]['rc'] == 1:
        file_name = data['contacted'][ip]['data'].replace('\n', '')
    else:
        return (False, "Error Calling support tool")

    if not file_uploaded:
        (success, data) = fetch_file(ip, file_name, file_name)

    return (True, {'file_uploaded': file_uploaded, 'file_name': file_name})
Exemple #2
0
def get_support_info(system_id, ticket):
    args = {}
    args["output_type"] = "support"
    args["output_raw"] = "True"
    args["output_file_prefix"] = ticket

    (success, ip) = get_system_ip_from_system_id(system_id)
    if not success:
        return (False, "Bad system_id '%s'" % system_id)

    if not ticket.isdigit() or len(ticket) != 8:
        return (False, "Bad ticket id format: %s" % ticket)

    file_uploaded = False
    file_name = ""

    data = get_doctor_data([ip], args)
    if ip in data["dark"]:
        return (False, data["dark"][ip]["msg"])

    if data["contacted"][ip]["rc"] == 0:
        file_uploaded = True
    elif data["contacted"][ip]["rc"] == 1:
        file_name = data["contacted"][ip]["data"].replace("\n", "")
    else:
        return (False, "Error Calling support tool")

    if not file_uploaded:
        (success, data) = fetch_file(ip, file_name, file_name)

    return (True, {"file_uploaded": file_uploaded, "file_name": file_name})
Exemple #3
0
def get_support_info (system_id, ticket):
    args = {}
    args['output_type'] = 'support'
    args['output_raw'] = 'True'
    args['verbose'] = 2
    args['output_file_prefix'] = ticket

    (success, ip) = get_system_ip_from_system_id(system_id)
    if not success:
        return (False, "Bad system_id '%s'" % system_id)

    if not ticket.isdigit() or len(ticket) != 8:
        return (False, "Bad ticket id format: %s" % ticket)

    file_uploaded = False
    file_name = ''

    data = get_doctor_data ([ip], args)
    if ip in data['dark']:
        return (False, data['dark'][ip]['msg'])

    if data['contacted'][ip]['rc'] == 0:
        file_uploaded = True
    elif data['contacted'][ip]['rc'] == 1:
        file_name = data['contacted'][ip]['data'].replace('\n', '')
        # Clean to extract the filename
        file_name = re.sub(r'.*\/var\/ossim', '/var/ossim', file_name)
        file_name = re.sub(r'\.doctor.*', '.doctor', file_name)
    else:
        return (False, "Error Calling support tool")

    if not file_uploaded:
        (success, data) = fetch_file(ip, file_name, file_name)

    return (True, {'file_uploaded': file_uploaded, 'file_name': file_name})
Exemple #4
0
    def start(self):
        """
        Starts the monitor activity

        :return: True on success, False otherwise
        """
        self.remove_monitor_data()
        monitor_data = {}

        success, system_id = get_system_id_from_local()
        if not success:
            return False

        # Just return if there is no internet connection.
        if not self.__check_internet_connection__():
            logger.error("Cannot connect to the Telemetry Server")
            monitor_data['telemetry_server_connectivity'] = False
            self.save_data(system_id, ComponentTypes.SYSTEM,
                           self.get_json_message(monitor_data))
            return True

        # Find the list of connected systems.
        (result, sensor_dict) = get_systems('Sensor',
                                            convert_to_dict=True,
                                            exclusive=True)
        if not result:
            logger.error("Cannot retrieve connected sensors")
            return False
        (result, database_dict) = get_systems('Database',
                                              convert_to_dict=True,
                                              exclusive=True)
        if not result:
            logger.error("Cannot retrieve connected databases")
            return False
        system_dict = dict(sensor_dict, **database_dict)

        result, local_system_id = get_system_id_from_local()
        if not result:
            logger.error("Cannot retrieve the local id")
            return False
        result, local_system_ip = get_system_ip_from_system_id(local_system_id)
        if not result:
            logger.error("Cannot retrieve the local IP address")
            return False
        system_dict = dict({local_system_id: local_system_ip}, **system_dict)

        args = {
            'output_type': 'ansible',
            'plugin_list': ','.join(self.__strike_zone_plugins),
            'verbose': 2
        }
        ansible_output = get_doctor_data(system_dict.values(), args)
        if ansible_output.get('dark'):
            logger.error('Cannot collect telemetry data: %s' %
                         str(ansible_output.get('dark')))
            return False

        return self.__send_data__(local_system_id, ansible_output)
Exemple #5
0
    def start(self):
        """
        Starts the monitor activity

        :return: True on success, False otherwise
        """
        self.remove_monitor_data()
        monitor_data = {}

        success, system_id = get_system_id_from_local()
        if not success:
            return False

        # Just return if there is no internet connection.
        if not self.__check_internet_connection__():
            logger.error("Cannot connect to the Telemetry Server")
            monitor_data['telemetry_server_connectivity'] = False
            self.save_data(system_id,
                           ComponentTypes.SYSTEM,
                           self.get_json_message(monitor_data))
            return True

        # Find the list of connected systems.
        (result, sensor_dict) = get_systems('Sensor', convert_to_dict=True, exclusive=True)
        if not result:
            logger.error("Cannot retrieve connected sensors")
            return False
        (result, database_dict) = get_systems('Database', convert_to_dict=True, exclusive=True)
        if not result:
            logger.error("Cannot retrieve connected databases")
            return False
        system_dict = dict(sensor_dict, **database_dict)

        result, local_system_id = get_system_id_from_local()
        if not result:
            logger.error("Cannot retrieve the local id")
            return False
        result, local_system_ip = get_system_ip_from_system_id(local_system_id)
        if not result:
            logger.error("Cannot retrieve the local IP address")
            return False
        system_dict = dict({local_system_id: local_system_ip}, **system_dict)

        args = {'output_type': 'ansible',
                'plugin_list': ','.join(self.__strike_zone_plugins),
                'verbose': 2}
        ansible_output = get_doctor_data(system_dict.values(), args)
        if ansible_output.get('dark'):
            logger.error('Cannot collect telemetry data: %s' % str(ansible_output.get('dark')))
            return False

        return self.__send_data__(local_system_id, ansible_output)