Dernière mise-à-jour : 2020/01/30 03:28
Dans l'ordinateur les périphériques sont reliés à un contrôleur qui communique avec le processeur à l'aide d'un bus. Le contrôleur ainsi que les périphériques nécessitent des pilotes. Sous Linux, les pilotes sont généralement fournis sous la forme d'un module. Chaque périphérique est représenté par un fichier spécial dans le répertoire /dev et c'est dans ce fichier que le système trouve les informations nécessaires pour s'adresser au pilote.
Important : Les périphériques qui nécessitent à ce que l'ordinateur soit éteint afin des les brancher/débrancher sont appelés communément Cold Plug Devices. Les périphériques qui peuvent être brancher/débrancher à chaud sont appelés des Hot Plug Devices.
Consultez le contenu du répertoire /dev :
[root@centos7 ~]# ls -l /dev | more total 0 crw-------. 1 root root 10, 235 Oct 28 09:40 autofs drwxr-xr-x. 2 root root 140 Oct 28 09:40 block drwxr-xr-x. 2 root root 80 Oct 28 09:40 bsg crw-------. 1 root root 10, 234 Oct 28 09:40 btrfs-control drwxr-xr-x. 3 root root 60 Oct 28 09:40 bus lrwxrwxrwx. 1 root root 3 Oct 28 09:40 cdrom -> sr0 drwxr-xr-x. 2 root root 2800 Oct 28 09:41 char crw-------. 1 root root 5, 1 Oct 28 09:40 console lrwxrwxrwx. 1 root root 11 Oct 28 09:40 core -> /proc/kcore drwxr-xr-x. 3 root root 80 Oct 28 09:40 cpu crw-------. 1 root root 10, 61 Oct 28 09:40 cpu_dma_latency crw-------. 1 root root 10, 62 Oct 28 09:40 crash drwxr-xr-x. 5 root root 100 Oct 28 09:40 disk drwxr-xr-x. 2 root root 60 Oct 28 09:40 dri lrwxrwxrwx. 1 root root 13 Oct 28 09:40 fd -> /proc/self/fd crw-rw-rw-. 1 root root 1, 7 Oct 28 09:40 full crw-rw-rw-. 1 root root 10, 229 Oct 28 09:41 fuse crw-------. 1 root root 10, 228 Oct 28 09:40 hpet drwxr-xr-x. 3 root root 0 Oct 28 09:40 hugepages prw-------. 1 root root 0 Oct 28 09:40 initctl drwxr-xr-x. 3 root root 240 Oct 28 09:40 input crw-r--r--. 1 root root 1, 11 Oct 28 09:40 kmsg --More--
root@debian8:~# ls -l /dev | more total 0 crw------- 1 root root 10, 235 Nov 1 08:39 autofs drwxr-xr-x 2 root root 140 Nov 1 08:39 block drwxr-xr-x 2 root root 80 Nov 1 08:39 bsg crw------- 1 root root 10, 234 Nov 1 08:39 btrfs-control drwxr-xr-x 3 root root 60 Nov 1 08:39 bus lrwxrwxrwx 1 root root 3 Nov 1 08:39 cdrom -> sr0 drwxr-xr-x 2 root root 2780 Nov 1 13:35 char crw------- 1 root root 5, 1 Nov 1 08:39 console lrwxrwxrwx 1 root root 11 Nov 1 08:39 core -> /proc/kcore drwxr-xr-x 2 root root 60 Nov 1 08:39 cpu crw------- 1 root root 10, 62 Nov 1 08:39 cpu_dma_latency crw-rw-rw- 1 root root 10, 203 Nov 1 08:39 cuse drwxr-xr-x 4 root root 80 Nov 1 08:39 disk drwxr-xr-x 2 root root 60 Nov 1 08:39 dri lrwxrwxrwx 1 root root 3 Nov 1 08:39 dvd -> sr0 lrwxrwxrwx 1 root root 13 Nov 1 08:39 fd -> /proc/self/fd crw-rw-rw- 1 root root 1, 7 Nov 1 08:39 full crw-rw-rw- 1 root root 10, 229 Nov 1 08:39 fuse crw------- 1 root root 251, 0 Nov 1 13:35 hidraw0 crw------- 1 root root 10, 228 Nov 1 08:39 hpet drwxr-xr-x 2 root root 0 Nov 1 08:39 hugepages lrwxrwxrwx 1 root root 25 Nov 1 08:39 initctl -> /run/systemd/initctl/fifo drwxr-xr-x 4 root root 340 Nov 1 13:35 input crw-r--r-- 1 root root 1, 11 Nov 1 08:39 kmsg lrwxrwxrwx 1 root root 28 Nov 1 08:39 log -> /run/systemd/journal/dev-log crw-rw---- 1 root disk 10, 237 Nov 1 08:39 loop-control drwxr-xr-x 2 root root 60 Nov 1 08:39 mapper crw------- 1 root root 10, 227 Nov 1 08:39 mcelog crw-r----- 1 root kmem 1, 1 Nov 1 08:39 mem drwxrwxrwt 2 root root 40 Nov 1 08:39 mqueue --More--
On peut noter dans la sortie de la commande que certains fichiers sont de type bloc (b), tandis que d'autre sont de type caractère (c).
... brw-rw---- 1 root disk 8, 1 Nov 1 08:39 sda1 ... crw-rw-rw- 1 root tty 5, 0 Nov 1 08:39 tty ...
La différence entre les deux repose sur le type de communication entre le système et le module. Dans le premier cas le système accède au périphérique par des coordonnées du bloc de données sur le support tandis que dans le deuxième cas la communication d'échange de données se fait octet par octet sans utiliser des tampons.
Les deux informations clefs du fichier spécial sont situées à la place de la taille d'un fichier normal et se nomment le majeur et le mineur :
Cette commande vous renseigne sur les adaptateurs reliés aux bus PCI, AGP et PCI express :
[root@centos7 ~]# lspci 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] 00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) 00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service 00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01) 00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB 00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08) 00:0b.0 USB controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller 00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
root@debian8:~# lspci 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] 00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) 00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service 00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01) 00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB 00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08) 00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
Pour obtenir de l'information sur un adaptateur spécifique, il convient d'utiliser la même commande avec l'option -v en spécifiant l'identifiant concerné :
[root@centos7 ~]# lspci -v -s 00:03.0 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 19 Memory at f0000000 (32-bit, non-prefetchable) [size=128K] I/O ports at d010 [size=8] Capabilities: [dc] Power Management version 2 Capabilities: [e4] PCI-X non-bridge device Kernel driver in use: e1000
root@debian8:~# lspci -v -s 00:03.0 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 10 Memory at f0000000 (32-bit, non-prefetchable) [size=128K] I/O ports at d010 [size=8] Capabilities: [dc] Power Management version 2 Capabilities: [e4] PCI-X non-bridge device Kernel driver in use: e1000
ou :
[root@centos7 ~]# lspci -vv -s 00:03.0 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- Latency: 64 (63750ns min) Interrupt: pin A routed to IRQ 19 Region 0: Memory at f0000000 (32-bit, non-prefetchable) [size=128K] Region 2: I/O ports at d010 [size=8] Capabilities: [dc] Power Management version 2 Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-) Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME- Capabilities: [e4] PCI-X non-bridge device Command: DPERE- ERO+ RBC=512 OST=1 Status: Dev=ff:1f.0 64bit- 133MHz- SCD- USC- DC=simple DMMRBC=2048 DMOST=1 DMCRS=8 RSCEM- 266MHz- 533MHz- Kernel driver in use: e1000
root@debian8:~# lspci -vv -s 00:03.0 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- Latency: 64 (63750ns min) Interrupt: pin A routed to IRQ 10 Region 0: Memory at f0000000 (32-bit, non-prefetchable) [size=128K] Region 2: I/O ports at d010 [size=8] Capabilities: [dc] Power Management version 2 Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-) Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME- Capabilities: [e4] PCI-X non-bridge device Command: DPERE- ERO+ RBC=512 OST=1 Status: Dev=ff:1f.0 64bit- 133MHz- SCD- USC- DC=simple DMMRBC=2048 DMOST=1 DMCRS=8 RSCEM- 266MHz- 533MHz- Kernel driver in use: e1000
Les options de cette commande sont :
[root@centos7 ~]# lspci --help lspci: invalid option -- '-' Usage: lspci [<switches>] Basic display modes: -mm Produce machine-readable output (single -m for an obsolete format) -t Show bus tree Display options: -v Be verbose (-vv for very verbose) -k Show kernel drivers handling each device -x Show hex-dump of the standard part of the config space -xxx Show hex-dump of the whole config space (dangerous; root only) -xxxx Show hex-dump of the 4096-byte extended config space (root only) -b Bus-centric view (addresses and IRQ's as seen by the bus) -D Always show domain numbers Resolving of device ID's to names: -n Show numeric ID's -nn Show both textual and numeric ID's (names & numbers) -q Query the PCI ID database for unknown ID's via DNS -qq As above, but re-query locally cached entries -Q Query the PCI ID database for all ID's via DNS Selection of devices: -s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]] Show only devices in selected slots -d [<vendor>]:[<device>] Show only devices with specified ID's Other options: -i <file> Use specified ID database instead of /usr/share/hwdata/pci.ids -p <file> Look up kernel modules in a given file instead of default modules.pcimap -M Enable `bus mapping' mode (dangerous; root only) PCI access options: -A <method> Use the specified PCI access method (see `-A help' for a list) -O <par>=<val> Set PCI access parameter (see `-O help' for a list) -G Enable PCI access debugging -H <mode> Use direct hardware access (<mode> = 1 or 2) -F <file> Read PCI configuration dump from a given file
root@debian8:~# lspci --help lspci: invalid option -- '-' Usage: lspci [<switches>] Basic display modes: -mm Produce machine-readable output (single -m for an obsolete format) -t Show bus tree Display options: -v Be verbose (-vv for very verbose) -k Show kernel drivers handling each device -x Show hex-dump of the standard part of the config space -xxx Show hex-dump of the whole config space (dangerous; root only) -xxxx Show hex-dump of the 4096-byte extended config space (root only) -b Bus-centric view (addresses and IRQ's as seen by the bus) -D Always show domain numbers Resolving of device ID's to names: -n Show numeric ID's -nn Show both textual and numeric ID's (names & numbers) -q Query the PCI ID database for unknown ID's via DNS -qq As above, but re-query locally cached entries -Q Query the PCI ID database for all ID's via DNS Selection of devices: -s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]] Show only devices in selected slots -d [<vendor>]:[<device>] Show only devices with specified ID's Other options: -i <file> Use specified ID database instead of /usr/share/misc/pci.ids.gz -p <file> Look up kernel modules in a given file instead of default modules.pcimap -M Enable `bus mapping' mode (dangerous; root only) PCI access options: -A <method> Use the specified PCI access method (see `-A help' for a list) -O <par>=<val> Set PCI access parameter (see `-O help' for a list) -G Enable PCI access debugging -H <mode> Use direct hardware access (<mode> = 1 or 2) -F <file> Read PCI configuration dump from a given file
Cette commande vous renseigne sur les adaptateurs reliés au bus usb :
[root@centos7 ~]# lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub [root@centos7 ~]# lsusb -vt /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/8p, 12M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/8p, 480M
root@debian8:~# lsusb Bus 001 Device 004: ID 80ee:0021 VirtualBox USB Tablet Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub root@debian8:~# lsusb -vt /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/8p, 12M |__ Port 1: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
Les options de cette commande sont :
[root@centos7 ~]# lsusb --help Usage: lsusb [options]... List USB devices -v, --verbose Increase verbosity (show descriptors) -s [[bus]:][devnum] Show only devices with specified device and/or bus numbers (in decimal) -d vendor:[product] Show only devices with the specified vendor and product ID numbers (in hexadecimal) -D device Selects which device lsusb will examine -t, --tree Dump the physical USB device hierarchy as a tree -V, --version Show version of program -h, --help Show usage and help
root@debian8:~# lsusb --help Usage: lsusb [options]... List USB devices -v, --verbose Increase verbosity (show descriptors) -s [[bus]:][devnum] Show only devices with specified device and/or bus numbers (in decimal) -d vendor:[product] Show only devices with the specified vendor and product ID numbers (in hexadecimal) -D device Selects which device lsusb will examine -t, --tree Dump the physical USB device hierarchy as a tree -V, --version Show version of program -h, --help Show usage and help
La commande dmidecode lit la table DMI (Desktop Management Interface) aussi appelée SMBIOS (System Management BIOS) et fourni les informations sur :
[root@centos7 ~]# dmidecode # dmidecode 2.12 SMBIOS 2.5 present. 10 structures occupying 450 bytes. Table at 0x000E1000. Handle 0x0000, DMI type 0, 20 bytes BIOS Information Vendor: innotek GmbH Version: VirtualBox Release Date: 12/01/2006 Address: 0xE0000 Runtime Size: 128 kB ROM Size: 128 kB Characteristics: ISA is supported PCI is supported Boot from CD is supported Selectable boot is supported 8042 keyboard services are supported (int 9h) CGA/mono video services are supported (int 10h) ACPI is supported Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: innotek GmbH Product Name: VirtualBox Version: 1.2 Serial Number: 0 UUID: DDEE345C-66F8-4250-B5A2-85CEF2C1C54D Wake-up Type: Power Switch SKU Number: Not Specified Family: Virtual Machine Handle 0x0008, DMI type 2, 15 bytes Base Board Information Manufacturer: Oracle Corporation Product Name: VirtualBox Version: 1.2 Serial Number: 0 Asset Tag: Not Specified Features: Board is a hosting board Location In Chassis: Not Specified Chassis Handle: 0x0003 Type: Motherboard Contained Object Handles: 0 Handle 0x0003, DMI type 3, 13 bytes Chassis Information Manufacturer: Oracle Corporation Type: Other Lock: Not Present Version: Not Specified Serial Number: Not Specified Asset Tag: Not Specified Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: None Handle 0x0007, DMI type 126, 42 bytes Inactive Handle 0x0005, DMI type 126, 15 bytes Inactive Handle 0x0006, DMI type 126, 28 bytes Inactive Handle 0x0002, DMI type 11, 7 bytes OEM Strings String 1: vboxVer_4.3.28 String 2: vboxRev_100309 Handle 0x0008, DMI type 128, 8 bytes OEM-specific Type Header and Data: 80 08 08 00 01 15 21 00 Handle 0xFEFF, DMI type 127, 4 bytes End Of Table
root@debian8:~# dmidecode # dmidecode 2.12 SMBIOS 2.5 present. 10 structures occupying 450 bytes. Table at 0x000E1000. Handle 0x0000, DMI type 0, 20 bytes BIOS Information Vendor: innotek GmbH Version: VirtualBox Release Date: 12/01/2006 Address: 0xE0000 Runtime Size: 128 kB ROM Size: 128 kB Characteristics: ISA is supported PCI is supported Boot from CD is supported Selectable boot is supported 8042 keyboard services are supported (int 9h) CGA/mono video services are supported (int 10h) ACPI is supported Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: innotek GmbH Product Name: VirtualBox Version: 1.2 Serial Number: 0 UUID: 3AEF2B0F-3420-4DF3-A98F-211C945D7CCA Wake-up Type: Power Switch SKU Number: Not Specified Family: Virtual Machine Handle 0x0008, DMI type 2, 15 bytes Base Board Information Manufacturer: Oracle Corporation Product Name: VirtualBox Version: 1.2 Serial Number: 0 Asset Tag: Not Specified Features: Board is a hosting board Location In Chassis: Not Specified Chassis Handle: 0x0003 Type: Motherboard Contained Object Handles: 0 Handle 0x0003, DMI type 3, 13 bytes Chassis Information Manufacturer: Oracle Corporation Type: Other Lock: Not Present Version: Not Specified Serial Number: Not Specified Asset Tag: Not Specified Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: None Handle 0x0007, DMI type 126, 42 bytes Inactive Handle 0x0005, DMI type 126, 15 bytes Inactive Handle 0x0006, DMI type 126, 28 bytes Inactive Handle 0x0002, DMI type 11, 7 bytes OEM Strings String 1: vboxVer_4.3.28 String 2: vboxRev_100309 Handle 0x0008, DMI type 128, 8 bytes OEM-specific Type Header and Data: 80 08 08 00 F2 13 21 00 Handle 0xFEFF, DMI type 127, 4 bytes End Of Table
Les options de cette commande sont :
[root@centos7 ~]# dmidecode --help Usage: dmidecode [OPTIONS] Options are: -d, --dev-mem FILE Read memory from device FILE (default: /dev/mem) -h, --help Display this help text and exit -q, --quiet Less verbose output -s, --string KEYWORD Only display the value of the given DMI string -t, --type TYPE Only display the entries of given type -u, --dump Do not decode the entries --dump-bin FILE Dump the DMI data to a binary file --from-dump FILE Read the DMI data from a binary file -V, --version Display the version and exit
root@debian8:~# dmidecode --help Usage: dmidecode [OPTIONS] Options are: -d, --dev-mem FILE Read memory from device FILE (default: /dev/mem) -h, --help Display this help text and exit -q, --quiet Less verbose output -s, --string KEYWORD Only display the value of the given DMI string -t, --type TYPE Only display the entries of given type -u, --dump Do not decode the entries --dump-bin FILE Dump the DMI data to a binary file --from-dump FILE Read the DMI data from a binary file -V, --version Display the version and exit
Le répertoire /proc contient des fichiers et des répertoires virtuels. Le contenu de ces fichiers est créé dynamiquement lors de la consultation. Seul root peut consulter la totalité des informations dans le répertoire /proc.
[root@centos7 ~]# ls /proc 1 217 260 2833 3085 465 5898 fb sched_debug 10 22619 2605 2879 3091 478 5933 filesystems scsi 11 22650 2606 2883 3104 482 5940 fs self 12 228 261 2884 3108 484 60 interrupts slabinfo 1215 229 262 29 3124 485 604 iomem softirqs 1217 22908 263 2901 3172 488 698 ioports stat 1227 230 264 2906 3185 490 7 irq swaps 1228 232 265 2910 3304 492 7110 kallsyms sys 1230 233 2671 2913 3496 494 8 kcore sysrq-trigger 1264 23387 2676 2924 3543 495 83 keys sysvipc 13 235 27 2926 363 5 9 key-users timer_list 1372 23580 2749 2931 370 502 acpi kmsg timer_stats 14 23916 2752 2937 372 503 asound kpagecount tty 15 23998 2759 2948 38 508 buddyinfo kpageflags uptime 16 24 2762 2955 381 509 bus loadavg version 17 24013 2764 2967 40 519 cgroups locks vmallocinfo 1732 2427 2765 2971 41 521 cmdline mdstat vmstat 1744 248 2767 2973 414 525 consoles meminfo zoneinfo 17788 2486 2768 2983 431 530 cpuinfo misc 18 25 2782 2985 432 536 crypto modules 19 2586 2798 2988 433 549 devices mounts 2 259 28 2998 434 586 diskstats mtrr 20 2595 2802 3 436 587 dma net 20638 2597 2806 3058 454 5894 driver pagetypeinfo 21 26 2818 3084 458 5897 execdomains partitions
root@debian8:~# ls /proc 1 1103 1238 170 30 68 957 execdomains net 10 1104 124 18 31 69 959 fb pagetypeinfo 1013 1106 1240 19 32 7 963 filesystems partitions 1014 1108 125 2 33 71 966 fs sched_debug 1023 1117 1251 20 424 72 975 interrupts self 1024 1120 1277 21 434 73 979 iomem slabinfo 1028 1127 1288 2180 439 74 980 ioports softirqs 1029 1131 1294 2284 441 772 984 irq stat 1032 1135 13 23 448 778 986 kallsyms swaps 1033 1139 14 2305 450 781 acpi kcore sys 1040 1140 1409 2306 452 793 asound keys sysrq-trigger 1043 1142 15 232 457 798 buddyinfo key-users sysvipc 1045 1156 1572 236 460 8 bus kmsg timer_list 1049 1163 158 24 461 80 cgroups kpagecount timer_stats 1053 1165 16 2599 464 807 cmdline kpageflags tty 1056 1166 163 263 471 821 consoles loadavg uptime 1065 1171 1682 2635 472 838 cpuinfo locks version 1080 1177 1685 2737 497 843 crypto meminfo vmallocinfo 1081 12 1687 2772 498 9 devices misc vmstat 1084 1216 1693 2811 5 948 diskstats modules zoneinfo 1092 1228 1694 2834 66 949 dma mounts 11 1230 17 3 67 956 driver mtrr
Ce répertoire contient des répertoires dans lesquels se trouvent des informations sur la capacité, le type et la géométrie des disques.
Ce répertoire contient des informations sur la gestion de l'énérgie, les températures, les vitesses de ventilateurs, la charge des batteries.
Ce répertoire contient un sous-répertoire par bus.
Ce répertoire contient des informations sur le réseau.
Ce répertoire contient des paramètres du noyau. Certains des fichiers dans ce répertoire sont accessibles en écriture par root en temps réel. Par exemple pour éviter des attaques réseau DoS utilisant la commande ping, saisissez la commande suivante :
# echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all [Entrée]
Cette commande a pour résultat d'ignorer les reqûetes ping.
Les fichiers dans le répertoire /proc/sys peuvent être administrés par la commande sysctl en temps réel.
La commande sysctl applique les règles consignés dans le fichier /etc/sysctl.conf au démarrage de la machine.
Saisissez la commande :
[root@centos7 ~]# cat /etc/sysctl.conf # System default settings live in /usr/lib/sysctl.d/00-system.conf. # To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file # # For more information, see sysctl.conf(5) and sysctl.d(5). [root@centos7 ~]# cat /usr/lib/sysctl.d/00-system.conf # Kernel sysctl configuration file # # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and # sysctl.conf(5) for more details. # Disable netfilter on bridges. net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 # Controls the maximum shared segment size, in bytes kernel.shmmax = 4294967295 # Controls the maximum number of shared memory segments, in pages [root@centos7 ~]# ls -l /etc/sysctl.d/ total 0 lrwxrwxrwx. 1 root root 14 Jun 4 09:54 99-sysctl.conf -> ../sysctl.conf [root@centos7 ~]# cat /etc/sysctl.d/99-sysctl.conf # System default settings live in /usr/lib/sysctl.d/00-system.conf. # To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file # # For more information, see sysctl.conf(5) and sysctl.d(5).
root@debian8:~# cat /etc/sysctl.conf # # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl.conf (5) for information. # #kernel.domainname = example.com # Uncomment the following to stop low-level messages on console #kernel.printk = 3 4 1 3 ##############################################################3 # Functions previously found in netbase # # Uncomment the next two lines to enable Spoof protection (reverse-path filter) # Turn on Source Address Verification in all interfaces to # prevent some spoofing attacks #net.ipv4.conf.default.rp_filter=1 #net.ipv4.conf.all.rp_filter=1 # Uncomment the next line to enable TCP/IP SYN cookies # See http://lwn.net/Articles/277146/ # Note: This may impact IPv6 TCP sessions too #net.ipv4.tcp_syncookies=1 # Uncomment the next line to enable packet forwarding for IPv4 #net.ipv4.ip_forward=1 # Uncomment the next line to enable packet forwarding for IPv6 # Enabling this option disables Stateless Address Autoconfiguration # based on Router Advertisements for this host #net.ipv6.conf.all.forwarding=1 ################################################################### # Additional settings - these settings can improve the network # security of the host and prevent against some network attacks # including spoofing attacks and man in the middle attacks through # redirection. Some network environments, however, require that these # settings are disabled so review and enable them as needed. # # Do not accept ICMP redirects (prevent MITM attacks) #net.ipv4.conf.all.accept_redirects = 0 #net.ipv6.conf.all.accept_redirects = 0 # _or_ # Accept ICMP redirects only for gateways listed in our default # gateway list (enabled by default) # net.ipv4.conf.all.secure_redirects = 1 # # Do not send ICMP redirects (we are not a router) #net.ipv4.conf.all.send_redirects = 0 # # Do not accept IP source route packets (we are not a router) #net.ipv4.conf.all.accept_source_route = 0 #net.ipv6.conf.all.accept_source_route = 0 # # Log Martian Packets #net.ipv4.conf.all.log_martians = 1 #
Les options de la commande sysctl sont :
[root@centos7 ~]# sysctl --help Usage: sysctl [options] [variable[=value] ...] Options: -a, --all display all variables -A alias of -a -X alias of -a --deprecated include deprecated parameters to listing -b, --binary print value without new line -e, --ignore ignore unknown variables errors -N, --names print variable names without values -n, --values print only values of a variables -p, --load[=<file>] read values from file -f alias of -p --system read values from all system directories -r, --pattern <expression> select setting that match expression -q, --quiet do not echo variable set -w, --write enable writing a value to variable -o does nothing -x does nothing -d alias of -h -h, --help display this help and exit -V, --version output version information and exit For more details see sysctl(8).
root@debian8:~# sysctl --help Usage: sysctl [options] [variable[=value] ...] Options: -a, --all display all variables -A alias of -a -X alias of -a --deprecated include deprecated parameters to listing -b, --binary print value without new line -e, --ignore ignore unknown variables errors -N, --names print variable names without values -n, --values print only values of a variables -p, --load[=<file>] read values from file -f alias of -p --system read values from all system directories -r, --pattern <expression> select setting that match expression -q, --quiet do not echo variable set -w, --write enable writing a value to variable -o does nothing -x does nothing -d alias of -h -h, --help display this help and exit -V, --version output version information and exit For more details see sysctl(8).
Important : Consultez la page de la traduction du manuel de sysctl ici pour comprendre la commande.
[root@centos7 ~]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 55 model name : Intel(R) Celeron(R) CPU N2840 @ 2.16GHz stepping : 8 microcode : 0x19 cpu MHz : 2167.721 cache size : 6144 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl pni monitor ssse3 lahf_lm bogomips : 4335.44 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management:
root@debian8:~# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 55 model name : Intel(R) Celeron(R) CPU N2840 @ 2.16GHz stepping : 8 microcode : 0x19 cpu MHz : 2167.709 cache size : 6144 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fdiv_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 nx rdtscp constant_tsc pni monitor ssse3 bogomips : 4335.41 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management:
[root@centos7 ~]# cat /proc/interrupts CPU0 0: 189 IO-APIC-edge timer 1: 5890 IO-APIC-edge i8042 8: 0 IO-APIC-edge rtc0 9: 1 IO-APIC-fasteoi acpi 12: 22452 IO-APIC-edge i8042 14: 0 IO-APIC-edge ata_piix 15: 13891 IO-APIC-edge ata_piix 19: 25816 IO-APIC-fasteoi ehci_hcd:usb1, enp0s3 20: 119352 IO-APIC-fasteoi vboxguest 21: 33754 IO-APIC-fasteoi ahci, snd_intel8x0 22: 0 IO-APIC-fasteoi ohci_hcd:usb2 NMI: 0 Non-maskable interrupts LOC: 1630315 Local timer interrupts SPU: 0 Spurious interrupts PMI: 0 Performance monitoring interrupts IWI: 83206 IRQ work interrupts RTR: 0 APIC ICR read retries RES: 0 Rescheduling interrupts CAL: 0 Function call interrupts TLB: 0 TLB shootdowns TRM: 0 Thermal event interrupts THR: 0 Threshold APIC interrupts MCE: 0 Machine check exceptions MCP: 48 Machine check polls ERR: 0 MIS: 0
root@debian8:~# cat /proc/interrupts CPU0 0: 43 XT-PIC-XT-PIC timer 1: 15159 XT-PIC-XT-PIC i8042 2: 0 XT-PIC-XT-PIC cascade 8: 0 XT-PIC-XT-PIC rtc0 9: 83729 XT-PIC-XT-PIC acpi, vboxguest 10: 20664 XT-PIC-XT-PIC eth0 11: 27534 XT-PIC-XT-PIC ohci_hcd:usb1, ahci, snd_intel8x0 12: 16216 XT-PIC-XT-PIC i8042 14: 0 XT-PIC-XT-PIC ata_piix 15: 7427 XT-PIC-XT-PIC ata_piix NMI: 0 Non-maskable interrupts LOC: 969554 Local timer interrupts SPU: 0 Spurious interrupts PMI: 0 Performance monitoring interrupts IWI: 0 IRQ work interrupts RTR: 0 APIC ICR read retries RES: 0 Rescheduling interrupts CAL: 0 Function call interrupts TLB: 0 TLB shootdowns TRM: 0 Thermal event interrupts THR: 0 Threshold APIC interrupts MCE: 0 Machine check exceptions MCP: 25 Machine check polls HYP: 0 Hypervisor callback interrupts ERR: 0 MIS: 0
Important : Un pilote de périphérique demande au processeur de fournir un service en utilisant un IRQ. Quand la demande est faite, le processeur interrompe ses activités et passe le contrôle au pilote identifié par l'IRQ. Techniquement l'attribution d'un IRQ à un périphérique doit être exclusive. Dans le cas où deux périphériques demandent un service en même temps, c'est le périphérique ayant l'IRQ le plus bas qui est prioritaire.
[root@centos7 ~]# cat /proc/dma 4: cascade
root@debian8:~# cat /proc/dma 4: cascade
[root@centos7 ~]# cat /proc/ioports | more 0000-001f : dma1 0020-0021 : pic1 0040-0043 : timer0 0050-0053 : timer1 0060-0060 : keyboard 0064-0064 : keyboard 0070-0071 : rtc_cmos 0070-0071 : rtc0 0080-008f : dma page reg 00a0-00a1 : pic2 00c0-00df : dma2 00f0-00ff : fpu 0170-0177 : 0000:00:01.1 0170-0177 : ata_piix 01f0-01f7 : 0000:00:01.1 01f0-01f7 : ata_piix 0376-0376 : 0000:00:01.1 0376-0376 : ata_piix 03c0-03df : vga+ 03f6-03f6 : 0000:00:01.1 03f6-03f6 : ata_piix 0cf8-0cff : PCI conf1 4000-4003 : ACPI PM1a_EVT_BLK --More--
root@debian8:~# cat /proc/ioports | more 0000-001f : dma1 0020-0021 : pic1 0040-0043 : timer0 0050-0053 : timer1 0060-0060 : keyboard 0064-0064 : keyboard 0070-0071 : rtc_cmos 0070-0071 : rtc0 0080-008f : dma page reg 00a0-00a1 : pic2 00c0-00df : dma2 00f0-00ff : fpu 0170-0177 : 0000:00:01.1 0170-0177 : ata_piix 01f0-01f7 : 0000:00:01.1 01f0-01f7 : ata_piix 0376-0376 : 0000:00:01.1 0376-0376 : ata_piix 03c0-03df : vga+ 03f6-03f6 : 0000:00:01.1 03f6-03f6 : ata_piix 0cf8-0cff : PCI conf1 4000-4003 : ACPI PM1a_EVT_BLK --More--
Si deux périphériques ont le même port, les deux périphériques seront inutilisables.
[root@centos7 ~]# cat /proc/devices Character devices: 1 mem 4 /dev/vc/0 4 tty 4 ttyS 5 /dev/tty 5 /dev/console 5 /dev/ptmx 6 lp 7 vcs 10 misc 13 input 14 sound 29 fb 99 ppdev 116 alsa 128 ptm 136 pts 162 raw 180 usb 188 ttyUSB 189 usb_device 202 cpu/msr 203 cpu/cpuid 226 drm 250 hidraw 251 usbmon 252 bsg 253 watchdog 254 rtc Block devices: 259 blkext 8 sd 9 md 11 sr 65 sd 66 sd 67 sd 68 sd 69 sd 70 sd 71 sd 128 sd 129 sd 130 sd 131 sd 132 sd 133 sd 134 sd 135 sd 253 device-mapper 254 mdp
root@debian8:~# cat /proc/devices Character devices: 1 mem 4 /dev/vc/0 4 tty 4 ttyS 5 /dev/tty 5 /dev/console 5 /dev/ptmx 6 lp 7 vcs 10 misc 13 input 21 sg 29 fb 99 ppdev 116 alsa 128 ptm 136 pts 180 usb 189 usb_device 226 drm 251 hidraw 252 bsg 253 watchdog 254 rtc Block devices: 259 blkext 8 sd 11 sr 65 sd 66 sd 67 sd 68 sd 69 sd 70 sd 71 sd 128 sd 129 sd 130 sd 131 sd 132 sd 133 sd 134 sd 135 sd
[root@centos7 ~]# cat /proc/modules | more tcp_lp 12663 0 - Live 0xffffffffa059d000 lp 17759 0 - Live 0xffffffffa0593000 nls_utf8 12557 1 - Live 0xffffffffa0527000 isofs 39844 1 - Live 0xffffffffa0588000 bnep 19704 2 - Live 0xffffffffa0516000 bluetooth 372662 7 bnep, Live 0xffffffffa052c000 rfkill 26536 3 bluetooth, Live 0xffffffffa051f000 fuse 87741 3 - Live 0xffffffffa04ff000 ip6t_rpfilter 12546 1 - Live 0xffffffffa04fa000 ip6t_REJECT 12939 2 - Live 0xffffffffa04f5000 ipt_REJECT 12541 2 - Live 0xffffffffa04f0000 xt_conntrack 12760 7 - Live 0xffffffffa04e6000 ebtable_nat 12807 0 - Live 0xffffffffa04e1000 ebtable_broute 12731 0 - Live 0xffffffffa04eb000 bridge 115385 1 ebtable_broute, Live 0xffffffffa04c3000 stp 12976 1 bridge, Live 0xffffffffa04be000 llc 14552 2 bridge,stp, Live 0xffffffffa04b5000 ebtable_filter 12827 0 - Live 0xffffffffa04b0000 ebtables 30913 3 ebtable_nat,ebtable_broute,ebtable_filter, Live 0xffffffffa04a3 000 ip6table_nat 12864 1 - Live 0xffffffffa049e000 nf_conntrack_ipv6 18738 5 - Live 0xffffffffa0498000 nf_defrag_ipv6 34651 1 nf_conntrack_ipv6, Live 0xffffffffa048a000 --More--
root@debian8:~# cat /proc/modules | more cfg80211 350041 0 - Live 0xf9426000 rfkill 18387 1 cfg80211, Live 0xf92ae000 vboxsf 36590 0 - Live 0xf81f1000 (O) nfsd 236959 2 - Live 0xf9360000 auth_rpcgss 45765 1 nfsd, Live 0xf81e4000 oid_registry 12387 1 auth_rpcgss, Live 0xf8064000 nfs_acl 12463 1 nfsd, Live 0xf7ff7000 nfs 168022 0 - Live 0xf9335000 lockd 73443 2 nfsd,nfs, Live 0xf8137000 fscache 44782 1 nfs, Live 0xf8096000 sunrpc 211341 6 nfsd,auth_rpcgss,nfs_acl,nfs,lockd, Live 0xf9300000 joydev 16847 0 - Live 0xf8193000 snd_intel8x0 30521 2 - Live 0xf812e000 snd_ac97_codec 96151 1 snd_intel8x0, Live 0xf8150000 snd_pcm 78128 2 snd_intel8x0,snd_ac97_codec, Live 0xf816e000 snd_timer 22010 1 snd_pcm, Live 0xf808f000 snd 55101 8 snd_intel8x0,snd_ac97_codec,snd_pcm,snd_timer, Live 0xf80a5000 soundcore 12890 1 snd, Live 0xf8069000 ac97_bus 12462 1 snd_ac97_codec, Live 0xf805f000 vboxvideo 12405 1 - Live 0xf8055000 (O) pcspkr 12531 0 - Live 0xf7e1b000 drm 203555 3 vboxvideo, Live 0xf9202000 psmouse 93505 0 - Live 0xf8077000 --More--
[root@centos7 ~]# cat /proc/diskstats 11 0 sr0 21 0 132 157 0 0 0 0 0 157 157 8 0 sda 19700 638 2178341 386424 13324 1605 547086 356748 0 164849 740706 8 1 sda1 2129 0 9438 2181 2057 0 4122 392 0 2527 2569 8 2 sda2 17213 598 2165719 382957 11202 1605 542964 356316 0 164048 736814 8 3 sda3 170 31 1608 775 0 0 0 0 0 775 775
root@debian8:~# cat /proc/diskstats 8 0 sda 18987 11031 1082886 269752 13611 11447 380664 169532 0 123708 438044 8 1 sda1 18763 10780 1079098 268224 13480 11316 379544 168960 0 123396 435948 8 2 sda2 2 0 4 120 0 0 0 0 0 120 120 8 5 sda5 99 141 1920 1212 9 131 1120 136 0 1316 1348 11 0 sr0 0 0 0 0 0 0 0 0 0 0 0
[root@centos7 ~]# cat /proc/partitions major minor #blocks name 11 0 56876 sr0 8 0 20971520 sda 8 1 204800 sda1 8 2 7168000 sda2 8 3 3072000 sda3
root@debian8:~# cat /proc/partitions major minor #blocks name 8 0 20971520 sda 8 1 9764864 sda1 8 2 1 sda2 8 5 1951744 sda5 11 0 1048575 sr0
[root@centos7 ~]# cat /proc/swaps Filename Type Size Used Priority /dev/sda3 partition 3071996 0 -1
root@debian8:~# cat /proc/swaps Filename Type Size Used Priority /dev/sda5 partition 1951740 500 -1
[root@centos7 ~]# cat /proc/loadavg 1.82 1.07 0.81 3/379 25349
root@debian8:~# cat /proc/loadavg 0.77 0.80 0.76 2/290 2984
[root@centos7 ~]# cat /proc/meminfo MemTotal: 1791624 kB MemFree: 72272 kB MemAvailable: 769436 kB Buffers: 404 kB Cached: 790132 kB SwapCached: 0 kB Active: 1002556 kB Inactive: 529520 kB Active(anon): 620404 kB Inactive(anon): 131808 kB Active(file): 382152 kB Inactive(file): 397712 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 3071996 kB SwapFree: 3071992 kB Dirty: 35168 kB Writeback: 0 kB AnonPages: 741568 kB Mapped: 138756 kB Shmem: 10664 kB Slab: 98304 kB SReclaimable: 59848 kB SUnreclaim: 38456 kB KernelStack: 5808 kB PageTables: 24140 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3967808 kB Committed_AS: 3006392 kB VmallocTotal: 34359738367 kB VmallocUsed: 28612 kB VmallocChunk: 34359706684 kB HardwareCorrupted: 0 kB AnonHugePages: 256000 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 75712 kB DirectMap2M: 1759232 kB
root@debian8:~# cat /proc/meminfo MemTotal: 1031864 kB MemFree: 79924 kB MemAvailable: 404848 kB Buffers: 74112 kB Cached: 362824 kB SwapCached: 208 kB Active: 613740 kB Inactive: 284400 kB Active(anon): 397624 kB Inactive(anon): 74292 kB Active(file): 216116 kB Inactive(file): 210108 kB Unevictable: 32 kB Mlocked: 32 kB HighTotal: 141256 kB HighFree: 10240 kB LowTotal: 890608 kB LowFree: 69684 kB SwapTotal: 1951740 kB SwapFree: 1951240 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 461060 kB Mapped: 182132 kB Shmem: 10716 kB Slab: 36092 kB SReclaimable: 26548 kB SUnreclaim: 9544 kB KernelStack: 2312 kB PageTables: 5880 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 2467672 kB Committed_AS: 2087760 kB VmallocTotal: 122880 kB VmallocUsed: 21900 kB VmallocChunk: 99844 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 34808 kB DirectMap2M: 872448 kB
[root@centos7 ~]# cat /proc/version Linux version 3.10.0-229.4.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Wed May 13 10:06:09 UTC 2015
root@debian8:~# cat /proc/version Linux version 3.16.0-4-686-pae (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.7-ckt11-1+deb8u5 (2015-10-09)
Les informations brutes stockées dans /proc peuvent être interprétées grâce à l'utilisation des commandes dites de gestion des performances :
La commande free permet de donner l’état de la mémoire totale, libre, partagée, swap et bufferisée. Saisissez donc la commande suivante :
[root@centos7 ~]# free -m total used free shared buff/cache available Mem: 1749 859 76 6 813 707 Swap: 2999 3 2996
root@debian8:~# free -m total used free shared buffers cached Mem: 1007 930 76 10 72 354 -/+ buffers/cache: 503 503 Swap: 1905 0 1905
Dans le cas de ce dernier exemple, nous pouvons constater que l’affichage montre :
La ligne -/+ buffers/cache: indique que les applications utilisent 503 Mo et qu’elles disposent de 503 (502) Mo de mémoire libre (72+354+76).
Les options de cette commande sont :
[root@centos7 ~]# free --help Usage: free [options] Options: -b, --bytes show output in bytes -k, --kilo show output in kilobytes -m, --mega show output in megabytes -g, --giga show output in gigabytes --tera show output in terabytes -h, --human show human-readable output --si use powers of 1000 not 1024 -l, --lohi show detailed low and high memory statistics -t, --total show total for RAM + swap -s N, --seconds N repeat printing every N seconds -c N, --count N repeat printing N times, then exit -w, --wide wide output --help display this help and exit -V, --version output version information and exit For more details see free(1).
root@debian8:~# free --help Usage: free [options] Options: -b, --bytes show output in bytes -k, --kilo show output in kilobytes -m, --mega show output in megabytes -g, --giga show output in gigabytes --tera show output in terabytes -h, --human show human-readable output --si use powers of 1000 not 1024 -l, --lohi show detailed low and high memory statistics -o, --old use old format (without -/+buffers/cache line) -t, --total show total for RAM + swap -s N, --seconds N repeat printing every N seconds -c N, --count N repeat printing N times, then exit --help display this help and exit -V, --version output version information and exit For more details see free(1).
Chacune des ces commandes indique la charge moyenne du ou des processeurs depuis 1 minute, 5 minutes et 15 minutes :
[root@centos7 ~]# uptime 14:43:46 up 4:05, 2 users, load average: 0.92, 1.23, 0.95 [root@centos7 ~]# w 14:43:49 up 4:05, 2 users, load average: 0.92, 1.23, 0.95 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT trainee :0 :0 Wed09 ?xdm? 40:01 0.74s gdm-session-worker [pam/gdm-password] trainee pts/0 :0 Wed10 5.00s 0.65s 26.90s /usr/libexec/gnome-terminal-server
root@debian8:~# uptime 09:37:06 up 2:31, 3 users, load average: 0.67, 0.34, 0.45 root@debian8:~# w 09:37:08 up 2:31, 3 users, load average: 0.67, 0.34, 0.45 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT trainee :0 :0 Sun08 ?xdm? 44:35 1.13s x-session-manager trainee pts/0 :0 Sun08 3.00s 0.56s 44.83s /usr/lib/gnome-terminal/gnome-terminal-server trainee pts/1 :0 Sun09 24.00s 0.40s 44.83s /usr/lib/gnome-terminal/gnome-terminal-server
Les valeurs load average ou charge moyenne indiquent le nombre moyen de processus en cours de traitement ou en attente pour la période concernée.
Par exemple si les valeurs sur un système muni d'un seul processeur étaient 3,48 4,00 3,85 ceci indiquerait que le processeur a du mal à traiter les processus mettant en moyenne :
Les options de ces commandes sont :
[root@centos7 ~]# uptime --help Usage: uptime [options] Options: -p, --pretty show uptime in pretty format -h, --help display this help and exit -s, --since system up since -V, --version output version information and exit For more details see uptime(1). [root@centos7 ~]# w --help Usage: w [options] Options: -h, --no-header do not print header -u, --no-current ignore current process username -s, --short short format -f, --from show remote hostname field -o, --old-style old style output -i, --ip-addr display IP address instead of hostname (if possible) --help display this help and exit -V, --version output version information and exit For more details see w(1).
root@debian8:~# uptime --help Usage: uptime [options] Options: -p, --pretty show uptime in pretty format -h, --help display this help and exit -s, --since system up since -V, --version output version information and exit For more details see uptime(1). root@debian8:~# w --help Usage: w [options] Options: -h, --no-header do not print header -u, --no-current ignore current process username -s, --short short format -f, --from show remote hostname field -o, --old-style old style output -i, --ip-addr display IP address instead of hostname (if possible) --help display this help and exit -V, --version output version information and exit For more details see w(1).
La commande iostat affiche des statistiques sur l'utilisation des disques, des terminaux et des lecteurs de cartouche :
[root@centos7 ~]# iostat Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 9.00 0.14 2.67 0.29 0.00 87.90 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn scd0 0.00 0.00 0.00 66 0 sda 2.56 95.04 37.09 1409026 549881
Sous Debian 8 les commandes iostat, mpstat et sar ne sont pas disponibles par défaut. Installez donc le paquet sysstat :
root@debian8:~# apt-get install sysstat Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: isag The following NEW packages will be installed: sysstat 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 290 kB of archives. After this operation, 1,390 kB of additional disk space will be used. Get:1 http://ftp.fr.debian.org/debian/ jessie/main sysstat i386 11.0.1-1 [290 kB] Fetched 290 kB in 5s (53.4 kB/s) Preconfiguring packages ... Selecting previously unselected package sysstat. (Reading database ... 167520 files and directories currently installed.) Preparing to unpack .../sysstat_11.0.1-1_i386.deb ... Unpacking sysstat (11.0.1-1) ... Processing triggers for man-db (2.7.0.2-5) ... Processing triggers for systemd (215-17+deb8u2) ... Setting up sysstat (11.0.1-1) ... Creating config file /etc/default/sysstat with new version update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode Processing triggers for systemd (215-17+deb8u2) ...
Exécutez maintenant la commande iostat :
root@debian8:~# iostat Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 27.19 0.00 5.79 0.80 0.00 66.22 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 4.58 69.17 29.19 613071 258736
Au-dessous de la première ligne indiquant la version du noyau du système et son nom d'hôte ainsi que la date actuelle, iostat affiche une vue d'ensemble de l'utilisation CPU moyenne du système depuis le dernier démarrage. Le rapport d'utilisation du CPU inclut les pourcentages suivants :
Notez la valeur de %iowait. Dans le cas où ce pourcentage est trop élévé, ceci indique que le processeur passe son temps à attendre les entrées et les sorties de disque.
Pour surveiller la vitesse des entrées et des sorties du disque, vous pouvez utiliser la commande hdparm.
Sous RHEL/CentOS 7, la commande hdparm n'est pas disponible par défaut. Installez donc le paquet hdparm :
[root@centos7 ~]# yum install hdparm Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.in2p3.fr * extras: distrib-coffee.ipsl.jussieu.fr * updates: distrib-coffee.ipsl.jussieu.fr Resolving Dependencies --> Running transaction check ---> Package hdparm.x86_64 0:9.43-5.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Installing: hdparm x86_64 9.43-5.el7 base 83 k Transaction Summary ====================================================================================================================================================== Install 1 Package Total download size: 83 k Installed size: 152 k Is this ok [y/d/N]: y Downloading packages: hdparm-9.43-5.el7.x86_64.rpm | 83 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : hdparm-9.43-5.el7.x86_64 1/1 Verifying : hdparm-9.43-5.el7.x86_64 1/1 Installed: hdparm.x86_64 0:9.43-5.el7 Complete!
[root@centos7 ~]# hdparm -t /dev/sda /dev/sda: Timing buffered disk reads: 254 MB in 3.02 seconds = 84.19 MB/sec
Sous Debian 8, la commande hdparm n'est pas disponible par défaut. Installez donc le paquet hdparm :
root@debian8:~# apt-get install hdparm Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: powermgmt-base Suggested packages: apmd The following NEW packages will be installed: hdparm powermgmt-base 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 118 kB of archives. After this operation, 263 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://ftp.fr.debian.org/debian/ jessie/main hdparm i386 9.43-2 [109 kB] Get:2 http://ftp.fr.debian.org/debian/ jessie/main powermgmt-base all 1.31+nmu1 [9,240 B] Fetched 118 kB in 0s (264 kB/s) Selecting previously unselected package hdparm. (Reading database ... 167600 files and directories currently installed.) Preparing to unpack .../hdparm_9.43-2_i386.deb ... Unpacking hdparm (9.43-2) ... Selecting previously unselected package powermgmt-base. Preparing to unpack .../powermgmt-base_1.31+nmu1_all.deb ... Unpacking powermgmt-base (1.31+nmu1) ... Processing triggers for systemd (215-17+deb8u2) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up hdparm (9.43-2) ... update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults Setting up powermgmt-base (1.31+nmu1) ... Processing triggers for systemd (215-17+deb8u2) ...
Exécutez maintenant la commandehdparm :
root@debian8:~# hdparm -t /dev/sda /dev/sda: Timing buffered disk reads: 228 MB in 3.13 seconds = 72.76 MB/sec
Au-dessous du rapport d'utilisation du CPU de la sortie de la commande iostat figure le rapport d'utilisation des périphériques. Ce dernier contient une ligne pour chaque périphérique disque du système et inclut les informations suivantes :
Les options de cette commande sont :
[root@centos7 ~]# iostat --help Usage: iostat [ options ] [ <interval> [ <count> ] ] Options are: [ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] [ -j { ID | LABEL | PATH | UUID | ... } ] [ [ -T ] -g <group_name> ] [ -p [ <device> [,...] | ALL ] ] [ <device> [...] | ALL ]
root@debian8:~# iostat --help Usage: iostat [ options ] [ <interval> [ <count> ] ] Options are: [ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] [ -j { ID | LABEL | PATH | UUID | ... } ] [ [ -T ] -g <group_name> ] [ -p [ <device> [,...] | ALL ] ] [ <device> [...] | ALL ]
La commande vmstat affiche des statistiques sur la mémoire, la pagination et la charge ponctuelle du processeur :
[root@centos7 ~]# vmstat 1 10 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 5 0 4600 352560 20 620332 0 0 114 37 157 236 9 3 88 0 0 1 0 4600 352736 20 620368 0 0 0 0 231 310 29 7 63 0 0 0 0 4600 352736 20 620368 0 0 0 0 223 318 32 7 60 0 0 1 0 4600 352776 20 620328 0 0 0 0 250 339 34 9 57 0 0 0 0 4600 352776 20 620328 0 0 0 0 215 285 30 9 61 0 0 0 0 4600 352776 20 620328 0 0 0 0 234 326 31 7 61 0 0 1 0 4600 352776 20 620328 0 0 0 0 219 306 31 8 62 0 0 0 0 4600 352776 20 620328 0 0 0 0 223 298 29 7 63 0 0 0 0 4600 352776 20 620328 0 0 0 0 223 314 32 7 60 0 0 1 0 4600 352776 20 620332 0 0 0 0 238 309 34 7 59 0 0
root@debian8:~# vmstat 1 10 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 2 0 4004 255664 19164 229560 0 0 92 33 159 722 27 6 66 1 0 0 0 4004 261608 19164 229584 0 0 0 0 156 861 51 8 41 0 0 0 0 4004 261608 19164 229584 0 0 0 0 146 1009 34 7 60 0 0 1 0 4004 258104 19164 229584 0 0 0 0 141 1021 32 8 59 0 0 0 0 4004 261608 19164 229584 0 0 0 0 133 724 31 7 62 0 0 0 0 4004 261616 19164 229584 0 0 0 0 141 1009 29 10 61 0 0 2 0 4004 258076 19164 229584 0 0 0 0 142 1033 33 7 60 0 0 0 0 4004 261560 19164 229584 0 0 0 20 139 746 31 6 62 0 0 0 0 4004 261332 19164 229584 0 0 0 0 140 988 32 9 60 0 0 1 0 4004 257984 19164 229584 0 0 0 0 136 980 34 5 61 0 0
La première ligne subdivise le champ en six catégories à savoir : processus, mémoire, swap, E/S, système et CPU sur lesquelles elle donne des statistiques. La seconde ligne identifie de manière encore plus détaillée chacun des champs, permettant ainsi de parcourir simplement et rapidement l'ensemble des données lors de la recherche de statistiques spécifiques.
Les champs relatifs aux processus sont les suivants :
Les champs relatifs à la mémoire sont les suivants :
Les champs relatifs au swap sont les suivants :
Les champs relatifs aux Entrées/Sorties (E/S) sont les suivants :
Les champs relatifs au système sont les suivants :
Les champs relatifs au CPU sont les suivants :
Les options de cette commande sont :
[root@centos7 ~]# vmstat --help Usage: vmstat [options] [delay [count]] Options: -a, --active active/inactive memory -f, --forks number of forks since boot -m, --slabs slabinfo -n, --one-header do not redisplay header -s, --stats event counter statistics -d, --disk disk statistics -D, --disk-sum summarize disk statistics -p, --partition <dev> partition specific statistics -S, --unit <char> define display unit -w, --wide wide output -t, --timestamp show timestamp -h, --help display this help and exit -V, --version output version information and exit For more details see vmstat(8).
root@debian8:~# vmstat --help Usage: vmstat [options] [delay [count]] Options: -a, --active active/inactive memory -f, --forks number of forks since boot -m, --slabs slabinfo -n, --one-header do not redisplay header -s, --stats event counter statistics -d, --disk disk statistics -D, --disk-sum summarize disk statistics -p, --partition <dev> partition specific statistics -S, --unit <char> define display unit -w, --wide wide output -h, --help display this help and exit -V, --version output version information and exit For more details see vmstat(8).
Important : Par défaut la commande vmstat affiche des informations depuis le démarrage du système.
La commande mpstat affiche des statistiques détaillées sur le CPU :
[root@centos7 ~]# mpstat Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:19:32 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 03:19:32 PM all 9.38 0.14 2.52 0.31 0.00 0.24 0.00 0.00 0.00 87.42
root@debian8:~# mpstat Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 09:54:31 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 09:54:31 AM all 27.49 0.00 5.59 0.77 0.00 0.22 0.00 0.00 0.00 65.92
Dans le cas où vous avez plusieurs processeurs ou coeurs, vous pouvez visualiser ces mêmes informations par unité de traitement :
[root@centos7 ~]# mpstat -P ALL Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:20:06 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 03:20:06 PM all 9.42 0.14 2.53 0.31 0.00 0.24 0.00 0.00 0.00 87.36 03:20:06 PM 0 9.42 0.14 2.53 0.31 0.00 0.24 0.00 0.00 0.00 87.36
root@debian8:~# mpstat -P ALL Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 09:54:59 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 09:54:59 AM all 27.50 0.00 5.59 0.77 0.00 0.22 0.00 0.00 0.00 65.92 09:54:59 AM 0 27.50 0.00 5.59 0.77 0.00 0.22 0.00 0.00 0.00 65.92
Pour afficher 5 jeux de statistiques à des intervales de 2 secondes pour tous les unités de traitement, il convient d'utiliser la commande suivante :
[root@centos7 ~]# mpstat -P ALL 2 5 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:20:43 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 03:20:45 PM all 27.46 0.00 7.04 0.00 0.00 0.00 0.00 0.00 0.00 65.49 03:20:45 PM 0 27.46 0.00 7.04 0.00 0.00 0.00 0.00 0.00 0.00 65.49 03:20:45 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 03:20:47 PM all 24.83 0.00 5.37 0.00 0.00 0.67 0.00 0.00 0.00 69.13 03:20:47 PM 0 24.83 0.00 5.37 0.00 0.00 0.67 0.00 0.00 0.00 69.13 03:20:47 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 03:20:49 PM all 17.95 0.00 4.49 0.00 0.00 0.00 0.00 0.00 0.00 77.56 03:20:49 PM 0 17.95 0.00 4.49 0.00 0.00 0.00 0.00 0.00 0.00 77.56 03:20:49 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 03:20:51 PM all 18.18 0.00 3.90 0.00 0.00 0.00 0.00 0.00 0.00 77.92 03:20:51 PM 0 18.18 0.00 3.90 0.00 0.00 0.00 0.00 0.00 0.00 77.92 03:20:51 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 03:20:53 PM all 24.14 0.00 6.21 0.00 0.00 0.00 0.00 0.00 0.00 69.66 03:20:53 PM 0 24.14 0.00 6.21 0.00 0.00 0.00 0.00 0.00 0.00 69.66 Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle Average: all 22.39 0.00 5.36 0.00 0.00 0.13 0.00 0.00 0.00 72.12 Average: 0 22.39 0.00 5.36 0.00 0.00 0.13 0.00 0.00 0.00 72.12
root@debian8:~# mpstat -P ALL 2 5 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 09:59:58 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 10:00:00 AM all 24.10 0.00 6.15 0.00 0.00 0.51 0.00 0.00 0.00 69.23 10:00:00 AM 0 24.10 0.00 6.15 0.00 0.00 0.51 0.00 0.00 0.00 69.23 10:00:00 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 10:00:02 AM all 87.06 0.00 11.76 0.00 0.00 0.00 0.00 0.00 0.00 1.18 10:00:02 AM 0 87.06 0.00 11.76 0.00 0.00 0.00 0.00 0.00 0.00 1.18 10:00:02 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 10:00:04 AM all 44.94 0.00 7.30 0.00 0.00 0.00 0.00 0.00 0.00 47.75 10:00:04 AM 0 44.94 0.00 7.30 0.00 0.00 0.00 0.00 0.00 0.00 47.75 10:00:04 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 10:00:06 AM all 36.32 0.00 6.32 0.00 0.00 0.00 0.00 0.00 0.00 57.37 10:00:06 AM 0 36.32 0.00 6.32 0.00 0.00 0.00 0.00 0.00 0.00 57.37 10:00:06 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 10:00:08 AM all 53.41 0.00 10.80 0.00 0.00 0.00 0.00 0.00 0.00 35.80 10:00:08 AM 0 53.41 0.00 10.80 0.00 0.00 0.00 0.00 0.00 0.00 35.80 Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle Average: all 48.18 0.00 8.36 0.00 0.00 0.11 0.00 0.00 0.00 43.34 Average: 0 48.18 0.00 8.36 0.00 0.00 0.11 0.00 0.00 0.00 43.34
Les options de cette commande sont :
[root@centos7 ~]# mpstat --help Usage: mpstat [ options ] [ <interval> [ <count> ] ] Options are: [ -A ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ] [ -P { <cpu> [,...] | ON | ALL } ]
root@debian8:~# mpstat --help Usage: mpstat [ options ] [ <interval> [ <count> ] ] Options are: [ -A ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ] [ -P { <cpu> [,...] | ON | ALL } ]
La commande sar permet de surveiller toutes les ressources du système selon l'option qui est passée en argument à la commande. Quelques options importantes sont :
Option | Description |
---|---|
-u | Pourcentage d'utilisation du CPU |
-q | Nombre de processus en attente |
-r | Utilisation de la mémoire centrale |
-w | Surveillance du swapping |
-p | Surveillance de la pagination |
-b | Utilisation des tampons |
-d | Utilisation des disques |
Sous RHEL/CentOS 7 la commande /usr/lib64/sa/sadc permet de collecter les informations :
[root@centos7 ~]# ls /usr/lib64/sa sa1 sa2 sadc
Sous Debian 8 la commande /usr/lib/sysstat/sadc permet de collecter les informations :
root@debian8:~# ls /usr/lib/sysstat/ debian-sa1 sa1 sa2 sadc
Les scripts /usr/lib/sa/sa1 et /usr/lib/sysstat/sa1 exécutent la commande sadc. Sous Debian 8, c'est le script debian-sa1 qui est appelé à la place de sa1 afin de rectifier une bogue dans ce dernier ( Bug#499461 ). Ce script, tout comme le script sa1, prend deux options :
Option | Description |
---|---|
-t | L'interval entre les collectes |
-n | Nombre de collectes |
Les scripts /usr/lib/sa/sa2 et /usr/lib/sysstat/sa2 exécutent la commande sar et consignent les informations dans un fichier au format /var/log/sa/sar<jj> ou /var/log/sysstat/sar<jj> selon la distribution.
Pour pouvoir fonctionner correctement, ces scripts doivent être appelés par cron.
Pour activer la collecte des données sous Debian 8, éditez le fichier /etc/default/sysstat ainsi :
root@debian8:~# cat /etc/default/sysstat # # Default settings for /etc/init.d/sysstat, /etc/cron.d/sysstat # and /etc/cron.daily/sysstat files # # Should sadc collect system activity informations? Valid values # are "true" and "false". Please do not put other values, they # will be overwritten by debconf! ENABLED="true"
Modifiez le fichier /etc/cron.d/sysstat ainsi :
[root@centos7 ~]# cat /etc/cron.d/sysstat # Run system activity accounting tool every 10 minutes # */10 * * * * root /usr/lib64/sa/sa1 1 1 */2 * * * * root /usr/lib64/sa/sa1 1 1 # 0 * * * * root /usr/lib64/sa/sa1 600 6 & # Generate a daily summary of process accounting at 23:53 53 23 * * * root /usr/lib64/sa/sa2 -A
root@debian8:~# cat /etc/cron.d/sysstat # The first element of the path is a directory where the debian-sa1 # script is located PATH=/usr/lib/sysstat:/usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin # Activity reports every 10 minutes everyday #5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 */2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 # Additional run at 23:59 to rotate the statistics file 59 23 * * * root command -v debian-sa1 > /dev/null && debian-sa1 60 2
Attendez deux minutes puis saisissez les commandes suivantes :
[root@centos7 ~]# sar Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 02:20:02 PM CPU %user %nice %system %iowait %steal %idle 02:30:01 PM all 12.95 0.01 3.36 0.01 0.00 83.67 02:40:01 PM all 27.64 0.50 7.84 0.06 0.00 63.96 02:50:01 PM all 11.56 2.46 4.59 1.18 0.00 80.21 03:00:01 PM all 0.45 0.01 0.64 0.03 0.00 98.88 03:10:01 PM all 0.38 0.01 0.61 0.01 0.00 98.98 03:20:01 PM all 25.80 0.02 6.68 0.85 0.00 66.66 03:28:02 PM all 21.59 0.06 6.84 0.21 0.00 71.31 03:30:01 PM all 22.88 0.01 5.76 0.00 0.00 71.35 03:32:01 PM all 11.34 0.01 2.99 0.11 0.00 85.55 Average: all 13.21 0.41 4.01 0.30 0.00 82.06
root@debian8:~# sar Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:35:01 PM CPU %user %nice %system %iowait %steal %idle 01:40:01 PM all 23.84 0.00 4.69 0.11 0.00 71.36 Average: all 23.84 0.00 4.69 0.11 0.00 71.36
[root@centos7 ~]# sar -u 5 3 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:34:01 PM CPU %user %nice %system %iowait %steal %idle 03:34:06 PM all 29.73 0.00 14.19 0.00 0.00 56.08 03:34:11 PM all 17.62 0.00 4.40 0.00 0.00 77.98 03:34:16 PM all 4.75 0.00 1.30 0.00 0.00 93.95 Average: all 15.55 0.00 5.68 0.00 0.00 78.78
root@debian8:~# sar -u 5 3 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:41:52 PM CPU %user %nice %system %iowait %steal %idle 01:41:57 PM all 11.29 0.00 4.31 0.00 0.00 84.39 01:42:02 PM all 11.02 0.00 4.78 0.00 0.00 84.20 01:42:07 PM all 6.79 0.00 1.85 2.47 0.00 88.89 Average: all 9.70 0.00 3.65 0.83 0.00 85.83
[root@centos7 ~]# sar -r 5 3 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:34:48 PM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty 03:34:53 PM 137708 1653916 92.31 20 561940 2950052 60.66 776232 539396 12 03:34:58 PM 130988 1660636 92.69 20 566552 3000196 61.69 779820 542436 20 03:35:03 PM 131360 1660264 92.67 20 566584 2999016 61.66 779288 542472 48 Average: 133352 1658272 92.56 20 565025 2983088 61.33 778447 541435 27
root@debian8:~# sar -r 5 3 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:42:53 PM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty 01:42:58 PM 221948 809916 78.49 38732 244904 2126568 71.28 485024 267320 20 01:43:03 PM 221892 809972 78.50 38740 244904 2126568 71.28 485044 267316 176 01:43:08 PM 221912 809952 78.49 38748 244904 2126568 71.28 485052 267316 224 Average: 221917 809947 78.49 38740 244904 2126568 71.28 485040 267317 140
[root@centos7 ~]# sar -w 5 3 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:35:51 PM proc/s cswch/s 03:35:56 PM 0.00 608.04 03:36:01 PM 1.06 531.75 03:36:06 PM 25.94 1226.28 Average: 8.36 767.19
root@debian8:~# sar -w 5 3 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:43:54 PM proc/s cswch/s 01:43:59 PM 0.00 539.92 01:44:04 PM 1.24 599.18 01:44:09 PM 0.00 317.45 Average: 0.41 485.32
[root@centos7 ~]# sar -b 5 3 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:36:09 PM tps rtps wtps bread/s bwrtn/s 03:36:14 PM 0.00 0.00 0.00 0.00 0.00 03:36:19 PM 0.00 0.00 0.00 0.00 0.00 03:36:24 PM 2.32 0.00 2.32 0.00 31.79 Average: 0.89 0.00 0.89 0.00 12.25
root@debian8:~# sar -b 5 3 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:44:36 PM tps rtps wtps bread/s bwrtn/s 01:44:41 PM 2.44 0.00 2.44 0.00 30.16 01:44:46 PM 0.00 0.00 0.00 0.00 0.00 01:44:51 PM 0.00 0.00 0.00 0.00 0.00 Average: 0.78 0.00 0.78 0.00 9.64
[root@centos7 ~]# sar -d 5 3 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:36:46 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 03:36:51 PM dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 03:36:51 PM dev8-0 0.31 0.00 2.45 8.00 0.00 0.00 0.00 0.00 03:36:51 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 03:36:56 PM dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 03:36:56 PM dev8-0 4.31 0.00 55.38 12.86 0.04 9.36 1.93 0.83 03:36:56 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 03:37:01 PM dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 03:37:01 PM dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util Average: dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Average: dev8-0 1.49 0.00 18.63 12.53 0.01 8.73 1.80 0.27
root@debian8:~# sar -d 5 3 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:44:48 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 01:44:53 PM dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 01:44:53 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 01:44:58 PM dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 01:44:58 PM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 01:45:03 PM dev8-0 1.28 0.00 23.98 18.67 0.00 2.00 2.00 0.26 Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util Average: dev8-0 0.43 0.00 7.97 18.67 0.00 2.00 2.00 0.09
[root@centos7 ~]# sar -p 5 3 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:37:16 PM CPU %user %nice %system %iowait %steal %idle 03:37:21 PM all 38.30 0.00 7.31 0.00 0.00 54.39 03:37:26 PM all 45.81 0.00 9.58 0.00 0.00 44.61 03:37:31 PM all 33.33 0.00 7.67 0.00 0.00 59.00 Average: all 39.11 0.00 8.18 0.00 0.00 52.71
root@debian8:~# sar -p 5 3 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:45:23 PM CPU %user %nice %system %iowait %steal %idle 01:45:28 PM all 59.87 0.00 11.28 0.00 0.00 28.85 01:45:33 PM all 48.01 0.00 9.43 1.26 0.00 41.30 01:45:38 PM all 45.91 0.00 9.70 0.00 0.00 44.40 Average: all 51.21 0.00 10.13 0.43 0.00 38.23
[root@centos7 ~]# sar -v 5 3 Linux 3.10.0-229.4.2.el7.x86_64 (centos7.fenestros.loc) 11/02/2015 _x86_64_ (1 CPU) 03:38:44 PM dentunusd file-nr inode-nr pty-nr 03:38:49 PM 136266 5792 122548 2 03:38:54 PM 136266 5792 122548 2 03:38:59 PM 136266 5792 122548 2 Average: 136266 5792 122548 2
root@debian8:~# sar -v 5 3 Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) 01:45:58 PM dentunusd file-nr inode-nr pty-nr 01:46:03 PM 26140 4576 26525 2 01:46:08 PM 26140 4576 26525 2 01:46:13 PM 26140 4576 26525 2 Average: 26140 4576 26525 2
Les options de cette commande sont :
[root@centos7 ~]# sar --help Usage: sar [ options ] [ <interval> [ <count> ] ] Options are: [ -A ] [ -B ] [ -b ] [ -C ] [ -d ] [ -H ] [ -h ] [ -p ] [ -q ] [ -R ] [ -r ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ] [ -w ] [ -y ] [ -I { <int> [,...] | SUM | ALL | XALL } ] [ -P { <cpu> [,...] | ALL } ] [ -m { <keyword> [,...] | ALL } ] [ -n { <keyword> [,...] | ALL } ] [ -j { ID | LABEL | PATH | UUID | ... } ] [ -f [ <filename> ] | -o [ <filename> ] | -[0-9]+ ] [ -i <interval> ] [ -s [ <hh:mm:ss> ] ] [ -e [ <hh:mm:ss> ] ]
root@debian8:~# sar --help Usage: sar [ options ] [ <interval> [ <count> ] ] Options are: [ -A ] [ -B ] [ -b ] [ -C ] [ -D ] [ -d ] [ -F ] [ -H ] [ -h ] [ -p ] [ -q ] [ -R ] [ -r ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ] [ -w ] [ -y ] [ -I { <int> [,...] | SUM | ALL | XALL } ] [ -P { <cpu> [,...] | ALL } ] [ -m { <keyword> [,...] | ALL } ] [ -n { <keyword> [,...] | ALL } ] [ -j { ID | LABEL | PATH | UUID | ... } ] [ -f [ <filename> ] | -o [ <filename> ] | -[0-9]+ ] [ -i <interval> ] [ -s [ <hh:mm:ss> ] ] [ -e [ <hh:mm:ss> ] ]
Dans ce cas utilisez les commandes suivantes :
Dans ce cas utilisez les commandes suivantes :
Utilisez la commande :
L'USB (Universal Serial Bus) est un bus de données qui peut offrir des taux de transfert jusqu'à 480Mb/s sous la version 2.0 et jusqu'à 4.8 Gb/s sous la version 3.0. Les modules nécessaires pour les contrôleurs USB sont :
Version USB | Module | Nom Complet |
---|---|---|
1.0\1.1 | UHCI | Universal Controller Host Interface |
OHCI | Open Controller Host Interface | |
2.0 | EHCI | Enhanced Host Controller Interface |
3.0 | XHCI | Extensible Host Controller Interface |
Le tableau suivant liste les modules courrament chargés en fonction du périphérique utilisé :
Module | Type de Périphérique |
---|---|
usb_storage | Supports de masse |
usbhid | Periphériques HID (Human Interface Device) |
snd-usb-audio | Cartes son usb |
usbvidéo | Cartes vidéo et d'acquisition |
irda-usb | Périphériques infrarouges |
usbnet | Cartes réseaux usb |
Les modules peuvent être chargés par un des moyens suivants :
A faire : Branchez une clef USB avant de continuer. Si vous utilisez VirtualBox, activez la clef dans votre machine virtuelle grâce aux menus Périphériques > Périphériques USB > le_nom_de_votre_clef.
Depuis le noyau Linux 2.6 Linux est capable de détecter des périphériques branchés à chaud. Cette technologie s'appelle le hotplugging. Le hotplugging est obtenu grâce à l'utilisation de trois composants :
Les rôles de chaque composant sont les suivants :
Lors de démarrage de Linux, Udev joue un rôle important :
Udev repose sur le filesystem sysfs monté sur /sys qui permet de rendre les périphériques visibles à Udev dans l'User Space. Par exemple, lors du branchement d'une clé USB, Udev crée /dev/sdb1 automatiquement et utilise les informations contenues dans le fichier /lib/modules/`uname -r`/modules.alias pour trouver le pilote nécessaire :
Le fichier de configuration principal d'Udev est /etc/udev/udev.conf :
[root@centos7 ~]# cat /etc/udev/udev.conf # see udev(7) for details #udev_log="info"
root@debian8:~# cat /etc/udev/udev.conf # see udev(7) for details # # udevd is started in the initramfs, so when this file is modified the # initramfs should be rebuilt. #udev_log="info"
Les fichiers de règles se trouvent dans /lib/udev/rules.d/ :
[root@centos7 ~]# ls /lib/udev/rules.d/ 10-dm.rules 61-gnome-bluetooth-rfkill.rules 77-mm-ericsson-mbm.rules 90-iprutils.rules 11-dm-lvm.rules 62-multipath.rules 77-mm-huawei-net-port-types.rules 90-pulseaudio.rules 11-dm-mpath.rules 63-md-raid-arrays.rules 77-mm-longcheer-port-types.rules 90-vconsole.rules 13-dm-disk.rules 64-btrfs.rules 77-mm-nokia-port-types.rules 91-drm-modeset.rules 40-libgphoto2.rules 65-libwacom.rules 77-mm-pcmcia-device-blacklist.rules 95-cd-devices.rules 40-redhat.rules 65-md-incremental.rules 77-mm-platform-serial-whitelist.rules 95-dm-notify.rules 40-usb_modeswitch.rules 65-sane-backends.rules 77-mm-simtech-port-types.rules 95-udev-late.rules 42-usb-hid-pm.rules 69-cd-sensors.rules 77-mm-telit-port-types.rules 95-upower-battery-recall-dell.rules 50-rbd.rules 69-dm-lvm-metad.rules 77-mm-usb-device-blacklist.rules 95-upower-battery-recall-fujitsu.rules 50-udev-default.rules 69-libmtp.rules 77-mm-usb-serial-adapters-greylist.rules 95-upower-battery-recall-gateway.rules 56-hpmud.rules 69-xorg-vmmouse.rules 77-mm-x22x-port-types.rules 95-upower-battery-recall-ibm.rules 60-alias-kmsg.rules 70-power-switch.rules 77-mm-zte-port-types.rules 95-upower-battery-recall-lenovo.rules 60-cdrom_id.rules 70-printers.rules 77-nm-olpc-mesh.rules 95-upower-battery-recall-toshiba.rules 60-fprint-autosuspend.rules 70-spice-vdagentd.rules 78-sound-card.rules 95-upower-csr.rules 60-keyboard.rules 70-touchpad-quirks.rules 80-drivers.rules 95-upower-hid.rules 60-net.rules 70-uaccess.rules 80-kvm.rules 95-upower-wup.rules 60-persistent-alsa.rules 70-wacom.rules 80-mm-candidate.rules 97-bluetooth-serial.rules 60-persistent-input.rules 71-biosdevname.rules 80-net-name-slot.rules 98-kexec.rules 60-persistent-serial.rules 71-seat.rules 80-udisks2.rules 98-rdma.rules 60-persistent-storage.rules 73-idrac.rules 81-kvm-rhel.rules 99-qemu-guest-agent.rules 60-persistent-storage-tape.rules 73-seat-late.rules 85-regulatory.rules 99-systemd.rules 60-persistent-v4l.rules 75-net-description.rules 85-usbmuxd.rules 60-raw.rules 75-probe_mtd.rules 90-alsa-restore.rules 61-accelerometer.rules 75-tty-description.rules 90-alsa-tools-firmware.rules
root@debian8:~# ls /lib/udev/rules.d/ 39-usbmuxd.rules 60-persistent-serial.rules 75-net-description.rules 78-sound-card.rules 40-usb-media-players.rules 60-persistent-storage-dm.rules 75-persistent-net-generator.rules 80-drivers.rules 40-usb_modeswitch.rules 60-persistent-storage.rules 75-probe_mtd.rules 80-mm-candidate.rules 42-usb-hid-pm.rules 60-persistent-storage-tape.rules 75-tty-description.rules 80-net-setup-link.rules 50-bluetooth-hci-auto-poweron.rules 60-persistent-v4l.rules 77-mm-cinterion-port-types.rules 80-networking.rules 50-firmware.rules 61-accelerometer.rules 77-mm-ericsson-mbm.rules 80-udisks2.rules 50-udev-default.rules 61-gnome-bluetooth-rfkill.rules 77-mm-huawei-net-port-types.rules 85-hdparm.rules 55-dm.rules 61-gnome-settings-daemon-rfkill.rules 77-mm-longcheer-port-types.rules 85-hplj10xx.rules 56-hpmud.rules 64-btrfs.rules 77-mm-mtk-port-types.rules 85-hwclock.rules 60-cdrom_id.rules 64-xorg-xkb.rules 77-mm-nokia-port-types.rules 85-regulatory.rules 60-crda.rules 69-cd-sensors.rules 77-mm-pcmcia-device-blacklist.rules 90-alsa-restore.rules 60-drm.rules 69-libmtp.rules 77-mm-platform-serial-whitelist.rules 90-libgpod.rules 60-fuse.rules 69-wacom.rules 77-mm-qdl-device-blacklist.rules 90-pulseaudio.rules 60-gnupg.rules 69-xorg-vmmouse.rules 77-mm-simtech-port-types.rules 95-cd-devices.rules 60-keyboard.rules 70-power-switch.rules 77-mm-telit-port-types.rules 95-udev-late.rules 60-libgphoto2-6.rules 70-printers.rules 77-mm-usb-device-blacklist.rules 95-upower-csr.rules 60-libsane.rules 70-uaccess.rules 77-mm-usb-serial-adapters-greylist.rules 95-upower-hid.rules 60-open-vm-tools.rules 71-seat.rules 77-mm-x22x-port-types.rules 95-upower-wup.rules 60-persistent-alsa.rules 73-idrac.rules 77-mm-zte-port-types.rules 97-hid2hci.rules 60-persistent-input.rules 73-seat-late.rules 77-nm-olpc-mesh.rules 99-systemd.rules
Important : Il vous est possible d'ajouter des règles si besoin est. Dans ce cas, créez un fichier 99-local.rules est éditez-le au lieu d'éditer les fichiers existants.
Comme indique le nom de chaque fichier, le contenu est composé de règles à l'attention d'udev. Le fichier des règles par défaut est le 50-udev-default.rules :
[root@centos7 ~]# cat /lib/udev/rules.d/50-udev-default.rules | more # do not edit this file, it will be overwritten on update SUBSYSTEM=="virtio-ports", KERNEL=="vport*", ATTR{name}=="?*", SYMLINK+="virtio-ports/$attr{name}" # select "system RTC" or just use the first one SUBSYSTEM=="rtc", ATTR{hctosys}=="1", SYMLINK+="rtc" SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb" SUBSYSTEM=="input", ENV{ID_INPUT}=="", IMPORT{builtin}="input_id" ENV{MODALIAS}!="", IMPORT{builtin}="hwdb --subsystem=$env{SUBSYSTEM}" ACTION!="add", GOTO="default_permissions_end" SUBSYSTEM=="tty", KERNEL=="ptmx", GROUP="tty", MODE="0666" SUBSYSTEM=="tty", KERNEL=="tty", GROUP="tty", MODE="0666" SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="tty", KERNEL=="sclp_line[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="tty", KERNEL=="ttysclp[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="tty", KERNEL=="3270/tty[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="vc", KERNEL=="vcs*|vcsa*", GROUP="tty" KERNEL=="tty[A-Z]*[0-9]|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP="dialout" SUBSYSTEM=="mem", KERNEL=="mem|kmem|port", GROUP="kmem", MODE="0640" SUBSYSTEM=="input", KERNEL=="js[0-9]*", MODE="0664" SUBSYSTEM=="video4linux", GROUP="video" SUBSYSTEM=="misc", KERNEL=="agpgart", GROUP="video" --More--
root@debian8:~# cat /lib/udev/rules.d/50-udev-default.rules | more # do not edit this file, it will be overwritten on update SUBSYSTEM=="virtio-ports", KERNEL=="vport*", ATTR{name}=="?*", SYMLINK+="virtio-ports/$attr{name}" # select "system RTC" or just use the first one SUBSYSTEM=="rtc", ATTR{hctosys}=="1", SYMLINK+="rtc" SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb" SUBSYSTEM=="input", ENV{ID_INPUT}=="", IMPORT{builtin}="input_id" ENV{MODALIAS}!="", IMPORT{builtin}="hwdb --subsystem=$env{SUBSYSTEM}" ACTION!="add", GOTO="default_permissions_end" SUBSYSTEM=="tty", KERNEL=="ptmx", GROUP="tty", MODE="0666" SUBSYSTEM=="tty", KERNEL=="tty", GROUP="tty", MODE="0666" SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="tty", KERNEL=="sclp_line[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="tty", KERNEL=="ttysclp[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="tty", KERNEL=="3270/tty[0-9]*", GROUP="tty", MODE="0620" SUBSYSTEM=="vc", KERNEL=="vcs*|vcsa*", GROUP="tty" KERNEL=="tty[A-Z]*[0-9]|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP="dialout" KERNEL=="mISDNtimer", GROUP="dialout" KERNEL=="mwave", GROUP="dialout" SUBSYSTEM=="mem", KERNEL=="mem|kmem|port", GROUP="kmem", MODE="0640" KERNEL=="nvram", GROUP="kmem", MODE="0640" SUBSYSTEM=="input", GROUP="input" SUBSYSTEM=="input", KERNEL=="js[0-9]*", MODE="0664" --More--
Chaque règle prend la forme suivante :
KEY, [KEY, …] NAME [, SYMLINK]
Chaque KEY est un champ au format type=valeur qui doit correspondre à un périphérique unique. La valeur de type peut prendre plusieurs formes :
Type | Description | Exemples |
---|---|---|
BUS | Type de bus | usb, scsi, ide |
KERNEL | Le nom par défault du périphérique donné par le noyau | hda, ttyUSB0, lp0 |
SUBSYSTEM | Le nom noyau du sous-système, généralement identique à la valeur du BUS | usb, scsi |
DRIVER | Le nom du pilote qui contrôle le périphérique | usb-storage |
ID | Le numéro du périphérique sur son bus | PCI bus id, USB id |
PLACE | Ne concerne que les périphériques USB et donne la position topologique du périphérique sur son bus | S/O |
SYSFS{filename} | Le nom du fichier dans /sys pour le périphérique. Ce fichier contient le fabricant, le label, le numéro de série et UUID du périphérique. La vérification de jusqu'à 5 fichiers est possible par règle | S/O |
PROGRAM | Ceci permet à Udev d'appeler un programme externe pour nommer un périphérique | S/O |
RESULT | Valeur à comparer au résultat de PROGRAM | S/O |
NAME et SYMLINK sont utilisées pour stipuler ce que Udev doit faire avec le périphérique :
Type | Description | Exemples |
---|---|---|
NAME | Le nome du nœud dans /dev | S/O |
SYMLINK | Le ou les lien(s) symbolique(s) qui pointe(nt) vers le NAME | S/O |
Pour obtenir de l'information sur un périphérique il convient d'utiliser la commande udevadm :
[root@centos7 ~]# udevadm info --query=all -n /dev/sda P: /devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda N: sda S: disk/by-id/ata-VBOX_HARDDISK_VBc40eec8a-49b6b6f3 E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VBc40eec8a-49b6b6f3 E: DEVNAME=/dev/sda E: DEVPATH=/devices/pci0000:00/0000:00:0d.0/ata3/host2/target2:0:0/2:0:0:0/block/sda E: DEVTYPE=disk E: ID_ATA=1 E: ID_ATA_FEATURE_SET_PM=1 E: ID_ATA_FEATURE_SET_PM_ENABLED=1 E: ID_ATA_SATA=1 E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1 E: ID_ATA_WRITE_CACHE=1 E: ID_ATA_WRITE_CACHE_ENABLED=1 E: ID_BUS=ata E: ID_MODEL=VBOX_HARDDISK E: ID_MODEL_ENC=VBOX\x20HARDDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 E: ID_PART_TABLE_TYPE=dos E: ID_REVISION=1.0 E: ID_SERIAL=VBOX_HARDDISK_VBc40eec8a-49b6b6f3 E: ID_SERIAL_SHORT=VBc40eec8a-49b6b6f3 E: ID_TYPE=disk E: MAJOR=8 E: MINOR=0 E: MPATH_SBIN_PATH=/sbin E: SUBSYSTEM=block E: TAGS=:systemd: E: USEC_INITIALIZED=957366
root@debian8:~# udevadm info --query=all -n /dev/sda P: /devices/pci0000:00/0000:00:0d.0/ata1/host0/target0:0:0/0:0:0:0/block/sda N: sda S: disk/by-id/ata-VBOX_HARDDISK_VB823e2981-6120fc97 E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VB823e2981-6120fc97 E: DEVNAME=/dev/sda E: DEVPATH=/devices/pci0000:00/0000:00:0d.0/ata1/host0/target0:0:0/0:0:0:0/block/sda E: DEVTYPE=disk E: ID_ATA=1 E: ID_ATA_FEATURE_SET_PM=1 E: ID_ATA_FEATURE_SET_PM_ENABLED=1 E: ID_ATA_SATA=1 E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1 E: ID_ATA_WRITE_CACHE=1 E: ID_ATA_WRITE_CACHE_ENABLED=1 E: ID_BUS=ata E: ID_MODEL=VBOX_HARDDISK E: ID_MODEL_ENC=VBOX\x20HARDDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 E: ID_PART_TABLE_TYPE=dos E: ID_PART_TABLE_UUID=2d923156 E: ID_REVISION=1.0 E: ID_SERIAL=VBOX_HARDDISK_VB823e2981-6120fc97 E: ID_SERIAL_SHORT=VB823e2981-6120fc97 E: ID_TYPE=disk E: MAJOR=8 E: MINOR=0 E: SUBSYSTEM=block E: TAGS=:systemd: E: USEC_INITIALIZED=9411
Les options de la commande udevadm sont :
[root@centos7 ~]# udevadm --help Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS] info query sysfs or the udev database trigger request events from the kernel settle wait for the event queue to finish control control the udev daemon monitor listen to kernel and udev events hwdb maintain the hardware database index test test an event run test-builtin test a built-in command [root@centos7 ~]# udevadm info --help Usage: udevadm info OPTIONS --query=<type> query device information: name name of device node symlink pointing to node path sys device path property the device properties all all values --path=<syspath> sys device path used for query or attribute walk --name=<name> node or symlink name used for query or attribute walk --root prepend dev directory to path names --attribute-walk print all key matches while walking along the chain of parent devices --device-id-of-file=<file> print major:minor of device containing this file --export export key/value pairs --export-prefix export the key name with a prefix --export-db export the content of the udev database --cleanup-db cleanup the udev database --help
root@debian8:~# udevadm --help Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS] info query sysfs or the udev database trigger request events from the kernel settle wait for pending udev events control control the udev daemon monitor listen to kernel and udev events hwdb maintain the hardware database index test test an event run test-builtin test a built-in command root@debian8:~# udevadm info --help Usage: udevadm info [OPTIONS] [DEVPATH|FILE] -q,--query=TYPE query device information: name name of device node symlink pointing to node path sys device path property the device properties all all values -p,--path=SYSPATH sys device path used for query or attribute walk -n,--name=NAME node or symlink name used for query or attribute walk -r,--root prepend dev directory to path names -a,--attribute-walk print all key matches walking along the chain of parent devices -d,--device-id-of-file=FILE print major:minor of device containing this file -x,--export export key/value pairs -P,--export-prefix export the key name with a prefix -e,--export-db export the content of the udev database -c,--cleanup-db cleanup the udev database --version print version of the program -h,--help print this message
Le système de fichiers virtuel /sys a été introduit avec le noyau Linux 2.6. Son rôle est de décrire le matériel pour udev.
Saisissez la commande suivante :
[root@centos7 ~]# ls -l /sys total 0 drwxr-xr-x. 2 root root 0 Oct 28 09:40 block drwxr-xr-x. 24 root root 0 Oct 28 09:40 bus drwxr-xr-x. 45 root root 0 Oct 28 09:40 class drwxr-xr-x. 4 root root 0 Oct 28 09:40 dev drwxr-xr-x. 11 root root 0 Oct 28 09:40 devices drwxr-xr-x. 5 root root 0 Oct 28 09:40 firmware drwxr-xr-x. 6 root root 0 Oct 28 09:40 fs drwxr-xr-x. 2 root root 0 Oct 28 09:40 hypervisor drwxr-xr-x. 9 root root 0 Oct 28 09:40 kernel drwxr-xr-x. 146 root root 0 Oct 28 09:40 module drwxr-xr-x. 2 root root 0 Oct 28 09:40 power
root@debian8:~# ls -l /sys total 0 drwxr-xr-x 2 root root 0 Nov 2 14:01 block drwxr-xr-x 24 root root 0 Nov 2 14:01 bus drwxr-xr-x 42 root root 0 Nov 2 14:01 class drwxr-xr-x 4 root root 0 Nov 2 14:01 dev drwxr-xr-x 13 root root 0 Nov 2 14:01 devices drwxr-xr-x 5 root root 0 Nov 2 14:03 firmware drwxr-xr-x 6 root root 0 Nov 2 14:01 fs drwxr-xr-x 2 root root 0 Nov 2 14:01 hypervisor drwxr-xr-x 7 root root 0 Nov 2 14:01 kernel drwxr-xr-x 105 root root 0 Nov 2 14:01 module drwxr-xr-x 2 root root 0 Nov 2 14:01 power
Chaque répertoire contient des informations :
Pour illustrer ceci, saisissez la commande suivante :
[root@centos7 ~]# cat /sys/block/sda/sda1/size 409600
root@debian8:~# cat /sys/block/sda/sda1/size 19529728
Ce chiffre correspond aux nombre de secteurs.
Les ressources disponibles aux utilisateurs peuvent être limitées par l'utilisation de la commande ulimit.
La commande ulimit gère deux types de limite, la limite hard en utilisant l'option -H et la limite soft en utilisant l'option -S. Seul root peut positionner une limite hard et ceci à condition que la limite ne dépasse pas les ressources réelles.
La limite soft est la limite imposée à l'utilisateur par défaut tandis que la limite hard est la limite que l'utilisateur peut atteindre en utilisant la commande ulimit lui-même.
L'utilisateur root peut paramétrer les limites accordées en éditant la fichier /etc/security/limits.conf :
[root@centos7 ~]# cat /etc/security/limits.conf # /etc/security/limits.conf # #This file sets the resource limits for the users logged in via PAM. #It does not affect resource limits of the system services. # #Also note that configuration files in /etc/security/limits.d directory, #which are read in alphabetical order, override the settings in this #file in case the domain is the same or more specific. #That means for example that setting a limit for wildcard domain here #can be overriden with a wildcard setting in a config file in the #subdirectory, but a user specific setting here can be overriden only #with a user specific setting in the subdirectory. # #Each line describes a limit for a user in the form: # #<domain> <type> <item> <value> # #Where: #<domain> can be: # - a user name # - a group name, with @group syntax # - the wildcard *, for default entry # - the wildcard %, can be also used with %group syntax, # for maxlogin limit # #<type> can have the two values: # - "soft" for enforcing the soft limits # - "hard" for enforcing hard limits # #<item> can be one of the following: # - core - limits the core file size (KB) # - data - max data size (KB) # - fsize - maximum filesize (KB) # - memlock - max locked-in-memory address space (KB) # - nofile - max number of open file descriptors # - rss - max resident set size (KB) # - stack - max stack size (KB) # - cpu - max CPU time (MIN) # - nproc - max number of processes # - as - address space limit (KB) # - maxlogins - max number of logins for this user # - maxsyslogins - max number of logins on the system # - priority - the priority to run user process with # - locks - max number of file locks the user can hold # - sigpending - max number of pending signals # - msgqueue - max memory used by POSIX message queues (bytes) # - nice - max nice priority allowed to raise to values: [-20, 19] # - rtprio - max realtime priority # #<domain> <type> <item> <value> # #* soft core 0 #* hard rss 10000 #@student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #@student - maxlogins 4 # End of file
root@debian8:~# cat /etc/security/limits.conf # /etc/security/limits.conf # #Each line describes a limit for a user in the form: # #<domain> <type> <item> <value> # #Where: #<domain> can be: # - a user name # - a group name, with @group syntax # - the wildcard *, for default entry # - the wildcard %, can be also used with %group syntax, # for maxlogin limit # - NOTE: group and wildcard limits are not applied to root. # To apply a limit to the root user, <domain> must be # the literal username root. # #<type> can have the two values: # - "soft" for enforcing the soft limits # - "hard" for enforcing hard limits # #<item> can be one of the following: # - core - limits the core file size (KB) # - data - max data size (KB) # - fsize - maximum filesize (KB) # - memlock - max locked-in-memory address space (KB) # - nofile - max number of open files # - rss - max resident set size (KB) # - stack - max stack size (KB) # - cpu - max CPU time (MIN) # - nproc - max number of processes # - as - address space limit (KB) # - maxlogins - max number of logins for this user # - maxsyslogins - max number of logins on the system # - priority - the priority to run user process with # - locks - max number of file locks the user can hold # - sigpending - max number of pending signals # - msgqueue - max memory used by POSIX message queues (bytes) # - nice - max nice priority allowed to raise to values: [-20, 19] # - rtprio - max realtime priority # - chroot - change root to directory (Debian-specific) # #<domain> <type> <item> <value> # #* soft core 0 #root hard core 100000 #* hard rss 10000 #@student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #ftp - chroot /ftp #@student - maxlogins 4 # End of file
Important : La valeur de la limite peut être un nombre ou le mot unlimited.
Par exemple, si root inscrit les deux ligne suivantes dans le fichier /etc/security/limits.conf :
... trainee soft nofile 1024 trainee hard nofile 4096 ...
la limite du nombre de fichiers ouverts simultanément par trainee est de 1 024. Par contre, trainee a la possibilité d'augmenter cette limite jusqu'à 4 096 en utilisant la commande suivante :
$ ulimit -n 4096
Pour consulter la liste des limites actuelles, il convient d'utiliser la commande ulimit avec l'option -a :
[root@centos7 ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 6929 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 6929 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
root@debian8:~# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 7892 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 65536 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 7892 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
Les options de ulimit sont :
[root@centos7 ~]# help ulimit ulimit: ulimit [-SHacdefilmnpqrstuvx] [limit] Modify shell resource limits. Provides control over the resources available to the shell and processes it creates, on systems that allow such control. Options: -S use the `soft' resource limit -H use the `hard' resource limit -a all current limits are reported -b the socket buffer size -c the maximum size of core files created -d the maximum size of a process's data segment -e the maximum scheduling priority (`nice') -f the maximum size of files written by the shell and its children -i the maximum number of pending signals -l the maximum size a process may lock into memory -m the maximum resident set size -n the maximum number of open file descriptors -p the pipe buffer size -q the maximum number of bytes in POSIX message queues -r the maximum real-time scheduling priority -s the maximum stack size -t the maximum amount of cpu time in seconds -u the maximum number of user processes -v the size of virtual memory -x the maximum number of file locks If LIMIT is given, it is the new value of the specified resource; the special LIMIT values `soft', `hard', and `unlimited' stand for the current soft limit, the current hard limit, and no limit, respectively. Otherwise, the current value of the specified resource is printed. If no option is given, then -f is assumed. Values are in 1024-byte increments, except for -t, which is in seconds, -p, which is in increments of 512 bytes, and -u, which is an unscaled number of processes. Exit Status: Returns success unless an invalid option is supplied or an error occurs.
root@debian8:~# ulimit --help -su: ulimit: --: invalid option ulimit: usage: ulimit [-SHabcdefilmnpqrstuvxT] [limit] root@debian8:~# help ulimit ulimit: ulimit [-SHabcdefilmnpqrstuvxT] [limit] Modify shell resource limits. Provides control over the resources available to the shell and processes it creates, on systems that allow such control. Options: -S use the `soft' resource limit -H use the `hard' resource limit -a all current limits are reported -b the socket buffer size -c the maximum size of core files created -d the maximum size of a process's data segment -e the maximum scheduling priority (`nice') -f the maximum size of files written by the shell and its children -i the maximum number of pending signals -l the maximum size a process may lock into memory -m the maximum resident set size -n the maximum number of open file descriptors -p the pipe buffer size -q the maximum number of bytes in POSIX message queues -r the maximum real-time scheduling priority -s the maximum stack size -t the maximum amount of cpu time in seconds -u the maximum number of user processes -v the size of virtual memory -x the maximum number of file locks -T the maximum number of threads Not all options are available on all platforms. If LIMIT is given, it is the new value of the specified resource; the special LIMIT values `soft', `hard', and `unlimited' stand for the current soft limit, the current hard limit, and no limit, respectively. Otherwise, the current value of the specified resource is printed. If no option is given, then -f is assumed. Values are in 1024-byte increments, except for -t, which is in seconds, -p, which is in increments of 512 bytes, and -u, which is an unscaled number of processes. Exit Status: Returns success unless an invalid option is supplied or an error occurs.
<html>
Copyright © 2004-2015 Hugh Norris.<br><br> <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”><img alt=“Licence Creative Commons” style=“border-width:0” src=“http://i.creativecommons.org/l/by-nc-nd/3.0/fr/88x31.png” /></a><br />Ce(tte) oeuvre est mise à disposition selon les termes de la <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”>Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Pas de Modification 3.0 France</a>.
</html>