コード例 #1
0
    def getDeviceDashboard(self):
        """return device info for bad device to dashboard"""
        zep = getFacade('zep')
        manager = IGUIDManager(self.context.dmd)
        deviceSeverities = zep.getDeviceIssuesDict()
        zem = self.context.dmd.ZenEventManager

        devdata = []
        for uuid in deviceSeverities.keys():
            dev = manager.getObject(uuid)
            if dev and isinstance(dev, Device):
                if (not zem.checkRemotePerm(ZEN_VIEW, dev)
                    or dev.productionState < zem.prodStateDashboardThresh
                    or dev.priority < zem.priorityDashboardThresh):
                    continue
                alink = dev.getPrettyLink()
                try:
                    severities = deviceSeverities[uuid]
                    severities = dict((zep.getSeverityName(sev).lower(), counts) for (sev, counts) in severities.iteritems())
                    pill = getEventPillME(dev, severities=severities)
                except ServiceException:
                    continue
                evts = [alink,pill]
                devdata.append((evts, severities))
        devdata.sort(key=lambda x:(x[1]['critical'], x[1]['error'], x[1]['warning']), reverse=True)
        return [x[0] for x in devdata[:100]]
コード例 #2
0
    def getDeviceDashboard(self):
        """return device info for bad device to dashboard"""
        zep = getFacade('zep')
        manager = IGUIDManager(self.context.dmd)
        deviceSeverities = zep.getDeviceIssuesDict()
        zem = self.context.dmd.ZenEventManager

        devdata = []
        for uuid in deviceSeverities.keys():
            dev = manager.getObject(uuid)
            if dev and isinstance(dev, Device):
                if (not zem.checkRemotePerm(ZEN_VIEW, dev)
                        or dev.productionState < zem.prodStateDashboardThresh
                        or dev.priority < zem.priorityDashboardThresh):
                    continue
                alink = dev.getPrettyLink()
                try:
                    severities = deviceSeverities[uuid]
                    severities = dict(
                        (zep.getSeverityName(sev).lower(), counts)
                        for (sev, counts) in severities.iteritems())
                    pill = getEventPillME(dev, severities=severities)
                except ServiceException:
                    continue
                evts = [alink, pill]
                devdata.append((evts, severities))
        devdata.sort(key=lambda x:
                     (x[1]['critical'], x[1]['error'], x[1]['warning']),
                     reverse=True)
        return [x[0] for x in devdata[:100]]
コード例 #3
0
def getmyDeviceDashboard(self, path):
    ZEN_VIEW = 'View'
    """return device info for bad device to dashboard"""
    zem = self.dmd.ZenEventManager
    where = ''
    if path.find("Devices") > 0:
        where = "deviceClass like '%s%%'" % path[8:]
    elif path.find("Groups") > 0:
        where = "deviceGroups like '%%|%s%%'" % path[7:]
    elif path.find("Systems") > 0:
        where = "systems like '%%|%s%%'" % path[8:]
    elif path.find("Locations") > 0:
        where = "location like '%s%%'" % path[10:]

    devices = [
        d[0] for d in zem.getDeviceIssues(where=where, severity=4, state=1)
    ]
    devdata = []
    devclass = zem.getDmdRoot("Devices")
    getcolor = re.compile(r'class=\"evpill-(.*?)\"', re.S | re.I | re.M).search
    colors = "red orange yellow blue grey green".split()

    def pillcompare(a, b):
        a, b = map(lambda x: getcolor(x[1]), (a, b))

        def getindex(x):
            try:
                color = x.groups()[0]
                smallcolor = x.groups()[0].replace('-acked', '')
                isacked = 'acked' in color
                index = colors.index(x.groups()[0].replace('-acked', ''))
                if isacked: index += .5
                return index
            except:
                return 5

        a, b = map(getindex, (a, b))
        return cmp(a, b)

    for devname in devices:
        dev = devclass.findDevice(devname)
        if dev and dev.id == devname:
            if (not zem.checkRemotePerm(ZEN_VIEW, dev)
                    or dev.productionState < zem.prodStateDashboardThresh
                    or dev.priority < zem.priorityDashboardThresh):
                continue
            alink = dev.getPrettyLink()
            try:
                pill = getEventPillME(zem, dev)[0]
            except IndexError:
                continue
            evts = [alink, pill]
            devdata.append(evts)
    devdata.sort(pillcompare)
    return devdata[:100]
