Exemplo n.º 1
0
class TestNfsCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('NfsCollector', {'interval': 1})

        self.collector = NfsCollector(config, None)

    def test_import(self):
        self.assertTrue(NfsCollector)

    @patch('__builtin__.open')
    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_open_proc_stat(self, publish_mock, open_mock):
        open_mock.return_value = StringIO('')
        self.collector.collect()
        open_mock.assert_called_once_with('/proc/net/rpc/nfs')

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data(self, publish_mock):
        #NfsCollector.PROC = self.getFixturePath('proc_nfs_1')
        #self.collector.collect()

        #self.assertPublishedMany(publish_mock, {})

        #NfsCollector.PROC = self.getFixturePath('proc_nfs_2')
        #self.collector.collect()

        metrics = {}

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])
Exemplo n.º 2
0
class TestNfsCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('NfsCollector', {
            'interval': 1
        })

        self.collector = NfsCollector(config, None)

    def test_import(self):
        self.assertTrue(NfsCollector)

    @patch('__builtin__.open')
    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_open_proc_stat(self, publish_mock, open_mock):
        open_mock.return_value = StringIO('')
        self.collector.collect()
        open_mock.assert_called_once_with('/proc/net/rpc/nfs')

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data(self, publish_mock):
        #NfsCollector.PROC = self.getFixturePath('proc_nfs_1')
        #self.collector.collect()

        #self.assertPublishedMany(publish_mock, {})

        #NfsCollector.PROC = self.getFixturePath('proc_nfs_2')
        #self.collector.collect()

        metrics = {
        }

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])
Exemplo n.º 3
0
class TestNfsCollector(CollectorTestCase):

    def setUp(self):
        config = get_collector_config('NfsCollector', {
            'interval': 1
        })

        self.collector = NfsCollector(config, None)

    def test_import(self):
        self.assertTrue(NfsCollector)

    @patch('__builtin__.open')
    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_open_proc_stat(self, publish_mock, open_mock):
        open_mock.return_value = StringIO('')
        self.collector.collect()
        open_mock.assert_called_once_with('/proc/net/rpc/nfs')

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data_rhel5(self, publish_mock):
        NfsCollector.PROC = self.getFixturePath('rhel5-1')
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})

        NfsCollector.PROC = self.getFixturePath('rhel5-2')
        self.collector.collect()

        metrics = {
            'net.packets': 0.0,
            'net.tcpcnt': 0.0,
            'net.tcpconn': 0.0,
            'net.udpcnt': 0.0,
            'rpc.authrefrsh': 0.0,
            'rpc.calls': 8042864.0,
            'rpc.retrans': 0.0,
            'v2.create': 0.0,
            'v2.fsstat': 0.0,
            'v2.getattr': 0.0,
            'v2.link': 0.0,
            'v2.lookup': 0.0,
            'v2.mkdir': 0.0,
            'v2.null': 0.0,
            'v2.read': 0.0,
            'v2.readdir': 0.0,
            'v2.readlink': 0.0,
            'v2.remove': 0.0,
            'v2.rename': 0.0,
            'v2.rmdir': 0.0,
            'v2.root': 0.0,
            'v2.setattr': 0.0,
            'v2.symlink': 0.0,
            'v2.wrcache': 0.0,
            'v2.write': 0.0,
            'v3.access': 40672.0,
            'v3.commit': 0.0,
            'v3.create': 91.0,
            'v3.fsinfo': 0.0,
            'v3.fsstat': 20830.0,
            'v3.getattr': 162507.0,
            'v3.link': 0.0,
            'v3.lookup': 89.0,
            'v3.mkdir': 0.0,
            'v3.mknod': 0.0,
            'v3.null': 0.0,
            'v3.pathconf': 0.0,
            'v3.read': 6093419.0,
            'v3.readdir': 4002.0,
            'v3.readdirplus': 0.0,
            'v3.readlink': 0.0,
            'v3.remove': 9.0,
            'v3.rename': 0.0,
            'v3.rmdir': 0.0,
            'v3.setattr': 8640.0,
            'v3.symlink': 0.0,
            'v3.write': 1712605.0,
            'v4.access': 0.0,
            'v4.close': 0.0,
            'v4.commit': 0.0,
            'v4.confirm': 0.0,
            'v4.create': 0.0,
            'v4.delegreturn': 0.0,
            'v4.fs_locations': 0.0,
            'v4.fsinfo': 0.0,
            'v4.getacl': 0.0,
            'v4.getattr': 0.0,
            'v4.link': 0.0,
            'v4.lock': 0.0,
            'v4.lockt': 0.0,
            'v4.locku': 0.0,
            'v4.lookup': 0.0,
            'v4.lookup_root': 0.0,
            'v4.null': 0.0,
            'v4.open': 0.0,
            'v4.open_conf': 0.0,
            'v4.open_dgrd': 0.0,
            'v4.open_noat': 0.0,
            'v4.pathconf': 0.0,
            'v4.read': 0.0,
            'v4.readdir': 0.0,
            'v4.readlink': 0.0,
            'v4.rel_lkowner': 0.0,
            'v4.remove': 0.0,
            'v4.rename': 0.0,
            'v4.renew': 0.0,
            'v4.server_caps': 0.0,
            'v4.setacl': 0.0,
            'v4.setattr': 0.0,
            'v4.setclntid': 0.0,
            'v4.statfs': 0.0,
            'v4.symlink': 0.0,
            'v4.write': 0.0
        }

        self.assertPublishedMany(publish_mock, metrics)

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data_rhel6(self, publish_mock):
        NfsCollector.PROC = self.getFixturePath('rhel6-1')
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})

        NfsCollector.PROC = self.getFixturePath('rhel6-2')
        self.collector.collect()

        metrics = {
            'net.packets': 0.0,
            'net.tcpcnt': 0.0,
            'net.tcpconn': 0.0,
            'net.udpcnt': 0.0,
            'rpc.authrefrsh': 32.0,
            'rpc.calls': 32.0,
            'rpc.retrans': 0.0,
            'v2.create': 0.0,
            'v2.fsstat': 0.0,
            'v2.getattr': 0.0,
            'v2.link': 0.0,
            'v2.lookup': 0.0,
            'v2.mkdir': 0.0,
            'v2.null': 0.0,
            'v2.read': 0.0,
            'v2.readdir': 0.0,
            'v2.readlink': 0.0,
            'v2.remove': 0.0,
            'v2.rename': 0.0,
            'v2.rmdir': 0.0,
            'v2.root': 0.0,
            'v2.setattr': 0.0,
            'v2.symlink': 0.0,
            'v2.wrcache': 0.0,
            'v2.write': 0.0,
            'v3.access': 6.0,
            'v3.commit': 0.0,
            'v3.create': 0.0,
            'v3.fsinfo': 0.0,
            'v3.fsstat': 17.0,
            'v3.getattr': 7.0,
            'v3.link': 0.0,
            'v3.lookup': 0.0,
            'v3.mkdir': 0.0,
            'v3.mknod': 0.0,
            'v3.null': 0.0,
            'v3.pathconf': 0.0,
            'v3.read': 0.0,
            'v3.readdir': 0.0,
            'v3.readdirplus': 0.0,
            'v3.readlink': 0.0,
            'v3.remove': 0.0,
            'v3.rename': 0.0,
            'v3.rmdir': 0.0,
            'v3.setattr': 1.0,
            'v3.symlink': 0.0,
            'v3.write': 1.0,
            'v4.access': 0.0,
            'v4.close': 0.0,
            'v4.commit': 0.0,
            'v4.confirm': 0.0,
            'v4.create': 0.0,
            'v4.create_ses': 0.0,
            'v4.delegreturn': 0.0,
            'v4.destroy_ses': 0.0,
            'v4.ds_write': 0.0,
            'v4.exchange_id': 0.0,
            'v4.fs_locations': 0.0,
            'v4.fsinfo': 0.0,
            'v4.get_lease_t': 0.0,
            'v4.getacl': 0.0,
            'v4.getattr': 0.0,
            'v4.getdevinfo': 0.0,
            'v4.getdevlist': 0.0,
            'v4.layoutcommit': 0.0,
            'v4.layoutget': 0.0,
            'v4.layoutreturn': 0.0,
            'v4.link': 0.0,
            'v4.lock': 0.0,
            'v4.lockt': 0.0,
            'v4.locku': 0.0,
            'v4.lookup': 0.0,
            'v4.lookup_root': 0.0,
            'v4.null': 0.0,
            'v4.open': 0.0,
            'v4.open_conf': 0.0,
            'v4.open_dgrd': 0.0,
            'v4.open_noat': 0.0,
            'v4.pathconf': 0.0,
            'v4.read': 0.0,
            'v4.readdir': 0.0,
            'v4.readlink': 0.0,
            'v4.reclaim_comp': 0.0,
            'v4.rel_lkowner': 0.0,
            'v4.remove': 0.0,
            'v4.rename': 0.0,
            'v4.renew': 0.0,
            'v4.sequence': 0.0,
            'v4.server_caps': 0.0,
            'v4.setacl': 0.0,
            'v4.setattr': 0.0,
            'v4.setclntid': 0.0,
            'v4.statfs': 0.0,
            'v4.symlink': 0.0,
            'v4.write': 0.0,
        }

        self.assertPublishedMany(publish_mock, metrics)
