数以千计的服务器存活状态检查
发表于:2025-02-10 作者:千家信息网编辑
千家信息网最后更新 2025年02月10日,# !/usr/bin/python# -*- coding: UTF-8 -*-import commandsimport sysimport timeclass server_unreache(o
千家信息网最后更新 2025年02月10日数以千计的服务器存活状态检查
# !/usr/bin/python# -*- coding: UTF-8 -*-import commandsimport sysimport timeclass server_unreache(object): def __init__(self, ip_list): self.ip_list = ip_list#第一次获取无法ping通的服务器列表 def unreachable_ip_list(self): global unreachable_iplist_one_time unreachable_iplist_one_time=[] get_un_iplist_str = "/sbin/fping -u -f {}".format(ip_list) (status, get_un_iplist) = commands.getstatusoutput(get_un_iplist_str) for unreach in get_un_iplist.split('\n'): unreachable_iplist_one_time.append(unreach) #return unreachable_iplist_one_time pass# 对第一次获取无法ping通的服务器列表,在进行3次ping操作,每次操作时间间隔为10秒 def do_3times_fping_unreachable(self): global unreache_3times unreache_3times=[] for j in range(3): for i in range(len(unreachable_iplist_one_time)): get_3times_un_iplist_str = "/sbin/fping -u {}".format(unreachable_iplist_one_time[i]) time.sleep(10) (status, get_3times_un_iplist) = commands.getstatusoutput(get_3times_un_iplist_str) print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) if status != 0 and get_3times_un_iplist not in unreache_3times: unreache_3times.append(get_3times_un_iplist) print("{} times,unreache_3times {}".format(j+1,unreache_3times[i])) print(unreache_3times) pass def do_reboot(self,count=0): global do_reboot_cmd do_reboot_cmd="ipmitool -I lanplus -H {} -U UserNmae -P PassWord chassis power status" for i in range(len(unreache_3times)): count = count + 1 #print(count) if count <= 2: print("do_reboot_ip:{},\n do_reboot_cmd:{}".format(unreache_3times[i],do_reboot_cmd.format(unreache_3times[i].replace('172.','10.')))) #print("do_reboot_ip", unreache_3times[i])if __name__ == '__main__': ip_list = sys.argv[1] ds=server_unreache(ip_list) ds.unreachable_ip_list() ds.do_3times_fping_unreachable() ds.do_reboot()
服务器
服务
第一次
时间
UTF-8
数以千计
状态
检查
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
四川电视墙服务器怎么安装
杭州定制化国产服务器
应用数据库技术的场景有哪些
程序化期货软件开发
服务器可以用来跑游戏吗
sql数据库表格量
软件开发征求意见函
最终幻想15服务器视频
关闭服务器后可以发邮件吗
美团众包怎么开通服务器
网络安全属于c语言
超星期刊论文数据库怎么样
软件开发工程师就业
迪普防火墙日志服务器配置
am服务器卡
软件开发驻场承诺
网络安全工作清单
工业手机网络技术
客户担心网络安全问题
网络安全宣传ppt课件英文
小学网络安全我有责微课
如何开发一个数据库管理工具
雷卡点歌系统数据库
杭州移动软件开发平台
浏览记录 数据库
部队网络安全保密图片
国家网络安全与信息化
网络安全总结1000
网络安全工作清单
手机捕鱼服务器架设
- 上一篇
IntelliJ IDEA创建Maven项目速度慢怎么办
这篇文章给大家分享的是有关IntelliJ IDEA创建Maven项目速度慢怎么办的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。IntelliJ IDEA 创建maven项
- 下一篇
如何在tc上安装buildkit.tcz、vscode.tcz、打通vscodeonline与openfaas模拟cloudbase打造碎片化编程开发部署环境
这篇文章将为大家详细讲解有关如何在tc上安装buildkit.tcz、vscode.tcz、打通vscodeonline与openfaas模拟cloudbase打造碎片化编程开发部署环境,小编觉得挺实