Example #1
0
File: linux.py Project: blin/zabby
    def uptime(self):
        """
        Obtains information from /proc/uptime

        See `man 5 proc` for more information
        """
        return int(float(lists_from_file('/proc/uptime')[0][0]))
Example #2
0
File: linux.py Project: blin/zabby
    def uptime(self):
        """
        Obtains information from /proc/uptime

        See `man 5 proc` for more information
        """
        return int(float(lists_from_file('/proc/uptime')[0][0]))
Example #3
0
    def test_returns_list_of_lists(self):
        ensure_contains_only_formatted_lines(FILE_PATH, '1 2')

        found_lists = lists_from_file(FILE_PATH)

        assert_is_instance(found_lists, list)

        for found_list in found_lists:
            assert_is_instance(found_list, list)
Example #4
0
    def test_returns_list_of_lists(self):
        ensure_contains_only_formatted_lines(FILE_PATH, '1 2')

        found_lists = lists_from_file(FILE_PATH)

        assert_is_instance(found_lists, list)

        for found_list in found_lists:
            assert_is_instance(found_list, list)
Example #5
0
File: linux.py Project: blin/zabby
    def _cpus_times(self):
        stats = lists_from_file('/proc/stat')
        cpus_times = []
        for stat in stats:
            key, values = stat[0], stat[1:]
            if key.startswith('cpu') and key != 'cpu':
                cpu_times = [int(cpu_time) for cpu_time in values[:7]]
                cpus_times.append(CpuTimes(*cpu_times))

        return cpus_times
Example #6
0
File: linux.py Project: blin/zabby
    def _cpus_times(self):
        stats = lists_from_file('/proc/stat')
        cpus_times = []
        for stat in stats:
            key, values = stat[0], stat[1:]
            if key.startswith('cpu') and key != 'cpu':
                cpu_times = [int(cpu_time) for cpu_time in values[:7]]
                cpus_times.append(CpuTimes(*cpu_times))

        return cpus_times
Example #7
0
File: linux.py Project: blin/zabby
 def _disk_devices_stats(self):
     diskstats = dict()
     disks = lists_from_file('/proc/diskstats')
     for disk in disks:
         device = disk[2]
         diskstat = DiskDeviceStats(read_sectors=int(disk[5]),
                                    read_operations=int(disk[3]),
                                    read_bytes=0,
                                    write_sectors=int(disk[9]),
                                    write_operations=int(disk[7]),
                                    write_bytes=0)
         diskstats[device] = diskstat
     return diskstats
Example #8
0
File: linux.py Project: blin/zabby
 def _disk_devices_stats(self):
     diskstats = dict()
     disks = lists_from_file('/proc/diskstats')
     for disk in disks:
         device = disk[2]
         diskstat = DiskDeviceStats(
             read_sectors=int(disk[5]),
             read_operations=int(disk[3]),
             read_bytes=0,
             write_sectors=int(disk[9]),
             write_operations=int(disk[7]),
             write_bytes=0
         )
         diskstats[device] = diskstat
     return diskstats
Example #9
0
File: linux.py Project: blin/zabby
    def swap_device_names(self):
        """
        Obtains information from /proc/swaps

        See `man 5 proc` for more information
        """
        swaps = lists_from_file('/proc/swaps')

        devices = set()
        for swap in swaps[1:]:  # skip header
            swap_type = swap[1]
            if swap_type != 'partition':
                continue

            device_path = swap[0]
            device = device_path.split('/')[-1]
            devices.add(device)

        return devices
Example #10
0
File: linux.py Project: blin/zabby
    def swap_device_names(self):
        """
        Obtains information from /proc/swaps

        See `man 5 proc` for more information
        """
        swaps = lists_from_file('/proc/swaps')

        devices = set()
        for swap in swaps[1:]:  # skip header
            swap_type = swap[1]
            if swap_type != 'partition':
                continue

            device_path = swap[0]
            device = device_path.split('/')[-1]
            devices.add(device)

        return devices