Exemplo n.º 4
0
class TestNfsCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('NfsCollector', {'interval': 1})

        self.collector = NfsCollector(config, None)

    def test_import(self):
        self.assertTrue(NfsCollector)

    @patch('__builtin__.open')
    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_open_proc_stat(self, publish_mock, open_mock):
        open_mock.return_value = StringIO('')
        self.collector.collect()
        open_mock.assert_called_once_with('/proc/net/rpc/nfs')

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data_rhel5(self, publish_mock):
        NfsCollector.PROC = self.getFixturePath('rhel5-1')
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})

        NfsCollector.PROC = self.getFixturePath('rhel5-2')
        self.collector.collect()

        metrics = {
            'net.packets': 0.0,
            'net.tcpcnt': 0.0,
            'net.tcpconn': 0.0,
            'net.udpcnt': 0.0,
            'rpc.authrefrsh': 0.0,
            'rpc.calls': 8042864.0,
            'rpc.retrans': 0.0,
            'v2.create': 0.0,
            'v2.fsstat': 0.0,
            'v2.getattr': 0.0,
            'v2.link': 0.0,
            'v2.lookup': 0.0,
            'v2.mkdir': 0.0,
            'v2.null': 0.0,
            'v2.read': 0.0,
            'v2.readdir': 0.0,
            'v2.readlink': 0.0,
            'v2.remove': 0.0,
            'v2.rename': 0.0,
            'v2.rmdir': 0.0,
            'v2.root': 0.0,
            'v2.setattr': 0.0,
            'v2.symlink': 0.0,
            'v2.wrcache': 0.0,
            'v2.write': 0.0,
            'v3.access': 40672.0,
            'v3.commit': 0.0,
            'v3.create': 91.0,
            'v3.fsinfo': 0.0,
            'v3.fsstat': 20830.0,
            'v3.getattr': 162507.0,
            'v3.link': 0.0,
            'v3.lookup': 89.0,
            'v3.mkdir': 0.0,
            'v3.mknod': 0.0,
            'v3.null': 0.0,
            'v3.pathconf': 0.0,
            'v3.read': 6093419.0,
            'v3.readdir': 4002.0,
            'v3.readdirplus': 0.0,
            'v3.readlink': 0.0,
            'v3.remove': 9.0,
            'v3.rename': 0.0,
            'v3.rmdir': 0.0,
            'v3.setattr': 8640.0,
            'v3.symlink': 0.0,
            'v3.write': 1712605.0,
            'v4.access': 0.0,
            'v4.close': 0.0,
            'v4.commit': 0.0,
            'v4.confirm': 0.0,
            'v4.create': 0.0,
            'v4.delegreturn': 0.0,
            'v4.fs_locations': 0.0,
            'v4.fsinfo': 0.0,
            'v4.getacl': 0.0,
            'v4.getattr': 0.0,
            'v4.link': 0.0,
            'v4.lock': 0.0,
            'v4.lockt': 0.0,
            'v4.locku': 0.0,
            'v4.lookup': 0.0,
            'v4.lookup_root': 0.0,
            'v4.null': 0.0,
            'v4.open': 0.0,
            'v4.open_conf': 0.0,
            'v4.open_dgrd': 0.0,
            'v4.open_noat': 0.0,
            'v4.pathconf': 0.0,
            'v4.read': 0.0,
            'v4.readdir': 0.0,
            'v4.readlink': 0.0,
            'v4.rel_lkowner': 0.0,
            'v4.remove': 0.0,
            'v4.rename': 0.0,
            'v4.renew': 0.0,
            'v4.server_caps': 0.0,
            'v4.setacl': 0.0,
            'v4.setattr': 0.0,
            'v4.setclntid': 0.0,
            'v4.statfs': 0.0,
            'v4.symlink': 0.0,
            'v4.write': 0.0
        }

        self.assertPublishedMany(publish_mock, metrics)

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data_rhel6(self, publish_mock):
        NfsCollector.PROC = self.getFixturePath('rhel6-1')
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})

        NfsCollector.PROC = self.getFixturePath('rhel6-2')
        self.collector.collect()

        metrics = {
            'net.packets': 0.0,
            'net.tcpcnt': 0.0,
            'net.tcpconn': 0.0,
            'net.udpcnt': 0.0,
            'rpc.authrefrsh': 32.0,
            'rpc.calls': 32.0,
            'rpc.retrans': 0.0,
            'v2.create': 0.0,
            'v2.fsstat': 0.0,
            'v2.getattr': 0.0,
            'v2.link': 0.0,
            'v2.lookup': 0.0,
            'v2.mkdir': 0.0,
            'v2.null': 0.0,
            'v2.read': 0.0,
            'v2.readdir': 0.0,
            'v2.readlink': 0.0,
            'v2.remove': 0.0,
            'v2.rename': 0.0,
            'v2.rmdir': 0.0,
            'v2.root': 0.0,
            'v2.setattr': 0.0,
            'v2.symlink': 0.0,
            'v2.wrcache': 0.0,
            'v2.write': 0.0,
            'v3.access': 6.0,
            'v3.commit': 0.0,
            'v3.create': 0.0,
            'v3.fsinfo': 0.0,
            'v3.fsstat': 17.0,
            'v3.getattr': 7.0,
            'v3.link': 0.0,
            'v3.lookup': 0.0,
            'v3.mkdir': 0.0,
            'v3.mknod': 0.0,
            'v3.null': 0.0,
            'v3.pathconf': 0.0,
            'v3.read': 0.0,
            'v3.readdir': 0.0,
            'v3.readdirplus': 0.0,
            'v3.readlink': 0.0,
            'v3.remove': 0.0,
            'v3.rename': 0.0,
            'v3.rmdir': 0.0,
            'v3.setattr': 1.0,
            'v3.symlink': 0.0,
            'v3.write': 1.0,
            'v4.access': 0.0,
            'v4.close': 0.0,
            'v4.commit': 0.0,
            'v4.confirm': 0.0,
            'v4.create': 0.0,
            'v4.create_ses': 0.0,
            'v4.delegreturn': 0.0,
            'v4.destroy_ses': 0.0,
            'v4.ds_write': 0.0,
            'v4.exchange_id': 0.0,
            'v4.fs_locations': 0.0,
            'v4.fsinfo': 0.0,
            'v4.get_lease_t': 0.0,
            'v4.getacl': 0.0,
            'v4.getattr': 0.0,
            'v4.getdevinfo': 0.0,
            'v4.getdevlist': 0.0,
            'v4.layoutcommit': 0.0,
            'v4.layoutget': 0.0,
            'v4.layoutreturn': 0.0,
            'v4.link': 0.0,
            'v4.lock': 0.0,
            'v4.lockt': 0.0,
            'v4.locku': 0.0,
            'v4.lookup': 0.0,
            'v4.lookup_root': 0.0,
            'v4.null': 0.0,
            'v4.open': 0.0,
            'v4.open_conf': 0.0,
            'v4.open_dgrd': 0.0,
            'v4.open_noat': 0.0,
            'v4.pathconf': 0.0,
            'v4.read': 0.0,
            'v4.readdir': 0.0,
            'v4.readlink': 0.0,
            'v4.reclaim_comp': 0.0,
            'v4.rel_lkowner': 0.0,
            'v4.remove': 0.0,
            'v4.rename': 0.0,
            'v4.renew': 0.0,
            'v4.sequence': 0.0,
            'v4.server_caps': 0.0,
            'v4.setacl': 0.0,
            'v4.setattr': 0.0,
            'v4.setclntid': 0.0,
            'v4.statfs': 0.0,
            'v4.symlink': 0.0,
            'v4.write': 0.0,
        }

        self.assertPublishedMany(publish_mock, metrics)
