예제 #1
0
    def testPerfFileSystemTransformPerfFS(self):
        """
        Test to make sure that the standard transform on the /Perf/Filesystem
        event class works properly for stock performance templates.
        """

        # Test an example event from a standard SNMP device.
        device = self.dmd.Devices.createInstance('snmpdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 4096
        fs.totalBlocks = 29221228

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'usedBlocks_usedBlocks|high disk usage'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of high disk usage exceeded: current value 23476882.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary,
                          'disk space threshold: 80.3% used (21.9GB free)')
예제 #2
0
    def testPerfFileSystemTransformPerfFS(self):
        """
        Test to make sure that the standard transform on the /Perf/Filesystem
        event class works properly for stock performance templates.
        """
        
        # Test an example event from a standard SNMP device.
        device = self.dmd.Devices.createInstance('snmpdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 4096
        fs.totalBlocks = 29221228

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'usedBlocks_usedBlocks|high disk usage'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of high disk usage exceeded: current value 23476882.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary, 'disk space threshold: 80.3% used (21.9GB free)')
예제 #3
0
    def testActorReidentificationFromEventClassKeyTransform(self):
        """
        Verify that changing the device in a transform properly reidentifies the device
        when matching an event by eventClassKey.
        """

        device_a = self.dmd.Devices.createInstance("transform_device_a")

        # Related: ZEN-1419
        # If you change a device from within a transform like so:
        #
        #   evt.device = 'my_new_device'
        #
        # The processing pipeline will recognize this and re-run the
        # identification pipes. Before it re-runs these pipes though, it will
        # clear several properties related to the device, one of which is the
        # device/element UUID. During the Identification pipe, if the UUID
        # is missing, it will try one last time to lookup the element
        # using the identifier and the ip address. If we do not set an
        # ip address here, this test will not be completely testing the
        # reidentification logic.
        device_a.setManageIp("192.168.100.100")

        device_b = self.dmd.Devices.createInstance("transform_device_b")

        _transform_key = 'transform_test_key'
        _transform = """
evt.device = '%s'
        """
        self.dmd.Events.createOrganizer('/transform_test')
        self.dmd.Events.transform_test.transform = _transform % device_b.id

        # the organizer above contains the transform, no create an instance
        # that actually contains the event class key.
        self.dmd.Events.transform_test.createInstance(_transform_key)

        event = Event()
        event.actor.element_identifier = device_a.id
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_WARNING
        event.summary = 'Testing transforms.'

        detail = event.details.add()
        detail.name = EventProxy.DEVICE_IP_ADDRESS_DETAIL_KEY
        detail.value.append(device_a.getManageIp())

        # Match the transform by event_class_key
        event.event_class_key = _transform_key
        processed = self._processEvent(event)

        self.assertEquals(device_b.id,
                          processed.event.actor.element_identifier)
        self.assertEquals(
            IGlobalIdentifier(device_b).getGUID(),
            processed.event.actor.element_uuid)
    def testActorReidentificationFromEventClassKeyTransform(self):
        """
        Verify that changing the device in a transform properly reidentifies the device
        when matching an event by eventClassKey.
        """

        device_a = self.dmd.Devices.createInstance("transform_device_a")

        # Related: ZEN-1419
        # If you change a device from within a transform like so:
        # 
        #   evt.device = 'my_new_device'
        #
        # The processing pipeline will recognize this and re-run the 
        # identification pipes. Before it re-runs these pipes though, it will
        # clear several properties related to the device, one of which is the
        # device/element UUID. During the Identification pipe, if the UUID
        # is missing, it will try one last time to lookup the element
        # using the identifier and the ip address. If we do not set an
        # ip address here, this test will not be completely testing the
        # reidentification logic.
        device_a.setManageIp("192.168.100.100")

        device_b = self.dmd.Devices.createInstance("transform_device_b")

        _transform_key = 'transform_test_key'
        _transform = """
evt.device = '%s'
        """
        self.dmd.Events.createOrganizer('/transform_test')
        self.dmd.Events.transform_test.transform = _transform % device_b.id

        # the organizer above contains the transform, no create an instance
        # that actually contains the event class key.
        self.dmd.Events.transform_test.createInstance(_transform_key)

        event = Event()
        event.actor.element_identifier = device_a.id
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_WARNING
        event.summary = 'Testing transforms.'

        detail = event.details.add()
        detail.name = EventProxy.DEVICE_IP_ADDRESS_DETAIL_KEY
        detail.value.append(device_a.getManageIp())

        # Match the transform by event_class_key
        event.event_class_key = _transform_key
        processed = self._processEvent(event)

        self.assertEquals(device_b.id, processed.event.actor.element_identifier)
        self.assertEquals(IGlobalIdentifier(device_b).getGUID(), 
                          processed.event.actor.element_uuid)
    def testActionDropped(self):
        transform = 'evt._action="drop"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.event_class = '/Perf/Filesystem'
        event.summary = 'should be dropped'

        self.assertRaises(DropEvent, self._processEvent, event)
