监控系统性能的脚本(cpu,disk,memory,network)
2017-05-10 13:59
411 查看
#!/usr/bin/pythonimport psutilimport jsonimport timedef item_disk():return dict(zip(['total','used','free','percent'],psutil.disk_usage('/')))def item_cpu():return dict(zip(['user','system','nice','idle'],psutil.cpu_times()))def item_mem():return dict(zip(['total','available','percent','used','free','active','inactive'],psutil.virtual_memory()))def item_net():return dict(zip(['bytes_sent','bytes_recv','packets_sent','packets_recv','errin','errout','dropin','dropout'],psutil.net_io_counters()))def runner():while True:yield{'disk' : item_disk(),'cpu' : item_cpu(),'mem' : item_mem(),'network' : item_net()}def format_(data):return json.dumps(data, indent=4, ensure_ascii=False)def running():for items in runner():print(format_(items))time.sleep(5)def main():print(running())if __name__ == '__main__':main()
相关文章推荐
- Jmeter-Plugins支持CPU、Memory、Swap、Disk和Network的监控
- Linux 性能监控 : CPU 、Memory 、 IO 、Network
- Linux性能监控 - CPU、Memory、IO、Network
- linux:关于Linux系统中 CPU Memory IO Network的性能监测
- linux:关于Linux系统中 CPU Memory IO Network的性能监测
- linux:关于Linux系统中 CPU Memory IO Network的性能监测
- 【操作系统】Linux性能监控——CPU、Memory、IO、Network
- linux:关于Linux系统中 CPU Memory IO Network的性能监测
- Linux-性能监控相关CPU、Memory、IO、Network等指标的讲解
- SNMP监控系统cpu、disk、memory等问题汇总
- Linux 性能监控 : CPU 、Memory 、 IO 、Network
- shell脚本监控系统负载、CPU和内存使用情况
- Redhat linux 系统的负载与CPU、内存、硬盘、用户数监控shell脚本 推荐
- 几个常用的Linux系统性能监控shell脚本
- shell脚本监控系统负载、CPU和内存使用情况
- 利用shell脚本来监控linux系统的负载与CPU占用情况
- linux系统性能监控--CPU利用率
- 利用Shell脚本来监控Linux系统的负载、CPU、内存、硬盘、用户登录数
- linux系统CPU内存磁盘监控发送邮件脚本之二
- shell脚本监控系统负载、CPU和内存使用情况