def start(self): """ Starts the monitor activity """ # Remove the previous monitor data. self.remove_monitor_data() # Iterate over the sensors. success, systems = get_systems(system_type="Sensor") if not success: logger.error("[MonitorUpdateHostPlugins] " "Can't retrieve the system info: {0}".format( str(systems))) return False assets = {} for (system_id, system_ip) in systems: success, sensor_id = get_sensor_id_from_system_id(system_id) if not success: logger.error( "[MonitorUpdateHostPlugins] " "Can't resolve senor_id of system {0}: {1}".format( system_id, sensor_id)) continue try: sensor_plugins = get_sensor_plugins_enabled_by_asset( sensor_id=sensor_id, no_cache=True) except APIException as e: logger.error( "[MonitorUpdateHostPlugins] " "Can't obtain plugin information from system {0}: {1}". format(system_id, str(e))) continue # Add asset plugin sids to assets list try: for asset, asset_plugins in sensor_plugins.iteritems(): if asset not in assets: assets[asset] = [] assets[asset] += [ plugin['plugin_id'] for plugin in asset_plugins.values() ] except KeyError as e: logger.warning( "[MonitorUpdateHostPlugins] " "Bad format in plugins enabled by asset: {0}".format( str(e))) success, msg = update_host_plugins(data=assets) if not success: logger.error( "[MonitorUpdateHostPlugins] " "Can't update host plugin information: {0}".format(msg)) return False return True
def bp_get_sensor_plugins_asset_enabled(sensor_id): """ Return the plugins enabled by asset in a sensor filtered by asset_id :param sensor_id: The sensor which we want to get the data :param asset_id: Filter by asset (canonical uuid) """ asset_id = request.args.get('asset_id', None) try: plugins = get_sensor_plugins_enabled_by_asset(sensor_id=sensor_id, asset_id=asset_id) except APIException as e: return make_error_from_exception(e) return make_ok(plugins=plugins)
def start(self): """ Starts the monitor activity """ # Remove the previous monitor data. self.remove_monitor_data() # Iterate over the sensors. success, systems = get_systems(system_type="Sensor") if not success: logger.error("[MonitorUpdateHostPlugins] " "Can't retrieve the system info: {0}".format(str(systems))) return False assets = {} for (system_id, system_ip) in systems: success, sensor_id = get_sensor_id_from_system_id(system_id) if not success: logger.error("[MonitorUpdateHostPlugins] " "Can't resolve senor_id of system {0}: {1}".format(system_id, sensor_id)) continue try: sensor_plugins = get_sensor_plugins_enabled_by_asset(sensor_id=sensor_id, no_cache=True) except APIException as e: logger.error("[MonitorUpdateHostPlugins] " "Can't obtain plugin information from system {0}: {1}".format( system_id, str(e))) continue # Add asset plugin sids to assets list try: for asset, asset_plugins in sensor_plugins.iteritems(): if asset not in assets: assets[asset] = [] assets[asset] += [plugin['plugin_id'] for plugin in asset_plugins.values()] except KeyError as e: logger.warning("[MonitorUpdateHostPlugins] " "Bad format in plugins enabled by asset: {0}".format(str(e))) success, msg = update_host_plugins(data=assets) if not success: logger.error("[MonitorUpdateHostPlugins] " "Can't update host plugin information: {0}".format(msg)) return False return True