GNU/Linux >> Belajar Linux >  >> Ubuntu

Cara Menginstal Logwatch di Ubuntu 20.04

Logwatch adalah penganalisis log sistem dan mengirim laporan itu ke email. Ini menghasilkan laporan log yang diringkas yang berisi sshd - kegagalan otentikasi, sudo - sesi dibuka, kegagalan vsftp, postfix, login gagal, ruang disk dan banyak lagi.

Logwatch juga dapat mencetak laporan di konsol. Laporan ini dapat dijadwalkan untuk dijalankan pada tanggal dan waktu tertentu menggunakan cron.

Dalam tutorial ini kita mempelajari cara menginstal Logwatch di Ubuntu 20.04 .

Menginstal Logwatch di Ubuntu

Logwatch dapat diinstal hanya dari repositori Ubuntu. Perbarui sistem terlebih dahulu.

$ sudo apt-get update

Untuk menginstal Logwatch, ketik:

$ apt-get install logwatch

Buat direktori sementara agar logwatch berfungsi:

$ sudo mkdir /var/cache/logwatch

Perintah Logwatch

Perintah logwatch menampilkan laporan di konsol.

$ logwatch

Anda juga dapat menggunakan opsi dengan perintah Logwatch untuk memfilter laporan:

$ logwatch --detail high --range yesterday --service vsftpd --service postfix --service zz-disk_space --format text

Keluaran:

################### Logwatch 7.5.2 (07/22/19) ####################
         Processing Initiated: Sat Jul 10 11:13:03 2021
         Date Range Processed: today
                               ( 2021-Jul-10 )
                               Period is day.
         Detail Level of Output: 10
         Type of Output/Format: stdout / text
         Logfiles for Host: li673-49
  ##################################################################
 --------------------- Postfix Begin ------------------------
  Summary ***
 62.872K  Bytes accepted                              64,381
    62.872K  Bytes delivered                             64,381
  ========   ==================================================
     1   Accepted                                   100.00%
 --------   --------------------------------------------------
         1   Total                                      100.00%
  ========   ==================================================
     1   Removed from queue                               1     1   Delivered                                        1
  Detail (1) 
     1   Delivered -------------------------------------------------------------------------------     1      node49.server.com
 === Delivery Delays Percentiles ============================================================
                      0%       25%       50%       75%       90%       95%       98%      100%
 
 Before qmgr      56.00     56.00     56.00     56.00     56.00     56.00     56.00     56.00
  In qmgr           0.01      0.01      0.01      0.01      0.01      0.01      0.01      0.01
  Conn setup        0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
  Transmission      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
  Total            56.00     56.00     56.00     56.00     56.00     56.00     56.00     56.00
  ============================================================================================
 ---------------------- Postfix End -------------------------
 --------------------- vsftpd-messages Begin ------------------------
 Failed FTP Logins:
      (::ffff:66.249.64.177): anonymous - 2 Time(s)
      (::ffff:66.249.64.179): anonymous - 1 Time(s)
 ---------------------- vsftpd-messages End -------------------------
 --------------------- Disk Space Begin ------------------------
 Filesystem      Size  Used Avail Use% Mounted on
  /dev/sda        157G   16G  134G  11% /
  /dev/loop0       56M   56M     0 100% /snap/core18/2066
  /dev/loop1       56M   56M     0 100% /snap/core18/2074
  /dev/loop2       70M   70M     0 100% /snap/lxd/19188
  /dev/loop3       33M   33M     0 100% /snap/snapd/12159
  /dev/loop4       68M   68M     0 100% /snap/lxd/20326
  /dev/loop5       33M   33M     0 100% /snap/snapd/12398
 ---------------------- Disk Space End -------------------------
 ###################### Logwatch End #########################

Sesuaikan Logwatch

File konfigurasi logwatch disimpan di /usr/share/logwatch/default.conf/logwatch.conf. Untuk kemudahan mengedit, salin logwatch.conf ke /etc/logwatch/conf/.

$ sudo cp /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/

Kustomisasi dasar adalah:

   Output = file|mail|stdout
   MailTo = [email protected]
   MailFrom = [email protected]
   Detail = Low, Med, High, or a number
   Service = All
   Service = service-name
   Range = Yesterday|Today|All
   Format = text|html

Keluaran - Tentukan ke mana harus mengirim laporan logwatch

MailTo - Tentukan alamat email untuk mengirim laporan. Untuk beberapa penerima, gunakan alamat email yang dipisahkan dengan spasi.

Rincian - Ini menentukan verbositas untuk laporan.

Layanan - Menentukan satu atau lebih layanan untuk diurai oleh logwatch. Semua layanan terdaftar di bawah /usr/share/logwatch/scripts/services. Untuk memilih layanan tertentu, beri komentar Service =All dan gunakan Service =service-name.

Rentang - Tentukan durasi waktu laporan.

Format - Laporan dapat berupa teks atau format html.

Jadwalkan Logwatch

Menggunakan cron, Anda dapat menjadwalkan logwatch untuk berjalan pada waktu dan tanggal tertentu.

Buka file crontab:

# crontab -e

Tambahkan tugas cron berikut untuk menjadwalkan logwatch agar berjalan setiap hari pada pukul 8 pagi:

0 8 * * * /sbin/logwatch

Kesimpulan

Dalam tutorial ini kami belajar cara menginstal Logwatch di Ubuntu 20.04. Untuk informasi lebih lanjut, periksa man logwatch.


Ubuntu
  1. Cara Menginstal Odoo di Ubuntu

  2. Cara menginstal R di Ubuntu 16.04

  3. Cara Menginstal Go di Ubuntu 18.04

  1. Cara Menginstal Maven di Ubuntu

  2. Cara Menginstal Anggur di Ubuntu

  3. Cara Menginstal Ruby di Ubuntu 20.04

  1. Cara Menginstal Putty di Ubuntu

  2. Cara Menginstal Ruby di Ubuntu 18.04

  3. Cara Menginstal Pip di Ubuntu 18.04