Table des matières

Niveau : Admin Junior Numéro de la Leçon Dernière Modification
2/4 <progrecss 11/12 style=inline /> 2020/01/30 03:28

Gestion des Paramètres du Matériel et les Ressources

Fichiers Spéciaux

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.

Consultez le contenu du répertoire /dev :

root@debian:~# ls -l /dev
total 0
drwxr-xr-x  2 root    root         300  7 avril 13:33 block
drwxr-xr-x  2 root    root          80  7 avril 13:33 bsg
lrwxrwxrwx  1 root    root           3  7 avril 13:33 cdrom -> sr0
drwxr-xr-x  2 root    root        2580  7 avril 13:33 char
crw-------  1 root    root      5,   1  7 avril 13:34 console
lrwxrwxrwx  1 root    root          11  7 avril 13:33 core -> /proc/kcore
crw-------  1 root    root     10,  62  7 avril 13:33 cpu_dma_latency
drwxr-xr-x  5 root    root         100  7 avril 13:33 disk
drwxr-xr-x  2 root    root          60  7 avril 13:33 dri
lrwxrwxrwx  1 root    root           3  7 avril 13:33 dvd -> sr0
lrwxrwxrwx  1 root    root          13  7 avril 13:33 fd -> /proc/self/fd
crw-rw-rw-  1 root    root      1,   7  7 avril 13:33 full
crw-rw----  1 root    fuse     10, 229  7 avril 13:33 fuse
crw-------  1 root    root     10, 228  7 avril 13:33 hpet
prw-------  1 root    root           0  7 avril 13:33 initctl
drwxr-xr-x  3 root    root         220  7 avril 13:33 input
crw-------  1 root    root      1,  11  7 avril 13:33 kmsg
srw-rw-rw-  1 root    root           0  7 avril 13:33 log
brw-rw----  1 root    disk      7,   0  7 avril 13:33 loop0
brw-rw----  1 root    disk      7,   1  7 avril 13:33 loop1
brw-rw----  1 root    disk      7,   2  7 avril 13:33 loop2
brw-rw----  1 root    disk      7,   3  7 avril 13:33 loop3
brw-rw----  1 root    disk      7,   4  7 avril 13:33 loop4
brw-rw----  1 root    disk      7,   5  7 avril 13:33 loop5
brw-rw----  1 root    disk      7,   6  7 avril 13:33 loop6
brw-rw----  1 root    disk      7,   7  7 avril 13:33 loop7
lrwxrwxrwx  1 root    root           9  7 avril 13:33 MAKEDEV -> /bin/true
crw-------  1 root    root     10, 227  7 avril 13:33 mcelog
crw-r-----  1 root    kmem      1,   1  7 avril 13:33 mem
drwxr-xr-x  2 root    root          60  7 avril 13:33 net
crw-------  1 root    root     10,  61  7 avril 13:33 network_latency
crw-------  1 root    root     10,  60  7 avril 13:33 network_throughput
crw-rw-rw-  1 root    root      1,   3  7 avril 13:33 null
crw-r-----  1 root    kmem      1,   4  7 avril 13:33 port
crw-------  1 root    root    108,   0  7 avril 13:33 ppp
crw-------  1 root    root     10,   1  7 avril 13:33 psaux
crw-rw-rw-  1 root    root      5,   2  8 avril 13:05 ptmx
drwxr-xr-x  2 root    root           0  7 avril 13:33 pts
crw-rw-rw-  1 root    root      1,   8  7 avril 13:33 random
crw-rw-r--+ 1 root    root     10,  57  7 avril 13:33 rfkill
lrwxrwxrwx  1 root    root           4  7 avril 13:33 root -> sda1
lrwxrwxrwx  1 root    root           4  7 avril 13:33 rtc -> rtc0
crw-------  1 root    root    254,   0  7 avril 13:33 rtc0
lrwxrwxrwx  1 root    root           3  7 avril 13:33 scd0 -> sr0
brw-rw----  1 root    disk      8,   0  7 avril 13:33 sda
brw-rw----  1 root    disk      8,   1  7 avril 13:33 sda1
brw-rw----  1 root    disk      8,   2  7 avril 13:33 sda2
brw-rw----  1 root    disk      8,   5  7 avril 13:33 sda5
crw-------  1 root    root     21,   0  7 avril 13:33 sg0
crw-rw----  1 root    cdrom    21,   1  7 avril 13:33 sg1
drwxrwxrwt  2 root    root          40  8 avril 13:02 shm
crw-------  1 root    root     10, 231  7 avril 13:33 snapshot
drwxr-xr-x  3 root    root         180  7 avril 13:33 snd
lrwxrwxrwx  1 root    root          24  7 avril 13:33 sndstat -> /proc/asound/oss/sndstat
brw-rw----+ 1 root    cdrom    11,   0  7 avril 13:33 sr0
lrwxrwxrwx  1 root    root          15  7 avril 13:33 stderr -> /proc/self/fd/2
lrwxrwxrwx  1 root    root          15  7 avril 13:33 stdin -> /proc/self/fd/0
lrwxrwxrwx  1 root    root          15  7 avril 13:33 stdout -> /proc/self/fd/1
crw-rw-rw-  1 root    root      5,   0  7 avril 13:33 tty
crw-------  1 root    root      4,   0  7 avril 13:33 tty0
crw-------  1 root    root      4,   1  7 avril 13:34 tty1
crw-------  1 root    root      4,  10  7 avril 13:33 tty10
crw-------  1 root    root      4,  11  7 avril 13:33 tty11
crw-------  1 root    root      4,  12  7 avril 13:33 tty12
crw-------  1 root    root      4,  13  7 avril 13:33 tty13
crw-------  1 root    root      4,  14  7 avril 13:33 tty14
crw-------  1 root    root      4,  15  7 avril 13:33 tty15
crw-------  1 root    root      4,  16  7 avril 13:33 tty16
crw-------  1 root    root      4,  17  7 avril 13:33 tty17
crw-------  1 root    root      4,  18  7 avril 13:33 tty18
crw-------  1 root    root      4,  19  7 avril 13:33 tty19
crw-------  1 root    root      4,   2  7 avril 13:34 tty2
crw-------  1 root    root      4,  20  7 avril 13:33 tty20
crw-------  1 root    root      4,  21  7 avril 13:33 tty21
crw-------  1 root    root      4,  22  7 avril 13:33 tty22
crw-------  1 root    root      4,  23  7 avril 13:33 tty23
crw-------  1 root    root      4,  24  7 avril 13:33 tty24
crw-------  1 root    root      4,  25  7 avril 13:33 tty25
crw-------  1 root    root      4,  26  7 avril 13:33 tty26
crw-------  1 root    root      4,  27  7 avril 13:33 tty27
crw-------  1 root    root      4,  28  7 avril 13:33 tty28
crw-------  1 root    root      4,  29  7 avril 13:33 tty29
crw-------  1 root    root      4,   3  7 avril 13:34 tty3
crw-------  1 root    root      4,  30  7 avril 13:33 tty30
crw-------  1 root    root      4,  31  7 avril 13:33 tty31
crw-------  1 root    root      4,  32  7 avril 13:33 tty32
crw-------  1 root    root      4,  33  7 avril 13:33 tty33
crw-------  1 root    root      4,  34  7 avril 13:33 tty34
crw-------  1 root    root      4,  35  7 avril 13:33 tty35
crw-------  1 root    root      4,  36  7 avril 13:33 tty36
crw-------  1 root    root      4,  37  7 avril 13:33 tty37
crw-------  1 root    root      4,  38  7 avril 13:33 tty38
crw-------  1 root    root      4,  39  7 avril 13:33 tty39
crw-------  1 root    root      4,   4  7 avril 13:34 tty4
crw-------  1 root    root      4,  40  7 avril 13:33 tty40
crw-------  1 root    root      4,  41  7 avril 13:33 tty41
crw-------  1 root    root      4,  42  7 avril 13:33 tty42
crw-------  1 root    root      4,  43  7 avril 13:33 tty43
crw-------  1 root    root      4,  44  7 avril 13:33 tty44
crw-------  1 root    root      4,  45  7 avril 13:33 tty45
crw-------  1 root    root      4,  46  7 avril 13:33 tty46
crw-------  1 root    root      4,  47  7 avril 13:33 tty47
crw-------  1 root    root      4,  48  7 avril 13:33 tty48
crw-------  1 root    root      4,  49  7 avril 13:33 tty49
crw-------  1 root    root      4,   5  7 avril 13:34 tty5
crw-------  1 root    root      4,  50  7 avril 13:33 tty50
crw-------  1 root    root      4,  51  7 avril 13:33 tty51
crw-------  1 root    root      4,  52  7 avril 13:33 tty52
crw-------  1 root    root      4,  53  7 avril 13:33 tty53
crw-------  1 root    root      4,  54  7 avril 13:33 tty54
crw-------  1 root    root      4,  55  7 avril 13:33 tty55
crw-------  1 root    root      4,  56  7 avril 13:33 tty56
crw-------  1 root    root      4,  57  7 avril 13:33 tty57
crw-------  1 root    root      4,  58  7 avril 13:33 tty58
crw-------  1 root    root      4,  59  7 avril 13:33 tty59
crw-------  1 root    root      4,   6  7 avril 13:34 tty6
crw-------  1 root    root      4,  60  7 avril 13:33 tty60
crw-------  1 root    root      4,  61  7 avril 13:33 tty61
crw-------  1 root    root      4,  62  7 avril 13:33 tty62
crw-------  1 root    root      4,  63  7 avril 13:33 tty63
crw-------  1 root    root      4,   7  7 avril 13:33 tty7
crw-------  1 root    root      4,   8  7 avril 13:33 tty8
crw-------  1 root    root      4,   9  7 avril 13:33 tty9
crw-rw----  1 root    dialout   4,  64  7 avril 13:33 ttyS0
crw-rw----  1 root    dialout   4,  65  7 avril 13:33 ttyS1
crw-rw----  1 root    dialout   4,  66  7 avril 13:33 ttyS2
crw-rw----  1 root    dialout   4,  67  7 avril 13:33 ttyS3
crw-rw-rw-  1 root    root      1,   9  7 avril 13:33 urandom
crw-rw----  1 vboxadd root     10,  59  7 avril 13:33 vboxguest
crw-rw-rw-  1 vboxadd root     10,  58  7 avril 13:33 vboxuser
crw-------  1 root    root      7,   0  7 avril 13:33 vcs
crw-------  1 root    root      7,   1  7 avril 13:33 vcs1
crw-------  1 root    root      7,   2  7 avril 13:33 vcs2
crw-------  1 root    root      7,   3  7 avril 13:33 vcs3
crw-------  1 root    root      7,   4  7 avril 13:33 vcs4
crw-------  1 root    root      7,   5  7 avril 13:33 vcs5
crw-------  1 root    root      7,   6  7 avril 13:33 vcs6
crw-------  1 root    root      7,   7  7 avril 13:33 vcs7
crw-------  1 root    root      7, 128  7 avril 13:33 vcsa
crw-------  1 root    root      7, 129  7 avril 13:33 vcsa1
crw-------  1 root    root      7, 130  7 avril 13:33 vcsa2
crw-------  1 root    root      7, 131  7 avril 13:33 vcsa3
crw-------  1 root    root      7, 132  7 avril 13:33 vcsa4
crw-------  1 root    root      7, 133  7 avril 13:33 vcsa5
crw-------  1 root    root      7, 134  7 avril 13:33 vcsa6
crw-------  1 root    root      7, 135  7 avril 13:33 vcsa7
crw-------  1 root    root     10,  63  7 avril 13:33 vga_arbiter
prw-r-----  1 root    adm            0  8 avril 13:05 xconsole
crw-rw-rw-  1 root    root      1,   5  7 avril 13:33 zero

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,   0  7 avril 13:33 sda
...
crw-rw-rw-  1 root    root      5,   0  7 avril 13:33 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 :

