如何记录 Linux 的系统运行时间的统计信息

Vivek Gite 的头像

·

·

·

6,568 次阅读

Linux/Unix 系统管理员对服务器的系统运行时间有一种奇怪的痴迷。这里有一个关于这个主题的 xkcd 漫画,一个好的系统管理员是一股不可阻挡的力量,他伫立在你家猫咪博客的服务器之前,对抗黑暗势力。

Fig.01: Devotion to Duty https://xkcd.com/705/

我们可以使用 uptime 命令或 w 命令top 命令来判断 Linux 系统运行了多久。我可以使用 tuptime 工具保留每次重新启动的运行时间,以获得系统运行时间的历史和统计报告

这就像 uptime 命令一样,但输出结果更令人印象深刻。最近我发现了另一种称为 uptimed 的工具,用于记录关于机器的系统运行时间和统计信息。让我们看看如何使用 Linux 操作系统上的 uptimeduprecords 来获得运行时间的记录统计信息。

查找系统运行时间非常简单,只需在基于 Linux 的系统上键入以下命令即可:

$ uptime -p
up 2 weeks, 4 days, 7 hours, 28 minutes

要保留有关 uptime 的历史统计信息,请使用 tuptimeuptimed 工具。

安装 uptimed

安装 uptimed 的最简单的方式是通过你的软件包管理器,比如 apt/apt-get/yum 这些你的 Linux 发行版的朋友。

在 Debian/Ubuntu Linux 上安装 uptimed

键入以下 apt 命令/apt-get 命令

$ sudo apt-get install uptimed

示例输出:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libuptimed0
The following NEW packages will be installed:
  libuptimed0 uptimed
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 40.7 kB of archives.
After this operation, 228 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.linode.com/ubuntu xenial/universe amd64 libuptimed0 amd64 1:0.3.17-4 [9,050 B]
Get:2 http://mirrors.linode.com/ubuntu xenial/universe amd64 uptimed amd64 1:0.3.17-4 [31.6 kB]
Fetched 40.7 kB in 0s (2,738 kB/s)  
Preconfiguring packages ...
Selecting previously unselected package libuptimed0.
(Reading database ... 39163 files and directories currently installed.)
Preparing to unpack .../libuptimed0_1%3a0.3.17-4_amd64.deb ...
Unpacking libuptimed0 (1:0.3.17-4) ...
Selecting previously unselected package uptimed.
Preparing to unpack .../uptimed_1%3a0.3.17-4_amd64.deb ...
Unpacking uptimed (1:0.3.17-4) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libuptimed0 (1:0.3.17-4) ...
Setting up uptimed (1:0.3.17-4) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...

在 CentOS/RHEL/Fedora/Oracle/Scientific Linux 上安装 uptimed

首先 在 CentOS/RHEL 使用 EPEL 仓库

$ sudo yum -y install epel-release

然后,键入以下 yum 命令

$ sudo yum install uptimed

示例输出:


Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: ftp.cuhk.edu.hk
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check

via: <https://www.cyberciti.biz/hardware/see-records-statistics-about-a-linux-servers-uptime/>

作者:[Vivek Gite](https://www.cyberciti.biz) 译者:[MjSeven](https://github.com/MjSeven) 校对:[wxy](https://github.com/wxy)

本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注