def test_serviceTemplates(self):
        service = LinuxService("test_service")

        # Add few templates to LinuxService component
        manage_addRRDTemplate(service, "OSService-UPSTART")
        manage_addRRDTemplate(service, "OSService-SYSTEMV")
        manage_addRRDTemplate(service, "OSService-SYSTEMD")
        manage_addRRDTemplate(service, "Extra-Template")
        manage_addRRDTemplate(service, "Another-Extra-Template")

        # SYSTEMD tests
        service.init_system = 'SYSTEMD'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 1)
        self.assertEqual(templates[0].id, 'OSService-SYSTEMD')

        # UPSTART tests
        service.init_system = 'UPSTART'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 1)
        self.assertEqual(templates[0].id, 'OSService-UPSTART')

        # SYSTEMV tests
        service.init_system = 'SYSTEMV'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 1)
        self.assertEqual(templates[0].id, 'OSService-SYSTEMV')

        # OTHER-INIT tests
        service.init_system = 'OTHER-INIT'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 0)
    def test_getRRDTemplates(self):
        boot_fs = FileSystem("boot")
        boot_fs.mount = "/boot"
        boot_fs.type = "ext4"
        self.device.os.filesystems._setObject(boot_fs.id, boot_fs)
        boot_fs = self.device.os.filesystems.boot

        nfs_fs = FileSystem("nfs")
        nfs_fs.mount = "/nfs"
        nfs_fs.type = "nfs"
        self.device.os.filesystems._setObject(nfs_fs.id, nfs_fs)
        nfs_fs = self.device.os.filesystems.nfs

        nfs4_fs = FileSystem("nfs4")
        nfs4_fs.mount = "/nfs4"
        nfs4_fs.type = "nfs4"
        self.device.os.filesystems._setObject(nfs4_fs.id, nfs4_fs)
        nfs4_fs = self.device.os.filesystems.nfs4

        # No templates exist.
        boot_templates = boot_fs.getRRDTemplates()
        self.assertEqual(len(boot_templates), 0)

        nfs_templates = nfs_fs.getRRDTemplates()
        self.assertEqual(len(nfs_templates), 0)

        # Only the FileSystem template exists.
        manage_addRRDTemplate(self.dmd.Devices.rrdTemplates, "FileSystem")

        boot_templates = boot_fs.getRRDTemplates()
        self.assertEqual(len(boot_templates), 1)
        self.assertEqual(boot_templates[0].id, "FileSystem")

        nfs_templates = nfs_fs.getRRDTemplates()
        self.assertEqual(len(nfs_templates), 0)

        # FileSystem and FileSystem_NFS_Client templates exist.
        manage_addRRDTemplate(self.dmd.Devices.rrdTemplates,
                              "FileSystem_NFS_Client")

        boot_templates = boot_fs.getRRDTemplates()
        self.assertEqual(len(boot_templates), 1)
        self.assertEqual(boot_templates[0].id, "FileSystem")

        nfs_templates = nfs_fs.getRRDTemplates()
        self.assertEqual(len(nfs_templates), 1)
        self.assertEqual(nfs_templates[0].id, "FileSystem_NFS_Client")

        nfs4_templates = nfs4_fs.getRRDTemplates()
        self.assertEqual(len(nfs4_templates), 1)
        self.assertEqual(nfs4_templates[0].id, "FileSystem_NFS_Client")
    def test_getRRDTemplates(self):
        boot_fs = FileSystem("boot")
        boot_fs.mount = "/boot"
        boot_fs.type = "ext4"
        self.device.os.filesystems._setObject(boot_fs.id, boot_fs)
        boot_fs = self.device.os.filesystems.boot

        nfs_fs = FileSystem("nfs")
        nfs_fs.mount = "/nfs"
        nfs_fs.type = "nfs"
        self.device.os.filesystems._setObject(nfs_fs.id, nfs_fs)
        nfs_fs = self.device.os.filesystems.nfs

        nfs4_fs = FileSystem("nfs4")
        nfs4_fs.mount = "/nfs4"
        nfs4_fs.type = "nfs4"
        self.device.os.filesystems._setObject(nfs4_fs.id, nfs4_fs)
        nfs4_fs = self.device.os.filesystems.nfs4

        # No templates exist.
        boot_templates = boot_fs.getRRDTemplates()
        self.assertEqual(len(boot_templates), 0)

        nfs_templates = nfs_fs.getRRDTemplates()
        self.assertEqual(len(nfs_templates), 0)

        # Only the FileSystem template exists.
        manage_addRRDTemplate(self.dmd.Devices.rrdTemplates, "FileSystem")

        boot_templates = boot_fs.getRRDTemplates()
        self.assertEqual(len(boot_templates), 1)
        self.assertEqual(boot_templates[0].id, "FileSystem")

        nfs_templates = nfs_fs.getRRDTemplates()
        self.assertEqual(len(nfs_templates), 0)

        # FileSystem and FileSystem_NFS_Client templates exist.
        manage_addRRDTemplate(self.dmd.Devices.rrdTemplates, "FileSystem_NFS_Client")

        boot_templates = boot_fs.getRRDTemplates()
        self.assertEqual(len(boot_templates), 1)
        self.assertEqual(boot_templates[0].id, "FileSystem")

        nfs_templates = nfs_fs.getRRDTemplates()
        self.assertEqual(len(nfs_templates), 1)
        self.assertEqual(nfs_templates[0].id, "FileSystem_NFS_Client")

        nfs4_templates = nfs4_fs.getRRDTemplates()
        self.assertEqual(len(nfs4_templates), 1)
        self.assertEqual(nfs4_templates[0].id, "FileSystem_NFS_Client")
