doujuegai8830 2012-03-31 22:30
浏览 21
已采纳

测量服务器正常运行时

I'm creating an game server list, and I want to measure uptime for certain server (to be specific, uptime should be displayed in percents).

I have configured a cronjob for my script, which is checking every 5 minutes if server is up or down, so I can easly get the server status.

I need an idea on how can I measure each server uptime basing on the above data. I'd have to save down and up time for each server every one minute the script is executing?

  • 写回答

5条回答 默认 最新

  • douyun6781 2012-03-31 22:46
    关注

    If you don't care about many details and you just want the up and down time. Then you could save 2 numbers in a file, one being the current percentage and the other being the current number of measures the script took.

    For example: '96 800'.

    Then, whenever the script is executed, use this formula, assuming that the percentage (96) is X, the number of saves is Y (800) and the current measure is Z (0 or 1)

    X=X/100;
    X=(X*Y+Z)/(Y+1);  //You get the new value of the percentage, X. Be careful as they need to be long values.
    Y=Y+1;    //And the current number of interactions.
    X=X*100;
    

    That's of course just pseudo code and won't work straight away, it's just to give you an idea of one way to do it. You must also include a way of reading a file and saving it wherever you want of your page that contains those 2 numbers.

    As Jamie stated, this is assuming that crontime is still working despite of the server is down.

    PS, you could also add a system from other server to check this server uptime, but it would need to be statistically calculated (and error tends to 0 when many other servers are added, but that'd be too difficult) as you'd need to take into account the other server's uptime also...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c