Exemplo n.º 1
0
    def migrate(self, pack):
        try:
            log.info('Fixing the SSH-Linux FileSystem template')
            facade = getFacade("template")
            template_uid = "/zport/dmd/Devices/Server/SSH/Linux/rrdTemplates/FileSystem"
            threshold_id = "Free Space 90 Percent"
            threshold_uid = "{template_uid}/thresholds/{threshold_id}".format(
                **locals())

            try:
                facade.removeThreshold(threshold_uid)
            except ObjectNotFoundException:
                log.info("'Free Space 90 Percent' threshold does not exist.")

            def delete_graph_point(graph_points_uid, graph_point_id):
                graph_point_uid = "{graph_points_uid}/{graph_point_id}".format(
                    **locals())
                try:
                    facade.deleteGraphPoint(graph_point_uid)
                except ObjectNotFoundException:
                    log.info(
                        "'Block Utilization' graph does not have '{graph_point_id}' graph point."
                        .format(**locals()))

            graph_points_uid = "{template_uid}/graphDefs/Block Utilization/graphPoints".format(
                **locals())
            delete_graph_point(graph_points_uid, threshold_id)
            delete_graph_point(graph_points_uid, "usedBlocks")

        except Exception, e:
            log.error(
                'Failed to fix the SSH-Linux FileSystem template. {e.__class__.__name__}: {e}'
                .format(**locals()))
Exemplo n.º 2
0
    def ack(self):
        if not self.options.evids:
            self.parser.error(
                "Require one or more event ids to be acknowledged.")
        if not self.options.userid:
            self.parser.error(
                "Require username who is acknowledging the event.")
        if not self.options.state in (0, 1):
            self.parser.error("Invalid state: %d" % self.options.state)

        zep = getFacade('zep', self.dmd)
        event_filter = zep.createEventFilter(uuid=self.options.evids)
        try:
            # Old event states = 0=New, 1=Acknowledge
            if self.options.state == 0:
                zep.reopenEventSummaries(eventFilter=event_filter,
                                         userName=self.options.userid)
            elif self.options.state == 1:
                zep.acknowledgeEventSummaries(eventFilter=event_filter,
                                              userName=self.options.userid)
        except Exception as e:
            if log.isEnabledFor(logging.DEBUG):
                log.exception("Failed to acknowledge events")
            print >> sys.stderr, e.message
            sys.exit(1)
    def migrate(self, pack):
        try:
            log.info('Fixing the SSH-Linux FileSystem template')
            facade = getFacade("template")
            template_uid = "/zport/dmd/Devices/Server/SSH/Linux/rrdTemplates/FileSystem"
            threshold_id = "Free Space 90 Percent"
            threshold_uid = "{template_uid}/thresholds/{threshold_id}".format(**locals())

            try:
                facade.removeThreshold(threshold_uid)
            except ObjectNotFoundException:
                log.info("'Free Space 90 Percent' threshold does not exist.")

            def delete_graph_point(graph_points_uid, graph_point_id):
                graph_point_uid = "{graph_points_uid}/{graph_point_id}".format(**locals())
                try:
                    facade.deleteGraphPoint(graph_point_uid)
                except ObjectNotFoundException:
                    log.info("'Block Utilization' graph does not have '{graph_point_id}' graph point.".format(**locals()))

            graph_points_uid = "{template_uid}/graphDefs/Block Utilization/graphPoints".format(**locals())
            delete_graph_point(graph_points_uid, threshold_id)
            delete_graph_point(graph_points_uid, "usedBlocks")

        except Exception, e:
            log.error('Failed to fix the SSH-Linux FileSystem template. {e.__class__.__name__}: {e}'.format(**locals()))
 def getMaxSeverity(self, me):
     from Products.Zuul.facades import getFacade
     """ Returns the severity of the most severe event. """
     zep = getFacade('zep')
     try:
         # Event class rainbows show all events through DEBUG severity
         uuid = IGlobalIdentifier(me).getGUID()
         return zep.getWorstSeverityByUuid(uuid)
     except TypeError:
         log.warn("Attempted to query events for %r which does not have a uuid" % self)
         return 0
Exemplo n.º 5
0
 def getMaxSeverity(self, me):
     from Products.Zuul.facades import getFacade
     """ Returns the severity of the most severe event. """
     zep = getFacade('zep')
     try:
         # Event class rainbows show all events through DEBUG severity
         uuid = IGlobalIdentifier(me).getGUID()
         return zep.getWorstSeverityByUuid(uuid)
     except TypeError:
         log.warn(
             "Attempted to query events for %r which does not have a uuid" %
             self)
         return 0
Exemplo n.º 6
0
 def processClass(self):
     # ZEN-3016: Get the primary acquisition. Processes should always have a class.
     klass = self._object.osProcessClass()
     if not klass:
         msg = 'Internal Error: OSProcess does not have an OSProcessClass: %s' % self.uid
         try:
             zep = getFacade('zep')
             device = self._object.device()
             zep.create(msg, 'Error', device.id, component=self.id, eventClass='/App')
         except ZepConnectionError:
             log.error(msg)
         return None
     return klass.primaryAq()
Exemplo n.º 7
0
 def processClass(self):
     # ZEN-3016: Get the primary acquisition. Processes should always have a class.
     klass = self._object.osProcessClass()
     if not klass:
         msg = 'Internal Error: OSProcess does not have an OSProcessClass: %s' % self.uid
         try:
             zep = getFacade('zep')
             device = self._object.device()
             zep.create(msg, 'Error', device.id, component=self.id, eventClass='/App')
         except ZepConnectionError:
             log.error(msg)
         return None
     return klass.primaryAq()
Exemplo n.º 8
0
    def ack(self):
        if not self.options.evids:
            self.parser.error("Require one or more event ids to be acknowledged.")
        if not self.options.userid:
            self.parser.error("Require username who is acknowledging the event.")
        if not self.options.state in (0,1):
            self.parser.error("Invalid state: %d" % self.options.state)

        zep = getFacade('zep', self.dmd)
        event_filter = zep.createEventFilter(uuid=self.options.evids)
        try:
            # Old event states = 0=New, 1=Acknowledge
            if self.options.state == 0:
                zep.reopenEventSummaries(eventFilter=event_filter, userName=self.options.userid)
            elif self.options.state == 1:
                zep.acknowledgeEventSummaries(eventFilter=event_filter, userName=self.options.userid)
        except Exception as e:
            if log.isEnabledFor(logging.DEBUG):
                log.exception("Failed to acknowledge events")
            print >>sys.stderr, e.message
            sys.exit(1)