GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Installa e usa lo strumento di monitoraggio delle prestazioni di collectl su Ubuntu 18.04 LTS

Il monitoraggio delle risorse di sistema e l'analisi delle prestazioni è un compito importante di qualsiasi amministratore di sistema. Esistono molti strumenti disponibili per Linux per monitorare le prestazioni del sistema, inclusi top, htop, free, ecc. Collectl è uno strumento di monitoraggio delle prestazioni gratuito, open source e leggero che può essere utilizzato per raccogliere informazioni sulle risorse di sistema come CPU, disco, memoria, rete, Infiniband, lustro, memoria, nfs, lastre e molti altri. A differenza di altri strumenti di monitoraggio, collectl si concentra su un piccolo insieme di statistiche. Collectl è in grado di monitorare diversi parametri contemporaneamente e di segnalarli in modo adeguato. Collectl viene fornito con una serie di opzioni che ti aiutano a identificare qualsiasi tipo di problema di prestazioni del sistema. Usando collectl, puoi generare lo stesso output di mpstat, netstat, nfsstat, sar, ps, top e iostat.

Caratteristiche

  • Possibilità di visualizzare l'output in molti formati.
  • Esportare i dati in vari formati di file.
  • Possibilità di essere eseguito come servizio per monitorare le macchine remote.
  • Monitoraggio di quasi tutti i sottosistemi.

In questo tutorial impareremo come installare e utilizzare Collectl sul server Ubuntu 18.04.

Requisiti

  • Un server che esegue Ubuntu 18.04.
  • È stata impostata una password di root sul tuo server.

Per iniziare

Prima di iniziare, dovrai aggiornare il tuo sistema con l'ultima versione. Puoi farlo eseguendo il seguente comando:

apt-get update -y
apt-get upgrade -y

Una volta aggiornato il server, riavvia il server per applicare le modifiche.

Installa Collectl

Per impostazione predefinita, Collectl è disponibile nel repository predefinito di Ubuntu 18.04. Puoi installarlo eseguendo il seguente comando:

apt-get install collectl -y

Una volta completata l'installazione, puoi eseguire il seguente comando per elencare tutte le opzioni disponibili con collectl:

collectl --h

Dovresti vedere il seguente output:

This is a subset of the most common switches and even the descriptions are
abbreviated.  To see all type 'collectl -x', to get started just type 'collectl'

