Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format
PDF et la grise au format ODT →
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
atelier:chantier:hddtemp-dev-disk-by-id-conky [23/04/2020 10:29] Debian Alain créée |
atelier:chantier:hddtemp-dev-disk-by-id-conky [25/04/2020 16:52] Debian Alain [Utilisation] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== hddtemp /dev/disk/by-id/ conky ====== | ====== hddtemp /dev/disk/by-id/ conky ====== | ||
- | * Objet : faire fonctionne hddtemp dans conky avec une identification par id | + | * Objet : faire fonctionner hddtemp dans conky avec une identification par id |
* Niveau requis : débutant avisé | * Niveau requis : débutant avisé | ||
* Commentaires : //hddtemp utilise l'identification par sdX , souvent elle est aléatoire . | * Commentaires : //hddtemp utilise l'identification par sdX , souvent elle est aléatoire . | ||
Ligne 16: | Ligne 16: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | hddtem utilise par défaut le nommage par /dev/sdX , | + | hddtemp utilise par défaut le nommage par /dev/sdX. |
- | ce nommage étant aléatoire , il est possible de le forcer à utiliser le nommage par /dev/disks/by-id/XXXXXX | + | Ce nommage étant aléatoire, il est possible de le forcer à utiliser le nommage par /dev/disks/by-id/XXXXXX. |
- | en préambule , il faut installer comme suit hddtemp : | + | En préambule, il faut installer comme suit hddtemp : |
<code root>apt install hddtemp </code> | <code root>apt install hddtemp </code> | ||
+ | |||
+ | Puis le reconfigurer afin qu'il soit lancé au démarrage de notre système et qu'il soit accessible par nos programmes (ici conky) : | ||
<code root>dpkg-reconfigure hddtemp</code> | <code root>dpkg-reconfigure hddtemp</code> | ||
Ligne 36: | Ligne 38: | ||
{{https://debian-facile.org/images/file-R8648856b9dd7415a67a6e8021eb6089a.png}} | {{https://debian-facile.org/images/file-R8648856b9dd7415a67a6e8021eb6089a.png}} | ||
- | ensuite , configurer le fichier /etc/default/hddtemp comme suit : | + | Nous devons ensuite configurer le fichier /etc/default/hddtemp afin de lui dire de lire aussi les disques nommés sous forme la /dev/disk/by-id/XXXXXX. |
+ | Pour obtenir la correspondance entre /dev/sdX et /dev/disk/by-id/XXXXXX nous pouvons faire un ls -l dans le dossier /dev/disk/by-id/. | ||
+ | |||
+ | Voici ce que j'obtiens : | ||
+ | <code user>ls -lh /dev/disk/by-id/</code> | ||
+ | <code>total 0 | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-CT500MX500SSD4_1813E134D584 -> ../../sdf | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-HL-DT-ST_BD-RE_BH10LS38_K9IB9NE1359 -> ../../sr1 | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-HL-DT-ST_BD-RE_BH10LS38_K9IC31M4320 -> ../../sr0 | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-ST2000DL003-9VT166_6YD1QBLS -> ../../sdc | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-ST2000DM001-1CH164_Z1E2XAN7 -> ../../sdb | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-ST2000DM001-9YN164_Z1E0AC50 -> ../../sda | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-ST4000VM000-2AF166_WDH0AFF6 -> ../../sdd | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 ata-ST4000VX007-2DT166_ZGY57FLJ -> ../../sde | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 11 avril 23 08:39 md-name-Alain-PC:0 -> ../../md127 | ||
+ | lrwxrwxrwx 1 root root 11 avril 23 08:39 md-uuid-4d4f9d9d:b7119121:c474b6d3:f56af7d6 -> ../../md127 | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 wwn-0x5000c5003fa4e30d -> ../../sda | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 wwn-0x5000c500465b459f -> ../../sdc | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 wwn-0x5000c5004fbead7a -> ../../sdb | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 wwn-0x5000c5009ca2e849 -> ../../sdd | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 wwn-0x5000c500b67c94c2 -> ../../sde | ||
+ | ... / ... | ||
+ | lrwxrwxrwx 1 root root 9 avril 23 08:39 wwn-0x500a0751e134d584 -> ../../sdf | ||
+ | ... / ... | ||
+ | </code> | ||
+ | |||
+ | Nous reportons ainsi la liste des devices qui nous intéresse dans le fichier de configuration d'hddtemp (ligne DISKS) | ||
+ | |||
+ | <code root>nano -w /etc/default/hddtemp</code> | ||
+ | |||
+ | <code> #Defaults for hddtemp initscript (/etc/init.d/hddtemp) | ||
+ | # This is a POSIX shell fragment | ||
+ | |||
+ | # [automatically edited by postinst, do not change line format ] | ||
+ | |||
+ | # hddtemp network daemon switch. If set to true, hddtemp will listen | ||
+ | # for incoming connections. | ||
+ | RUN_DAEMON="true" | ||
+ | |||
+ | # List of devices you want to use with hddtemp. If none specified, | ||
+ | # hddtemp will probe standard devices. | ||
+ | #DISKS="/dev/hda" | ||
+ | DISKS="/dev/sd[a-f] /dev/disk/by-id/wwn-0x5000c5003fa4e30d /dev/disk/by-id/wwn-0x5000c5004fbead7a /dev/disk/by-id/wwn-0x5000c500465b459f /dev/disk/by-id/wwn-0x5000c5009ca2e849 /dev/disk/by-id/wwn-0x5000c500b67c94c2 /dev/disk/by-id/wwn-0x500a0751e134d584" | ||
+ | |||
+ | # List of devices you want to use with hddtemp, but that would not be | ||
+ | # probed for a working sensor. | ||
+ | DISKS_NOPROBE="" | ||
+ | |||
+ | # IP address of the interface on which you want hddtemp to be bound | ||
+ | # on. If none specified, goes to 127.0.0.1. Use 0.0.0.0 to bind hddtemp | ||
+ | # on all interfaces. | ||
+ | INTERFACE="127.0.0.1" | ||
+ | |||
+ | # Port number on which you want hddtemp to listen on. If none specified, | ||
+ | # the port 7634 is used. | ||
+ | PORT="7634" | ||
+ | |||
+ | # Database file to use. If none specified, /etc/hddtemp.db is used. | ||
+ | #DATABASE="/etc/hddtemp.db" | ||
+ | |||
+ | # Separator to use between fields. The default separator is '|'. | ||
+ | #SEPARATOR="|" | ||
+ | |||
+ | # Logging period (in seconds) for the temperatures. If set to a value | ||
+ | # different than 0, hddtemp will run as a daemon periodically logging | ||
+ | # the temperatures through syslog | ||
+ | RUN_SYSLOG="1" | ||
+ | |||
+ | # Other options to pass to hddtemp | ||
+ | OPTIONS="" | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ===== Test ===== | ||
+ | |||
+ | Il ne nous reste plus qu'a tester pour voir si hddtemp récupère bien les températures de nos disques. | ||
+ | |||
+ | Exemple avec le disque wwn-0x500a0751e134d584 (sdf) : | ||
+ | <code>alain@Alain-PC:~$ sudo hddtemp /dev/disk/by-id/wwn-0x500a0751e134d584 | ||
+ | [sudo] Mot de passe de alain : | ||
+ | /dev/disk/by-id/wwn-0x500a0751e134d584: CT500MX500SSD4: 46°C</code> | ||
+ | |||
+ | Nous pouvons alors reporter cette commande dans conky afin de monitorer la température de notre disque : | ||
+ | <code user>${alignc} disque ssd : ${hddtemp /dev/disk/by-id/wwn-0x500a0751e134d584}°C</code> | ||
+ | {{https://debian-facile.org/images/file-R6c8adfb35f6817f5a13827ff6885abff.png}} | ||
- | ===== Installation ===== | ||
===== Utilisation ===== | ===== Utilisation ===== | ||
+ | |||
+ | <code>DISKS="/dev/sd[a-f] /dev/disk/by-id/wwn-0x5000c5003fa4e30d /dev/disk/by-id/wwn-0x5000c5004fbead7a /dev/disk/by-id/wwn-0x5000c500465b459f /dev/disk/by-id/wwn-0x5000c5009ca2e849 /dev/disk/by-id/wwn-0x5000c500b67c94c2 /dev/disk/by-id/wwn-0x500a0751e134d584"</code> | ||
+ | |||
+ | Avec la modification ci-dessus du fichier /etc/default/hddtemp, vous avez accès aussi bien à la notation /dev/sdX qu'a la notation /dev/disk/by-id/XXXXX. | ||
+ | |||
+ | ==== Température ssd en couleur ==== | ||
+ | |||
+ | <note tip>ceci est un exemple . dans votre cas , il faut l'adapter . </note> | ||
+ | |||
+ | créer le script suivant : | ||
+ | |||
+ | <code user>sudo nano ~/Téléchargements/show_ssd.sh </code> | ||
+ | <file bash show_ssd.sh> | ||
+ | # Get temperature value | ||
+ | SENSOR_PROBE='/dev/disk/by-id/wwn-0x500a0751e134d584' | ||
+ | TEMP_STRING=$(hddtemp "$SENSOR_PROBE" | grep --only-matching '[0-9.]\+°C' | head --lines=1 ) | ||
+ | TEMP_NUMBER=${TEMP_STRING%°C} | ||
+ | |||
+ | # Set display mode based on arguments | ||
+ | # Default is to display temperature in a console | ||
+ | unset DISPLAY_MODE | ||
+ | if [ $# -eq 1 ]; then | ||
+ | case "$1" in | ||
+ | ('conky'|'shell') | ||
+ | DISPLAY_MODE="$1" | ||
+ | ;; | ||
+ | esac | ||
+ | fi | ||
+ | : "${DISPLAY_MODE:=shell}" | ||
+ | |||
+ | # Set display color based on temperature value | ||
+ | # ≥ 70°C is high, ≥ 80°C is critical | ||
+ | if [ $TEMP_NUMBER -ge 60 ]; then | ||
+ | case "$DISPLAY_MODE" in | ||
+ | ('conky') | ||
+ | COLOR='red' | ||
+ | ;; | ||
+ | ('shell') | ||
+ | COLOR=31 | ||
+ | ;; | ||
+ | esac | ||
+ | elif [ $TEMP_NUMBER -ge 50 ]; then | ||
+ | case "$DISPLAY_MODE" in | ||
+ | ('conky') | ||
+ | COLOR='yellow' | ||
+ | ;; | ||
+ | ('shell') | ||
+ | COLOR=33 | ||
+ | ;; | ||
+ | esac | ||
+ | else | ||
+ | case "$DISPLAY_MODE" in | ||
+ | ('conky') | ||
+ | COLOR='green' | ||
+ | ;; | ||
+ | ('shell') | ||
+ | COLOR=32 | ||
+ | ;; | ||
+ | esac | ||
+ | fi | ||
+ | |||
+ | # Set message syntax based on display mode | ||
+ | case "$DISPLAY_MODE" in | ||
+ | ('conky') | ||
+ | MESSAGE='${color %s}%s${color}' | ||
+ | ;; | ||
+ | ('shell') | ||
+ | MESSAGE='\033[1;%sm%s\033[0m\n' | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | # Print the formatted message | ||
+ | printf "$MESSAGE" "$COLOR" "$TEMP_STRING" | ||
+ | |||
+ | exit 0 | ||
+ | |||
+ | </file> | ||
+ | |||
+ | puis , dans conky : | ||
+ | |||
+ | <code>${alignc} disque ssd : ${execpi 5 /home/alain/Téléchargements/show_ssd.sh conky} | ||
+ | </code> | ||
+ | |||
+ | |||
+ | vous devriez obtenir ceci , par exemple : | ||
+ | |||
+ | {{https://debian-facile.org/images/file-Rc472b5879667b83cf4123be96ec5e1d1.png}} | ||
+ | |||