Ejemplo n.º 4
0
    def createFakeDevice( self, name ):
        """
        Create a fake device with a datapoint
        """
        from Products.ZenModel.Device import manage_createDevice
        self.dev = manage_createDevice(self.dmd,
                                deviceName=name,
                                devicePath='/Test')

        from Products.ZenModel.RRDTemplate import manage_addRRDTemplate
        manage_addRRDTemplate(self.dmd.Devices.Test.rrdTemplates, 'Device')
        t = self.dmd.Devices.Test.rrdTemplates.Device
        ds = t.manage_addRRDDataSource('ds', 'BasicDataSource.COMMAND')
        dp = ds.manage_addRRDDataPoint('dp')
        thresh = t.manage_addRRDThreshold('limit', 'MinMaxThreshold')
        thresh.maxval = "100"
        thresh.dsnames = ('ds_dp',)
    def test_serviceTemplates(self):
        service = LinuxService("test_service")

        # Add few templates to LinuxService component
        manage_addRRDTemplate(service, "OSService-UPSTART")
        manage_addRRDTemplate(service, "OSService-SYSTEMV")
        manage_addRRDTemplate(service, "OSService-SYSTEMD")
        manage_addRRDTemplate(service, "Extra-Template")
        manage_addRRDTemplate(service, "Another-Extra-Template")

        # Service modeled by "too old" of a modeler plugin (ZPS-4334).
        service.modeler_version = None
        service.init_system = 'SYSTEMD'
        self.assertEqual(len(service.getRRDTemplates()), 0)
        service.modeler_version = 0
        self.assertEqual(len(service.getRRDTemplates()), 0)

        # Set current modeler_version for remaining tests.
        service.modeler_version = OS_SERVICE_MODELER_VERSION

        # No init system modeled.
        service.init_system = None
        self.assertEqual(len(service.getRRDTemplates()), 0)

        # SYSTEMD tests
        service.init_system = 'SYSTEMD'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 1)
        self.assertEqual(templates[0].id, 'OSService-SYSTEMD')

        # UPSTART tests
        service.init_system = 'UPSTART'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 1)
        self.assertEqual(templates[0].id, 'OSService-UPSTART')

        # SYSTEMV tests
        service.init_system = 'SYSTEMV'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 1)
        self.assertEqual(templates[0].id, 'OSService-SYSTEMV')

        # OTHER-INIT tests
        service.init_system = 'OTHER-INIT'
        templates = service.getRRDTemplates()
        self.assertEqual(len(templates), 0)
