首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

python通过ssh-powershell监控windows

对于服务器的监控来说,监控linux不管是自己动手写脚本还是用一些开源的工具比如nagios,zenoss什么的。但毕竟还是有些公司有 windows做服务器的,相对linux来说,windows没有方便的shell,cmd下提供的命令对于监控来说远远没有linux方便。但是现在 windows上如果安装了powershell(win7,2008自带),就比以前方便多了,linux上的命令基本都能在powershell里执 行,比如查看进程还是ps. 自己封装了一个python通过ssh(通过pexpect模块)调用powershell的脚本,里面包 快ps,netstat,ping检测,查看硬盘,cpu信息和负载,内存信息。通过创建ssh_win32类对象,然后调用它的方法,返回的都是解析好 的python对象。 ssh_powershell.py

02

Python使用requests库做爬虫时,乱码问题解决方案

分析: res = requests.get(“http://www.baidu.com“) res.text返回的是Unicode型的数据。 使用res.content返回的是bytes型的数据。 也就是说,如果你想取文本,可以通过res.text。 如果想取图片,文件,则可以通过res.content。 方法1:使用res.content,得到的是bytes型,再转为str url='http://news.baidu.com' res = requests.get(url) html=res.content html_doc=str(html,'utf-8') #html_doc=html.decode("utf-8","ignore") print(html_doc) 方法2:使用res.text url="http://news.baidu.com" res=requests.get(url) res.encoding='utf-8' print(res.text) 方法3:使用res.text+apparent_encoding url="http://news.baidu.com" res=requests.get(url) res.encoding=res.apparent_encoding print(res.text)

01

python通过ssh-powershell监控windows

对于服务器的监控来说,监控linux不管是自己动手写脚本还是用一些开源的工具比如nagios,zenoss什么的。但毕竟还是有些公司有 windows做服务器的,相对linux来说,windows没有方便的shell,cmd下提供的命令对于监控来说远远没有linux方便。但是现在 windows上如果安装了powershell(win7,2008自带),就比以前方便多了,linux上的命令基本都能在powershell里执 行,比如查看进程还是ps. 自己封装了一个python通过ssh(通过pexpect模块)调用powershell的脚本,里面包 快ps,netstat,ping检测,查看硬盘,cpu信息和负载,内存信息。通过创建ssh_win32类对象,然后调用它的方法,返回的都是解析好 的python对象。 ssh_powershell.py

01
领券