Commandes

La Commande lspci

Cette commande vous renseigne sur les adaptateurs reliés aux bus PCI, AGP et PCI express :

root@debian:~# 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:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0d.0 SATA controller: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller (rev 02)

Pour obtenir de l'information sur un adaptateur spécifique, il convient d'utilise la même commande avec l'option -v en spécifiant l'identifiant concerné :

root@debian:~# 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

ou :

root@debian:~# 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

Options de la commande

Les options de cette commande sont :

root@debian:~# 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

La Commande lsusb

Cette commande vous renseigne sur les adaptateurs reliés au bus usb :

root@debian:~# lsusb
Bus 002 Device 002: ID 80ee:0021  
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Pour obtenir de l'information sur un périphérique usb, il convient d'utiliser la même commande avec l'option -d en spécifiant l'identifiant concerné.

Options de la commande

Les options de cette commande sont :

root@debian:~# lsusb --help
lsusb: unrecognized option '--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
      Dump the physical USB device hierarchy as a tree
  -V, --version
      Show version of program

La Commande dmidecode

La commande dmidecode lit la table DMI (Desktop Management Interface) aussi appelée SMBIOS (System Management BIOS) et fourni les informations sur :

root@debian:~# dmidecode
# dmidecode 2.9
SMBIOS 2.5 present.
5 structures occupying 352 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: F6F1A48B-A77A-45C1-8480-75078321B051
	Wake-up Type: Power Switch
	SKU Number: Not Specified
	Family: Virtual Machine

Handle 0x0003, DMI type 126, 13 bytes
Inactive

Handle 0x0002, DMI type 126, 7 bytes
Inactive

Handle 0xFEFF, DMI type 127, 147 bytes
End Of Table

Options de la commande

Les options de cette commande sont :

root@debian:~# 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
 -V, --version          Display the version and exit

Répertoire /proc

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. Le répertoire /proc contient des fichiers pour nous renseigner sur le matériel présent dans la machine.

Répertoires

ide/scsi

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.

acpi

Ce répertoire contient des informations sur la gestion de l'énérgie, les températures, les vitesses de ventilateurs, la charge des batteries.

bus

Ce répertoire contient un sous-répertoire par bus.

net

Ce répertoire contient des informations sur le réseau.

sys

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

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@debian:~# cat /etc/sysctl.conf
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additonal 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
#
Options de la commande

Les options de la commande sysctl sont :

root@debian:~# sysctl --help
usage:  sysctl [-n] [-e] variable ... 
        sysctl [-n] [-e] [-q] -w variable=value ... 
        sysctl [-n] [-e] -a 
        sysctl [-n] [-e] [-q] -p <file>   (default /etc/sysctl.conf) 
        sysctl [-n] [-e] -A

