自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何記錄Linux的系統(tǒng)運行時間的統(tǒng)計信息

系統(tǒng) Linux 系統(tǒng)運維
Linux/Unix 系統(tǒng)管理員對服務(wù)器的系統(tǒng)運行時間有一種奇怪的癡迷。這里有一個關(guān)于這個主題的 xkcd 漫畫,一個好的系統(tǒng)管理員是一股不可阻擋的力量,他佇立在你家貓咪博客的服務(wù)器之前,對抗黑暗勢力。

[[225165]]

Linux/Unix 系統(tǒng)管理員對服務(wù)器的系統(tǒng)運行時間有一種奇怪的癡迷。這里有一個關(guān)于這個主題的 xkcd 漫畫,一個好的系統(tǒng)管理員是一股不可阻擋的力量,他佇立在你家貓咪博客的服務(wù)器之前,對抗黑暗勢力。

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

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

我們可以使用 uptime 命令或 w 命令top 命令來判斷 Linux 系統(tǒng)運行了多久。我可以使用 tuptime 工具保留每次重新啟動的運行時間,以獲得系統(tǒng)運行時間的歷史和統(tǒng)計報告

這就像 uptime 命令一樣,但輸出結(jié)果更令人印象深刻。最近我發(fā)現(xiàn)了另一種稱為 uptimed 的工具,用于記錄關(guān)于機器的系統(tǒng)運行時間和統(tǒng)計信息。讓我們看看如何使用 Linux 操作系統(tǒng)上的 uptimeduprecords 來獲得運行時間的記錄統(tǒng)計信息。

查找系統(tǒng)運行時間非常簡單,只需在基于 Linux 的系統(tǒng)上鍵入以下命令即可:

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

要保留有關(guān) uptime 的歷史統(tǒng)計信息,請使用 tuptimeuptimed 工具。

 

安裝 uptimed

安裝 uptimed 的最簡單的方式是通過你的軟件包管理器,比如 apt/apt-get/yum 這些你的 Linux 發(fā)行版的朋友。

 

在 Debian/Ubuntu Linux 上安裝 uptimed

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

  1. $ sudo apt-get install uptimed

示例輸出:

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

 

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

首先 在 CentOS/RHEL 使用 EPEL 倉庫

  1. $ sudo yum -y install epel-release

然后,鍵入以下 yum 命令

  1. $ sudo yum install uptimed

示例輸出:

  1. Loaded plugins: fastestmirror
  2. Loading mirror speeds from cached hostfile
  3. * base: centos.excellmedia.net
  4. * epel: ftp.cuhk.edu.hk
  5. * extras: centos.excellmedia.net
  6. * updates: centos.excellmedia.net
  7. Resolving Dependencies
  8. --> Running transaction check
  9. ---> Package uptimed.x86_64 0:0.4.0-6.el7 will be installed
  10. --> Finished Dependency Resolution
  11.  
  12. Dependencies Resolved
  13.  
  14. ===============================================================================
  15. Package Arch Version Repository Size
  16. ===============================================================================
  17. Installing:
  18. uptimed x86_64 0.4.0-6.el7 epel 47 k
  19.  
  20. Transaction Summary
  21. ===============================================================================
  22. Install 1 Package
  23.  
  24. Total download size: 47 k
  25. Installed size: 98 k
  26. Is this ok [y/d/N]: y
  27. Downloading packages:
  28. uptimed-0.4.0-6.el7.x86_64.rpm | 47 kB 00:01
  29. Running transaction check
  30. Running transaction test
  31. Transaction test succeeded
  32. Running transaction
  33. Installing : uptimed-0.4.0-6.el7.x86_64 1/1
  34. Verifying : uptimed-0.4.0-6.el7.x86_64 1/1
  35.  
  36. Installed:
  37. uptimed.x86_64 0:0.4.0-6.el7
  38.  
  39. Complete!

如果你正在使用 Fedora Linux,運行以下 dnf 命令:

  1. $ sudo dnf install uptimed

 

在 Arch Linux 上安裝 uptimed

鍵入以下 pacman 命令:

  1. $ sudo pacman -S uptimed

 

在 Gentoo Linux 上安裝 uptimed

鍵入以下 emerge 命令:

  1. $ sudo emerge --ask uptimed

 

如何配置 uptimed

