Skip to content

Commit 3ae8b0a

Browse files
authored
Merge pull request #5994 from DIRACGridBot/cherry-pick-2-5ebf1000a-integration
[sweep:integration] fix: allow to run Watchdog on non x86 platforms
2 parents 1f59291 + b0cf6ac commit 3ae8b0a

File tree

1 file changed

+9
-5
lines changed
  • src/DIRAC/WorkloadManagementSystem/JobWrapper

1 file changed

+9
-5
lines changed

src/DIRAC/WorkloadManagementSystem/JobWrapper/Watchdog.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import socket
2525
import getpass
2626
import psutil
27+
from pathlib import Path
2728

2829
from DIRAC import S_OK, S_ERROR, gLogger
2930
from DIRAC.Core.Utilities import Time
@@ -38,7 +39,7 @@
3839
from DIRAC.WorkloadManagementSystem.Client import JobMinorStatus
3940

4041

41-
class Watchdog(object):
42+
class Watchdog:
4243

4344
#############################################################################
4445
def __init__(self, pid, exeThread, spObject, jobCPUTime, memoryLimit=0, processors=1, jobArgs={}):
@@ -968,10 +969,13 @@ def getNodeInformation(self):
968969
result["Memory(kB)"] = int(psutil.virtual_memory()[1] / 1024)
969970
result["LocalAccount"] = getpass.getuser()
970971

971-
with open("/proc/cpuinfo", "r") as cpuinfo:
972-
info = cpuinfo.readlines()
973-
result["ModelName"] = info[4].split(":")[1].replace(" ", "").replace("\n", "")
974-
result["CacheSize(kB)"] = [x.strip().split(":")[1] for x in info if "cache size" in x][0].strip()
972+
path = Path("/proc/cpuinfo")
973+
if path.is_file():
974+
# Assume all of the CPUs are the same and only consider the first one
975+
raw_info = path.read_text().split("\n\n")[0]
976+
info = dict(map(str.strip, x.split(":", 1)) for x in raw_info.split("\n"))
977+
result["ModelName"] = info.get("model name", "Unknown")
978+
result["CacheSize(kB)"] = info.get("cache size", "Unknown")
975979

976980
return result
977981

0 commit comments

Comments
 (0)