예제 #6
0
    def testActionDropped(self):
        transform = 'evt._action="drop"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.event_class = '/Perf/Filesystem'
        event.summary = 'should be dropped'

        self.assertRaises(DropEvent, self._processEvent, event)
    def testActionHistory(self):
        transform = 'evt._action="history"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.event_class = '/Perf/Filesystem'
        event.summary = 'should be closed'

        processed = self._processEvent(event)
        self.assertEqual(STATUS_CLOSED, processed.event.status)
예제 #8
0
    def testActionHistory(self):
        transform = 'evt._action="history"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.event_class = '/Perf/Filesystem'
        event.summary = 'should be closed'

        processed = self._processEvent(event)
        self.assertEqual(STATUS_CLOSED, processed.status)
예제 #9
0
    def testActionStatusDoesntChangeSuppressed(self):
        """
        If an event comes in as suppressed and the _action says to keep it in _status (the default),
        make sure that we don't accidentally change the status of the event back to STATUS_NEW.
        """
        transform = 'evt._action="status"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.status = STATUS_SUPPRESSED
        event.event_class = '/Perf/Filesystem'
        event.summary = 'should be suppressed'

        processed = self._processEvent(event)
        self.assertEqual(STATUS_SUPPRESSED, processed.status)
예제 #10
0
    def testIntSeverityTransform(self):
        """
        Transform the event severity to a string and see if it evaluates.
        """
        transform = 'evt.severity="0"; evt.summary="transformed"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.event_class = '/Perf/Filesystem'
        event.summary = 'bad thingy'

        processed = self._processEvent(event)
        self.assertEqual(SEVERITY_CLEAR, processed.severity)
        self.assertEqual('transformed', processed.summary)
        self.assert_(isinstance(processed.severity, int))
    def testActionStatusDoesntChangeSuppressed(self):
        """
        If an event comes in as suppressed and the _action says to keep it in _status (the default),
        make sure that we don't accidentally change the status of the event back to STATUS_NEW.
        """
        transform = 'evt._action="status"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.status = STATUS_SUPPRESSED
        event.event_class = '/Perf/Filesystem'
        event.summary = 'should be suppressed'

        processed = self._processEvent(event)
        self.assertEqual(STATUS_SUPPRESSED, processed.event.status)
    def testIntSeverityTransform(self):
        """
        Transform the event severity to a string and see if it evaluates.
        """
        transform = 'evt.severity="0"; evt.summary="transformed"'
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = transform

        event = Event()
        event.actor.element_identifier = 'localhost'
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_ERROR
        event.event_class = '/Perf/Filesystem'
        event.summary = 'bad thingy'

        processed = self._processEvent(event)
        self.assertEqual(SEVERITY_CLEAR, processed.event.severity)
        self.assertEqual('transformed', processed.event.summary)
        self.assert_(isinstance(processed.event.severity, int))