使用文本編輯器編輯 /etc/uptimed.conf 文件,例如 vim 命令:

  1. $ sudo vim /etc/uptimed.conf

最少設(shè)置一個 email 地址來發(fā)送記錄。假定有個兼容 sendmail 的 MTA 安裝在 /usr/lib/sendmail。

  1. EMAIL=vivek@server1.cyberciti.biz

保存并關(guān)閉文件。

 

如何在系統(tǒng)啟動時啟動 uptimed 服務(wù)?

使用 systemctl 命令啟動 uptimed 服務(wù):

  1. $ sudo systemctl enable uptimed

 

我該如何 啟動/停止/重啟 或者查看 uptimed 服務(wù)的狀態(tài)?

  1. $ sudo systemctl start uptimed ## start it ##
  2. $ sudo systemctl stop uptimed ## stop it ##
  3. $ sudo systemctl restart uptimed ## restart it ##
  4. $ sudo systemctl status uptimed ## view status ##

示例輸出:

  1. uptimed.service - uptime record daemon
  2. Loaded: loaded (/lib/systemd/system/uptimed.service; enabled; vendor preset: enabled)
  3. Active: active (running) since Thu 2017-11-09 17:49:14 UTC; 18min ago
  4. Main PID: 11137 (uptimed)
  5. CGroup: /system.slice/uptimed.service
  6. └─11137 /usr/sbin/uptimed -f
  7.  
  8. Nov 09 17:49:14 gfs04 systemd[1]: Started uptime record daemon.

 

如何查看 uptime 記錄

只需鍵入以下命令即可查看 uptimed(8) 程序的統(tǒng)計信息:

  1. $ uprecords

示例輸出:

Fig.02: uprecords in action

Fig.02: uprecords in action

uprecords 有一些選項:

  1. $ uprecords -?

示例輸出:

  1. usage: uprecords [OPTION]...
  2.  
  3. -? this help
  4. -a do not print ansi codes
  5. -b sort by boottime
  6. -B reverse sort by boottime
  7. -k sort by sysinfo
  8. -K reverse sort by sysinfo
  9. -d print downtime seen before every uptimes instead of system
  10. -c do not show current entry if not in top entries
  11. -f run continously in a loop
  12. -s do not print extra statistics
  13. -w wide output (more than 80 cols per line)
  14. -i INTERVAL use INTERVAL seconds for loop instead of 5, implies -f
  15. -m COUNT show a maximum of top COUNT entries instead of 10
  16. -M show next milestone
  17. -v version information

 

結(jié)論

這是一個極好的小工具,可以顯示服務(wù)器正常運行時間的記錄,以證明機器正常運行時間和你的業(yè)務(wù)連續(xù)性。在相關(guān)說明中,你可以看到官方的 XKCD 系統(tǒng)管理員 T恤 因為漫畫被制作成襯衫,其中包括背面的新插圖。

[[225166]]

Fig.03: Sysadmin XKCD shirt features the original comic on the front and a new illustration on the back. 

責(zé)任編輯:龐桂玉 來源: Linux中國
相關(guān)推薦

2020-04-06 11:47:44

Linux命令腳本

2022-11-04 09:09:54

Linux服務(wù)器

2021-05-10 07:30:07

Linux統(tǒng)計程序

2021-08-11 11:02:17

Linuxtime命令

2021-05-11 11:52:23

Linuxtime命令

2021-08-18 08:32:09

代碼運行時間示波器

2019-10-14 09:14:37

Linuxbash命令

2021-06-24 10:28:19

uptimed命令Linux

2016-08-23 10:17:42

2022-10-08 00:00:00

V8channel對象

2019-01-15 14:00:59

Linux服務(wù)器命令

2022-01-19 08:50:53

設(shè)備樹Linux文件系統(tǒng)

2018-06-24 15:23:05

軟件工程環(huán)境開發(fā)

2015-07-20 15:44:46

Swift框架MJExtension反射

2020-12-07 13:31:43

GoMutex開發(fā)者

2017-01-19 20:28:44

2015-09-09 10:10:35

運行時改變圖標(biāo)

2010-01-27 14:14:48

C++程序運行時間

2024-03-28 08:17:46

JestJS服務(wù)端

2024-03-21 09:15:58

JS運行的JavaScrip
點贊
收藏

51CTO技術(shù)棧公眾號