Nel nostro ultimo articolo, abbiamo appreso come installare e aggiornare il pacchetto sysstat e comprendere brevemente le utilità fornite con il pacchetto.
Oggi lavoreremo con alcuni interessanti esempi pratici di utilità mpstat , pidstat , iostat e sar , che possono aiutarci a identificare i problemi. Abbiamo diverse opzioni per utilizzare queste utilità, voglio dire che puoi lanciare i comandi manualmente con diverse opzioni per diversi tipi di lavoro o puoi creare i tuoi script personalizzati in base alle tue esigenze. Sai che gli amministratori di sistema sono sempre un po’ pigri e hanno sempre cercato di trovare il modo più semplice per fare le cose con il minimo sforzo.
mpstat – Statistiche dei processori
1. Utilizzando il comando mpstat senza alcuna opzione, verranno visualizzate le attività medie globali di tutte le CPU.
tecmint@tecmint ~ $ mpstat Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU) 12:23:57 CPU IST %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 12:23:57 IST tutti 37,35 0,01 4,72 2,96 0,00 0,07 0,00 0,00 0,00 54,88
2. Utilizzando mpstat con l’opzione ‘ -P ‘ (Indicate Processor Number) e ‘ALL’, verranno visualizzate le statistiche su tutte le CPU una per una a partire da 0. 0 sarà la prima.
tecmint@tecmint ~ $ mpstat -P ALL Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU) 12:29:26 CPU IST %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 12:29:26 IST tutti 37,33 0,01 4,57 2,58 0,00 0,07 0,00 0,00 0,00 55,44 12:29:26 IST 0 37,90 0,01 4,96 2,62 0,00 0,03 0,00 0,00 0,00 54,48 12:29:26 IST 1 36,75 0,01 4,19 2,54 0,00 0,11 0,00 0,00 0,00 56,40
3. Per visualizzare le statistiche per N numero di iterazioni dopo n secondi di intervallo con la media di ciascuna CPU utilizzare il seguente comando.
tecmint@tecmint ~ $ mpstat -P ALL 2 5 Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU) 12:36:21 CPU IST %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 12:36:23 IST tutti 53,38 0,00 2,26 0,00 0,00 0,00 0,00 0,00 0,00 44,36 12:36:23 IST 0 46,23 0,00 1,51 0,00 0,00 0,00 0,00 0,00 0,00 52,26 12:36:23 IST 1 60,80 0,00 3,02 0,00 0,00 0,00 0,00 0,00 0,00 36,18 12:36:23 CPU IST %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 12:36:25 IST tutti 34,18 0,00 2,30 0,00 0,00 0,00 0,00 0,00 0,00 63,52 12:36:25 IST 0 31,63 0,00 1,53 0,00 0,00 0,00 0,00 0,00 0,00 66,84 12:36:25 IST 1 36,73 0,00 2,55 0,00 0,00 0,00 0,00 0,00 0,00 60,71 12:36:25 CPU IST %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 12:36:27 IST tutti 33,42 0,00 5,06 0,25 0,00 0,25 0,00 0,00 0,00 61,01 12:36:27 IST 0 34,34 0,00 4,04 0,00 0,00 0,00 0,00 0,00 0,00 61,62 12:36:27 IST 1 32,82 0,00 6,15 0,51 0,00 0,00 0,00 0,00 0,00 60,51
4. L’opzione ‘ I ‘ stamperà il numero totale di statistiche di interrupt per processore.
tecmint@tecmint ~ $ mpstat -I Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU) 12:39:56 IST CPU intr/s 12:39:56 IST tutti 651.04 12:39:56 CPU IST 0/s 1/s 6/s 8/s 9/s 12/s 16/s 17/s 20/s 21/s 22/s 23/s 45/s 46/s 47 /s NMI/s LOC/s SPU/s PMI/s IWI/s RTR/s RES/s CAL/s TLB/s TRM/s THR/s MCE/s MCP/s ERR/s MIS/s 12:39:56 IST 0 76,27 1,73 0,00 0,00 0,42 0,33 0,00 0,06 11,46 0,00 0,00 0,01 7,62 1,87 0,05 0,33 182,26 0,00 0,33 3,03 0,00 22,66 0,16 5,14 0,00 0,00 0,00 0,00 0,00 0,00 12:39:56 IST 1 70,88 1,44 0,00 0,00 0,41 0,33 0,00 27,91 10,33 0,00 0,00 0,01 7,27 1,79 0,05 0,32 184,11 0,00 0,32 5,17 0,00 22,09 0,13 4,73 0,00 0,00 0,00 0,00 0,00 0,00 0,00 12:39:56 IST CPU HI/s TIMER/s NET_TX/s NET_RX/s BLOCK/s BLOCK_IOPOLL/s TASKLET/s SCHED/s HTIMER/s RCU/s 12:39:56 IST 0 0,00 116,49 0,05 0,27 7,33 0,00 1,22 10,44 0,13 37,47 12:39:56 IST 1 0,00 111,65 0,05 0,41 7,07 0,00 56,36 9,97 0,13 41,38
5. Ottieni tutte le informazioni di cui sopra in un comando, equivalente a ” -u -I ALL -p ALL “.
tecmint@tecmint ~ $ mpstat -A Linux 3.11.0-23-generic (tecmint.com) giovedì 04 settembre 2014 _i686_ (2 CPU) 12:41:39 CPU IST %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 12:41:39 IST tutti 38,70 0,01 4,47 2,01 0,00 0,06 0,00 0,00 0,00 54,76 12:41:39 IST 0 39,15 0,01 4,82 2,05 0,00 0,02 0,00 0,00 0,00 53,95 12:41:39 IST 1 38,24 0,01 4,12 1,98 0,00 0,09 0,00 0,00 0,00 55,57 12:41:39 IST CPU intr/s 12:41:39 IST tutti 651.73 12:41:39 IST 0 173.16 12:41:39 IST 1 225.89 12:41:39 CPU IST 0/s 1/s 6/s 8/s 9/s 12/s 16/s 17/s 20/s 21/s 22/s 23/s 45/s 46/s 47 /s NMI/s LOC/s SPU/s PMI/s IWI/s RTR/s RES/s CAL/s TLB/s TRM/s THR/s MCE/s MCP/s ERR/s MIS/s 12:41:39 IST 0 76,04 1,77 0,00 0,00 0,41 0,36 0,00 0,06 11,60 0,00 0,00 0,01 7,42 1,83 0,05 0,34 182,89 0,00 0,34 2,97 0,00 22,69 0,16 5,22 0,00 0,00 0,00 0,00 0,00 0,00 12:41:39 IST 1 70,70 1,48 0,00 0,00 0,40 0,36 0,00 27,47 10,46 0,00 0,00 0,01 7,08 1,75 0,05 0,32 184,83 0,00 0,32 5,10 0,00 22,19 0,13 4,91 0,00 0,00 0,00 0,00 0,00 0,00 12:41:39 IST CPU HI/s TIMER/s NET_TX/s NET_RX/s BLOCK/s BLOCK_IOPOLL/s TASKLET/s SCHED/s HTIMER/s RCU/s 12:41:39 IST 0 0,00 116,96 0,05 0,26 7,12 0,00 1,24 10,42 0,12 36,99 12:41:39 IST 1 0,00 112,25 0,05 0,40 6,88 0,00 55,05 9,93 0,13 41,20