Reading Device Status

We provide functions for reading device information. This feature is used to obtain the device's running status, including real-time operational information for disk, battery, CPU, memory, network, etc., allowing you to get a detailed understanding of the device's current status.

Get Status Instance

Before you begin, you need to get a Status instance to perform subsequent operations. You can make the following call to get an instance for reading the device status.

status = d.stub("Status")

Get Boot Time

You can get the current device's boot time by making the following call.

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

Get Disk Usage

You can get the disk usage for a specific mount point by making 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

Get Battery Information

You can get the current device's battery level, temperature, and other information by making 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

Get CPU Usage

You can get the current device's CPU information and usage by making 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

Get Disk I/O

You can get the overall disk I/O information for the current device by making 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

Get Disk I/O (userdata)

You can get the disk I/O information for the userdata partition on the current device by making 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

Get Network I/O

You can get the overall network I/O information for the current device by making 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

Get Network I/O (Specific Interface)

You can get the data transmission and reception information for a specific network interface on the current device by making 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

Get Memory Usage

You can get the current device's memory usage by making 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