对站点进行 ping 操作是检查站点是否已关闭的好方法吗?
我正在尝试编写一个小型网站监控程序,它可以检查我的网络主机以查看它们是否已关闭,并计算正常运行时间或在其关闭时警告我。它将是一个独立的应用程序。
我想知道 ping 是否是查明站点是否已关闭的好方法?
提前致谢。
I'm trying to write a small website monitoring program, that can check my web hosts to see whether they are down or not, and to calculate the uptime or warn me if it's down. It's going to be a standalone app.
I wanted to know whether pinging is a good way of finding out whether a site is down or not?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是您可以做的一件事,但无论如何都不是确定的。
有些站点会忽略 ICMP 数据包,因此不会给出 ping 响应。即使 Web 服务器(或您需要的任何服务)关闭,某些站点也会响应 ping。
您可以确定给定站点将提供服务的唯一方法是使用该服务。没有什么比这更准确的了。
更好的方法是提供一系列步骤来检测故障所在,至少在您可以控制的基础设施中。例如:
然后,您的测试客户只需尝试“联系”这四个点并报告成功情况。由于您希望您的网站大部分时间都能正常运行,因此我只检查第四个选项以查看是否一切正常,只有在发现问题时才进行其他检查。
That's one thing that you can do but it's by no means a certainty either way.
Some sites will ignore ICMP packets so that no ping response is given. Some sites will respond to pings even when the web server (or whatever service you're after) is down.
The only way you can be certain that a given site will provide a service is to, well, use that service. Nothing else will be as accurate.
A better method would be to provide a series of steps which would detect where a fault lay, at least in the infrastructure that you can control. For example:
Then your tester client would simply attempt to "contact" those four points and report on the success. Since you would expect your site to be up most of the time, I'd just check the fourth option to see if everything was okay, and do the other checks only if a problem were found.
这取决于您如何定义 ping。如果您谈论的是“低级别”ICMP 回显,那么它不太可能很好地指示您的网站是否已关闭。您最好实际让应用程序从您的站点拉取页面以确保 HTTP 服务器正在运行。有很多这方面的服务,您也可以从谷歌下载一些代码。 http:// www.dailyblogtips.com/test-if-a-website-is-down-for-everyone-or-just-for-your/
It depends on how you define ping. If you're talking about the "low level" ICMP echo, then no it isn't likely to be a good indicator of whether or not your site is down. You would be better off to actually have an application pull a page down from your site to ensure that the HTTP server is running. There are plenty of services for this and likely some code you could download from google as well. http://www.dailyblogtips.com/test-if-a-website-is-down-for-everyone-or-just-for-your/
ICMP可以证明服务器还活着。
TCP 检查可以显示 Web 服务器正在运行,但不能显示站点正在运行。
要执行站点检查,您应该执行 http GET 请求(即使 HEAD 有时不起作用)以确保页面正常。(返回状态 200)
您可以编写自己的检查系统或使用一些第三方站点,例如 http://allping.net/
ICMP can prove the server is alive.
TCP checking can show the web server is working, but not the site.
To perform site checking, you should do http GET request(even HEAD doesn't work sometimes) to make sure the page was fine.(return status 200)
You can write your own checking system or use some third party site like http://allping.net/
ping 可让您深入了解特定位置的延迟情况,并指出可能的网络问题(数据包丢失)。正如之前的回答所述,某些服务器不响应 ping 请求,在这种情况下 ping 是无用的。
要检查来自全球 50 多个地点的 ping 服务器,请查看此免费工具:http://just-ping.com /
ping gives you insight in latency from a specific location and also points to possible network issues (packet loss). As said in a previous answer, some servers don't respond to ping requests in which case ping is useless.
To check a server with ping from over 50 locations worldwide have a look at this free tool: http://just-ping.com/