Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: sysmon: Add cpu usage fields in sysmon system subcommand #1359

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pymobiledevice3/cli/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,24 @@ def sysmon_system(service_provider: LockdownClient, fields):
with DvtSecureSocketProxyService(lockdown=service_provider) as dvt:
sysmontap = Sysmontap(dvt)
with sysmontap as sysmon:
system = None
system_usage = None
system_usage_seen = False # Tracks if the first occurrence of SystemCPUUsage

for row in sysmon:
if 'System' in row:
if 'System' in row and system is None:
system = sysmon.system_attributes_cls(*row['System'])

if 'SystemCPUUsage' in row:
if system_usage_seen:
system_usage = row['SystemCPUUsage']
else: # Ignore the first occurrence because first occurrence always gives a incorrect value - 100 or 0
system_usage_seen = True

if system and system_usage:
break

attrs_dict = asdict(system)
attrs_dict = {**asdict(system), **system_usage}
for name, value in attrs_dict.items():
if (fields is None) or (name in fields):
print(f'{name}: {value}')
Expand Down
Loading