Ejemplo n.º 6
0
    def createFakeDevice(self, name):
        """
        Create a fake device with a datapoint
        """
        from Products.ZenModel.Device import manage_createDevice
        self.dev = manage_createDevice(self.dmd,
                                       deviceName=name,
                                       devicePath='/Test')

        from Products.ZenModel.RRDTemplate import manage_addRRDTemplate
        manage_addRRDTemplate(self.dmd.Devices.Test.rrdTemplates, 'Device')
        t = self.dmd.Devices.Test.rrdTemplates.Device
        ds = t.manage_addRRDDataSource('ds', 'BasicDataSource.COMMAND')
        dp = ds.manage_addRRDDataPoint('dp')
        thresh = t.manage_addRRDThreshold('limit', 'MinMaxThreshold')
        thresh.maxval = "100"
        thresh.dsnames = ('ds_dp', )
    def testThresholdGraphPoints(self):
        """
        Test that the correct RRD commands are generated for a number of
        ThresholdGraphPoint configurations.
        """
        device = self.dmd.Devices.createInstance('testdevice')
        device.setPerformanceMonitor('localhost')
        
        manage_addRRDTemplate(device, 'TestTemplate')
        device.bindTemplates(['TestTemplate'])
        template = device.TestTemplate
        
        ds = template.manage_addRRDDataSource('dsname', 'BuiltInDS.Built-In')
        dp = ds.manage_addRRDDataPoint('dpname')
        
        t = template.manage_addRRDThreshold('defaultLegend', 'MinMaxThreshold')
        t.dsnames = ['dsname_dpname']
        t.maxval = '5'
        
        t = template.manage_addRRDThreshold('blankLegend', 'MinMaxThreshold')
        t.dsnames = ['dsname_dpname']
        t.legend = ''
        t.maxval = '10'
        
        t = template.manage_addRRDThreshold('talesLegend', 'MinMaxThreshold')
        t.dsnames = ['dsname_dpname']
        t.legend = '${here/id}'
        t.maxval = '15'
        
        graph = template.manage_addGraphDefinition('graph')
        graph.manage_addDataPointGraphPoints(
            ['dsname_dpname'], includeThresholds=True)
        
        graph.graphPoints.defaultLegend.legend = '${graphPoint/id}'
        graph.graphPoints.blankLegend.legend = ''
        graph.graphPoints.talesLegend.legend = '${here/id}'

        graphUrl = device.getDefaultGraphDefs()[0]['url']
        gopts = re.search('gopts=([^&]+)', graphUrl).groups()[0]
        gopts = zlib.decompress(urlsafe_b64decode(unquote(gopts)))
        self.assertTrue('defaultLegend' in gopts)
        self.assertTrue('dpname greater than 10' in gopts)
        self.assertTrue('testdevice' in gopts)
Ejemplo n.º 8
0
    def testThresholdGraphPoints(self):
        """
        Test that the correct RRD commands are generated for a number of
        ThresholdGraphPoint configurations.
        """
        device = self.dmd.Devices.createInstance('testdevice')
        device.setPerformanceMonitor('localhost')

        manage_addRRDTemplate(device, 'TestTemplate')
        device.bindTemplates(['TestTemplate'])
        template = device.TestTemplate

        ds = template.manage_addRRDDataSource('dsname', 'BuiltInDS.Built-In')
        dp = ds.manage_addRRDDataPoint('dpname')

        t = template.manage_addRRDThreshold('defaultLegend', 'MinMaxThreshold')
        t.dsnames = ['dsname_dpname']
        t.maxval = '5'

        t = template.manage_addRRDThreshold('blankLegend', 'MinMaxThreshold')
        t.dsnames = ['dsname_dpname']
        t.legend = ''
        t.maxval = '10'

        t = template.manage_addRRDThreshold('talesLegend', 'MinMaxThreshold')
        t.dsnames = ['dsname_dpname']
        t.legend = '${here/id}'
        t.maxval = '15'

        graph = template.manage_addGraphDefinition('graph')
        graph.manage_addDataPointGraphPoints(['dsname_dpname'],
                                             includeThresholds=True)

        graph.graphPoints.defaultLegend.legend = '${graphPoint/id}'
        graph.graphPoints.blankLegend.legend = ''
        graph.graphPoints.talesLegend.legend = '${here/id}'

        graphUrl = device.getDefaultGraphDefs()[0]['url']
        gopts = re.search('gopts=([^&]+)', graphUrl).groups()[0]
        gopts = zlib.decompress(urlsafe_b64decode(unquote(gopts)))
        self.assertTrue('defaultLegend' in gopts)
        self.assertTrue('dpname greater than 10' in gopts)
        self.assertTrue('testdevice' in gopts)
