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
Exemple #3
0
    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 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, 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
Exemple #6
0
    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
Exemple #7
0
    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, 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
Exemple #9
0
    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