Reading Device Status¶
We provide device information retrieval functionality, which allows you to obtain real-time operational status of the device, including disk, battery, CPU, memory, network, and other runtime information. This enables you to gain a detailed understanding of the current state of the device.
Obtaining a Status Instance¶
Before proceeding, you must first obtain a Status instance in order to perform subsequent operations. You can acquire an instance for reading device status with the following call:
status = d.stub("Status")
Getting Boot Time¶
You can retrieve the device’s boot time (system uptime) using the following call:
status.get_boot_time()
>>> status.get_boot_time()
1234567890
Getting Disk Usage¶
You can retrieve disk usage for a specific mount point using the following call:
status.get_disk_usage(mountpoint="/data")
>>> status.get_disk_usage(mountpoint="/data")
disk_total: 117153181696
disk_used: 8111099904
disk_free: 108907864064
disk_percent: 6.900000095367432
>>> result = status.get_disk_usage(mountpoint="/data")
>>> print(result.disk_free)
108907864064
Getting Battery Information¶
You can retrieve battery-related information such as charge level and temperature using the following call:
status.get_battery_info()
>>> status.get_battery_info()
batt_charging: true
batt_percent: 100
batt_temperature: 26.899999618530273
>>> result = status.get_battery_info()
>>> print(result.batt_charging)
True
Getting CPU Usage¶
You can retrieve CPU usage and related information using the following call:
status.get_cpu_info()
>>> status.get_cpu_info()
cpu_percent: 20.799999237060547
cpu_count: 8
cpu_freq_current: 823.2000122070312
cpu_freq_max: 1929.5999755859375
cpu_freq_min: 614.4000244140625
cpu_times_user: 13.699999809265137
cpu_times_system: 5.800000190734863
cpu_times_idle: 79.80000305175781
>>> result = status.get_cpu_info()
>>> print(result.cpu_percent)
20.799999237060547
Getting Overall Disk I/O¶
You can retrieve overall disk I/O statistics for the device using the following call:
status.get_overall_disk_io_info()
>>> status.get_overall_disk_io_info()
disk_io_read_bytes: 11569016832
disk_io_read_count: 917667
disk_io_write_bytes: 6973407232
disk_io_write_count: 909946
disk_io_read_time: 364713
disk_io_write_time: 268013
disk_io_busy_time: 152621
>>> result = status.get_overall_disk_io_info()
>>> print(result.disk_io_write_bytes)
6973407232
Getting Disk I/O (Userdata)¶
You can retrieve disk I/O statistics specifically for the userdata partition using the following call:
status.get_userdata_disk_io_info()
>>> status.get_userdata_disk_io_info()
disk_io_read_bytes: 2899529728
disk_io_read_count: 115970
disk_io_write_bytes: 1815506944
disk_io_write_count: 45254
disk_io_read_time: 152239
disk_io_write_time: 120825
disk_io_busy_time: 49127
>>> result = status.get_userdata_disk_io_info()
>>> print(result.disk_io_read_bytes)
2899529728
Getting Overall Network I/O¶
You can retrieve overall network traffic statistics for the device using the following call:
status.get_overall_net_io_info()
>>> status.get_overall_net_io_info()
net_io_bytes_sent: 65296119
net_io_packets_sent: 78793
net_io_bytes_recv: 60046396
net_io_packets_recv: 80745
>>> result = status.get_overall_net_io_info()
>>> print(result.net_io_bytes_recv)
60046396
Getting Network I/O (Specific Interface)¶
You can retrieve network traffic statistics for a specific network interface using the following call:
status.get_net_io_info("wlan0")
>>> status.get_net_io_info("wlan0")
net_io_bytes_sent: 36896321
net_io_packets_sent: 59869
net_io_bytes_recv: 58846862
net_io_packets_recv: 66759
>>> result = status.get_net_io_info("wlan0")
>>> print(result.net_io_bytes_recv)
58846862
Getting Memory Usage¶
You can retrieve memory usage statistics using the following call:
status.get_mem_info()
>>> status.get_mem_info()
mem_total: 7823970304
mem_available: 3208761344
mem_percent: 59.0
mem_used: 4327931904
mem_free: 298639360
mem_active: 3535876096
mem_inactive: 1634873344
mem_buffers: 4243456
mem_cached: 3193155584
mem_shared: 34979840
mem_slab: 426651648
>>> result = status.get_mem_info()
>>> print(result.mem_total)
7823970304