def install(zport, zenpack):
    """
    Set the collector plugin
    """
    dmd = zport.dmd

    if not getattr(aq_base(dmd.Events.Status), 'Kannel', None):
        manage_addEventClass(dmd.Events.Status, 'Kannel')

    tpls = dmd.Devices.Server.rrdTemplates

    if not getattr(aq_base(tpls), 'KannelServer', None):
        manage_addRRDTemplate(tpls, 'KannelServer')
        tpl = tpls.KannelServer

        tpl.manage_changeProperties(description='Monitors Kannel SMPP Servers',
                                    targetPythonClass='Products.ZenModel.Device')
                                
        tpl.manage_addRRDDataSource('kannel', 'KannelDataSource.KannelDataSource')

        dsk = tpl.datasources.kannel
        map(lambda x: dsk.manage_addRRDDataPoint(x), DATAPOINTS)

        # hmmm - recv/sent are accumulated totals, we just want to track the diffs
        for dp_name in ('recv', 'sent'):
            dp = dsk.datapoints._getOb(dp_name)
            if dp.rrdtype != 'DERIVE':
                # hmmm - we seem to be required to provide a max if we provide a min
                dp.manage_changeProperties(rrdtype='DERIVE', rrdmin='0', rrdmax='10000000')

        gdq = dsk.manage_addGraphDefinition('Kannel SMSC Queue')
        setDataPoints(gdq, 'kannel',  GRAPHPOINTS['smsc'])

        gds = dsk.manage_addGraphDefinition('Kannel Store Size')
        setDataPoints(gds, 'kannel', GRAPHPOINTS['store'])

    addZenPackObjects(zenpack, (zport.dmd.Events.Status.Kannel, tpls.KannelServer))
Ejemplo n.º 10
0
 def testThresholdGraphPoints(self):
     """
     Test that the correct RRD commands are generated for a number of
     ThresholdGraphPoint configurations.
     """
     device = self.dmd.Devices.createInstance('testdevice')
     device.setPerformanceMonitor('localhost')
     
     manage_addRRDTemplate(device, 'TestTemplate')
     device.bindTemplates(['TestTemplate'])
     template = device.TestTemplate
     
     ds = template.manage_addRRDDataSource('dsname', 'BuiltInDS.Built-In')
     dp = ds.manage_addRRDDataPoint('dpname')
     
     t = template.manage_addRRDThreshold('defaultLegend', 'MinMaxThreshold')
     t.dsnames = ['dsname_dpname']
     t.maxval = '5'
     
     t = template.manage_addRRDThreshold('blankLegend', 'MinMaxThreshold')
     t.dsnames = ['dsname_dpname']
     t.legend = ''
     t.maxval = '10'
     
     t = template.manage_addRRDThreshold('talesLegend', 'MinMaxThreshold')
     t.dsnames = ['dsname_dpname']
     t.legend = '${here/id}'
     t.maxval = '15'
     
     graph = template.manage_addGraphDefinition('graph')
     graph.manage_addDataPointGraphPoints(
         ['dsname_dpname'], includeThresholds=True)
     
     graph.graphPoints.defaultLegend.legend = '${graphPoint/id}'
     graph.graphPoints.blankLegend.legend = ''
     graph.graphPoints.talesLegend.legend = '${here/id}'