对站点进行 ping 操作是检查站点是否已关闭的好方法吗?

发布于 2024-10-09 03:48:38 字数 129 浏览 11 评论 0原文

我正在尝试编写一个小型网站监控程序,它可以检查我的网络主机以查看它们是否已关闭,并计算正常运行时间或在其关闭时警告我。它将是一个独立的应用程序。

我想知道 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

假装爱人 2024-10-16 03:48:39

这是您可以做的一件事,但无论如何都不是确定的。

有些站点会忽略 ICMP 数据包,因此不会给出 ping 响应。即使 Web 服务器(或您需要的任何服务)关闭,某些站点也会响应 ping。

您可以确定给定站点将提供服务的唯一方法是使用该服务。没有什么比这更准确的了。

更好的方法是提供一系列步骤来检测故障所在,至少在您可以控制的基础设施中。例如:

  • 允许接收 ping 并对其采取行动。
  • Web 服务器中有一个静态网页。
  • 在应用程序服务器中有一个提供静态内容的动态页面。
  • 在使用数据库的应用程序服务器中有一个动态页面。

然后,您的测试客户只需尝试“联系”这四个点并报告成功情况。由于您希望您的网站大部分时间都能正常运行,因此我只检查第四个选项以查看是否一切正常,只有在发现问题时才进行其他检查。

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:

  • allow pings to be received and acted upon.
  • have a static web page in the web server.
  • have a dynamic page in the application server which delivers static content.
  • have a dynamic page in the application server which uses the database.

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.

木落 2024-10-16 03:48:39

这取决于您如何定义 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/

惟欲睡 2024-10-16 03:48:39

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/

离线来电— 2024-10-16 03:48:39

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文