usage: collectl [switches]
  -c, --count      count      collect this number of samples and exit
  -f, --filename   file       name of directory/file to write to
  -i, --interval   int        collection interval in seconds [default=1]
  -o, --options    options    misc formatting options, --showoptions for all
                                d|D - include date in output
                                  T - include time in output
                                  z - turn off compression of plot files
  -p, --playback   file       playback results from 'file' (be sure to quote
			      if wild carded) or the shell might mess it up
  -P, --plot                  generate output in 'plot' format
  -s, --subsys     subsys     specify one or more subsystems [default=cdn]
      --verbose               display output in verbose format (automatically
                              selected when brief doesn't make sense)

Various types of help
  -h, --help                  print this text
  -v, --version               print version
  -V, --showdefs              print operational defaults
  -x, --helpextend            extended help, more details descriptions too
  -X, --helpall               shows all help concatenated together

  --showoptions               show all the options
  --showsubsys                show all the subsystems
  --showsubopts               show all subsystem specific options
  --showtopopts               show --top options

  --showheader                show file header that 'would be' generated
  --showcolheaders            show column headers that 'would be' generated
  --showslabaliases           for SLUB allocator, show non-root aliases
  --showrootslabs             same as --showslabaliases but use 'root' names

Copyright 2003-2016 Hewlett-Packard Development Company, L.P.
collectl may be copied only under the terms of either the Artistic License
or the GNU General Public License, which may be found in the source kit

Lavorare con Collectl

Ora, esegui il collectl senza alcuna opzione visualizzerà informazioni su CPU, disco e statistiche di rete in un formato molto breve e leggibile dall'uomo.

collectl

Dovresti vedere il seguente output:

waiting for 1 second sample...
#<--------cpu--------><----------disks-----------><----------network---------->
#cpu sys inter  ctxsw KBRead  Reads KBWrit Writes   KBIn  PktIn  KBOut  PktOut 
  17  11   503    320      4      1     20      3      0      0      0       0 
   2   1   565    165      0      0      0      0      0      2      0       2 
   6   3   545     83      0      0      0      0      0      2      0       2 
   0   0   508     39      0      0      0      0      0      2      0       2 
   1   1   517     42      0      0      0      0      0      2      0       2 
   1   1   442     37      0      0      0      0      0      2      0       2 
   1   1   538     65      0      0     20      2      0      2      0       2 
   1   1   443     39      0      0      0      0      0      2      0       2 
   1   1   409     39      0      0      0      0      0      2      0       2 
   1   1   381     38      0      0      0      0      0      2      0       2 
   1   1   451     44      0      0      0      0      0      2      0       2 
   3   2   482     42      0      0      0      0      0      2      0       2 
   9   2   528    101      0      0      0      0      0      2      0       2 
   1   1   428     39      0      0      0      0      0      2      0       2 

Puoi anche elencare le statistiche per tutti i sottosistemi con il seguente comando:

collectl --all

Uscita:

waiting for 1 second sample...
#<--------cpu--------><-----------------memory-----------------><----------disks-----------><----------network----------><-------tcp--------><------sockets-----><----files---><------nfs totals------="">
#cpu sys inter  ctxsw Cpu0 Free Buff Cach Inac Slab  Map   Fragments KBRead  Reads KBWrit Writes   KBIn  PktIn  KBOut  PktOut   IP  Tcp  Udp Icmp  Tcp  Udp  Raw Frag Handle Inodes  Reads Writes Meta Comm 
   3   0   459     48  459 139M  63M 573M 413M  93M 136M jibaa4a59ab      0      0      0      0      0      0      0       0    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
  12   7   528    142  530 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      1       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   3   1   477     57  477 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   5   2   437     55  435 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   1   0   426     43  426 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   4   1   435     54  435 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   4   2   471     49  472 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44712      0      0    0    0 

Puoi anche usare il comando collectl con l'opzione --top come mostrato di seguito:

collectl --top

Uscita:

# TOP PROCESSES sorted by time (counters are /sec) 14:14:24
# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command
 5194  root     20  1233    0 R   66M   27M  0  0.06  0.13  19  00:02.79    0    0    0    0 /usr/bin/perl 
    8  root     20     2    0 I     0     0  0  0.01  0.00   1  00:01.86    0    0    0    0 rcu_sched 
 1165  root     20   866    0 S  103M    7M  0  0.01  0.00   1  00:05.00    0    0    0    0 sshd: 
 3593  root     20     2    0 I     0     0  0  0.01  0.00   1  00:01.45    0    0    0    0 kworker/0:0 
    1  root     20     0    0 S   76M    9M  0  0.00  0.00   0  00:10.28    0    0    0    0 /sbin/init 
    2  root     20     0    0 S     0     0  0  0.00  0.00   0  00:00.02    0    0    0    0 kthreadd 
    4  root      0     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kworker/0:0H 
    6  root      0     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 mm_percpu_wq 
    7  root     20     2    0 S     0     0  0  0.00  0.00   0  00:02.75    0    0    0    0 ksoftirqd/0 
    9  root     20     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 rcu_bh 
   10  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 migration/0 
   11  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.03    0    0    0    0 watchdog/0 
   12  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 cpuhp/0 
   13  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kdevtmpfs 
   14  root      0     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 netns 
   15  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 rcu_tasks_kthre 
   16  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kauditd 

Monitoraggio CPU, memoria e utilizzo del disco

Puoi monitorare l'utilizzo della CPU eseguendo l'opzione collectl con -sc:

collectl -sc

Uscita:

waiting for 1 second sample...
#<--------cpu-------->
#cpu sys inter  ctxsw 
   1   1   461     35 
   2   2   631     71 
  11   0   472    109 
   1   1   552     48 
   1   1   457     39 
   0   0   566     46 
   5   3   572    101 
   0   0   543     38 
   1   1   445     40 
   1   1   591     43 
   1   1   441     36 
   0   0   565     51 

Puoi anche visualizzare informazioni dettagliate sull'utilizzo della CPU con il seguente comando:

collectl -sC

Uscita:

waiting for 1 second sample...

# SINGLE CPU STATISTICS
#   Cpu  User Nice  Sys Wait IRQ  Soft Steal Guest NiceG Idle
      0     2    0    3    0    0    0     0     0     0   94
      0     0    0    1    0    0    0     0     0     0   98
      0     0    0    1    0    0    0     0     0     0   98
      0     0    0    0    0    0    1     0     0     0   98
      0     0    0    0    0    0    0     0     0     0  100
      0     0    0    0    0    0    0     0     0     0  100
      0     1    0    1    0    0    0     0     0     0   97
      0     0    0    0    0    0    0     0     0     0  100
      0     0    0    1    1    0    1     0     0     0   96
      0     0    0    0    0    0    0     0     0     0  100
      0     0    0    1    0    0    0     0     0     0   98

Per monitorare l'utilizzo della memoria del tuo sistema, esegui il comando seguente:

collectl -sm

Uscita:

waiting for 1 second sample...
#<-----------memory----------->
#Free Buff Cach Inac Slab  Map 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 

Monitora l'utilizzo della memoria con informazioni dettagliate con il seguente comando:

collectl -sM

Uscita:

waiting for 1 second sample...

# MEMORY STATISTICS 
# Node    Total     Used     Free     Slab   Mapped     Anon    AnonH   Locked    Inact HitPct
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866968K  142676K   95928K   46160K   93416K        0    5408K  423952K 100.00

Puoi monitorare l'utilizzo del disco con il seguente comando:

collectl -sd

Uscita:

waiting for 1 second sample...
#<----------disks----------->
#KBRead  Reads KBWrit Writes 
      0      0      0      0 
      0      0      0      0 
      0      0      0      0 
      0      0      0      0 
      0      0      0      0 
      0      0      8      0 
      0      0      0      2

Monitora l'utilizzo del disco con informazioni dettagliate con il seguente comando:

collectl -sD

Uscita:

waiting for 1 second sample...

# DISK STATISTICS (/sec)
#          <---------reads---------------><---------writes--------------><--------averages--------> Pct
#Name       KBytes Merged  IOs Size  Wait  KBytes Merged  IOs Size  Wait  RWSize  QLen  Wait SvcTim Util
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0      20      1    1   20     0      20     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0

Monitoraggio CPU, memoria e disco alla volta

Puoi monitorare l'utilizzo di CPU, memoria e disco eseguendo il singolo comando:

collectl -scmd

Uscita:

waiting for 1 second sample...
#<--------cpu--------><-----------memory-----------><----------disks----------->
#cpu sys inter  ctxsw Free Buff Cach Inac Slab  Map KBRead  Reads KBWrit Writes 
   1   0   518     43 140M  63M 573M 413M  93M 135M      0      0      0      0 
   7   2   509    104 140M  63M 573M 413M  93M 135M      0      0     20      1 
   3   1   518     52 140M  63M 573M 413M  93M 135M      0      0      0      0 
   1   1   445     43 140M  63M 573M 413M  93M 135M      0      0      0      0 
   2   1   482     51 140M  63M 573M 413M  93M 135M      0      0      0      0 
   1   1   535     56 140M  63M 573M 413M  93M 135M      0      0      0      0 
   3   1   499     48 140M  63M 573M 413M  93M 135M      0      0      0      0 
   2   1   482     53 140M  63M 573M 413M  93M 135M      0      0     20      2 

Conclusione

Nell'articolo di cui sopra, ho fornito una breve panoramica di collectl. Collectl include molte opzioni che semplificano il monitoraggio del tuo sistema Linux.


Ubuntu
  1. Come installare lo strumento di monitoraggio Zabbix su Ubuntu 18.04 LTS

  2. Come installare e utilizzare iostat su Ubuntu 16.04 LTS

  3. Come installare e utilizzare sosreport su Ubuntu 18.04 LTS

  4. Come installare e utilizzare Telnet su Ubuntu 20.04 LTS

  5. Installa e usa Linuxbrew sul sistema Linux Ubuntu 20.04 LTS

Come installare e utilizzare Wireshark su Ubuntu 20.04 LTS

Come installare e utilizzare lo strumento Screenshot dell'otturatore in Ubuntu 20.04

Come installare e utilizzare R su Ubuntu

Come installare e utilizzare Jenkins su Ubuntu 18.04 e 16.04 LTS

3 modi per installare e utilizzare HandBrake Ubuntu 22.04 | 20.04 LTS

Come installare e utilizzare lo strumento di monitoraggio delle risorse Bpytop su Ubuntu 20.04