Ejemplo n.º 1
0
    def system(self):
        
        system_info_dict = {}
        
        now = unix_utc_now() # unix time
        
        if 'memory' in self.active_checks:
            memory = system_info_collector.get_memory_info()

            if memory != False:
                memory['time'] = now
                system_info_dict['memory'] = memory

        
        if 'cpu' in self.active_checks:
            cpu = system_info_collector.get_cpu_utilization()

            if cpu != False:
                cpu['time'] = now
                system_info_dict['cpu'] = cpu
        

        if 'loadavg' in self.active_checks:
            loadavg = system_info_collector.get_load_average()

            if loadavg != False:
                loadavg['time'] = now
                system_info_dict['loadavg'] = loadavg


        if 'disk' in self.active_checks:
            disk = system_info_collector.get_disk_usage()

            if disk != False:
                disk['time'] = now
                system_info_dict['disk'] = disk

        if 'network' in self.active_checks and sys.platform != 'darwin':
            network = system_info_collector.get_network_traffic()

            if network != False:
                network['time'] = now
                system_info_dict['network'] = network

        return system_info_dict
Ejemplo n.º 2
0
    def system(self):

        system_info_dict = {}

        now = unix_utc_now()  # unix time

        if 'memory' in self.active_checks:
            memory = system_info_collector.get_memory_info()

            if memory != False:
                memory['time'] = now
                system_info_dict['memory'] = memory

        if 'cpu' in self.active_checks:
            cpu = system_info_collector.get_cpu_utilization()

            if cpu != False:
                cpu['time'] = now
                system_info_dict['cpu'] = cpu

        if 'loadavg' in self.active_checks:
            loadavg = system_info_collector.get_load_average()

            if loadavg != False:
                loadavg['time'] = now
                system_info_dict['loadavg'] = loadavg

        if 'disk' in self.active_checks:
            disk = system_info_collector.get_disk_usage()

            if disk != False:
                disk['time'] = now
                system_info_dict['disk'] = disk

        if 'network' in self.active_checks and sys.platform != 'darwin':
            network = system_info_collector.get_network_traffic()

            if network != False:
                network['time'] = now
                system_info_dict['network'] = network

        return system_info_dict
Ejemplo n.º 3
0
    def test_cpu(self):
        cpu = system_info_collector.get_cpu_utilization()

        # For debugging purposes only
        #print cpu
        #import subprocess
        #mpstat = subprocess.Popen(['iostat', '-c'], stdout=subprocess.PIPE, close_fds=True).communicate()[0]
        #print mpstat

        assert 'idle' in cpu
        assert 'user' in cpu
        assert 'system' in cpu
        print cpu.values()

        for v in cpu.values():
            if sys.platform == 'darwin':
                assert isinstance(v, int)
            else:
                # Could be 1.10 - 4, 10.10 - 5, 100.00 - 6
                assert len(v) == 4 or len(v) == 5 or len(v) == 6