测量服务器正常运行时间 [英] Measuring server uptime

查看:109
本文介绍了测量服务器正常运行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个游戏服务器列表,我想衡量某些服务器的正常运行时间(具体来说,正常运行时间应该以百分比显示)。



我为我的脚本配置了一个cronjob,如果服务器启动或关闭,每5分钟检查一次,所以我可以轻松获得服务器状态。

我需要一个想法,如何根据上述数据测量每个服务器的正常运行时间。

解决方案

如果你不知道该怎么做,关心许多细节,你只是想要的上下时间。然后你可以在一个文件中保存2个数字,一个是当前百分比,另一个是脚本采取的当前测量数。



例如:'96 800'



然后,无论何时执行脚本,使用此公式,假设百分比(96)为X,保存数为Y(800) measure是Z(0或1)

  X = X / 100; 
X =(X * Y + Z)/(Y + 1); //你得到百分比的新值,X.注意,因为他们需要是长的值。
Y = Y + 1; //和当前的互动次数。
X = X * 100;

这当然只是伪代码,不会立即工作,它只是给你一个想法的一种方式做到。



如Jamie所说,这是假设crontime是一个文件,仍然工作,尽管服务器已经关闭。



PS,您还可以从其他服务器添加系统以检查此服务器正常运行时间,但需要统计计算并且当添加许多其他服务器时错误趋向于0,但是这太难了),因为您需要考虑其他服务器的正常运行时间...


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?

解决方案

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...

这篇关于测量服务器正常运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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