예제 #13
0
    def testPerfFileSystemTransformSSH(self):
        # Test an example event from a standard SSH device.
        device = self.dmd.Devices.createInstance('sshdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 1024
        fs.totalBlocks = 149496116

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.id
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'disk|disk_usedBlocks|Free Space 90 Percent'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of Free Space 90 Percent exceeded: current value 73400348.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary, 'disk space threshold: 49.1% used (72.6GB free)')
예제 #14
0
    def testPerfFileSystemTransformPerfmon(self):
        # Test an example event from a standard Perfmon device.
        device = self.dmd.Devices.createInstance('perfmondevice')
        device.os.addFileSystem('C', False)
        fs = device.os.filesystems()[0]
        fs.mount = ' Label:C: Serial Number: 1471843B'
        fs.blockSize = 8192
        fs.totalBlocks = 1047233

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'FreeMegabytes_FreeMegabytes'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of low disk space not met: current value 4156.00'
        
        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary, 'disk space threshold: 49.2% used (4.1GB free)')
예제 #15
0
    def testPerfFileSystemTransformSSH(self):
        # Test an example event from a standard SSH device.
        device = self.dmd.Devices.createInstance('sshdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 1024
        fs.totalBlocks = 149496116

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.id
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'disk|disk_usedBlocks|Free Space 90 Percent'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of Free Space 90 Percent exceeded: current value 73400348.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary,
                          'disk space threshold: 49.1% used (72.6GB free)')
예제 #16
0
    def testPerfFileSystemTransformPerfmon(self):
        # Test an example event from a standard Perfmon device.
        device = self.dmd.Devices.createInstance('perfmondevice')
        device.os.addFileSystem('C', False)
        fs = device.os.filesystems()[0]
        fs.mount = ' Label:C: Serial Number: 1471843B'
        fs.blockSize = 8192
        fs.totalBlocks = 1047233

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'FreeMegabytes_FreeMegabytes'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of low disk space not met: current value 4156.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary,
                          'disk space threshold: 49.2% used (4.1GB free)')