コード例 #4
0
def getmyDeviceDashboard(self, path):
	ZEN_VIEW='View'
        """return device info for bad device to dashboard"""
        zem = self.dmd.ZenEventManager
        where=''
        if path.find("Devices")>0:
           where = "deviceClass like '%s%%'" % path[8:]
        elif path.find("Groups")>0:
           where = "deviceGroups like '%%|%s%%'" % path[7:]
        elif path.find("Systems")>0:
           where = "systems like '%%|%s%%'" % path[8:]
        elif path.find("Locations")>0:
           where = "location like '%s%%'" % path[10:]

        devices = [d[0] for d in zem.getDeviceIssues(
                            where=where,
                            severity=4, state=1)]
        devdata = []
        devclass = zem.getDmdRoot("Devices")
        getcolor = re.compile(r'class=\"evpill-(.*?)\"', re.S|re.I|re.M).search
        colors = "red orange yellow blue grey green".split()
        def pillcompare(a,b):
            a, b = map(lambda x:getcolor(x[1]), (a, b))
            def getindex(x):
                try: 
                    color = x.groups()[0]
                    smallcolor = x.groups()[0].replace('-acked','')
                    isacked = 'acked' in color
                    index = colors.index(x.groups()[0].replace('-acked',''))
                    if isacked: index += .5
                    return index
                except: return 5
            a, b = map(getindex, (a, b))
            return cmp(a, b)
        for devname in devices:
            dev = devclass.findDevice(devname)
            if dev and dev.id == devname:
                if (not zem.checkRemotePerm(ZEN_VIEW, dev)
                    or dev.productionState < zem.prodStateDashboardThresh
                    or dev.priority < zem.priorityDashboardThresh):
                    continue
                alink = dev.getPrettyLink()
                try:
                    pill = getEventPillME(zem, dev)[0]
                except IndexError:
                    continue
                evts = [alink,pill]
                devdata.append(evts)
        devdata.sort(pillcompare)
        return devdata[:100]
コード例 #5
0
ファイル: Portlets.py プロジェクト: zenoss/zenoss-prodbin
    def getDeviceDashboard(self):
        """return device info for bad device to dashboard"""
        zep = getFacade('zep')
        manager = IGUIDManager(self.context.dmd)
        deviceSeverities = zep.getDeviceIssuesDict()
        zem = self.context.dmd.ZenEventManager

        bulk_data = []

        for uuid in deviceSeverities.keys():
            uuid_data = {}
            uuid_data['uuid'] = uuid
            severities = deviceSeverities[uuid]
            try:
                uuid_data['severities'] = dict(
                    (zep.getSeverityName(sev).lower(), counts)
                    for (sev, counts) in severities.iteritems())
            except ServiceException:
                continue
            bulk_data.append(uuid_data)

        bulk_data.sort(key=lambda x: (x['severities']['critical'], x[
            'severities']['error'], x['severities']['warning']),
                       reverse=True)

        devices_found = 0
        MAX_DEVICES = 100

        devdata = []
        for data in bulk_data:
            uuid = data['uuid']
            severities = data['severities']
            dev = manager.getObject(uuid)
            if dev and isinstance(dev, Device):
                if (not zem.checkRemotePerm(ZEN_VIEW, dev) or
                        dev.getProductionState() < zem.prodStateDashboardThresh
                        or dev.priority < zem.priorityDashboardThresh):
                    continue
                alink = dev.getPrettyLink()
                pill = getEventPillME(dev, severities=severities)
                evts = [alink, pill]
                devdata.append(evts)
                devices_found = devices_found + 1
                if devices_found >= MAX_DEVICES:
                    break
        return devdata
コード例 #6
0
ファイル: Portlets.py プロジェクト: bbc/zenoss-prodbin
    def getDeviceDashboard(self):
        """return device info for bad device to dashboard"""
        zep = getFacade('zep')
        manager = IGUIDManager(self.context.dmd)
        deviceSeverities = zep.getDeviceIssuesDict()
        zem = self.context.dmd.ZenEventManager

        bulk_data = []

        for uuid in deviceSeverities.keys():
            uuid_data = {}
            uuid_data['uuid'] = uuid
            severities = deviceSeverities[uuid]
            try:
                uuid_data['severities'] = dict((zep.getSeverityName(sev).lower(), counts) for (sev, counts) in severities.iteritems())
            except ServiceException:
                continue
            bulk_data.append(uuid_data)

        bulk_data.sort(key=lambda x:(x['severities']['critical'], x['severities']['error'], x['severities']['warning']), reverse=True)

        devices_found = 0
        MAX_DEVICES = 100

        devdata = []
        for data in bulk_data:
            uuid = data['uuid']
            severities = data['severities']
            dev = manager.getObject(uuid)
            if dev and isinstance(dev, Device):
                if (not zem.checkRemotePerm(ZEN_VIEW, dev)
                    or dev.productionState < zem.prodStateDashboardThresh
                    or dev.priority < zem.priorityDashboardThresh):
                    continue
                alink = dev.getPrettyLink()
                pill = getEventPillME(dev, severities=severities)
                evts = [alink,pill]
                devdata.append(evts)
                devices_found = devices_found + 1
                if devices_found >= MAX_DEVICES:
                    break
        return devdata