Skip to content

Commit

Permalink
handle exception on grabbing host env
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 committed May 3, 2024
1 parent 139488a commit 86a9c20
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions agentops/host_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,51 @@


def get_sdk_details():
return {
"AgentOps SDK Version": get_agentops_version(),
"Python Version": platform.python_version(),
}
try:
return {
"AgentOps SDK Version": get_agentops_version(),
"Python Version": platform.python_version(),
}
except:
return {}


def get_os_details():
return {
"Hostname": socket.gethostname(),
"OS": platform.system(),
"OS Version": platform.version(),
"OS Release": platform.release()
}
try:
return {
"Hostname": socket.gethostname(),
"OS": platform.system(),
"OS Version": platform.version(),
"OS Release": platform.release()
}
except:
return {}


def get_cpu_details():
return {
"Physical cores": psutil.cpu_count(logical=False),
"Total cores": psutil.cpu_count(logical=True),
# "Max Frequency": f"{psutil.cpu_freq().max:.2f}Mhz", # Fails right now
"CPU Usage": f"{psutil.cpu_percent()}%"
}
try:
return {
"Physical cores": psutil.cpu_count(logical=False),
"Total cores": psutil.cpu_count(logical=True),
# "Max Frequency": f"{psutil.cpu_freq().max:.2f}Mhz", # Fails right now
"CPU Usage": f"{psutil.cpu_percent()}%"
}
except:
return {}


def get_ram_details():
ram_info = psutil.virtual_memory()
return {
"Total": f"{ram_info.total / (1024**3):.2f} GB",
"Available": f"{ram_info.available / (1024**3):.2f} GB",
"Used": f"{ram_info.used / (1024**3):.2f} GB",
"Percentage": f"{ram_info.percent}%"
}
try:
ram_info = psutil.virtual_memory()
return {
"Total": f"{ram_info.total / (1024 ** 3):.2f} GB",
"Available": f"{ram_info.available / (1024 ** 3):.2f} GB",
"Used": f"{ram_info.used / (1024 ** 3):.2f} GB",
"Percentage": f"{ram_info.percent}%"
}
except:
return {}



def get_disk_details():
Expand Down

0 comments on commit 86a9c20

Please sign in to comment.