如何检查服务器状态 [英] how to check server status

查看:213
本文介绍了如何检查服务器状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试制作页面以自动检查服务器是否启动/关闭.
我是在vb中制作的,但是该页面需要很长时间才能加载.如果有人可以帮助我并告诉我如何使用JavaScript或其他任何可以自动且快速检查它的方式.
谢谢.
我的vb代码在这里.

Hello , I am trying to make page to automatically check if the servers are up/down.
I made it in vb but the page takes a long time to load. If anyone would help me and tell me how to do it in JavaScript or any other way that will check it automatically and faster.
thanks.
my vb code here.

Dim ping0 As New Ping
lblServer0.Text="MyDEVServer1021"
       Try
           Dim pingreply = ping0.Send(lblServer0.Text, 2000)
           If pingreply.Status = IPStatus.Success Then
               imgServer0.ImageUrl = ("~/Images/green_light.png")
           Else
               imgServer0.ImageUrl = ("~/Images/red_light.png")
           End If
       Catch ex As Exception
           imgServer0.ImageUrl = ("~/Images/red_light.png")
       End Try
lblServer1.Text="MyDEVServer10232"
       Dim ping As New Ping
       Try
           Dim pingreply = ping.Send(lblServer1.Text, 2000)
           If pingreply.Status = IPStatus.Success Then
               imgServer1.ImageUrl = ("~/Images/green_light.png")
           Else
               imgServer1.ImageUrl = ("~/Images/red_light.png")
           End If
       Catch ex As Exception
           imgServer1.ImageUrl = ("~/Images/red_light.png")
       End Try

推荐答案

1)如何将代码从服务器移到客户端以使其更快?
2)客户端可以看到您要ping的服务器吗?如果不能,则客户端脚本不是您的解决方案.
3)ping可能不是查找服务器状态的最佳方法.使用的过程将由您要尝试的访问类型定义.
-Web服务:应该具有您可以点击的心跳或isAlive接口,如果存在,则将仅返回true.否则,您的通话将失败.一个简单的try-catch即可实现.
-DB:只需尝试连接...

我为Web Apps和服务器运行状况提供的个人解决方案通常包括运行状况检查页面,该页面可查询关键系统路径并以简洁明了的方式报告所有这些系统的状态.
1) How will moving the code from server to client make it quicker?
2) Can the client see the server you want to ping? If it can''t, then client-side script is not your solution.
3) A ping is perhaps not the best way to look for a server''s state. The process to use is going to be defined by the type of access you are going to attempt.
- Web Service: Should have a heartbeat or isAlive interface that you can hit which will simply return true if it exists. Your call will fail if it doesn''t. A simple try-catch will achive this.
- DB: Just try and connect...

My personal solution for Web Apps and server health usually consists of a healthcheck page which queries critical system paths and reports the status of all these systems back in a clear, concise manner.


这篇关于如何检查服务器状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