def bulkLoadMetricData(self, infos):
        """
        If the info objects have the attribute dataPointsToFetch we
        will load all the datapoints in one metric service query
        instead of one per info object
        """
        if len(infos) == 0:
            return
        datapoints = set()
        indexedInfos = dict()
        for info in infos:
            indexedInfos[info._object.getResourceKey()] = info
            if hasattr(info, "dataPointsToFetch"):
                [datapoints.add(dp) for dp in info.dataPointsToFetch]

        # in case no metrics were asked for
        if len(datapoints) == 0:
            return
        # get the metric facade
        mfacade = getFacade('metric', self._dmd)
        # metric facade expects zenmodel objects or uids
        results = mfacade.getMultiValues([i._object for i in infos], datapoints, returnSet="LAST")

        # assign the metrics to the info objects
        for resourceKey, record in results.iteritems():
            if indexedInfos.get(resourceKey) is not None:
                info = indexedInfos[resourceKey]
                for key, val in record.iteritems():
                    info.setBulkLoadProperty(key, val)
    def bulkLoadMetricData(self, infos):
        """
        If the info objects have the attribute dataPointsToFetch we
        will load all the datapoints in one metric service query
        instead of one per info object
        """
        if len(infos) == 0:
            return
        datapoints = set()
        indexedInfos = dict()
        for info in infos:
            indexedInfos[info._object.getResourceKey()] = info
            if hasattr(info, "dataPointsToFetch"):
                [datapoints.add(dp) for dp in info.dataPointsToFetch]

        # in case no metrics were asked for
        if len(datapoints) == 0:
            return
        # get the metric facade
        mfacade = getFacade('metric', self._dmd)
        # metric facade expects zenmodel objects or uids
        results = mfacade.getMultiValues([i._object for i in infos],
                                         datapoints,
                                         returnSet="LAST")

        # assign the metrics to the info objects
        for resourceKey, record in results.iteritems():
            if indexedInfos.get(resourceKey) is not None:
                info = indexedInfos[resourceKey]
                for key, val in record.iteritems():
                    info.setBulkLoadProperty(key, val)
Exemple #3
0
 def _assignPingStatuses(self, infos, pingStatuses):
     """
     Takes the results from zep and determines what the
     status should be on that ip address row
     """
     prop = 'pingstatus'
     for info in infos:
         dev = info.device
         if not dev:
             info.setBulkLoadProperty(prop, 5)
             continue
         # get from ping statuses
         status = pingStatuses[info.device.uuid]
         count = status[SEVERITY_ERROR]['count'] + status[SEVERITY_CRITICAL]['count'] + status[SEVERITY_WARNING]['count']
         info.setBulkLoadProperty(prop, count)
Exemple #4
0
 def _assignPingStatuses(self, infos, pingStatuses):
     """
     Takes the results from zep and determines what the
     status should be on that ip address row
     """
     prop = 'pingstatus'
     for info in infos:
         dev = info.device
         if not dev:
             info.setBulkLoadProperty(prop, 5)
             continue
         # get from ping statuses
         status = pingStatuses[info.device.uuid]
         count = status[SEVERITY_ERROR]['count'] + status[SEVERITY_CRITICAL]['count'] + status[SEVERITY_WARNING]['count']
         info.setBulkLoadProperty(prop, count)
 def _assignSnmpStatuses(self, infos, snmpStatuses):
     """
     Takes the results from zep and assigns the correct snmp
     status. This must also look at a couple of zproperties
     """
     prop = "snmpstatus"
     for info in infos:
         dev = info.device
         if not dev:
             info.setBulkLoadProperty(prop, 5)
             continue
         info.setBulkLoadProperty(prop, -1)
         obj = dev._object
         if (
             not getattr(obj, "zSnmpMonitorIgnore", False)
             and getattr(obj, "zSnmpCommunity", "")
             and obj.monitorDevice()
         ):
             # get from snmp statuses
             status = snmpStatuses[info.device.uuid]
             count = (
                 status[SEVERITY_ERROR]["count"]
                 + status[SEVERITY_CRITICAL]["count"]
                 + status[SEVERITY_WARNING]["count"]
             )
             info.setBulkLoadProperty(prop, count)
Exemple #6
0
 def _assignSnmpStatuses(self, infos, snmpStatuses):
     """
     Takes the results from zep and assigns the correct snmp
     status. This must also look at a couple of zproperties
     """
     prop = 'snmpstatus'
     for info in infos:
         dev = info.device
         if not dev:
             info.setBulkLoadProperty(prop, 5)
             continue
         info.setBulkLoadProperty(prop, -1)
         obj = dev._object
         if (not getattr(obj, 'zSnmpMonitorIgnore', False)
             and getattr(obj, 'zSnmpCommunity', "")
             and obj.monitorDevice()):
             # get from snmp statuses
             status = snmpStatuses[info.device.uuid]
             count = status[SEVERITY_ERROR]['count'] + status[SEVERITY_CRITICAL]['count'] + status[SEVERITY_WARNING]['count']
             info.setBulkLoadProperty(prop, count)