服务器正常运行脚本

发布于 2024-10-25 20:59:32 字数 77 浏览 0 评论 0原文

我正在尝试为我的网站做一些事情,具体来说,我正在尝试为正常运行时间编写一个脚本。

我有阅读器,一个从表格中读取百分比的脚本。

I'm trying to do something for my website, to be specific, I'm trying to do a script for uptime.

I have the reader, a script which read the percents from a table.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

就此别过 2024-11-01 20:59:32

这不是使用关系数据库的非常有效的方法。相反,我建议(至少在 SQL 方面)如下:

CREATE TABLE `servers` (
  `srv_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  -- Additional Fields Omitted here.
  PRIMARY KEY (`srv_id`)
)
ENGINE = InnoDB;
CREATE TABLE `stats` (
  `stat_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `srv_id` INTEGER UNSIGNED NOT NULL,
  `date` TIMESTAMP NOT NULL,
  `uptime` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`stat_id`)
)
ENGINE = InnoDB;

通过这种方式,您可以针对任意数量的服务器记录任意数量的度量,然后使用 SQL 删除旧内容或保留旧内容旧内容并使用 WHERE 参数来过滤显示这些统计信息的界面中使用的数据。

This is not a very efficient way to use a Relational Database. I would, instead, suggest (at least with the SQL side), the following:

CREATE TABLE `servers` (
  `srv_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  -- Additional Fields Omitted here.
  PRIMARY KEY (`srv_id`)
)
ENGINE = InnoDB;
CREATE TABLE `stats` (
  `stat_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `srv_id` INTEGER UNSIGNED NOT NULL,
  `date` TIMESTAMP NOT NULL,
  `uptime` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`stat_id`)
)
ENGINE = InnoDB;

This way you can record as many measures as you like, against as many servers as you like, and then use SQL to either delete old content or keep the old content and use WHERE arguments to filter the data used in the interface displaying these stats.

街角卖回忆 2024-11-01 20:59:32
        $day = int(strftime("%j") % 5);
        $key = 'day' . $day;
        if($row[$key] == 0)
        {
            if($checkls && $checkgs) //if server is online update the percent
                mysql_query("UPDATE s_stats SET ${key}=".($stats_row[$key] + 0.5)." WHERE srv_id=".$r[id]." ")  or die(mysql_error()); //every 7.2 minutes add 0.5 percent
            else echo "error day $day";
        }
        $day = int(strftime("%j") % 5);
        $key = 'day' . $day;
        if($row[$key] == 0)
        {
            if($checkls && $checkgs) //if server is online update the percent
                mysql_query("UPDATE s_stats SET ${key}=".($stats_row[$key] + 0.5)." WHERE srv_id=".$r[id]." ")  or die(mysql_error()); //every 7.2 minutes add 0.5 percent
            else echo "error day $day";
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文