你必须知道的python运维常用脚本
11页1、你必须知道的python运维常用脚本判断是否是一个目录#!/usr/bin/env python3# -*- coding: utf-8 -*-# Time : 2018-12-18 15:16# Author : opsonly# Site : # File : opsUse.py# Software: PyCharmimport osdir = /var/www/html/EnjoyCarApi/if os.path.isdir(dir): print(%s is a dir % dir)else: print(%s is not a dir % dir)系统内存与磁盘检测#!/usr/bin/env python3# -*- coding: utf-8 -*-# Time : 2018-12-17 17:16# Author : opsonly# Site : # File : systemissue.py# Software: PyCharmimport psutildef memissue(): print(内存信息:) mem = psutil.virtual_memory
2、() # 单位换算为MB memtotal = mem.total/1024/1024 memused = mem.used/1024/1024 membaifen = str(mem.used/mem.total*100) + % print(%.2fMB % memused) print(%.2fMB % memtotal) print(membaifen)def cuplist(): print(磁盘信息:) disk = psutil.disk_partitions() diskuse = psutil.disk_usage(/) #单位换算为GB diskused = diskuse.used / 1024 / 1024 / 1024 disktotal = diskuse.total / 1024 / 1024 / 1024 diskbaifen = diskused / disktotal * 100 print(%.2fGB % diskused) print(%.2fGB % disktotal) print(%.2f % diskbaifen)memissue()p
3、rint(*)cuplist()统计nginx日志前十ip访问量并以柱状图显示#!/usr/bin/env python3# -*- coding: utf-8 -*-# Time : 2018-12-18 15:49# Author : opsonly# Site : # File : nginx_ip.py# Software: PyCharmimport matplotlib.pyplot as plt#nginx_file = nginx2018-12-18_07:45:26ip = # 筛选nginx日志文件中的ipwith open(nginx_file) as f: for i in f.readlines(): s = i.strip().split()0 lengh = len(ip.keys() # 统计每个ip的访问量以字典存储 if s in ip.keys(): ips = ips + 1 else: ips = 1#以ip出现的次数排序返回对象为list http:/f-1.ccip = sorted(ip.items(), key=lambda e:e1,
《你必须知道的python运维常用脚本》由会员m****分享,可在线阅读,更多相关《你必须知道的python运维常用脚本》请在金锄头文库上搜索。
DB2发生死锁情况时应该怎么处理
Python 为何能成最强编程语言
面试前必须要知道的Redis面试
MySQL下自动删除指定时间以前的记录的操作方法
深入理解FastCGI协议以及在PHP中的实现
MySQL数据库性能优化之硬件瓶颈分析
NoSQL数据库大全收集整理
2018 – 2019 年前端 JavaScript 面试题
PHP文件包含漏洞的形式总结
5种使用Python代码轻松实现数据可视化的方法
改进JavaScript和Bust的互操作性:深入认识wasm-bindgen组件
C#图片缩放平移从功能分析到编码实现
详解网络蜘蛛的安全隐患及预防方法
利用NAP解除安全隐患自动隐藏你的IP地址
解决分布式数据库和离线网络中原子性问题的新方法
bbed恢复数据遇到延迟块清除的问题
Oracle Data Redaction数据加密
linux下du和df结果不一致的原因及处理
基于QMP实现对qemu虚拟机进行交互
解读Java并发队列BlockingQueue
2023-09-09 59页
2023-08-28 1页
2023-08-27 18页
2023-08-27 7页
2023-08-27 6页
2023-08-27 6页
2023-08-27 8页
2023-08-23 6页
2023-08-23 3页
2023-08-23 20页