<note important> Consultez la page de la traduction du manuel de sysctl ici pour comprendre la commande. </note>

Fichiers

Processeur

root@debian:~# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 37
model name	: Intel(R) Core(TM) i5 CPU       M 480  @ 2.67GHz
stepping	: 5
cpu MHz		: 2648.086
cache size	: 6144 KB
fdiv_bug	: no
hlt_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 syscall nx lm constant_tsc up pni monitor ssse3 lahf_lm
bogomips	: 5296.17
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

Interruptions système

root@debian:~# cat /proc/interrupts
            CPU0       
   0:         50   IO-APIC-edge      timer
   1:        295   IO-APIC-edge      i8042
   8:          0   IO-APIC-edge      rtc0
   9:          0   IO-APIC-fasteoi   acpi
  12:        517   IO-APIC-edge      i8042
  14:       9705   IO-APIC-edge      ata_piix
  15:       1966   IO-APIC-edge      ata_piix
  19:       2015   IO-APIC-fasteoi   ehci_hcd:usb1, eth1
  20:      22428   IO-APIC-fasteoi   vboxguest
  21:         47   IO-APIC-fasteoi   ahci, Intel 82801AA-ICH
  22:         26   IO-APIC-fasteoi   ohci_hcd:usb2
 NMI:          0   Non-maskable interrupts
 LOC:      96590   Local timer interrupts
 SPU:          0   Spurious interrupts
 PMI:          0   Performance monitoring interrupts
 PND:          0   Performance pending work
 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:          2   Machine check polls
 ERR:          0
 MIS:          0

Canaux DMA

root@debian:~# cat /proc/dma
 4: cascade

Plages d'entrée/sortie

root@debian:~# cat /proc/ioports
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
4004-4005 : ACPI PM1a_CNT_BLK
4008-400b : ACPI PM_TMR
4020-4021 : ACPI GPE0_BLK
d000-d00f : 0000:00:01.1
  d000-d00f : ata_piix
d010-d017 : 0000:00:03.0
  d010-d017 : e1000
d020-d03f : 0000:00:04.0
d100-d1ff : 0000:00:05.0
  d100-d1ff : Intel 82801AA-ICH
d200-d23f : 0000:00:05.0
  d200-d23f : Intel 82801AA-ICH
d240-d247 : 0000:00:0d.0
  d240-d247 : ahci
d250-d257 : 0000:00:0d.0
  d250-d257 : ahci
d260-d26f : 0000:00:0d.0
  d260-d26f : ahci

Périphériques

root@debian:~# 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
216 rfcomm
226 drm
252 hidraw
253 bsg
254 rtc

Block devices:
259 blkext
  7 loop
  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

Modules

root@debian:~# cat /proc/modules
cpufreq_userspace 1480 0 - Live 0xf7cda000
cpufreq_conservative 4018 0 - Live 0xf7cc9000
cpufreq_stats 1940 0 - Live 0xf7cb4000
cpufreq_powersave 602 0 - Live 0xf7ca7000
vboxvideo 1073 1 - Live 0xf7c80000
drm 112088 2 vboxvideo, Live 0xf7d14000
ppdev 4058 0 - Live 0xf7c36000
lp 5570 0 - Live 0xf7c2d000
sco 5857 2 - Live 0xf7c1f000
bridge 33019 0 - Live 0xf7d09000
stp 996 1 bridge, Live 0xf7cd7000
bnep 7444 2 - Live 0xf7ccb000
rfcomm 25175 0 - Live 0xf7cbb000
l2cap 21709 6 bnep,rfcomm, Live 0xf7c78000
crc16 1027 1 l2cap, Live 0xf7c67000
bluetooth 36319 6 sco,bnep,rfcomm,l2cap, Live 0xf7c5c000
rfkill 10264 3 bluetooth, Live 0xf7c1a000
vboxsf 28252 0 - Live 0xf9739000
binfmt_misc 4907 1 - Live 0xf9724000
fuse 44256 1 - Live 0xf970a000
loop 9765 0 - Live 0xf96eb000
snd_intel8x0 19595 1 - Live 0xf95e6000
snd_ac97_codec 79148 1 snd_intel8x0, Live 0xf95bb000
ac97_bus 710 1 snd_ac97_codec, Live 0xf9595000
snd_pcm 47226 2 snd_intel8x0,snd_ac97_codec, Live 0xf957c000
snd_seq 35463 0 - Live 0xf9554000
snd_timer 12258 2 snd_pcm,snd_seq, Live 0xf953a000
snd_seq_device 3673 1 snd_seq, Live 0xf952b000
snd 34375 8 snd_intel8x0,snd_ac97_codec,snd_pcm,snd_seq,snd_timer,snd_seq_device, Live 0xf9513000
soundcore 3450 1 snd, Live 0xf94f9000
snd_page_alloc 5045 2 snd_intel8x0,snd_pcm, Live 0xf94ed000
i2c_piix4 7076 0 - Live 0xf94e0000
i2c_core 12787 2 drm,i2c_piix4, Live 0xf94cf000
parport_pc 15799 0 - Live 0xf94af000
ac 1640 0 - Live 0xf949e000
battery 3782 0 - Live 0xf807e000
processor 26327 0 - Live 0xf9484000
joydev 6739 0 - Live 0xf8067000
pcspkr 1207 0 - Live 0xf805b000
button 3598 0 - Live 0xf804c000
parport 22554 3 ppdev,lp,parport_pc, Live 0xf802d000
evdev 5609 9 - Live 0xf800d000
vboxguest 123953 6 vboxsf, Live 0xf7fcd000
psmouse 44809 0 - Live 0xf7f84000
serio_raw 2916 0 - Live 0xf7f6b000
ext3 94204 1 - Live 0xf7f45000
jbd 32169 1 ext3, Live 0xf7f0f000
mbcache 3762 1 ext3, Live 0xf7ef8000
usbhid 28008 0 - Live 0xf7ec1000
hid 50909 1 usbhid, Live 0xf7e9f000
sg 15968 0 - Live 0xf7e7f000
sr_mod 10770 0 - Live 0xf7e6c000
sd_mod 26005 3 - Live 0xf7e57000
crc_t10dif 1012 1 sd_mod, Live 0xf7e43000
cdrom 26487 1 sr_mod, Live 0xf7e33000
ata_generic 2067 0 - Live 0xf7e21000
ohci_hcd 16987 0 - Live 0xf7e0b000
ata_piix 17736 2 - Live 0xf7df3000
ahci 27270 0 - Live 0xf7dda000
thermal 9206 0 - Live 0xf7dc2000
thermal_sys 9378 2 processor,thermal, Live 0xf7db1000
ehci_hcd 28681 0 - Live 0xf7d9f000
libata 115753 3 ata_generic,ata_piix,ahci, Live 0xf7d62000
usbcore 98733 4 usbhid,ohci_hcd,ehci_hcd, Live 0xf7cdd000
nls_base 4541 2 vboxsf,usbcore, Live 0xf7ca9000
e1000 77317 0 - Live 0xf7c88000
scsi_mod 101429 4 sg,sr_mod,sd_mod,libata, Live 0xf7c41000

Statitiques de l'utilisation des disques

