Beberapa waktu yang lalu, kami membahas cara menemukan waktu aktif sistem Linux menggunakan Tuptime utilitas di Linux. Hari ini, kita akan mempelajari tentang utilitas serupa bernama Uptimed . Ini adalah utilitas baris perintah yang digunakan untuk merekam dan melacak waktu sistem Linux. Menggunakan Uptimed, kita dapat dengan mudah menampilkan ringkasan catatan uptime historis, seperti berapa lama sistem Linux Anda telah menyala, berapa uptime tertinggi, kapan sistem telah di-boot ulang, dll. Dalam panduan singkat ini, mari kita lihat cara memantau Uptime sistem Linux menggunakan utilitas Uptimed.
Instal Uptimed Di Linux
Uptimed tersedia di repositori resmi sistem operasi Linux populer.
Untuk menginstal Uptimed di Linux Arch , cukup jalankan:
$ sudo pacman -S uptimed
Di Debian , Ubuntu , Linux Mint :
$ sudo apt-get install uptimed
Harap dicatat bahwa di Ubuntu dan turunannya, pastikan diaktifkan [universe] penyimpanan.
$ sudo add-apt-repository universe
Di Fedora :
$ sudo dnf install uptimed
Di CentOS 7 :
Uptimed tidak tersedia di repositori default CentOS. Jadi, Anda perlu mengaktifkan repositori EPEL untuk menginstalnya.
Aktifkan repositori EPEL:
$ sudo yum install epel-release
Dan kemudian instal Uptimed menggunakan perintah:
$ sudo yum install uptimed
Pada sistem Linux lainnya, unduh Uptimed dari laman rilis lalu kompilasi dan instal secara manual.
# wget https://github.com/rpodgorny/uptimed/archive/v0.4.2.zip -O uptimed.zip
# unzip uptimed.zip
# cd uptimed-0.4.2/
# ./configure
# make
# make install
Setelah menginstal Uptimed, aktifkan dan mulai layanan uptimed:
# systemctl enable uptimed
# systemctl start uptimed
Periksa status layanan uptime:
# systemctl status uptimed ● uptimed.service - Uptime record tracking daemon Loaded: loaded (/usr/lib/systemd/system/uptimed.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2020-02-11 14:21:12 IST; 1s ago Docs: man:uptimed(8) man:uprecords(1) Main PID: 1435 (uptimed) Status: "Next milestone (five days) at Sun Feb 16 14:13:59 2020" CGroup: /system.slice/uptimed.service └─1435 /usr/sbin/uptimed -f Feb 11 14:21:12 server.ostechnix.local systemd[1]: Starting Uptime record tracking daemon... Feb 11 14:21:12 server.ostechnix.local systemd[1]: Started Uptime record tracking daemon.
Memantau Uptime Sistem Linux Menggunakan Uptimed
Untuk memantau waktu aktif sistem Linux antara reboot sistem, cukup jalankan:
# uprecords
Contoh keluaran:
# Uptime | System Boot up ----------------------------+--------------------------------------------------- 1 0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el Tue Feb 11 14:22:33 2020 2 0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el Tue Feb 11 14:13:59 2020 -> 3 0 days, 00:02:11 | Linux 3.10.0-1062.1.1.el Tue Feb 11 17:02:29 2020 ----------------------------+--------------------------------------------------- 1up in 0 days, 00:05:17 | at Tue Feb 11 17:09:56 2020 no1 in 0 days, 02:33:41 | at Tue Feb 11 19:38:20 2020 up 0 days, 02:45:29 | since Tue Feb 11 14:13:59 2020 down 0 days, 00:05:12 | since Tue Feb 11 14:13:59 2020 %up 96.953 | since Tue Feb 11 14:13:59 2020
Di sini, tanda panah di kolom pertama menunjukkan waktu aktif terbaru.
Urutkan hasil berdasarkan waktu boot
Untuk menampilkan waktu aktif sistem Linux Anda yang diurutkan berdasarkan waktu boot, gunakan -b bendera:
# uprecords -b # Uptime | System Boot up ----------------------------+--------------------------------------------------- 1 0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el Tue Feb 11 14:13:59 2020 2 0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el Tue Feb 11 14:22:33 2020 -> 3 0 days, 00:30:14 | Linux 3.10.0-1062.1.1.el Tue Feb 11 17:02:29 2020
Demikian pula, untuk membalikkan pengurutan berdasarkan waktu boot (yaitu hanya menampilkan reboot terbaru), gunakan -B bendera:
# uprecords -B # Uptime | System Boot up ----------------------------+--------------------------------------------------- -> 1 0 days, 00:14:51 | Linux 3.10.0-1062.1.1.el Tue Feb 11 17:02:29 2020 2 0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el Tue Feb 11 14:22:33 2020 3 0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el Tue Feb 11 14:13:59 2020
Menampilkan X jumlah waktu aktif
Saat menjalankan perintah uprecords tanpa opsi apa pun, ini akan menampilkan ringkasan 10 catatan uptime historis teratas secara default. Namun, Anda dapat mengubahnya menggunakan -m bendera. Misalnya, perintah berikut akan menampilkan 20 record teratas:
# uprecords -m 20
Jangan potong keluaran
Seperti yang Anda perhatikan pada output di atas, informasi versi kernel Linux di sistem kolom telah terpotong (yaitu Linux 3.10.0-1062.1.1.el). Jika Anda tidak ingin memotong informasi, gunakan -w bendera (keluaran lebar).
# uprecords -w # Uptime | System Boot up ----------------------------+--------------------------------------------------- 1 0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el7.x86_64 Tue Feb 11 14:22:33 2020 -> 2 0 days, 00:16:35 | Linux 3.10.0-1062.1.1.el7.x86_64 Tue Feb 11 17:02:29 2020 3 0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el7.x86_64 Tue Feb 11 14:13:59 2020 ----------------------------+--------------------------------------------------- no1 in 0 days, 02:19:17 | at Tue Feb 11 19:38:21 2020 up 0 days, 02:59:53 | since Tue Feb 11 14:13:59 2020 down 0 days, 00:05:12 | since Tue Feb 11 14:13:59 2020 %up 97.190 | since Tue Feb 11 14:13:59 2020
Waktu henti tampilan
Anda juga dapat menampilkan waktu henti antara reboot alih-alih versi kernel menggunakan -d tandai seperti di bawah ini:
# uprecords -d # Uptime | Last downtime Boot up ----------------------------+--------------------------------------------------- 1 0 days, 02:35:51 | 0 days, 00:01:07 Tue Feb 11 14:22:33 2020 -> 2 0 days, 00:13:02 | 0 days, 00:04:05 Tue Feb 11 17:02:29 2020 3 0 days, 00:07:27 | 0 days, 00:00:00 Tue Feb 11 14:13:59 2020 ----------------------------+--------------------------------------------------- no1 in 0 days, 02:22:50 | at Tue Feb 11 19:38:21 2020 up 0 days, 02:56:20 | since Tue Feb 11 14:13:59 2020 down 0 days, 00:05:12 | since Tue Feb 11 14:13:59 2020 %up 97.136 | since Tue Feb 11 14:13:59 2020
Uprecords memiliki beberapa opsi lagi. Untuk menampilkan semua opsi dengan deskripsi, jalankan:
# uprecords -? usage: uprecords [OPTION]... -? this help -a do not print ansi codes -b sort by boottime -B reverse sort by boottime -k sort by sysinfo -K reverse sort by sysinfo -d print downtime seen before every uptimes instead of system -c do not show current entry if not in top entries -f run continously in a loop -s do not print extra statistics -w wide output (more than 80 cols per line) -i INTERVAL use INTERVAL seconds for loop instead of 5, implies -f -m COUNT show a maximum of top COUNT entries instead of 10 -M show next milestone -v version information
Untuk detail lebih lanjut, lihat halaman manual.
$ man uprecords