Linux: Outils de monitoring/performances : Différence entre versions
(Page créée avec « = Processeur = == Top == Outil de base, top donne les performances globales, ou par coeur. Commandes intéressantes: * 1 : bascule stats globales / par coeur. Options... ») |
m |
||
| (14 révisions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
| − | = Processeur = | + | = Processeur/mémoire = |
| − | == | + | |
| + | ==ps== | ||
| + | Outil de base, permet de choisir ce qu'on veut afficher, par exemple: | ||
| + | $ ps -e -o pid,euid,egid,cmd:50,pcpu,size,vsz,share |grep firefox | grep -v grep | ||
| + | PID EUID EGID CMD %CPU SIZE VSZ - | ||
| + | ... | ||
| + | 20881 1000 1000 /opt/firefox/firefox 3.7 8445232 9673364 - | ||
| + | 21053 1000 1000 /opt/firefox/firefox -contentproc -childID 2 -isFo 0.1 1317140 2099840 - | ||
| + | == top == | ||
Outil de base, top donne les performances globales, ou par coeur. | Outil de base, top donne les performances globales, ou par coeur. | ||
Commandes intéressantes: | Commandes intéressantes: | ||
* 1 : bascule stats globales / par coeur. | * 1 : bascule stats globales / par coeur. | ||
Options intéressantes: | Options intéressantes: | ||
| − | * -b -n 1 : cliché one-shot de tous les process. | + | * -b -n 1 : cliché one-shot de tous les process. |
| − | = | + | |
| − | == | + | == Htop (EPEL) == |
| − | iftop donne des stats sur une ou toutes les interfaces: | + | Similaire à top, un peu plus visuel et permet de scroller verticalement et horizontalement, fonctionnalités moindres par rapport à top. |
| − | + | ||
| + | ==sar== | ||
| + | $ sar -u 5 12 -P ALL | ||
| + | Linux 3.10.0-693.17.1.el7.x86_64 (lxhpi3.home) 04/02/2018 _x86_64_ (4 CPU) | ||
| + | 16:30:38 CPU %user %nice %system %iowait %steal %idle | ||
| + | 16:30:43 all 2,59 0,00 1,59 0,10 0,00 95,72 | ||
| + | 16:30:43 0 2,80 0,00 1,20 0,40 0,00 95,60 | ||
| + | ... | ||
| + | |||
| + | == vmstat == | ||
| + | $ vmstat 5 | ||
| + | procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- | ||
| + | r b swpd free buff cache si so bi bo in cs us sy id wa st | ||
| + | 0 0 571632 4139764 34136 1516080 6 19 133 132 145 73 18 3 78 0 0 | ||
| + | 0 0 571632 4128056 34136 1515892 0 0 0 6 1639 3965 5 4 91 0 0 | ||
| + | 0 0 571632 4128480 34136 1515892 0 0 0 0 1585 4053 4 4 92 0 0 | ||
| + | |||
| + | $ vmstat -s | ||
| + | 7878340 K total memory | ||
| + | 2077860 K used memory | ||
| + | 1620968 K active memory | ||
| + | 1311044 K inactive memory | ||
| + | 4240392 K free memory | ||
| + | 34136 K buffer memory | ||
| + | 1525952 K swap cache | ||
| + | 4194300 K total swap | ||
| + | 571632 K used swap | ||
| + | 3622668 K free swap | ||
| + | 2763391 non-nice user cpu ticks | ||
| + | 7250 nice user cpu ticks | ||
| + | 487031 system cpu ticks | ||
| + | 11934229 idle cpu ticks | ||
| + | 52051 IO-wait cpu ticks | ||
| + | 0 IRQ cpu ticks | ||
| + | 22577 softirq cpu ticks | ||
| + | 0 stolen cpu ticks | ||
| + | 20341703 pages paged in | ||
| + | 20236535 pages paged out | ||
| + | 230526 pages swapped in | ||
| + | 719893 pages swapped out | ||
| + | 150777683 interrupts | ||
| + | 354066009 CPU context switches | ||
| + | 1528470595 boot time | ||
| + | 366342 forks | ||
| + | |||
| + | = Entrées/Sorties (réseau, disque...) = | ||
| + | == iotop == | ||
| + | Mesure l'activité disque par process. Peut fonctionner comme top soit en continu à l'écran soit en mode batch (pour sauver dans un fichier). | ||
| + | Exemple (affichage seulement des process ayant de l'activité disque): | ||
| + | Total DISK READ : 3.79 K/s | Total DISK WRITE : 352.81 K/s | ||
| + | Actual DISK READ: 3.79 K/s | Actual DISK WRITE: 7.59 K/s | ||
| + | TID PRIO USER DISK READ DISK WRITE SWAPIN IO COMMAND | ||
| + | 20914 be/4 toine 3.79 K/s 15.17 K/s 0.00 % 0.71 % firefox [Cache2 I/O] | ||
| + | 1008 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.01 % X :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for-gdm-qmCecJ/database -seat seat0 -nolisten tcp vt1 | ||
| + | 4296 be/4 toine 0.00 B/s 15.17 K/s 0.00 % 0.00 % kdeinit4: konsole [kdeinit] | ||
| + | 21001 be/4 toine 0.00 B/s 307.29 K/s 0.00 % 0.00 % firefox [mozStorage #1] | ||
| + | 21009 be/4 toine 0.00 B/s 15.17 K/s 0.00 % 0.00 % firefox [DOM Worker] | ||
| + | |||
| + | == iftop == | ||
| + | iftop donne des stats de débit par destination sur une ou toutes les interfaces: | ||
| + | $ sudo iftop -i ens0 | ||
| + | # Host name (port/service if enabled) last 2s last 10s last 40s cumulative | ||
| + | -------------------------------------------------------------------------------------------- | ||
| + | 1 lxhpi3.home => 14,6Kb 4,13Kb 2,90Kb 5,79KB | ||
| + | imap.free.fr <= 725Kb 146Kb 91,8Kb 184KB | ||
| + | 2 lxhpi3.home => 0b 4,10Kb 2,56Kb 5,12KB | ||
| + | 2400:cb00:2048:1::6810:2802 <= 0b 66,3Kb 41,4Kb 82,9KB | ||
| + | 3 lxhpi3.home => 22,5Kb 9,02Kb 5,63Kb 11,3KB | ||
| + | server-13-32-153-141.cdg54.r.cloudfront <= 189Kb 46,2Kb 28,9Kb 57,7KB | ||
| + | |||
| + | == nstat / rtacct == | ||
| + | nstat, rtacct - network statistics tools (package iproute). | ||
| + | nstat [ -h?vVzrnasd:t: ] [ PATTERN [ PATTERN ] ] | ||
| + | rtacct [ -h?vVzrnasd:t: ] [ ListOfRealms ] | ||
| + | |||
| + | == iostat== | ||
| + | Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions. | ||
| + | $ iostat | ||
| + | Linux 3.10.0-693.17.1.el7.x86_64 (lxhpi3.home) 04/02/2018 _x86_64_ (4 CPU) | ||
| + | avg-cpu: %user %nice %system %iowait %steal %idle | ||
| + | 5,61 0,03 1,89 0,42 0,00 92,04 | ||
| + | Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn | ||
| + | sda 2,74 53,83 43,67 4889756 3967316 | ||
| + | dm-0 3,13 4,65 7,91 421992 718364 | ||
| + | dm-1 0,00 0,02 0,00 2120 0 | ||
| + | |||
| + | $ iostat -x sda | ||
| + | Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util | ||
| + | sda 1,03 1,81 1,54 1,20 53,76 43,63 71,09 0,08 28,14 10,27 51,04 2,79 0,76 | ||
| + | |||
| + | ==sar== | ||
| + | Collect, report, or save system activity information. Appliqué aux interfaces réseau | ||
| + | $ sar -u 5 1 -n DEV | ||
| + | Linux 3.10.0-693.17.1.el7.x86_64 (lxhpi3.home) 04/02/2018 _x86_64_ (4 CPU) | ||
| + | 16:34:49 CPU %user %nice %system %iowait %steal %idle | ||
| + | 16:34:54 all 5,61 0,00 2,73 0,25 0,00 91,41 | ||
| + | # | ||
| + | 16:34:49 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s | ||
| + | 16:34:54 wlp0s26u1u4 487,20 265,40 612,56 27,85 0,00 0,00 0,00 | ||
| + | # | ||
| + | 16:34:49 IFACE rxerr/s txerr/s coll/s rxdrop/s txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s | ||
| + | 16:34:54 wlp0s26u1u4 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 | ||
| + | |||
| + | == tracer les messages reseau sur un PID avec strace== | ||
| + | Par exemple, avec l'option -f pour suivre la trace sur les process fils du process en trace: | ||
| + | $ strace -v -f -e trace=network -p 4300 | ||
| + | strace: Process 4300 attached | ||
| + | socket(AF_NETLINK, SOCK_RAW, NETLINK_AUDIT) = 3 | ||
| + | sendmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(2)=[{"\35\0\0\0d\4\1\0\0\0\0\0\0\0\0\0", 16}, {"ping 8.8.8.8\0", 13}], msg_controllen=0, msg_flags=0}, 0) = 29 | ||
| + | strace: Process 23396 attached | ||
| + | [pid 23396] socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) = -1 EACCES (Permission denied) | ||
| + | [pid 23396] socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) = 3 | ||
| + | [pid 23396] socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 4 | ||
| + | [pid 23396] connect(4, {sa_family=AF_INET, sin_port=htons(1025), sin_addr=inet_addr("8.8.8.8")}, 16) = 0 | ||
| + | [pid 23396] getsockname(4, {sa_family=AF_INET, sin_port=htons(58430), sin_addr=inet_addr("192.168.1.16")}, [16]) = 0 | ||
| + | [pid 23396] setsockopt(3, SOL_RAW, ICMP_FILTER, ~(1<<ICMP_ECHOREPLY|1<<ICMP_DEST_UNREACH|1<<ICMP_SOURCE_QUENCH|1<<ICMP_REDIRECT|1<<ICMP_TIME_EXCEEDED|1<<ICMP_PARAMETERPROB), 4) = 0 | ||
| + | [pid 23396] setsockopt(3, SOL_IP, IP_RECVERR, [1], 4) = 0 | ||
| + | [pid 23396] setsockopt(3, SOL_SOCKET, SO_SNDBUF, [324], 4) = 0 | ||
| + | [pid 23396] setsockopt(3, SOL_SOCKET, SO_RCVBUF, [65536], 4) = 0 | ||
| + | [pid 23396] getsockopt(3, SOL_SOCKET, SO_RCVBUF, [131072], [4]) = 0 | ||
| + | [pid 23396] setsockopt(3, SOL_SOCKET, SO_TIMESTAMP, [1], 4) = 0 | ||
| + | [pid 23396] setsockopt(3, SOL_SOCKET, SO_SNDTIMEO, "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0 | ||
| + | [pid 23396] setsockopt(3, SOL_SOCKET, SO_RCVTIMEO, "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0 | ||
| + | [pid 23396] sendto(3, "\10\0\33\21[d\0\1\237\10wZ\0\0\0\0\242S\n\0\0\0\0\0\20\21\22\23\24\25\26\27"..., 64, 0, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("8.8.8.8")}, 16) = 64 | ||
| + | [pid 23396] recvmsg(3, {msg_name(16)={sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("8.8.8.8")}, msg_iov(1)=[{"E\0\0T\321\360\0\0;\1\333\360\10\10\10\10\300\250\1\20\0\0#\21[d\0\1\237\10wZ"..., 192}], msg_controllen=32, [{cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=0x1d /* SCM_??? */}], msg_flags=0}, 0) = 84 | ||
| + | [pid 23396] --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} --- | ||
| + | [pid 23396] +++ exited with 0 +++ | ||
| + | --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=23396, si_uid=1000, si_status=0, si_utime=0, si_stime=0} --- | ||
| + | |||
| + | = outils eBPF (kernel > 4.2) = | ||
| + | Voir ces mécanismes : https://opensource.com/article/17/11/bccbpf-performance | ||
| + | |||
| + | [[Category:Linux]] | ||
| + | [[Category:Monitoring]] | ||
| + | [[Category:Performance]] | ||
Version actuelle datée du 16 juin 2018 à 10:32
Sommaire
Processeur/mémoire
ps
Outil de base, permet de choisir ce qu'on veut afficher, par exemple:
$ ps -e -o pid,euid,egid,cmd:50,pcpu,size,vsz,share |grep firefox | grep -v grep PID EUID EGID CMD %CPU SIZE VSZ - ... 20881 1000 1000 /opt/firefox/firefox 3.7 8445232 9673364 - 21053 1000 1000 /opt/firefox/firefox -contentproc -childID 2 -isFo 0.1 1317140 2099840 -
top
Outil de base, top donne les performances globales, ou par coeur. Commandes intéressantes:
- 1 : bascule stats globales / par coeur.
Options intéressantes:
- -b -n 1 : cliché one-shot de tous les process.
Htop (EPEL)
Similaire à top, un peu plus visuel et permet de scroller verticalement et horizontalement, fonctionnalités moindres par rapport à top.
sar
$ sar -u 5 12 -P ALL Linux 3.10.0-693.17.1.el7.x86_64 (lxhpi3.home) 04/02/2018 _x86_64_ (4 CPU) 16:30:38 CPU %user %nice %system %iowait %steal %idle 16:30:43 all 2,59 0,00 1,59 0,10 0,00 95,72 16:30:43 0 2,80 0,00 1,20 0,40 0,00 95,60 ...
vmstat
$ vmstat 5 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 571632 4139764 34136 1516080 6 19 133 132 145 73 18 3 78 0 0 0 0 571632 4128056 34136 1515892 0 0 0 6 1639 3965 5 4 91 0 0 0 0 571632 4128480 34136 1515892 0 0 0 0 1585 4053 4 4 92 0 0
$ vmstat -s
7878340 K total memory
2077860 K used memory
1620968 K active memory
1311044 K inactive memory
4240392 K free memory
34136 K buffer memory
1525952 K swap cache
4194300 K total swap
571632 K used swap
3622668 K free swap
2763391 non-nice user cpu ticks
7250 nice user cpu ticks
487031 system cpu ticks
11934229 idle cpu ticks
52051 IO-wait cpu ticks
0 IRQ cpu ticks
22577 softirq cpu ticks
0 stolen cpu ticks
20341703 pages paged in
20236535 pages paged out
230526 pages swapped in
719893 pages swapped out
150777683 interrupts
354066009 CPU context switches
1528470595 boot time
366342 forks
Entrées/Sorties (réseau, disque...)
iotop
Mesure l'activité disque par process. Peut fonctionner comme top soit en continu à l'écran soit en mode batch (pour sauver dans un fichier). Exemple (affichage seulement des process ayant de l'activité disque):
Total DISK READ : 3.79 K/s | Total DISK WRITE : 352.81 K/s Actual DISK READ: 3.79 K/s | Actual DISK WRITE: 7.59 K/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO COMMAND 20914 be/4 toine 3.79 K/s 15.17 K/s 0.00 % 0.71 % firefox [Cache2 I/O] 1008 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.01 % X :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for-gdm-qmCecJ/database -seat seat0 -nolisten tcp vt1 4296 be/4 toine 0.00 B/s 15.17 K/s 0.00 % 0.00 % kdeinit4: konsole [kdeinit] 21001 be/4 toine 0.00 B/s 307.29 K/s 0.00 % 0.00 % firefox [mozStorage #1] 21009 be/4 toine 0.00 B/s 15.17 K/s 0.00 % 0.00 % firefox [DOM Worker]
iftop
iftop donne des stats de débit par destination sur une ou toutes les interfaces:
$ sudo iftop -i ens0
# Host name (port/service if enabled) last 2s last 10s last 40s cumulative
--------------------------------------------------------------------------------------------
1 lxhpi3.home => 14,6Kb 4,13Kb 2,90Kb 5,79KB
imap.free.fr <= 725Kb 146Kb 91,8Kb 184KB
2 lxhpi3.home => 0b 4,10Kb 2,56Kb 5,12KB
2400:cb00:2048:1::6810:2802 <= 0b 66,3Kb 41,4Kb 82,9KB
3 lxhpi3.home => 22,5Kb 9,02Kb 5,63Kb 11,3KB
server-13-32-153-141.cdg54.r.cloudfront <= 189Kb 46,2Kb 28,9Kb 57,7KB
nstat / rtacct
nstat, rtacct - network statistics tools (package iproute).
nstat [ -h?vVzrnasd:t: ] [ PATTERN [ PATTERN ] ] rtacct [ -h?vVzrnasd:t: ] [ ListOfRealms ]
iostat
Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
$ iostat
Linux 3.10.0-693.17.1.el7.x86_64 (lxhpi3.home) 04/02/2018 _x86_64_ (4 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
5,61 0,03 1,89 0,42 0,00 92,04
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 2,74 53,83 43,67 4889756 3967316
dm-0 3,13 4,65 7,91 421992 718364
dm-1 0,00 0,02 0,00 2120 0
$ iostat -x sda Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 1,03 1,81 1,54 1,20 53,76 43,63 71,09 0,08 28,14 10,27 51,04 2,79 0,76
sar
Collect, report, or save system activity information. Appliqué aux interfaces réseau
$ sar -u 5 1 -n DEV Linux 3.10.0-693.17.1.el7.x86_64 (lxhpi3.home) 04/02/2018 _x86_64_ (4 CPU) 16:34:49 CPU %user %nice %system %iowait %steal %idle 16:34:54 all 5,61 0,00 2,73 0,25 0,00 91,41 # 16:34:49 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 16:34:54 wlp0s26u1u4 487,20 265,40 612,56 27,85 0,00 0,00 0,00 # 16:34:49 IFACE rxerr/s txerr/s coll/s rxdrop/s txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s 16:34:54 wlp0s26u1u4 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00
tracer les messages reseau sur un PID avec strace
Par exemple, avec l'option -f pour suivre la trace sur les process fils du process en trace:
$ strace -v -f -e trace=network -p 4300
strace: Process 4300 attached
socket(AF_NETLINK, SOCK_RAW, NETLINK_AUDIT) = 3
sendmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(2)=[{"\35\0\0\0d\4\1\0\0\0\0\0\0\0\0\0", 16}, {"ping 8.8.8.8\0", 13}], msg_controllen=0, msg_flags=0}, 0) = 29
strace: Process 23396 attached
[pid 23396] socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) = -1 EACCES (Permission denied)
[pid 23396] socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) = 3
[pid 23396] socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
[pid 23396] connect(4, {sa_family=AF_INET, sin_port=htons(1025), sin_addr=inet_addr("8.8.8.8")}, 16) = 0
[pid 23396] getsockname(4, {sa_family=AF_INET, sin_port=htons(58430), sin_addr=inet_addr("192.168.1.16")}, [16]) = 0
[pid 23396] setsockopt(3, SOL_RAW, ICMP_FILTER, ~(1<<ICMP_ECHOREPLY|1<<ICMP_DEST_UNREACH|1<<ICMP_SOURCE_QUENCH|1<<ICMP_REDIRECT|1<<ICMP_TIME_EXCEEDED|1<<ICMP_PARAMETERPROB), 4) = 0
[pid 23396] setsockopt(3, SOL_IP, IP_RECVERR, [1], 4) = 0
[pid 23396] setsockopt(3, SOL_SOCKET, SO_SNDBUF, [324], 4) = 0
[pid 23396] setsockopt(3, SOL_SOCKET, SO_RCVBUF, [65536], 4) = 0
[pid 23396] getsockopt(3, SOL_SOCKET, SO_RCVBUF, [131072], [4]) = 0
[pid 23396] setsockopt(3, SOL_SOCKET, SO_TIMESTAMP, [1], 4) = 0
[pid 23396] setsockopt(3, SOL_SOCKET, SO_SNDTIMEO, "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
[pid 23396] setsockopt(3, SOL_SOCKET, SO_RCVTIMEO, "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
[pid 23396] sendto(3, "\10\0\33\21[d\0\1\237\10wZ\0\0\0\0\242S\n\0\0\0\0\0\20\21\22\23\24\25\26\27"..., 64, 0, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("8.8.8.8")}, 16) = 64
[pid 23396] recvmsg(3, {msg_name(16)={sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("8.8.8.8")}, msg_iov(1)=[{"E\0\0T\321\360\0\0;\1\333\360\10\10\10\10\300\250\1\20\0\0#\21[d\0\1\237\10wZ"..., 192}], msg_controllen=32, [{cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=0x1d /* SCM_??? */}], msg_flags=0}, 0) = 84
[pid 23396] --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
[pid 23396] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=23396, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
outils eBPF (kernel > 4.2)
Voir ces mécanismes : https://opensource.com/article/17/11/bccbpf-performance