root@debian:~# cat /proc/diskstats
   8       0 sda 10000 533 435946 108372 1363 2727 32736 33532 0 38448 141892
   8       1 sda1 8093 138 431260 105960 1363 2727 32736 33532 0 38320 139484
   8       2 sda2 2 0 4 16 0 0 0 0 0 16 16
   8       5 sda5 147 90 1052 308 0 0 0 0 0 308 308
   8       6 sda6 179 16 396 312 0 0 0 0 0 304 312
   8       7 sda7 358 32 390 180 0 0 0 0 0 176 180
   8       8 sda8 51 0 408 236 0 0 0 0 0 236 236
   8       9 sda9 181 13 388 288 0 0 0 0 0 272 288
   8      10 sda10 219 176 402 288 0 0 0 0 0 284 288
   8      11 sda11 173 22 396 172 0 0 0 0 0 172 172
   8      12 sda12 173 22 396 336 0 0 0 0 0 304 336
   8      13 sda13 366 24 390 220 0 0 0 0 0 212 216
  11       0 sr0 0 0 0 0 0 0 0 0 0 0 0
   7       0 loop0 0 0 0 0 0 0 0 0 0 0 0
   7       1 loop1 0 0 0 0 0 0 0 0 0 0 0
   7       2 loop2 0 0 0 0 0 0 0 0 0 0 0
   7       3 loop3 0 0 0 0 0 0 0 0 0 0 0
   7       4 loop4 0 0 0 0 0 0 0 0 0 0 0
   7       5 loop5 0 0 0 0 0 0 0 0 0 0 0
   7       6 loop6 0 0 0 0 0 0 0 0 0 0 0
   7       7 loop7 0 0 0 0 0 0 0 0 0 0 0

Partitions

root@debian:~# cat /proc/partitions
major minor  #blocks  name

   8        0   16777216 sda
   8        1    4770281 sda1
   8        2          1 sda2
   8        5    1951866 sda5
   8        6     522081 sda6
   8        7     208813 sda7
   8        8     313236 sda8
   8        9     522081 sda9
   8       10     417658 sda10
   8       11     522081 sda11
   8       12     522081 sda12
   8       13     208813 sda13

Espaces de pagination

root@debian:~# cat /proc/swaps
Filename				Type		Size	Used	Priority
/dev/sda5                               partition	1951856	0	-1

Statistiques d'utilisation du processeur

root@debian:~# cat /proc/loadavg
0.00 0.03 0.06 1/229 2114

Statistiques d'utilisation de la mémoire

root@debian:~# cat /proc/meminfo
MemTotal:        1034480 kB
MemFree:          604420 kB
Buffers:           54888 kB
Cached:           221508 kB
SwapCached:            0 kB
Active:           213992 kB
Inactive:         189920 kB
Active(anon):     127680 kB
Inactive(anon):     3668 kB
Active(file):      86312 kB
Inactive(file):   186252 kB
Unevictable:          16 kB
Mlocked:              16 kB
HighTotal:        143304 kB
HighFree:            336 kB
LowTotal:         891176 kB
LowFree:          604084 kB
SwapTotal:       1951856 kB
SwapFree:        1951856 kB
Dirty:                12 kB
Writeback:             0 kB
AnonPages:        127560 kB
Mapped:            69892 kB
Shmem:              3832 kB
Slab:              14612 kB
SReclaimable:       9252 kB
SUnreclaim:         5360 kB
KernelStack:        1824 kB
PageTables:         2940 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2469096 kB
Committed_AS:     522276 kB
VmallocTotal:     122880 kB
VmallocUsed:       27852 kB
VmallocChunk:      86728 kB
HardwareCorrupted:     0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       4096 kB
DirectMap4k:       12280 kB
DirectMap4M:      892928 kB

Version du noyau

root@debian:~# cat /proc/version
Linux version 2.6.32-5-686 (Debian 2.6.32-31) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Tue Mar 8 21:36:00 UTC 2011

Interprétation des informations dans /proc

Les informations brutes stockées dans /proc peuvent être interprétées grâce à l'utilisation des commandes dites de gestion des performances :

Sous Debian, certains outils tels iostat, vmstat, mpstat, sar … ne sont pas installés par défaut. Il convient donc de les installer à l'aide de la commande apt-get :

root@debian:~# apt-get install sysstat hdparm
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances       
Lecture des informations d'état... Fait
hdparm est déjà la plus récente version disponible.
hdparm passé en « installé manuellement ».
Paquets suggérés :
  isag
Les NOUVEAUX paquets suivants seront installés :
  sysstat
0 mis à jour, 1 nouvellement installés, 0 à enlever et 219 non mis à jour.
Il est nécessaire de prendre 284 ko dans les archives.
Après cette opération, 1 151 ko d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer [O/n] ? o
Réception de : 1 http://ftp.fr.debian.org/debian/ squeeze/main sysstat i386 9.0.6.1-2 [284 kB]
284 ko réceptionnés en 0s (786 ko/s)
Préconfiguration des paquets...
Sélection du paquet sysstat précédemment désélectionné.
(Lecture de la base de données... 130516 fichiers et répertoires déjà installés.)
Dépaquetage de sysstat (à partir de .../sysstat_9.0.6.1-2_i386.deb) ...
Traitement des actions différées (« triggers ») pour « man-db »...
Paramétrage de sysstat (9.0.6.1-2) ...

Creating config file /etc/default/sysstat with new version
update-alternatives: utilisation de « /usr/bin/sar.sysstat » pour fournir « /usr/bin/sar » (sar) en mode automatique.

Commandes

free

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@debian:~# free -m
             total       used       free     shared    buffers     cached
Mem:          1010        658        351          0         54        272
-/+ buffers/cache:        331        679
Swap:         1906          0       1906

Dans le cas de cet exemple, nous pouvons constater que l’affichage montre :

La ligne -/+ buffers/cache: indique que les applications utilisent 331 Mo et qu’elles disposent de 677 Mo de mémoire libre (54+272+351).

Les options de cette commande sont :

root@debian:~# free -h
free: invalid option -- 'h'
usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
  -b,-k,-m,-g show output in bytes, KB, MB, or GB
  -l show detailed low and high memory statistics
  -o use old format (no -/+buffers/cache line)
  -t display total for RAM + swap
  -s update every [delay] seconds
  -c update [count] times
  -V display version information and exit
uptime ou w

Chacune des ces commandes indique la charge moyenne du ou des processeurs depuis 1 minute, 5 minutes et 15 minutes :

root@debian:~# uptime
 13:52:14 up  1:44,  2 users,  load average: 0.00, 0.02, 0.00
root@debian:~# w
 13:52:16 up  1:45,  2 users,  load average: 0,00, 0,02, 0,00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
trainee  tty7     :0               Sun13   24:35m  1:55   0.17s x-session-manag
trainee  pts/1    :0.0             Sun13    0.00s  0.47s 17.07s gnome-terminal

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@debian:~# uptime --help
usage: uptime [-V]
    -V    display version
root@debian:~# w --help
w : option invalide -- '-'
usage: w -hlsufV [user]
    -h    skip header
    -l    long listing (default)
    -s    short listing
    -u    ignore uid of processes
    -f    toggle FROM field (default on)
    -o    old-style output
    -V    display version
iostat

La commande iostat affiche des statistiques sur l'utilisation des disques, des terminaux et des lecteurs de cartouche :

root@debian:~# iostat
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          13,39    0,05    6,65    1,10    0,00   78,81

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               4,22        98,99        59,59     668252     402312

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 :