Exemplo n.º 5
0
class TestNfsCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('NfsCollector', {
            'interval': 1
        })

        self.collector = NfsCollector(config, None)

    def test_import(self):
        self.assertTrue(NfsCollector)

    @patch('__builtin__.open')
    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_open_proc_stat(self, publish_mock, open_mock):
        open_mock.return_value = StringIO('')
        self.collector.collect()
        open_mock.assert_called_once_with('/proc/net/rpc/nfs')

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data(self, publish_mock):
        NfsCollector.PROC = self.getFixturePath('proc_nfs_1')
        self.collector.collect()

        self.assertPublishedMany(publish_mock, {})

        NfsCollector.PROC = self.getFixturePath('proc_nfs_2')
        self.collector.collect()

        metrics = {
            '.input_output.bytes-read': 3139369493.0,
            '.input_output.bytes-written': 15691669.0,
            '.net.cnt': 14564086.0,
            '.net.tcpcnt': 14562696.0,
            '.net.tcpconn': 30773.0,
            '.read-ahead.10-pct': 8751152.0,
            '.read-ahead.cache-size': 32.0,
            '.read-ahead.not-found': 18612.0,
            '.reply_cache.misses': 71080.0,
            '.reply_cache.nocache': 14491982.0,
            '.rpc.calls': 14563007.0,
            '.threads.10-20-pct': 22163.0,
            '.threads.100-pct': 22111.0,
            '.threads.20-30-pct': 8448.0,
            '.threads.30-40-pct': 1642.0,
            '.threads.50-60-pct': 5072.0,
            '.threads.60-70-pct': 1210.0,
            '.threads.70-80-pct': 3889.0,
            '.threads.80-90-pct': 2654.0,
            '.threads.fullcnt': 1324492.0,
            '.threads.threads': 8.0,
            '.v2.null': 8.0,
            '.v3.access': 136921.0,
            '.v3.commit': 635.0,
            '.v3.create': 1655.0,
            '.v3.fsinfo': 11.0,
            '.v3.fsstat': 34450.0,
            '.v3.getattr': 724974.0,
            '.v3.lookup': 213165.0,
            '.v3.null': 8.0,
            '.v3.read': 8761683.0,
            '.v3.readdir': 11295.0,
            '.v3.readdirplus': 132298.0,
            '.v3.remove': 1488.0,
            '.v3.write': 67937.0,
            '.v4.compound': 4476320.0,
            '.v4.null': 18.0,
            '.v4.access': 2083822.0,
            '.v4.close': 34801.0,
            '.v4.commit': 3955.0,
            '.v4.getattr': 2302848.0,
            '.v4.lookup': 68501.0,
            '.v4.open': 34847.0,
            '.v4.open_conf': 29002.0,
            '.v4.read': 8030.0,
            '.v4.readdir': 272.0,
            '.v4.remove': 7802.0,
            '.v4.renew': 28594.0,
            '.v4.setattr': 7870.0,
            '.v4.setclntid': 6226.0,
            '.v4.write': 76562.0
    	}

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])
        self.assertPublishedMany(publish_mock, metrics)