Reading Device Status

We provide device information reading functionality, which is used to obtain real-time operating information of the device, including disk, battery, CPU, memory, network, and other real-time running information, allowing you to understand the current status information of the device in detail.

Getting Status Instance

Before starting below, you also need to first get a Status instance so that you can perform subsequent operations. You can make the following call to get an instance for reading device status.

status = d.stub("Status")

Getting Boot Time

You can get the boot time of the current device through the following call.

status.get_boot_time()
>>> status.get_boot_time()
1234567890

Getting Disk Usage

You can get the disk usage of a specific mount point through 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 get the current device’s battery level, temperature, and other information through 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 get the current device’s CPU and usage information through 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 Disk I/O

You can get the overall disk usage of the current device through 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 get the usage of the current device’s userdata disk through 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 Network I/O

You can get the overall network sending and receiving situation of the current device through 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 get the data sending and receiving situation of a specific network interface of the current device through 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 get the memory usage of the current device through 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