예제 #17
0
    def testActorReidentificationFromEventClassKeyTransformWithComponent(self):
        """
        Verify that changing the device in a transform properly reidentifies
        the device when matching an event by eventClassKey.
        """

        devA = self.dmd.Devices.createInstance("transform_device_a")
        devA.os.addFileSystem("component", False)
        devA.setManageIp("192.168.100.100")

        devB = self.dmd.Devices.createInstance("transform_device_b")
        devB.os.addFileSystem("component", False)
        devB.setManageIp("192.168.100.101")

        _transform_key = 'transform_test_key'
        self.dmd.Events.createOrganizer('/transform_test')
        self.dmd.Events.transform_test.transform = "evt.device = '%s'" % devB.id
        self.dmd.Events.transform_test.createInstance(_transform_key)

        event = Event()
        event.actor.element_identifier = devA.id
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_WARNING
        event.summary = 'Testing transforms on component.'
        event.actor.element_sub_type_id = COMPONENT
        event.actor.element_sub_identifier = devA.getDeviceComponents()[0].id

        detail = event.details.add()
        detail.name = EventProxy.DEVICE_IP_ADDRESS_DETAIL_KEY
        detail.value.append(devA.getManageIp())

        # Match the transform by event_class_key
        event.event_class_key = _transform_key
        processed = self._processEvent(event)
        self.assertEquals(
            IGlobalIdentifier(devB.getDeviceComponents()[0]).getGUID(),
            processed.actor.element_sub_uuid)
    def testActorReidentificationFromEventClassKeyTransformWithComponent(self):
        """
        Verify that changing the device in a transform properly reidentifies
        the device when matching an event by eventClassKey.
        """

        devA = self.dmd.Devices.createInstance("transform_device_a")
        devA.os.addFileSystem("component", False)
        devA.setManageIp("192.168.100.100")

        devB = self.dmd.Devices.createInstance("transform_device_b")
        devB.os.addFileSystem("component", False)
        devB.setManageIp("192.168.100.101")

        _transform_key = 'transform_test_key'
        self.dmd.Events.createOrganizer('/transform_test')
        self.dmd.Events.transform_test.transform = "evt.device = '%s'" % devB.id
        self.dmd.Events.transform_test.createInstance(_transform_key)

        event = Event()
        event.actor.element_identifier = devA.id
        event.actor.element_type_id = DEVICE
        event.severity = SEVERITY_WARNING
        event.summary = 'Testing transforms on component.'
        event.actor.element_sub_type_id = COMPONENT
        event.actor.element_sub_identifier = devA.getDeviceComponents()[0].id

        detail = event.details.add()
        detail.name = EventProxy.DEVICE_IP_ADDRESS_DETAIL_KEY
        detail.value.append(devA.getManageIp())

        # Match the transform by event_class_key
        event.event_class_key = _transform_key
        processed = self._processEvent(event)
        self.assertEquals(IGlobalIdentifier(devB.getDeviceComponents()[0]).getGUID(),
                          processed.event.actor.element_sub_uuid)
    def testPerfFileSystemTransform(self):
        """
        Test to make sure that the standard transform on the /Perf/Filesystem
        event class works properly for stock performance templates.
        """
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = perfFilesystemTransform
        
        # Test an example event from a standard SNMP device.
        device = self.dmd.Devices.createInstance('snmpdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 4096
        fs.totalBlocks = 29221228

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'usedBlocks_usedBlocks|high disk usage'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of high disk usage exceeded: current value 23476882.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary, 'disk space threshold: 80.3% used (21.9GB free)')
        
        # Test an example event from a standard Perfmon device.
        device = self.dmd.Devices.createInstance('perfmondevice')
        device.os.addFileSystem('C', False)
        fs = device.os.filesystems()[0]
        fs.mount = ' Label:C: Serial Number: 1471843B'
        fs.blockSize = 8192
        fs.totalBlocks = 1047233

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'FreeMegabytes_FreeMegabytes'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of low disk space not met: current value 4156.00'
        
        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary, 'disk space threshold: 49.2% used (4.1GB free)')
    
        # Test an example event from a standard SSH device.
        device = self.dmd.Devices.createInstance('sshdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 1024
        fs.totalBlocks = 149496116

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.id
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'disk|disk_usedBlocks|Free Space 90 Percent'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of Free Space 90 Percent exceeded: current value 73400348.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.event.summary, 'disk space threshold: 49.1% used (72.6GB free)')
예제 #20
0
    def testPerfFileSystemTransform(self):
        """
        Test to make sure that the standard transform on the /Perf/Filesystem
        event class works properly for stock performance templates.
        """
        self.dmd.Events.createOrganizer('/Perf/Filesystem')
        self.dmd.Events.Perf.Filesystem.transform = perfFilesystemTransform

        # Test an example event from a standard SNMP device.
        device = self.dmd.Devices.createInstance('snmpdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 4096
        fs.totalBlocks = 29221228

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'usedBlocks_usedBlocks|high disk usage'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of high disk usage exceeded: current value 23476882.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.summary,
                          'disk space threshold: 80.3% used (21.9GB free)')

        # Test an example event from a standard Perfmon device.
        device = self.dmd.Devices.createInstance('perfmondevice')
        device.os.addFileSystem('C', False)
        fs = device.os.filesystems()[0]
        fs.mount = ' Label:C: Serial Number: 1471843B'
        fs.blockSize = 8192
        fs.totalBlocks = 1047233

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.name()
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'FreeMegabytes_FreeMegabytes'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of low disk space not met: current value 4156.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.summary,
                          'disk space threshold: 49.2% used (4.1GB free)')

        # Test an example event from a standard SSH device.
        device = self.dmd.Devices.createInstance('sshdevice')
        device.os.addFileSystem('/', False)
        fs = device.os.filesystems()[0]
        fs.mount = '/'
        fs.blockSize = 1024
        fs.totalBlocks = 149496116

        event = Event()
        event.actor.element_identifier = device.id
        event.actor.element_type_id = DEVICE
        event.actor.element_sub_identifier = fs.id
        event.actor.element_sub_type_id = COMPONENT
        event.severity = SEVERITY_WARNING
        event.event_key = 'disk|disk_usedBlocks|Free Space 90 Percent'
        event.event_class = '/Perf/Filesystem'
        event.summary = 'threshold of Free Space 90 Percent exceeded: current value 73400348.00'

        processed = self._processEvent(event)
        self.assertEquals(processed.summary,
                          'disk space threshold: 49.1% used (72.6GB free)')