root@debian:~# hdparm -t /dev/sda

/dev/sda:
 Timing buffered disk reads: 188 MB in  3.02 seconds =  62.21 MB/sec

Au-dessous du rapport d'utilisation du CPU 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@debian:~# iostat --help
Utilisation : iostat [ options... ] [ <intervalle> [ <itérations> ] ]
Options possibles :
[ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]
[ <périph.> [...] | ALL ] [ -p [ <périph.> [,...] | ALL ] ]
vmstat

La commande vmstat affiche des statistiques sur la mémoire, la pagination et la charge ponctuelle du processeur :

root@debian:~# 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
 1  0      0 269392  60876 311488    0    0    73    25  560 1524 13  6 80  1
 0  0      0 270012  60876 311508    0    0     0     0  940 2229 31 10 59  0
 0  0      0 269640  60876 311508    0    0     0     0  514 1114 13  5 82  0
 0  0      0 269696  60888 311492    0    0     0   124  631 1295 10  8 82  0
 0  0      0 269668  60888 311508    0    0     0     0  691 1404  9  3 88  0
 0  0      0 269668  60888 311508    0    0     0     0  696 1422  8  6 86  0
 0  0      0 269640  60888 311508    0    0     0     0 1037 2341 22  8 70  0
 1  0      0 269668  60888 311508    0    0     0     0  558 1150  7  9 84  0
 0  0      0 269668  60888 311508    0    0     0     0  872 1938  7  6 87  0
 0  0      0 269640  60900 311508    0    0     0    56  736 1570  5  7 88  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@debian:~# vmstat --help
vmstat: invalid option -- '-'
usage: vmstat [-V] [-n] [delay [count]]
              -V prints version.
              -n causes the headers not to be reprinted regularly.
              -a print inactive/active page stats.
              -d prints disk statistics
              -D prints disk table
              -p prints disk partition statistics
              -s prints vm table
              -m prints slabinfo
              -S unit size
              delay is the delay between updates in seconds. 
              unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)
              count is the number of updates.

Par défaut la commande vmstat affiche des informations depuis le démarrage du système.

mpstat

La commande mpstat affiche des statistiques détaillées sur le CPU :

root@debian:~# mpstat
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:39:53     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
14:39:53     all   12,74    0,04    6,19    0,83    0,24    0,05    0,00    0,00   79,90

Dans le cas où vous avez plusieurs processeurs ou coeurs, vous pouvez visualiser ces mêmes informations par unité de traitement :

root@debian:~# mpstat -P ALL
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:40:06     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
14:40:06     all   12,74    0,04    6,19    0,83    0,24    0,05    0,00    0,00   79,91
14:40:06       0   12,74    0,04    6,19    0,83    0,24    0,05    0,00    0,00   79,91

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@debian:~# mpstat -P ALL 2 5
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:41:01     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
14:41:03     all   26,00    0,00   15,00    0,00    0,50    0,50    0,00    0,00   58,00
14:41:03       0   26,00    0,00   15,00    0,00    0,50    0,50    0,00    0,00   58,00

14:41:03     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
14:41:05     all    8,50    0,00    5,00    0,00    0,50    0,00    0,00    0,00   86,00
14:41:05       0    8,50    0,00    5,00    0,00    0,50    0,00    0,00    0,00   86,00

14:41:05     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
14:41:07     all   22,00    0,00   12,00    0,00    0,50    0,00    0,00    0,00   65,50
14:41:07       0   22,00    0,00   12,00    0,00    0,50    0,00    0,00    0,00   65,50

14:41:07     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
14:41:09     all   27,00    0,00    8,00    0,00    1,00    0,00    0,00    0,00   64,00
14:41:09       0   27,00    0,00    8,00    0,00    1,00    0,00    0,00    0,00   64,00

14:41:09     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
14:41:11     all   20,00    0,00   14,50    0,00    0,00    0,00    0,00    0,00   65,50
14:41:11       0   20,00    0,00   14,50    0,00    0,00    0,00    0,00    0,00   65,50

Moyenne :    CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
Moyenne :    all   20,70    0,00   10,90    0,00    0,50    0,10    0,00    0,00   67,80
Moyenne :      0   20,70    0,00   10,90    0,00    0,50    0,10    0,00    0,00   67,80

Les options de cette commande sont :

root@debian:~# mpstat --help
Utilisation : mpstat [ options... ] [ <intervalle> [ <itérations> ] ]
Options possibles :
[ -A ] [ -I { SUM | CPU | ALL } ] [ -u ] [ -P { <cpu> [,...] | ALL } ] [ -V ]
sar

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

La commande /usr/lib/sysstat/sadc permet de collecter les informations.

root@debian:~# ls /usr/lib/sysstat/
debian-sa1  sa1  sa2  sadc

Le script /usr/lib/sysstat/sa1 exécute la commande /usr/lib/sysstat/sadc. Ce script prend deux options :

Option Description
-t L'interval entre les collectes
-n Nombre de collectes

Le script /usr/lib/sysstat/sa2 exécute la commande sar et consigne les informations dans un fichier au format /var/log/sysstat/sar<jj>.

Pour pouvoir fonctionner correctement, ces scripts doivent être appelés par cron.

Pour constater ce fonctionnement manuellement saisissez la commande suivante :

root@debian:~# /usr/lib/sysstat/sa1 5 5

Saisissez ensuite les commandes suivantes :

root@debian:~# sar
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:45:50        CPU     %user     %nice   %system   %iowait    %steal     %idle
14:45:55        all     13,20      0,00      8,00      0,00      0,00     78,80
14:46:00        all     30,20      0,00     12,40      0,00      0,00     57,40
14:46:05        all     10,42      0,00      6,81      0,20      0,00     82,57
14:46:10        all     10,60      0,00      6,60      0,00      0,00     82,80
Moyenne :       all     16,11      0,00      8,45      0,05      0,00     75,39

root@debian:~# sar -u 5 3
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:47:03        CPU     %user     %nice   %system   %iowait    %steal     %idle
14:47:08        all     10,98      0,00      7,19      0,00      0,00     81,84
14:47:13        all      6,41      0,00      4,61      0,00      0,00     88,98
14:47:18        all     12,18      0,00      6,59      0,00      0,00     81,24
Moyenne :       all      9,86      0,00      6,13      0,00      0,00     84,01

root@debian:~# sar -r 5 3
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:47:43    kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
14:47:48       272584    761896     73,65     61684    311988    949064     31,78
14:47:53       272584    761896     73,65     61692    311988    949064     31,78
14:47:58       272584    761896     73,65     61692    311988    949072     31,78
Moyenne :      272584    761896     73,65     61689    311988    949067     31,78

root@debian:~# sar -w 5 3
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:48:21       proc/s   cswch/s
14:48:26         0,00    658,28
14:48:31         0,00    795,40
14:48:36         0,00    859,40
Moyenne :        0,00    770,95

root@debian:~# sar -b 5 3
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:48:47          tps      rtps      wtps   bread/s   bwrtn/s
14:48:52         0,00      0,00      0,00      0,00      0,00
14:48:57         2,00      0,00      2,00      0,00     25,60
14:49:02         0,00      0,00      0,00      0,00      0,00
Moyenne :        0,67      0,00      0,67      0,00      8,54

