0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

複数台に死活監視 ping for Windows

Posted at

複数台の古い Windows PC をサーバーとして使っているので、時々死活監視をする必要がありました。
コマンドプロンプトから ping を打てばよいのですが、コマンドを作成してみました。
ファイルサーバー上でも使えるように、ファイル名前の先頭は「%~dp0」を付けています。

HealthChk.cmd
@echo off
rem ===============
rem  状態確認ツール
rem ===============

echo ### Health checker ###
echo.

for /f "tokens=1,2 delims=," %%i in (%~dp0pc.list) do (
  ping -n 1 %%i | find "ms TTL=" >NUL 2>&1
  if ERRORLEVEL 1 (
    echo   %%j	%%i	[--NG--]
  ) else (
    echo   %%j	%%i	[  OK  ]
  )
)
echo.
pause
pc.list
; [Windows PC]
192.168.0.11,PC#1
192.168.0.12,PC#2
192.168.0.99,PC#3

実行結果はこんな感じ。

### Health checker ###
  PC#1        192.168.0.11    [  OK  ]
  PC#2        192.168.0.12    [  OK  ]
  PC#3        192.168.0.99    [--NG--]

続行するには何かキーを押してください . . .

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?