如何筛选PING不通的机器并自动发送提醒邮件?
dos吧
全部回复
仅看楼主
level 1
qsck 楼主

机房里有N台机器,为保证机器一直正常运行,在网内一台闲置服务器上拟做一计划任务,每十分钟PING一次所有机器,一旦某一台机器PING不通,则发送提醒邮件到我的手机邮箱。
下面是PING.bat的内容:
@echo off
rem ip.bat Createdby noname
time/t >=%date:~2,8%-%time:~0,2%%time:~3,2%%time:~6,2%.txt
for /f "eol=;" %%f in (IP.txt) do (
ping -n 1 %%f >>%date:~2,8%-%time:~0,2%%time:~3,2%%time:~6,2%.txt
echo/>>%date:~2,8%-%time:~0,2%%time:~3,2%%time:~6,2%.txt
)
得到的结果如下:
23:32
Pinging 192.168.1.102 with 32 bytes of data: Reply from 192.168.1.102: bytes=32 time<1ms TTL=64 Ping statistics for 192.168.1.102: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
Pinging 192.168.1.103 with 32 bytes of data: Reply from 192.168.1.103: bytes=32 time<1ms TTL=64 Ping statistics for 192.168.1.103: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
实际如果所有机器都PING通的话,不需要保存,只有在有机器PING不通的时候保存,并且只保存PING不通的结果,并且以“ping192.168.1.102不通”为主题发送邮件。
谢谢各位大侠
最好不要使用第三方程序,比如NC.exe

2012年06月01日 15点06分 1
level 1
qsck 楼主
没有人可以帮我吗?应该不是很复杂的那种吧?
2012年06月02日 04点06分 2
level 7
MARK下
2012年06月07日 05点06分 3
1