Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import glob
- import os
- import sys
- SYS_CPU = '/sys/devices/system/cpu/cpu{}'
- SYS_CPU_SETTING = '/sys/devices/system/cpu/cpu{cpu}/{setting}'
- SETTINGS = {
- 'Online': 'online',
- 'Min Freq.': 'cpufreq/cpuinfo_min_freq',
- 'Max Freq.': 'cpufreq/cpuinfo_max_freq',
- 'Scaling Driver': 'cpufreq/scaling_driver',
- 'Scaling Governor': 'cpufreq/scaling_governor',
- 'Scaling Governor': 'cpufreq/scaling_governor',
- }
- if __name__ == '__main__':
- cpus = [int(path[len(SYS_CPU.format('')):]) for path in \
- glob.glob(SYS_CPU.format('[0-9]*'))]
- for cpu in cpus:
- hdr = 'CPU {}'.format(cpu)
- divider = '-' * len(hdr)
- print(hdr)
- print(divider)
- for setting, path in SETTINGS.items():
- try:
- with open(SYS_CPU_SETTING.format(cpu=cpu, setting=path), 'r') as f:
- value = f.read().strip()
- except IOError:
- pass
- print('{}:\t{}'.format(setting, value))
- node = -1
- try:
- nodes = glob.glob(SYS_CPU_SETTING.format(cpu=cpu, setting='node*'))
- if len(nodes) is not 1:
- node = -1
- else:
- node = int(nodes[0]\
- [len(SYS_CPU_SETTING.format(cpu=cpu, setting='node')):])
- except IOError:
- node = -1
- print('NUMA Node: {}'.format(node))
- print('')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement