def run(self, dmd, args):
        # This allows us to easily use the common start/end/consolidation
        # parameters that you'd typically want for graphs.
        summary = Utilization.getSummaryArgs(dmd, args)
        
        self.cFunc = summary['function']
        # FIXME 16APR09:  This will not work with distributed collectors
        self.collector = dmd.Monitors.Performance.localhost
        
        # Setup basic graph properties.
        graph = [
            '-F', '-E',
            '--height=250', '--width=600', '--lower-limit=0',
            '--vertical-label=Humidity',
            '--start=%d' % (int(summary['start']),),
            '--end=%d' % (int(summary['end']),)
            ]
        

        # This is the workhorse method that goes and generates the real data in
        # the graph.
        graph.extend(self.getHumidity( dmd.Devices.Power.SentryCDU.getSubDevices()))

        # Do some post-processing to get a proper URL for the graph image.
        graph = self.collector._fullPerformancePath(graph)
        url = self.collector.buildGraphUrlFromCommands(graph, summary['end'] - summary['start'])

        
        # This is done to prevent "None" from appearing in the legend.
        return url + "&comment=All CDU/PDU Humidity Sensors"
Example #2
0
 def run(self, dmd, args):
     # This allows us to easily use the common start/end/consolidation
     # parameters that you'd typically want for graphs.
     summary = Utilization.getSummaryArgs(dmd, args)
     
     self.cFunc = summary['function']
     self.collector = dmd.Monitors.Performance.localhost
     
     # Setup basic graph properties.
     graph = [
         '-F', '-E',
         '--height=250', '--width=600', '--lower-limit=0',
         '--vertical-label=requests/s',
         '--start=%d' % (int(summary['start']),),
         '--end=%d' % (int(summary['end']),),
         "COMMENT:\\s",
         "COMMENT:     Current",
         "COMMENT:     Average",
         "COMMENT:     Maximum\\l",
         ]
     
     # This is the workhorse method that goes and generates the real data in
     # the graph.
     graph.extend(self.getClusterRequests(
         dmd.Devices.Server.Linux.Web.children()))
     
     # Do some post-processing to get a proper URL for the graph image.
     graph = self.collector._fullPerformancePath(graph)
     url = self.collector.buildGraphUrlFromCommands(graph,
         summary['end'] - summary['start'])
     
     # This is done to prevent "None" from appearing in the legend.
     return url + "&comment="
    def run(self, dmd, args, templateArgs=None):
        """
        Generate the report using the columns and aliases

        @param dmd the dmd context to access the context objects
        @param args the report args from the ui
        @param templateArgs the template tags from the ui

        @rtype a list of L{Utils.Record}s
        """
        i = 0
        # Get the summary arguments from the request args
        summary = Utilization.getSummaryArgs(dmd, args)

        # Create a dict of column to the datapoint/alias pairs
        # that return a value for the column
        columnDatapointsMap = self._mapColumnsToDatapoints(dmd)

        # Don't run against all devices, which kills large systems
        if not args.get('generate') or args.get('deviceClass', '/') == '/':
            return []

        # Filter the device list down according to the
        # values from the filter widget
        componentPath = self.getComponentPath()
        report = []
        for device in Utilization.filteredDevices(dmd, args):
            i += 1
            if i % 100 == 0: transaction.abort()
            if componentPath is None:
                record = self._createRecord(device, None, columnDatapointsMap,
                                            summary, templateArgs)
                report.append(record)
            else:
                components = self._getComponents(device, componentPath)
                for component in components:
                    i += 1
                    if i % 100 == 0: transaction.abort()
                    record = self._createRecord(device, component,
                                                columnDatapointsMap, summary,
                                                templateArgs)
                    report.append(record)
        return report
Example #4
0
    def run(self, dmd, args, templateArgs=None):
        """
        Generate the report using the columns and aliases

        @param dmd the dmd context to access the context objects
        @param args the report args from the ui
        @param templateArgs the template tags from the ui

        @rtype a list of L{Utils.Record}s
        """
        i=0
        # Get the summary arguments from the request args
        summary = Utilization.getSummaryArgs(dmd, args)

        # Create a dict of column to the datapoint/alias pairs
        # that return a value for the column
        columnDatapointsMap = self._mapColumnsToDatapoints(dmd)

        # Don't run against all devices, which kills large systems
        if not args.get('generate') or args.get('deviceClass', '/') == '/':
            return []

        # Filter the device list down according to the
        # values from the filter widget
        componentPath = self.getComponentPath()
        report = []
        for device in Utilization.filteredDevices(dmd, args):
            i += 1
            if i % 100 == 0: transaction.abort()
            if componentPath is None:
                record = self._createRecord(
                    device, None, columnDatapointsMap, summary, templateArgs)
                report.append(record)
            else:
                components = self._getComponents(device, componentPath)
                for component in components:
                    i+=1
                    if i % 100 == 0: transaction.abort()
                    record = self._createRecord(
                        device, component, columnDatapointsMap, summary,
                        templateArgs)
                    report.append(record)
        return report
