Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Thousands of server survival status checks

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

#! / usr/bin/python#-*-coding: UTF-8-*-import commandsimport sysimport timeclass server_unreache (object): def _ _ init__ (self Ip_list): self.ip_list = ip_list# gets the list of servers that cannot be ping for the first time def unreachable_ip_list (self): global unreachable_iplist_one_time unreachable_iplist_one_time= [] get_un_iplist_str = "/ sbin/fping-u-f {}" .fo rmat (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# to get the list of servers that cannot ping for the first time Performing 3 ping operations The interval between each operation is 10 seconds 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 (unreache3times [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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report