我要写个(python)运维监控软件

psuitl模块学习
CPU

psutil.cpu_count( ) CPU逻辑数量
1

psutil.cpu_count( logical=False ) CPU物理数量
1
内存

psutil.virtual_memory( ) 内存的信息
svmem(total=2078871552, available=368168960, percent=82.3, used=1467621376, free=72568832, active=1025441792, inactive=517386240, buffers=692224, cached=537989120, shared=50515968, slab=233480192)

m = psutil.virtual_memory( )
m.total 内存总数
2078871552

m.free 未使用的内存
72425472

交换分区

psutil.swap_memory( ) 交换分区信息
sswap(total=3171475456, used=4202496, free=3167272960, percent=0.1, sin=6545408, sout=9482240)

磁盘
psutil.disk_io_counters( psutil.disk_partitions( psutil.disk_usage( 磁盘信息的命令

psutil.disk_partitions( ) 磁盘完整信息
[sdiskpart(device=’/dev/mapper/centos-root’, mountpoint=’/’, fstype=‘xfs’, opts=‘rw,relatime,attr2,inode64,noquota’), sdiskpart(device=’/dev/sda1’, mountpoint=’/boot’, fstype=‘xfs’, opts=‘rw,relatime,attr2,inode64,noquota’), sdiskpart(device=’/dev/sr0’, mountpoint=’/run/media/root/CentOS 7 x86_64’, fstype=‘iso9660’, opts=‘ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500’)]

psutil.disk_usage( “/” ) 磁盘分区的使用情况
sdiskusage(total=18238930944, used=8913346560, free=9325584384, percent=48.9)

psutil.disk_io_counters( ) 磁盘的读写情况
sdiskio(read_count=76739, write_count=35629, read_bytes=5081857024, write_bytes=774587392, read_time=2445606, write_time=4432420, read_merged_count=1515, write_merged_count=7474, busy_time=690300)

网络
psutil.net… 查看网络情况

用户
psutil.users( ) 当前用户的信息
[suser(name=‘root’, terminal=’:0’, host=‘localhost’, started=1561507200.0, pid=2232), suser(name=‘root’, terminal=‘pts/0’, host=‘localhost’, started=1561507200.0, pid=3222), suser(name=‘root’, terminal=‘pts/1’, host=‘1,1,1,1’, started=1561598720.0, pid=41107

进程

psutil.pids( )
[1, 2, 3, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 27, 28, 29, 30, 38, 40, 41, 42, 44, 57, 89, 266, 267, 268, 274, 275, 278, 280, 281 …

p = psutil.Process(41107)
p.name( )
‘bash’

p.status( )
‘sleeping’

p.num_threads( )
1

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值