root@debian:~# sar -d 5 3
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:49:12          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
14:49:17       dev8-0      0,00      0,00      0,00      0,00      0,00      0,00      0,00      0,00

14:49:17          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
14:49:22       dev8-0      1,20      0,00     12,83     10,67      0,00      0,00      0,00      0,00

14:49:22          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
14:49:27       dev8-0      2,20      0,00     40,00     18,18      0,00      0,36      0,36      0,08

Moyenne :         DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
Moyenne :      dev8-0      1,13      0,00     17,60     15,53      0,00      0,24      0,24      0,03

root@debian:~# sar -p 5 3
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:49:41        CPU     %user     %nice   %system   %iowait    %steal     %idle
14:49:46        all     16,57      0,00      8,58      0,00      0,00     74,85
14:49:51        all     28,20      0,00     11,20      0,00      0,00     60,60
14:49:56        all     10,00      0,00      8,40      0,00      0,00     81,60
Moyenne :       all     18,25      0,00      9,39      0,00      0,00     72,35

root@debian:~# sar -v 5 3
Linux 2.6.32-5-686 (debian) 	09/04/2012 	_i686_	(1 CPU)

14:50:07    dentunusd   file-nr  inode-nr    pty-nr
14:50:12        34204      4416     14569       283
14:50:17        34204      4416     14570       283
14:50:22        34206      4416     14569       283
Moyenne :       34205      4416     14569       283

Les options de cette commande sont :

