0

ホスト名の入力を求めるスクリプトを作成しようとしています。これから、またはを介してDNSからIPアドレス222012-DC01を解決するとします。pingnslookup

次に、 IP アドレスを変更して、そのサイトのルーターに ping を送信する必要があります。IP アドレスがだった場合は、そのサイトのルーターに対して10.123.2.1ping を実行する必要があります。10.123.1.1

スクリプトは、server offlineまたはrouter offlineの出力を提供するはずです。

数百のサイトを管理する環境で作業し、サーバーの所有権は取得しますが、ルーター障害などのネットワーク インシデントは取得しません。

あなたの助けは大歓迎です...

4

1 に答える 1

1

将来的には、あなたが得て試したことを投稿してください。ここにテスト済みのスクリプトがあります

function get_ip(strTarget)
  set objShell = CreateObject("WScript.Shell")
  set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
  strPingResults = LCase(objExec.StdOut.ReadAll)
  get_ip = ""
  if InStr(strPingResults, "reply from") then
    wscript.echo VbCrLf & strTarget & " responded to ping."
    set regEx = New RegExp
    regEx.Pattern = "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
    set matches = regEx.Execute(strPingResults)
    if matches.count > 0 then
      get_ip = matches(0)
    end if
  else
    wscript.echo vbCrLf & strTarget & " did not respond to ping."
    wscript.quit 1
  end If
end function

function is_online(strTarget)
  set objShell = CreateObject("WScript.Shell")
  set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
  strPingResults = LCase(objExec.StdOut.ReadAll)
  if inStr(strPingResults, "reply from") then
    is_online = true
  else
    is_online = false
  end If
end function

pcname = inputbox( "Give the pc-name to ping:")
ip = get_ip(pcname)
wscript.echo "ip of pc " & pcname & " is " & ip
aIp = split(ip, ".")
aIp(2) = 1
router = join(aIp, ".")
wscript.echo "pinging " & router
if is_online(strTarget) then
  wscript.echo "router is online"
else
  wscript.echo "router is offline"
end if
于 2012-07-27T14:02:16.660 に答える