Exemple #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)')
    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)')
    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)
Exemple #4
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)
Exemple #6
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)
    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))
Exemple #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)
Exemple #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 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)')
    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)')
Exemple #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)')
Exemple #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)')
    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)')
Exemple #16
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)')