forked from Sysdeploy/idlers-agent
Compare commits
No commits in common. "0e996333b2e14aea2eac22278473f0277cfe02a0" and "de3d5fb4abb42bd64a3f3751ef6a33b8acbe80aa" have entirely different histories.
0e996333b2
...
de3d5fb4ab
12
agent.py
12
agent.py
|
@ -13,6 +13,7 @@ NON_UPDATABLE_KEYS = [
|
|||
'bandwidth',
|
||||
'was_promo',
|
||||
'active',
|
||||
'show_public',
|
||||
'owned_since',
|
||||
'currency',
|
||||
'price',
|
||||
|
@ -38,17 +39,6 @@ class ServerData:
|
|||
return ram, disk
|
||||
|
||||
def get_cpu_count(self):
|
||||
cpu_count = 0
|
||||
if os.path.isfile('/usr/sbin/dmidecode'):
|
||||
try:
|
||||
output = subprocess.check_output(['sudo', '/usr/sbin/dmidecode', '-t', 'processor']).decode('utf-8')
|
||||
core_match = re.search(r'Core Count: (\d+)', output)
|
||||
thread_match = re.search(r'Thread Count: (\d+)', output)
|
||||
if core_match and thread_match:
|
||||
cpu_count = int(core_match.group(1)) * int(thread_match.group(1))
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
if cpu_count == 0:
|
||||
with open('/proc/cpuinfo', 'r') as f:
|
||||
cpuinfo = f.read()
|
||||
cpu_count = cpuinfo.count('processor')
|
||||
|
|
Loading…
Reference in New Issue
Block a user