服务器间 存活状态,数以千计的服务器存活状态检查

简介这篇文章主要介绍了数以千计的服务器存活状态检查以及相关的经验技巧,文章约2153字,浏览量371,点赞数4,值得参考!

# !/usr/bin/python

# -*- coding: UTF-8 -*-

import commands

import sys

import time

class 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(‘

‘):

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:{},

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()

以上就是本文的全部内容,希望对大家的学习有所帮助,本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Power BI 是一种强大的商业智能工具,用于数据可视化和分析。要学习 Power BI,你可以按照以下步骤进行: 1. **了解基础**: - 熟悉 Microsoft Office 365 或者 Power BI Desktop 的基本界面和工作流。 - 学习Power BI的核心概念,如数据源、数据模型(包括数据准备和转换)、报表和仪表板的创建。 2. **官方资源**: - 访问 Power BI 的官方文档 <https://docs.microsoft.com/power-bi>,这里有详细的教程、视频和技术参考。 - 注册 Power BI 服务(Power BI Desktop 或者 Power BI Service),可以免费获得许多学习资料和示例。 3. **在线课程**: - 在 Microsoft Learn 或者 Coursera、Udemy 上找到 Power BI 课程,如 Power BI Certification Training。 - YouTube 上有许多教学频道提供免费教程。 4. **实践项目**: - 使用Power BI Desktop 尝试处理真实数据集,通过创建自己的报告和仪表板来熟悉工具。 - 在 Power BI Service 中搭建数据门户,分享你的工作。 5. **社区交流**: - 加入 Power BI 社区,例如 Power BI Ideas、Power BI User Group (PBUG) 或者 Stack Overflow,提问并参与讨论。 6. **认证考试**: - 如果你想进一步提升职业发展,考虑参加 Power BI 认证考试,如 Microsoft Certified: Power BI Data Professional 或 Developer。 相关问题-- 1. Power BI Desktop 与 Power BI Service 有什么区别? 2. 在Power BI中如何连接不同的数据源? 3. 如何优化 Power BI 报表性能? 4. 如何在 Power BI 中创建交互式仪表板?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值