root@debian:~# sar --help
Utilisation : sar [ options... ] [ <intervalle> [ <itérations> ] ]
Options possibles :
[ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [-m] [ -p ] [ -q ] [ -r ] [ -R ]
[ -S ] [ -t ] [ -u [ ALL ] ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ]
[ -I { <entier> [,...] | SUM | ALL | XALL } ] [ -P { <cpu> [,...] | ALL } ]
[ -n { <mot_clé> [,...] | ALL } ]
[ -o [ <nom_fichier> ] | -f [ <nom_fichier> ] ]
[ -i <intervalle> ] [ -s [ <hh:mm:ss> ] ] [ -e [ <hh:mm:ss> ] ]

Utilisation des commandes en production

Identifier un système limité par le processeur

Dans ce cas utilisez les commandes suivantes :

Identifier un système ayant un problème de mémoire

Dans ce cas utilisez les commandes suivantes :

Identifier un système ayant un problème d'E/S

Utilisez la commande :

Modules usb

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 :

<note> 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. </note>

udev

Le noyau Linux 2.6 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 :

root@debian:~# ls /dev | grep sdb
sdb
sdb1
root@debian:~# ls /dev/.udev/db | grep sdb
block:sdb
block:sdb1
root@debian:~# ls /sys/block/sdb
alignment_offset  dev	     holders   queue	  ro	slaves	   trace
bdi		  device     inflight  range	  sdb1	stat	   uevent
capability	  ext_range  power     removable  size	subsystem

et utilise les informations contenues dans le fichier /lib/modules/`uname -r`/modules.alias pour trouver le pilote nécessaire :

Le contenu du fichier /dev/.udev/db/block:sdb1 est :

root@debian:~# cat /dev/.udev/db/block:sdb1
N:sdb1
S:block/8:17
S:disk/by-id/usb-JetFlash_Transcend_8GB_48MSBMWJ2851SPKF-0:0-part1
S:disk/by-path/pci-0000:00:0b.0-usb-0:1:1.0-scsi-0:0:0:0-part1
S:disk/by-uuid/2D9370690D5D6E39
W:18
E:ID_VENDOR=JetFlash
E:ID_VENDOR_ENC=JetFlash
E:ID_VENDOR_ID=8564
E:ID_MODEL=Transcend_8GB
E:ID_MODEL_ENC=Transcend\x208GB\x20\x20\x20
E:ID_MODEL_ID=1000
E:ID_REVISION=1100
E:ID_SERIAL=JetFlash_Transcend_8GB_48MSBMWJ2851SPKF-0:0
E:ID_SERIAL_SHORT=48MSBMWJ2851SPKF
E:ID_TYPE=disk
E:ID_INSTANCE=0:0
E:ID_BUS=usb
E:ID_USB_INTERFACES=:080650:
E:ID_USB_INTERFACE_NUM=00
E:ID_USB_DRIVER=usb-storage
E:ID_PATH=pci-0000:00:0b.0-usb-0:1:1.0-scsi-0:0:0:0
E:ID_PART_TABLE_TYPE=dos
E:ID_FS_UUID=2D9370690D5D6E39
E:ID_FS_UUID_ENC=2D9370690D5D6E39
E:ID_FS_TYPE=ntfs
E:ID_FS_USAGE=filesystem
E:UDISKS_PRESENTATION_NOPOLICY=0
E:UDISKS_PARTITION=1
E:UDISKS_PARTITION_SCHEME=mbr
E:UDISKS_PARTITION_NUMBER=1
E:UDISKS_PARTITION_TYPE=0x07
E:UDISKS_PARTITION_SIZE=8098152448
E:UDISKS_PARTITION_SLAVE=/sys/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.0/host3/target3:0:0/3:0:0:0/block/sdb
E:UDISKS_PARTITION_OFFSET=1048576
E:UDISKS_PARTITION_ALIGNMENT_OFFSET=0

Voici le contenu de /dev :

root@debian:~# ls -lR /dev/disk
/dev/disk:
total 0
drwxr-xr-x 2 root root 520  9 avril 15:41 by-id
drwxr-xr-x 2 root root 300  9 avril 15:41 by-path
drwxr-xr-x 2 root root  80  9 avril 15:41 by-uuid

/dev/disk/by-id:
total 0
lrwxrwxrwx 1 root root  9  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25 -> ../../sda
lrwxrwxrwx 1 root root 10  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part1 -> ../../sda1
lrwxrwxrwx 1 root root 11  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part10 -> ../../sda10
lrwxrwxrwx 1 root root 11  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part11 -> ../../sda11
lrwxrwxrwx 1 root root 11  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part12 -> ../../sda12
lrwxrwxrwx 1 root root 11  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part13 -> ../../sda13
lrwxrwxrwx 1 root root 10  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part7 -> ../../sda7
lrwxrwxrwx 1 root root 10  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part8 -> ../../sda8
lrwxrwxrwx 1 root root 10  9 avril 15:41 ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25-part9 -> ../../sda9
lrwxrwxrwx 1 root root  9  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25 -> ../../sda
lrwxrwxrwx 1 root root 10  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part1 -> ../../sda1
lrwxrwxrwx 1 root root 11  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part10 -> ../../sda10
lrwxrwxrwx 1 root root 11  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part11 -> ../../sda11
lrwxrwxrwx 1 root root 11  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part12 -> ../../sda12
lrwxrwxrwx 1 root root 11  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part13 -> ../../sda13
lrwxrwxrwx 1 root root 10  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part7 -> ../../sda7
lrwxrwxrwx 1 root root 10  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part8 -> ../../sda8
lrwxrwxrwx 1 root root 10  9 avril 15:41 scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25-part9 -> ../../sda9

/dev/disk/by-path:
total 0
lrwxrwxrwx 1 root root  9  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root 10  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 11  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part10 -> ../../sda10
lrwxrwxrwx 1 root root 11  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part11 -> ../../sda11
lrwxrwxrwx 1 root root 11  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part12 -> ../../sda12
lrwxrwxrwx 1 root root 11  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part13 -> ../../sda13
lrwxrwxrwx 1 root root 10  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part7 -> ../../sda7
lrwxrwxrwx 1 root root 10  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part8 -> ../../sda8
lrwxrwxrwx 1 root root 10  9 avril 15:41 pci-0000:00:01.1-scsi-0:0:0:0-part9 -> ../../sda9
lrwxrwxrwx 1 root root  9  9 avril 15:41 pci-0000:00:01.1-scsi-1:0:0:0 -> ../../sr0

/dev/disk/by-uuid:
total 0
lrwxrwxrwx 1 root root 10  9 avril 15:41 a42a1ddd-14bc-4dde-a537-e6c1b984a782 -> ../../sda1
lrwxrwxrwx 1 root root 10  9 avril 15:41 e21d8931-21ca-4ab3-9fbb-bd71657b312e -> ../../sda5

Le fichier de configuration principal d'Udev est /etc/udev/udev.conf :

root@debian:~# cat /etc/udev/udev.conf
# The initial syslog(3) priority: "err", "info", "debug" or its
# numerical equivalent. For runtime debugging, the daemons internal
# state can be changed with: "udevadm control --log-priority=<value>".
udev_log="err"

Les fichiers de règles se trouvent dans /lib/udev/rules.d/ :

root@debian:~# ls /lib/udev/rules.d/
40-hplip.rules			   75-tty-description.rules
40-usb-media-players.rules	   77-mm-ericsson-mbm.rules
40-usb_modeswitch.rules		   77-mm-longcheer-port-types.rules
45-libmtp8.rules		   77-mm-pcmcia-device-blacklist.rules
50-udev-default.rules		   77-mm-platform-serial-whitelist.rules
55-dm.rules			   77-mm-simtech-port-types.rules
56-hpmud_support.rules		   77-mm-usb-device-blacklist.rules
60-fuse-utils.rules		   77-mm-zte-port-types.rules
60-gnupg.rules			   77-nm-olpc-mesh.rules
60-libgphoto2-2.rules		   78-sound-card.rules
60-libsane-extras.rules		   79-fstab_import.rules
60-libsane.rules		   80-alsa.rules
60-persistent-alsa.rules	   80-drivers.rules
60-persistent-input.rules	   80-udisks.rules
60-persistent-serial.rules	   85-hplj10xx.rules
60-persistent-storage-dm.rules	   85-hwclock.rules
60-persistent-storage.rules	   85-usbmuxd.rules
60-persistent-storage-tape.rules   90-libgpod.rules
60-persistent-v4l.rules		   91-permissions.rules
61-gnome-bluetooth-rfkill.rules    95-keyboard-force-release.rules
61-mobile-action.rules		   95-keymap.rules
62-bluez-hid2hci.rules		   95-udev-late.rules
64-xorg-xkb.rules		   95-upower-battery-recall-dell.rules
69-xserver-xorg-input-wacom.rules  95-upower-battery-recall-fujitsu.rules
70-acl.rules			   95-upower-battery-recall-gateway.rules
70-hid2hci.rules		   95-upower-battery-recall-ibm.rules
70-printers.rules		   95-upower-battery-recall-lenovo.rules
75-cd-aliases-generator.rules	   95-upower-battery-recall-toshiba.rules
75-net-description.rules	   95-upower-csr.rules
75-persistent-net-generator.rules  95-upower-hid.rules
75-probe_mtd.rules		   95-upower-wup.rules

<note 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. </note>

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@debian:~# cat /lib/udev/rules.d/50-udev-default.rules 
SUBSYSTEM=="block",				SYMLINK{unique}+="block/%M:%m"
SUBSYSTEM!="block",				SYMLINK{unique}+="char/%M:%m"

# import the properties of optical drives
ACTION!="remove", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", \
	KERNEL=="sr[0-9]*|hd[a-z]|pcd[0-9]|xvd*", \
	IMPORT{program}="cdrom_id --export $tempnode"

# SCSI devices
SUBSYSTEMS=="scsi", KERNEL=="sr[0-9]*",		SYMLINK+="scd%n"
SUBSYSTEM=="bsg",				NAME="bsg/%k"

# workaround for kernels < 2.6.30
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", WAIT_FOR="descriptors"

# USB devices
SUBSYSTEMS=="usb", KERNEL=="auer[0-9]*",	NAME="usb/%k"
SUBSYSTEMS=="usb", KERNEL=="cpad[0-9]*",	NAME="usb/%k"
SUBSYSTEMS=="usb", KERNEL=="dabusb[0-9]*",	NAME="usb/%k"
SUBSYSTEMS=="usb", KERNEL=="hiddev[0-9]*",	NAME="usb/%k"
SUBSYSTEMS=="usb", KERNEL=="legousbtower[0-9]*", NAME="usb/%k"
SUBSYSTEMS=="usb", KERNEL=="lp[0-9]*",		NAME="usb/%k"
SUBSYSTEMS=="usb", KERNEL=="iowarrior[0-9]*",	NAME="usb/%k"
SUBSYSTEMS=="usb", KERNEL=="ttyUSB*", \
	ATTRS{product}=="[Hh]andspring*Treo*|[Hh]andspring*Visor*|[Pp]alm*Handheld*", \
						SYMLINK+="pilot"

# usbfs-like devices
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device",	NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}"

# serial devices
KERNEL=="capi",			NAME="capi20",
KERNEL=="capi[0-9]*",		NAME="capi/%n"

# video devices
KERNEL=="dvb*",	ENV{DVB_ADAPTER_NUM}=="?*",	NAME="dvb/adapter$env{DVB_ADAPTER_NUM}/$env{DVB_DEVICE_TYPE}$env{DVB_DEVICE_NUM}"
# workaround for kernels < 2.6.29
KERNEL=="dvb*",	ENV{DVB_ADAPTER_NUM}=="", PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter%%i/%%s $${K%%%%.*} $${K#*.}", ACTION!="remove", \
				NAME="$result"
KERNEL=="card[0-9]*",		NAME="dri/%k"

# virtio serial / console ports
KERNEL=="vport*", ATTR{name}=="?*", SYMLINK+="virtio-ports/$attr{name}"

# misc devices
KERNEL=="hw_random",		NAME="hwrng"
KERNEL=="tun",			NAME="net/%k"
KERNEL=="evtchn",		NAME="xen/%k"
SUBSYSTEM=="rtc", DRIVERS=="rtc_cmos",		SYMLINK+="rtc"

KERNEL=="rawctl",		NAME="raw/rawctl"
KERNEL=="cdemu[0-9]*",		NAME="cdemu/%n"
KERNEL=="pktcdvd[0-9]*",	NAME="pktcdvd/%n"
KERNEL=="pktcdvd",		NAME="pktcdvd/control"

KERNEL=="cpu[0-9]*",		NAME="cpu/%n/cpuid"
KERNEL=="msr[0-9]*",		NAME="cpu/%n/msr"
KERNEL=="microcode",		NAME="cpu/microcode"

KERNEL=="umad*",		NAME="infiniband/%k"
KERNEL=="issm*",		NAME="infiniband/%k"
KERNEL=="uverbs*",		NAME="infiniband/%k"
KERNEL=="ucm*",			NAME="infiniband/%k"
KERNEL=="uat",			NAME="infiniband/%k"
KERNEL=="ucma",			NAME="infiniband/%k"
KERNEL=="rdma_cm",		NAME="infiniband/%k"

# ALSA devices
KERNEL=="controlC[0-9]*",	NAME="snd/%k"
KERNEL=="hwC[D0-9]*",		NAME="snd/%k"
KERNEL=="pcmC[D0-9cp]*",	NAME="snd/%k"
KERNEL=="midiC[D0-9]*",		NAME="snd/%k"
KERNEL=="timer",		NAME="snd/%k"
KERNEL=="seq",			NAME="snd/%k"

KERNEL=="snd", SUBSYSTEM=="module", ACTION=="add", \
	RUN+="/bin/ln -sf /proc/asound/oss/sndstat $root/sndstat"


# ieee1394 devices
KERNEL=="dv1394*",		NAME="dv1394/%n"
KERNEL=="video1394*",		NAME="video1394/%n"

# input devices
KERNEL=="mice",			NAME="input/%k"
KERNEL=="mouse[0-9]*",		NAME="input/%k"
KERNEL=="event[0-9]*",		NAME="input/%k"
KERNEL=="js[0-9]*",		NAME="input/%k"
KERNEL=="ts[0-9]*",		NAME="input/%k"
KERNEL=="uinput",		SYMLINK="input/%k"

# Zaptel
KERNEL=="zapctl",		NAME="zap/ctl"
KERNEL=="zapchannel",		NAME="zap/channel"
KERNEL=="zappseudo",		NAME="zap/pseudo"
KERNEL=="zaptimer",		NAME="zap/timer"
KERNEL=="transcode",		NAME="zap/transcode"
KERNEL=="zap[0-9]*",		NAME="zap/%n"

# AOE character devices
SUBSYSTEM=="aoe",		NAME="etherd/%k"

KERNEL=="device-mapper",	NAME="mapper/control"

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

La commande udevadm

Pour obtenir de l'information sur un périphérique il convient d'utiliser la commande udevadm qui a remplacé la commande udevinfo disponible dans CentOS 5 :

root@debian:~# udevadm info --query=all -n /dev/sda
P: /devices/pci0000:00/0000:00:01.1/host1/target1:0:0/1:0:0:0/block/sda
N: sda
S: block/8:0
S: disk/by-id/scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25
S: disk/by-id/ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25
S: disk/by-path/pci-0000:00:01.1-scsi-0:0:0:0
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:01.1/host1/target1:0:0/1:0:0:0/block/sda
E: MAJOR=8
E: MINOR=0
E: DEVNAME=/dev/sda
E: DEVTYPE=disk
E: SUBSYSTEM=block
E: ID_ATA=1
E: ID_TYPE=disk
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_REVISION=1.0
E: ID_SERIAL=VBOX_HARDDISK_VB6c3c9e26-131bbb25
E: ID_SERIAL_SHORT=VB6c3c9e26-131bbb25
E: ID_ATA_WRITE_CACHE=1
E: ID_ATA_WRITE_CACHE_ENABLED=1
E: ID_ATA_FEATURE_SET_PM=1
E: ID_ATA_FEATURE_SET_PM_ENABLED=1
E: ID_SCSI_COMPAT=SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25
E: ID_PATH=pci-0000:00:01.1-scsi-0:0:0:0
E: ID_PART_TABLE_TYPE=dos
E: UDISKS_PRESENTATION_NOPOLICY=0
E: UDISKS_PARTITION_TABLE=1
E: UDISKS_PARTITION_TABLE_SCHEME=mbr
E: UDISKS_PARTITION_TABLE_COUNT=3
E: UDISKS_ATA_SMART_IS_AVAILABLE=0
E: DEVLINKS=/dev/block/8:0 /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB6c3c9e26-131bbb25 /dev/disk/by-id/ata-VBOX_HARDDISK_VB6c3c9e26-131bbb25 /dev/disk/by-path/pci-0000:00:01.1-scsi-0:0:0:0

La commande udevadm peut également être utilisée pour connaître toute l'information sysfs concernant un périphérique :

root@debian:~# udevadm info -a -p /sys/class/input/mouse0/

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:06.0/usb2/2-1/2-1:1.0/input/input1/mouse0':
    KERNEL=="mouse0"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2/2-1/2-1:1.0/input/input1':
    KERNELS=="input1"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="VirtualBox USB Tablet"
    ATTRS{phys}=="usb-0000:00:06.0-1/input0"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0003v80EEp0021e0110-e0,1,2,3,4,k110,111,112,113,114,r8,a0,1,m4,lsfw"

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2/2-1/2-1:1.0':
    KERNELS=="2-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{modalias}=="usb:v80EEp0021d0100dc00dsc00dp00ic03isc00ip00"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2/2-1':
    KERNELS=="2-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="80"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{urbnum}=="14"
    ATTRS{idVendor}=="80ee"
    ATTRS{idProduct}=="0021"
    ATTRS{bcdDevice}=="0100"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="2"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="VirtualBox"
    ATTRS{product}=="USB Tablet"

  looking at parent device '/devices/pci0000:00/0000:00:06.0/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="40"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0001"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="1"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="8"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.32-5-686 ohci_hcd"
    ATTRS{product}=="OHCI Host Controller"
    ATTRS{serial}=="0000:00:06.0"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:06.0':
    KERNELS=="0000:00:06.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ohci_hcd"
    ATTRS{vendor}=="0x106b"
    ATTRS{device}=="0x003f"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{class}=="0x0c0310"
    ATTRS{irq}=="22"
    ATTRS{local_cpus}=="ffffffff"
    ATTRS{local_cpulist}=="0-31"
    ATTRS{modalias}=="pci:v0000106Bd0000003Fsv00000000sd00000000bc0Csc03i10"
    ATTRS{enable}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

Les options de la commande

Les options de la commande udevadm sont :

root@debian:~# 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
  test         simulation run

root@debian:~# 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-db                export the content of the udev database
  --help

Système de fichiers /sys

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@debian:~# ls -l /sys
total 0
drwxr-xr-x  2 root root 0  8 avril 14:00 block
drwxr-xr-x 16 root root 0  8 avril 13:16 bus
drwxr-xr-x 36 root root 0  8 avril 13:16 class
drwxr-xr-x  4 root root 0  8 avril 13:16 dev
drwxr-xr-x 10 root root 0  8 avril 13:16 devices
drwxr-xr-x  5 root root 0  8 avril 13:16 firmware
drwxr-xr-x  4 root root 0  8 avril 13:16 fs
drwxr-xr-x  6 root root 0  8 avril 13:16 kernel
drwxr-xr-x 83 root root 0  8 avril 13:56 module
drwxr-xr-x  2 root root 0  8 avril 13:16 power

Chaque répertoire contient des informations :

Pour illustrer ceci, saisissez la commande suivante :

root@debian:~# cat /sys/block/sda/sda1/size
9540562

Ce chiffre correspond aux nombre de secteurs.

Limitation des ressources

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 :

trainee@debian:~$ 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:
#        - an 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

<note important> La valeur de la limite peut être un nombre ou le mot unlimited. </note>

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@debian:~# 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) 16382
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) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Options de la commande

Les options de ulimit sont :

trainee@debian:~$ 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.

~~DISCUSSION:off~~

Donner votre Avis

{(rater>id=debian_6_l117|name=cette page|type=rate|trace=user|tracedetails=1)}