def _getListQueuesCmd(self, exitCode, output_filename): points = [] components = ( "zenoss.queues.modelrequests.vmware", "zenoss.queues.zep.migrated.summary", "zenoss.queues.zep.migrated.archive", "zenoss.queues.zep.rawevents", "zenoss.queues.dsa.impactchange", "zenoss.queues.zep.heartbeats", "zenoss.queues.state.zenevents", "zenoss.queues.dsa.statechange", "zenoss.queues.zep.zenevents", "zenoss.queues.zep.modelchange", "zenoss.queues.impact.modelchange", ) fields = ("ready", "unacknowledged", "messages", "consumers", "memory") for component in components: for dp_id in fields: dpc = DataPointConfig() dpc.id = dp_id dpc.component = component points.append(dpc) cmd = self._getCmd( "rabbit@maverick", "rabbitmqctl -q -n rabbit@dev1 list_queues -p /zenoss name messages_ready messages_unacknowledged messages consumers memory status 2>&1", exitCode, output_filename, points, ) return cmd
def _getListConnectionsCmd(self, exitCode, output_filename): points = [] fields = ( 'connections', 'channels', 'sendQueue', 'recvBytes', 'recvCount', 'sendBytes', 'sendCount', ) for dp_id in fields: dpc = DataPointConfig() dpc.id = dp_id dpc.component = 'rabbit@maverick' points.append(dpc) cmd = self._getCmd( 'rabbit@maverick', 'rabbitmqctl -q -n rabbit@maverick list_connections pid channels recv_oct recv_cnt send_oct send_cnt send_pend 2>&1', exitCode, output_filename, points) return cmd
def _getDsDatapoints(self, comp, ds, ploader, perfServer): """ Given a component a data source, gather its data points """ parser = ploader.create() points = [] component_name = ds.getComponent(comp) contextUUID = comp.getUUID() devuuid = comp.device().getUUID() componentId = comp.id for dp in ds.getRRDDataPoints(): dpc = DataPointConfig() dpc.id = dp.id dpc.component = component_name dpc.contextUUID = contextUUID dpc.componentId = componentId dpc.dpName = dp.name() dpc.devuuid = devuuid dpc.rrdType = dp.rrdtype dpc.rrdCreateCommand = dp.getRRDCreateCommand(perfServer) dpc.rrdMin = dp.rrdmin dpc.rrdMax = dp.rrdmax dpc.data = parser.dataForParser(comp, dp) points.append(dpc) return points
def _datasources(self, deviceOrComponent, deviceId, componentId, collector): for template in deviceOrComponent.getRRDTemplates(): # Get all enabled datasources that are PythonDataSource or # subclasses thereof. datasources = [ ds for ds in template.getRRDDataSources() \ if ds.enabled and isinstance(ds, PythonDataSource)] for ds in datasources: datapoints = [] for dp in ds.datapoints(): dp_config = DataPointConfig() dp_config.id = dp.id dp_config.component = componentId dp_config.rrdPath = '/'.join((deviceOrComponent.rrdPath(), dp.name())) dp_config.rrdType = dp.rrdtype dp_config.rrdCreateCommand = dp.getRRDCreateCommand(collector) dp_config.rrdMin = dp.rrdmin dp_config.rrdMax = dp.rrdmax # Attach unknown properties to the dp_config for key in dp.propdict().keys(): if key in known_point_properties: continue try: setattr(dp_config, key, getattr(dp, key)) except Exception: pass datapoints.append(dp_config) ds_config = PythonDataSourceConfig() ds_config.device = deviceId ds_config.manageIp = deviceOrComponent.getManageIp() ds_config.component = componentId ds_config.plugin_classname = ds.plugin_classname ds_config.template = template.id ds_config.datasource = ds.titleOrId() ds_config.config_key = ds.getConfigKey(deviceOrComponent) ds_config.params = ds.getParams(deviceOrComponent) ds_config.cycletime = ds.getCycleTime(deviceOrComponent) ds_config.eventClass = ds.eventClass ds_config.eventKey = ds.eventKey ds_config.severity = ds.severity ds_config.points = datapoints # Populate attributes requested by plugin. plugin_class = load_plugin_class(ds.plugin_classname) for attr in plugin_class.proxy_attributes: value = getattr(deviceOrComponent, attr, None) if callable(value): value = value() setattr(ds_config, attr, value) yield ds_config
def _datasources(self, deviceOrComponent, deviceId, componentId, collector): for template in deviceOrComponent.getRRDTemplates(): # Get all enabled datasources that are PythonDataSource or # subclasses thereof. datasources = [ ds for ds in template.getRRDDataSources() \ if ds.enabled and isinstance(ds, PythonDataSource)] for ds in datasources: datapoints = [] for dp in ds.datapoints(): dp_config = DataPointConfig() dp_config.id = dp.id dp_config.component = componentId dp_config.rrdPath = '/'.join( (deviceOrComponent.rrdPath(), dp.name())) dp_config.rrdType = dp.rrdtype dp_config.rrdCreateCommand = dp.getRRDCreateCommand( collector) dp_config.rrdMin = dp.rrdmin dp_config.rrdMax = dp.rrdmax # Attach unknown properties to the dp_config for key in dp.propdict().keys(): if key in known_point_properties: continue try: setattr(dp_config, key, getattr(dp, key)) except Exception: pass datapoints.append(dp_config) ds_config = PythonDataSourceConfig() ds_config.device = deviceId ds_config.manageIp = deviceOrComponent.getManageIp() ds_config.component = componentId ds_config.plugin_classname = ds.plugin_classname ds_config.template = template.id ds_config.datasource = ds.titleOrId() ds_config.config_key = ds.getConfigKey(deviceOrComponent) ds_config.params = ds.getParams(deviceOrComponent) ds_config.cycletime = ds.getCycleTime(deviceOrComponent) ds_config.eventClass = ds.eventClass ds_config.eventKey = ds.eventKey ds_config.severity = ds.severity ds_config.points = datapoints # Populate attributes requested by plugin. plugin_class = load_plugin_class(ds.plugin_classname) for attr in plugin_class.proxy_attributes: setattr(ds_config, attr, getattr(deviceOrComponent, attr, None)) yield ds_config
def _getCmd(self, output_filename): cmd = Cmd() # DeviceConfig no longer exists as of Zenoss 4. try: from Products.ZenRRD.zencommand import DeviceConfig cmd.deviceConfig = DeviceConfig() except ImportError: from Products.ZenCollector.services.config import DeviceProxy cmd.deviceConfig = DeviceProxy() cmd.deviceConfig.device = 'swift' cmd.component = 'swift' cmd.command = 'poll_swift_recon -H 127.0.0.1' cmd.eventClass = '/Status/Swift' cmd.eventKey = 'rabbitmq_node_status' cmd.result = FakeCmdResult(0, loadData(output_filename)) metrics = ( 'asyncPending', 'diskSizeAvg', 'diskSizeMax', 'diskSizeMin', 'diskUsageAvg', 'diskUsageMax', 'diskUsageMin', 'load1', 'load15', 'load15PerDisk', 'load5', 'pidRate', 'quarantinedAccounts', 'quarantinedContainers', 'quarantinedObjects', 'replicationTime', 'runningProcs', 'totalDisks', 'totalProcs', 'unmountedDisks', ) points = [] for metric in metrics: dpc = DataPointConfig() dpc.id = metric dpc.component = 'swift' points.append(dpc) cmd.points = points return cmd
def _getListChannelsCmd(self, exitCode, output_filename): points = [] for dp_id in ('consumers', 'unacknowledged', 'uncommitted'): dpc = DataPointConfig() dpc.id = dp_id dpc.component = 'rabbit@maverick' points.append(dpc) cmd = self._getCmd( 'rabbit@maverick', 'rabbitmqctl -q -n rabbit@maverick list_channels pid consumer_count messages_unacknowledged acks_uncommitted 2>&1', exitCode, output_filename, points) return cmd
def _getDumpAggregateCmd(self, exitCode, filename): points = [] for dp_id in ('packet_count', 'byte_count', 'flow_count',): dpc = DataPointConfig() dpc.id = dp_id dpc.component = 'bridges' points.append(dpc) cmd = self._getCmd( 'bridge-3fe10504-e059-4398-8b12-b7627e7b5b95', '/usr/bin/ovs-ofctl dump-aggregate br-int', exitCode, filename, points) return cmd
def _getListChannelsCmd(self, exitCode, output_filename): points = [] for dp_id in ('consumers', 'unacknowledged', 'uncommitted'): dpc = DataPointConfig() dpc.id = dp_id dpc.component = 'rabbit@maverick' points.append(dpc) cmd = self._getCmd( 'rabbit@maverick', 'rabbitmqctl -q -n rabbit@maverick list_channels pid consumer_count messages_unacknowledged acks_uncommitted status 2>&1', exitCode, output_filename, points) return cmd
def _getListChannelsCmd(self, exitCode, output_filename): points = [] for dp_id in ("consumers", "unacknowledged", "uncommitted"): dpc = DataPointConfig() dpc.id = dp_id dpc.component = "rabbit@maverick" points.append(dpc) cmd = self._getCmd( "rabbit@maverick", "rabbitmqctl -q -n rabbit@maverick list_channels pid consumer_count messages_unacknowledged acks_uncommitted status 2>&1", exitCode, output_filename, points, ) return cmd
def _getListInterfacesCmd(self, exitCode, filename): points = [] for dp_id in ('rx_bytes', 'tx_bytes', 'rx_packets', 'tx_packets' 'collisions', 'rx_dropped', 'tx_dropped', 'rx_crc_err', 'rx_frame_err', 'rx_errors', 'tx_errors', ): dpc = DataPointConfig() dpc.id = dp_id dpc.component = 'interfaces' points.append(dpc) cmd = self._getCmd( 'interface-6898492f-2d2e-439e-9370-a0073a0669f8', '/usr/bin/ovs-vsctl --columns=_uuid,statistics,external_ids,mac_in_use,name list interface', exitCode, filename, points) return cmd
def component_datasources(self, component, collector): for template in component.getRRDTemplates(): # Get all enabled datasources that are PerfAMQPDataSources datasources = [ ds for ds in template.getRRDDataSources() if ds.enabled and isinstance(ds, PerfAMQPDataSource) ] device = component.device() for ds in datasources: datapoints = [] for dp in ds.datapoints(): dp_config = DataPointConfig() dp_config.id = dp.id dp_config.dpName = dp.name() dp_config.component = component.id dp_config.rrdPath = '/'.join( (component.rrdPath(), dp.name())) dp_config.rrdType = dp.rrdtype dp_config.rrdCreateCommand = dp.getRRDCreateCommand( collector) dp_config.rrdMin = dp.rrdmin dp_config.rrdMax = dp.rrdmax # MetricMixin.getMetricMetadata() added in Zenoss 5. if hasattr(component, 'getMetricMetadata'): dp_config.metadata = component.getMetricMetadata() datapoints.append(dp_config) ds_config = OpenStackDataSourceConfig() ds_config.device = device.id ds_config.component = component.id ds_config.component_meta_type = component.meta_type ds_config.template = template.id ds_config.datasource = ds.titleOrId() ds_config.points = datapoints ds_config.meter = ds.meter ds_config.resourceId = component.resourceId yield ds_config
def _getListConnectionsCmd(self, exitCode, output_filename): points = [] fields = ("connections", "channels", "sendQueue", "recvBytes", "recvCount", "sendBytes", "sendCount") for dp_id in fields: dpc = DataPointConfig() dpc.id = dp_id dpc.component = "rabbit@maverick" points.append(dpc) cmd = self._getCmd( "rabbit@maverick", "rabbitmqctl -q -n rabbit@maverick list_connections pid channels recv_oct recv_cnt send_oct send_cnt send_pend status 2>&1", exitCode, output_filename, points, ) return cmd
def component_datasources(self, component, collector): for template in component.getRRDTemplates(): # Get all enabled datasources that are PerfAMQPDataSources datasources = [ ds for ds in template.getRRDDataSources() if ds.enabled and isinstance(ds, PerfAMQPDataSource)] device = component.device() for ds in datasources: datapoints = [] for dp in ds.datapoints(): dp_config = DataPointConfig() dp_config.id = dp.id dp_config.dpName = dp.name() dp_config.component = component.id dp_config.rrdPath = '/'.join((component.rrdPath(), dp.name())) dp_config.rrdType = dp.rrdtype dp_config.rrdCreateCommand = dp.getRRDCreateCommand(collector) dp_config.rrdMin = dp.rrdmin dp_config.rrdMax = dp.rrdmax # MetricMixin.getMetricMetadata() added in Zenoss 5. if hasattr(component, 'getMetricMetadata'): dp_config.metadata = component.getMetricMetadata() datapoints.append(dp_config) ds_config = OpenStackDataSourceConfig() ds_config.device = device.id ds_config.component = component.id ds_config.component_meta_type = component.meta_type ds_config.template = template.id ds_config.datasource = ds.titleOrId() ds_config.points = datapoints ds_config.meter = ds.meter ds_config.resourceId = component.resourceId yield ds_config
def _getDsDatapoints(self, device, comp, ds, ploader, perfServer): """ Given a component a data source, gather its data points """ parser = ploader.create() points = [] component_name = ds.getComponent(comp, device=device) for dp in ds.getRRDDataPoints(): dpc = DataPointConfig() dpc.id = dp.id dpc.component = component_name dpc.dpName = dp.name() dpc.rrdType = dp.rrdtype dpc.rrdCreateCommand = dp.getRRDCreateCommand(perfServer) dpc.rrdMin = dp.rrdmin dpc.rrdMax = dp.rrdmax dpc.data = parser.dataForParser(comp, dp) dpc.metadata = comp.getMetricMetadata(device) points.append(dpc) return points
def _getDsDatapoints(self, comp, ds, ploader, perfServer): """ Given a component a data source, gather its data points """ parser = ploader.create() points = [] component_name = ds.getComponent(comp) basepath = comp.rrdPath() for dp in ds.getRRDDataPoints(): dpc = DataPointConfig() dpc.id = dp.id dpc.component = component_name dpc.rrdPath = "/".join((basepath, dp.name())) dpc.rrdType = dp.rrdtype dpc.rrdCreateCommand = dp.getRRDCreateCommand(perfServer) dpc.rrdMin = dp.rrdmin dpc.rrdMax = dp.rrdmax dpc.data = parser.dataForParser(comp, dp) points.append(dpc) return points
def _getDsDatapoints(self, device, comp, ds, ploader, perfServer): """ Given a component a data source, gather its data points """ parser = ploader.create() points = [] component_name = ds.getComponent(comp, device=device) for dp in ds.getRRDDataPoints(): dpc = DataPointConfig() dpc.id = dp.id dpc.component = component_name dpc.dpName = dp.name() dpc.rrdType = dp.rrdtype dpc.rrdCreateCommand = dp.getRRDCreateCommand(perfServer) dpc.rrdMin = dp.rrdmin dpc.rrdMax = dp.rrdmax dpc.data = parser.dataForParser(comp, dp) dpc.metadata = comp.getMetricMetadata(device) dpc.tags = dp.getTags(comp) points.append(dpc) return points
def _getListQueuesCmd(self, exitCode, output_filename): points = [] components = ( 'zenoss.queues.modelrequests.vmware', 'zenoss.queues.zep.migrated.summary', 'zenoss.queues.zep.migrated.archive', 'zenoss.queues.zep.rawevents', 'zenoss.queues.dsa.impactchange', 'zenoss.queues.zep.heartbeats', 'zenoss.queues.state.zenevents', 'zenoss.queues.dsa.statechange', 'zenoss.queues.zep.zenevents', 'zenoss.queues.zep.modelchange', 'zenoss.queues.impact.modelchange', ) fields = ( 'ready', 'unacknowledged', 'messages', 'consumers', 'memory', ) for component in components: for dp_id in fields: dpc = DataPointConfig() dpc.id = dp_id dpc.component = component points.append(dpc) cmd = self._getCmd( 'rabbit@maverick', 'rabbitmqctl -q -n rabbit@dev1 list_queues -p /zenoss name messages_ready messages_unacknowledged messages consumers memory status 2>&1', exitCode, output_filename, points) return cmd
def _datasources(self, deviceOrComponent, deviceId, componentId, collector): for template in deviceOrComponent.getRRDTemplates(): # Get all enabled datasources that are PythonDataSource or # subclasses thereof. datasources = [ ds for ds in template.getRRDDataSources() \ if ds.enabled and isinstance(ds, PythonDataSource)] device = deviceOrComponent.device() for ds in datasources: datapoints = [] try: ds_plugin_class = ds.getPluginClass() except Exception as e: log.error( "Failed to load plugin %r for %s/%s: %s", ds.plugin_classname, template.id, ds.titleOrId(), e) continue for dp in ds.datapoints(): dp_config = DataPointConfig() dp_config.id = dp.id dp_config.dpName = dp.name() dp_config.component = componentId dp_config.rrdPath = '/'.join((deviceOrComponent.rrdPath(), dp.name())) dp_config.rrdType = dp.rrdtype dp_config.rrdCreateCommand = dp.getRRDCreateCommand(collector) dp_config.rrdMin = dp.rrdmin dp_config.rrdMax = dp.rrdmax # MetricMixin.getMetricMetadata() added in Zenoss 5. if hasattr(deviceOrComponent, 'getMetricMetadata'): dp_config.metadata = deviceOrComponent.getMetricMetadata() # Attach unknown properties to the dp_config for key in dp.propdict().keys(): if key in known_point_properties: continue try: value = getattr(dp, key) if isinstance(value, basestring) and '$' in value: extra = { 'device': device, 'dev': device, 'devname': device.id, 'datasource': ds, 'ds': ds, 'datapoint': dp, 'dp': dp, } value = talesEvalStr( value, deviceOrComponent, extra=extra) setattr(dp_config, key, value) except Exception: pass datapoints.append(dp_config) ds_config = PythonDataSourceConfig() ds_config.device = deviceId ds_config.manageIp = deviceOrComponent.getManageIp() ds_config.component = componentId ds_config.plugin_classname = ds.plugin_classname ds_config.template = template.id ds_config.datasource = ds.titleOrId() ds_config.config_key = ds.getConfigKey(deviceOrComponent) ds_config.params = ds.getParams(deviceOrComponent) ds_config.cycletime = ds.getCycleTime(deviceOrComponent) ds_config.eventClass = ds.eventClass ds_config.eventKey = ds.eventKey ds_config.severity = ds.severity ds_config.points = datapoints # Populate attributes requested by plugin. for attr in ds_plugin_class.proxy_attributes: value = getattr(deviceOrComponent, attr, None) if callable(value): value = value() setattr(ds_config, attr, value) yield ds_config