Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the cross-platform library psutil

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Cross-platform library psutil how to understand, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this can learn, I hope you can gain something.

psutil is a cross-platform library that makes it easy to get information about the processes and system utilization (including CPU, memory, disk, network, etc.) of the system running. It is mainly used for system monitoring, analysis and limitation of system resources and process management. It implements the functionality provided by equivalent command line tools such as ps, top, lsof, netstat, ifconfig, who, df, kill, free, nice, ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap, etc.

http://psutil.readthedocs.io/en/latest/ Detailed use cases

1、CPU

1 psutil.cpu_times(percpu=False)

Return cpu usage time ancestor. If percpu=True, returns a list of CPU usage.

1 psutil.cpu_percent(interval,percpu) #Returns CPU utilization

2 psutil.cpu_times_percent(interval=None, percpu=False)

3 psutil.cpu_count(logical=True) #Return system logical CPU

4 psutil.cpu_stats() #Returns CPU statistics

5 psutil.cpu_freq(percpu=False) #Returns the CPU frequency

2. Memory

1 psutil.virtual_memory() #Returns statistics on system memory usage

2 psutil.swap_memory() #Returns system swap memory statistics

3. Disk

1 psutil.disk_partitions(all=False) #Returns a list of all mounted disk devices, including devices, mount points, and file system ancestors

2 psutil.disk_usage(path) #Returns disk statistics

3 psutil.disk_io_counters(perdisk=False, nowrap=True) #Returns disk IO statistics

4. Network

1 psutil.net_io_counters(pernic=False) #Returns system network IO statistics

2 psutil.net_connections(kind ='inet ') #return system socket connections

3 psutil.net_if_addrs() #Returns the IP, subnet mask and broadcast address bound to the NIC

4 psutil.net_if_stats() #Returns information about the NIC

5. Sensors

1 psutil.sensors_temperatures(Fahrenheit=False) #Returns the temperature of hardware

2 psutil.sensors_fans() #Returns hardware fan speed

3 psutil.sensors_battery() #Returns battery status

6. Other

1 psutil.boot_time() #System boot time

2 psutil.users() #List of users connected to the system

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report