Example #5
0
    def run(self, dmd, args):
        summary = Utilization.getSummaryArgs(dmd, args)
        deviceClass = args.get('deviceClass', '/Server')
        organizer = deviceClass
        showAll = args.get('showAll', '') == "on"
        deviceFilter = args.get('deviceFilter', '')
        deviceMatch = re.compile('.*%s.*' % deviceFilter)

        report = []
        if deviceClass == '/': return []

        parts = organizer.lstrip('/').split('/')
        try:
            if not len(parts):
                raise AttributeError()  # Invalid organizer
            root = dmd.getDmdRoot(parts[0])
            for part in parts[1:]:
                root = getattr(root, part)
        except AttributeError:
            root = dmd.Devices

        for org in [
                root,
        ] + root.getSubOrganizers():
            path = org.getPrimaryUrlPath()
            for devObj in org.getDevices():
                devObj = devObj.primaryAq()
                if not deviceMatch.match(devObj.id): continue
                types = getattr(org, 'zPerfReportableMetaTypes',
                                ['IpInterface'])
                avePeriod = getattr(org, 'zPerfReportableAvePeriod', 86400)
                fullComponentList = []
                for typeEntry in types:
                    fullComponentList = fullComponentList + devObj.getMonitoredComponents(
                        type=str(typeEntry))
                for intObj in fullComponentList:
                    if not showAll:
                        if intObj.snmpIgnore(): continue
                        isLocal = re.compile(devObj.zLocalInterfaceNames)
                        if isLocal.match(intObj.name()): continue
                        if not intObj.speed:
                            speed = 'Unknown'
                        else:
                            speed = intObj.speed

                        counters = [
                            'ifHCInOctets', 'ifHCOutOctets', 'ifInOctets',
                            'ifOutOctets'
                        ]

                        def multiply(number, by):
                            if number is None or by is None:
                                return None
                            return number * by

                        aveVals = getRRDValues(intObj,
                                               dsNames=counters,
                                               operation='AVERAGE',
                                               **summary)
                        volAveIn = multiply(
                            aveVals.get('ifHCInOctets',
                                        aveVals.get('ifInOctets', None)),
                            avePeriod)
                        volAveOut = multiply(
                            aveVals.get('ifHCOutOctets',
                                        aveVals.get('ifOutOctets', None)),
                            avePeriod)

                        totalVals = getRRDValues(intObj,
                                                 counters,
                                                 operation='TOTAL',
                                                 **summary)
                        volIn = totalVals.get(
                            'ifHCInOctets', totalVals.get('ifInOctets', None))
                        volOut = totalVals.get(
                            'ifHCOutOctets',
                            totalVals.get('ifOutOctets', None))

                        if volAveOut and volAveIn:
                            volTotal = volOut + volIn
                        else:
                            volTotal = 0

                        record = Utils.Record(
                            device=devObj.id,
                            devicePath=devObj.getPrimaryUrlPath(),
                            id=intObj.id,
                            path=intObj.getPrimaryUrlPath(),
                            description=intObj.description,
                            speed=speed,
                            volIn=volIn,
                            volOut=volOut,
                            volAveIn=volAveIn,
                            volAveOut=volAveOut,
                            volTotal=volTotal)
                        report.append(record)
        return report
    def run(self, dmd, args):
        summary = Utilization.getSummaryArgs(dmd, args)
        deviceClass = args.get('deviceClass', '/Server')
        organizer = deviceClass
        showAll = args.get('showAll', '') == "on"
        deviceFilter = args.get('deviceFilter', '')
        deviceMatch = re.compile('.*%s.*' % deviceFilter)

        report = []
        if deviceClass == '/': return []

        parts = organizer.lstrip('/').split('/')
        try:
            if not len(parts):
                raise AttributeError() # Invalid organizer
            root = dmd.getDmdRoot(parts[0])
            for part in parts[1:]:
                root = getattr(root, part)
        except AttributeError:
            root = dmd.Devices

        for org in [root,] + root.getSubOrganizers():
            path = org.getPrimaryUrlPath()
            for devObj in org.getDevices():
                devObj = devObj.primaryAq()
                if not deviceMatch.match(devObj.id): continue
                types = getattr(org, 'zPerfReportableMetaTypes', ['IpInterface'])
                avePeriod = getattr(org, 'zPerfReportableAvePeriod', 86400)
                fullComponentList = []
                for typeEntry in types:
                    fullComponentList = fullComponentList + devObj.getMonitoredComponents(type=str(typeEntry))
                for intObj in fullComponentList:
                    if not showAll:
                        if intObj.snmpIgnore(): continue
                        isLocal = re.compile(devObj.zLocalInterfaceNames)
                        if isLocal.match(intObj.name()): continue
                        if not intObj.speed:
                            speed = 'Unknown'
                        else:
                            speed = intObj.speed

                        counters = ['ifHCInOctets', 'ifHCOutOctets', 'ifInOctets', 'ifOutOctets']

                        def multiply(number, by):
                            if number is None or by is None:
                                return None
                            return number * by

                        aveVals = getRRDValues(intObj, dsNames=counters, operation='AVERAGE', **summary)
                        volAveIn = multiply(aveVals.get('ifHCInOctets', aveVals.get('ifInOctets', None)), avePeriod)
                        volAveOut = multiply(aveVals.get('ifHCOutOctets', aveVals.get('ifOutOctets', None)), avePeriod)

                        totalVals = getRRDValues(intObj, counters, operation='TOTAL', **summary)
                        volIn = totalVals.get('ifHCInOctets', totalVals.get('ifInOctets', None))
                        volOut = totalVals.get('ifHCOutOctets', totalVals.get('ifOutOctets', None))

                        if volAveOut and volAveIn:
                            volTotal = volOut + volIn
                        else:
                            volTotal = 0

                        record = Utils.Record(device = devObj.id,
                            devicePath = devObj.getPrimaryUrlPath(),
                            id = intObj.id,
                            path = intObj.getPrimaryUrlPath(),
                            description = intObj.description,
                            speed = speed,
                            volIn = volIn,
                            volOut = volOut,
                            volAveIn = volAveIn,
                            volAveOut = volAveOut,
                            volTotal = volTotal)
                        report.append(record)
        return report