重新启动时间后检查服务器 [英] Check servers after its re-boot time
本文介绍了重新启动时间后检查服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含30个服务器的列表,其中包含在excel文件中的预定重新启动时间。我只想检查服务器是否在使用vb脚本重新启动计划后启动,并在检查每个服务器后将状态邮寄给我。
I have a list of 30 servers with its scheduled re-boot time in an excel file. I just want to check whether the servers are up after its scheduled re-boot using vb script and mail me the status after checking each server.
推荐答案
添加一列到您的脚本是否包含每个服务器的tcp / ip地址并且可能执行ping操作?
这样的事情会让你开始使用ping位本身 - 做一个google for 'vbscript smtp mail'我相信你会发现很多代码可以给自己发电子邮件
Add a column to your script with the tcp/ip address of each server and do a ping perhaps ?
Something like this will get you started on the ping bit itself - do a google for 'vbscript smtp mail' and Im sure you'll find plenty of code for emailing yourself
'==========================================================================
' The following function will test if a machine is reachable via a ping
' using WMI and the Win32_PingStatus Class
'==========================================================================
If Reachable("10.50.138.48") Then
WScript.Echo "Computer is Reachable!"
Else
WScript.Echo "Computer is Unreachable!"
End If
Function Reachable(strComputer)
' On Error Resume Next
Dim wmiQuery, objWMIService, objPing, objStatus
wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputer & "'"
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objPing = objWMIService.ExecQuery(wmiQuery)
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then
Reachable = False 'if computer is unreacable, return false
Else
Reachable = True 'if computer is reachable, return true
End If
Next
End Function
参考:
http://www.visualbasicscript.com/Ping-WMI-amp-NonWMI-Versions-Functions-amp-Simple-Connectivity-Monitor-m42535.aspx [ ^ ]
这篇关于重新启动时间后检查服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文