CONKY : Additionner resultat de 2 commandes ? [Réglé]

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Reprise du message précédent
Ok, essayons ça :Code BASH :
#!/bin/bash if [ "x${1}" = "xRX" ]; then ENP7S0="$(/sbin/ip -s -a link show dev enp7s0 | sed -ne '/RX:/{n;p;}' | sed -e 's/[[:space:]]*\([\.[:alnum:]]*\)[[:space:]].*$/\1/')" WLP8S0="$(/sbin/ip -s -a link show dev wlp8s0 | sed -ne '/RX:/{n;p;}' | sed -e 's/[[:space:]]*\([\.[:alnum:]]*\)[[:space:]].*$/\1/')" elif [ "x${1}" = "xTX" ]; then ENP7S0="$(/sbin/ip -s -a link show dev enp7s0 | sed -ne '/TX:/{n;p;}' | sed -e 's/[[:space:]]*\([\.[:alnum:]]*\)[[:space:]].*$/\1/')" WLP8S0="$(/sbin/ip -s -a link show dev wlp8s0 | sed -ne '/TX:/{n;p;}' | sed -e 's/[[:space:]]*\([\.[:alnum:]]*\)[[:space:]].*$/\1/')" fi SUM="$(echo $((${ENP7S0:=0}+${WLP8S0:=0})) | numfmt --to=iec --suffix=o )" echo "${SUM}" exit 0
Dans la console, confirmes tu que lorsque tu tapes :
sumlink RX
sumlink TX
tu as bien les deux résultats souhaité ?
Je n'aime pas que les résultats ne s'actualisent pas... Dans la console, est-ce que ça s'actualise ?
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Code TEXT :
${color cyan}${goto 15}Total reçu: ${goto 130}${color white}${texeci 1000 /home/${USER}/bin/sumlink RX} ${color cyan}${goto 15}Total émis: ${goto 130}${color white}${texeci 1000 /home/${USER}/bin/sumlink TX}
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

Fred6681 Membre non connecté
-
- Voir le profil du membre Fred6681
- Inscrit le : 14/04/2008
- Groupes :
pour ce qui est du nouveau script y'a un probleme
Code :
$ sumlink TX
/home/fredo/.local/bin/sumlink: ligne 12: erreur de syntaxe : fin de fichier prématurée
$ sumlink RX
/home/fredo/.local/bin/sumlink: ligne 12: erreur de syntaxe : fin de fichier prématurée
Édité par Fred6681 Le 07/10/2020 à 14h33

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
elif [ "x${1}" = "xTX" ]; then
à la place de :
else if [ "x${1}" = "xTX" ]; then
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

Fred6681 Membre non connecté
-
- Voir le profil du membre Fred6681
- Inscrit le : 14/04/2008
- Groupes :

ça fonctionne correctement, merci Beaucoup

J'aurais préféré que les modifs soient faites uniquement dans le fichier conky.rc mais bon ça fonctionne bien comme ça.
Encore Merci
Édité par Fred6681 Le 07/10/2020 à 16h04

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Code TEXT :
${texeci 1000 commande}
s'il te plait ?
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

Fred6681 Membre non connecté
-
- Voir le profil du membre Fred6681
- Inscrit le : 14/04/2008
- Groupes :
Code TEXT :
${color cyan}${goto 15}Total reçu: ${goto 130}${color white}${exec sumlink RX} ${color cyan}${goto 15}Total émis: ${goto 130}${color white}${exec sumlink TX}
J'ai remplacer le texeci 1000 par exec, je sais pas pourquoi mais ça empêcher l'actualisation des données
Édité par Fred6681 Le 07/10/2020 à 16h01

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Voir :
http://conky.sourceforge.net/variables.html
Citation :
texeci | interval command | Runs a command at an interval inside a thread and displays the output. Same as $execi, except the command is run inside a thread. Use this if you have a slow script to keep Conky updating. You should make the interval slightly longer then the time it takes your script to execute. For example, if you have a script that take 5 seconds to execute, you should make the interval at least 6 seconds. See also $execi. This object will clean up the thread when it is destroyed, so it can safely be used in a nested fashion, though it may not produce the desired behaviour if used this way.
Je suppose que l'interval est défini dans la structure conky.config , et la base de temps serait en seconde, voir :
https://www.linux.com/news/experts-guide-configuring-conky/
Citation :
The first thing you have to do is specify the update interval, or how often Conky “collects” the monitored data. Specify the update_interval option in seconds;
Donc, apparemment, d'après ton code complet vu ici :
https://www.mageialinux-online.org/forum/topic-27971-1+conky-additionner-resultat-de-2-commandes-e.php#m274759
tu mettais à jour l'affichage des données toutes les 1000 secondes, soit toutes les 17 minutes...
As tu bien attendu 17 minutes avant de dire que le script ne marchait pas ?
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

Fred6681 Membre non connecté
-
- Voir le profil du membre Fred6681
- Inscrit le : 14/04/2008
- Groupes :
tu as raison j'aurais du attendre 17 minutes pour dire que les résultats ne s'actualisent pas
donc la je me demande si je laisse tel quel avec exec qui d'aprés ce que je vois semble s'actualisé toutes les secondes où alors je le remplace par texeci et un nombre de secondes

Jybz Membre non connecté
-
- Voir le profil du membre Jybz
- Inscrit le : 10/10/2018
- Groupes :
-
Administrateur
-
Forgeron
Qu'en penses tu ?
Téléverser une image : /wiki/hebergement-de-fichiers-sur-mlo
Arch | Machine | OS |
x86_64 | lenovo x250 | mga9 |
armv7hl | bananapro | mga9 |
aarch64 | Raspberry Pi 4B | mga9 |

magnux77 Membre non connecté
-
- Voir le profil du membre magnux77
- Inscrit le : 21/09/2009
- Groupes :
-
Membre d'Honneur
Citation :
texeci
Arguments
interval command
Runs a command at an interval inside a thread and displays the output. Same as ${execi} except the command is run inside a thread. Use this if you have a slow script to keep Conky updating. You should make the interval slightly longer then the time it takes your script to execute. For example, if you have a script that takes 5 seconds to execute, you should make the interval at least 6 seconds. See also ${execi}. This object will clean up the thread when it is destroyed, so it can safely be used in a nested fashion, though it may not produce the desired behaviour if used this way.
${texeci 600 ~/work.sh}
Arguments
interval command
Runs a command at an interval inside a thread and displays the output. Same as ${execi} except the command is run inside a thread. Use this if you have a slow script to keep Conky updating. You should make the interval slightly longer then the time it takes your script to execute. For example, if you have a script that takes 5 seconds to execute, you should make the interval at least 6 seconds. See also ${execi}. This object will clean up the thread when it is destroyed, so it can safely be used in a nested fashion, though it may not produce the desired behaviour if used this way.
${texeci 600 ~/work.sh}
Comme toi, Jybz, je pouvais faire une somme dans le shell mais je n'avais aucune commande de calcul dans le Casey's Conky Reference
Édité par magnux77 Le 07/10/2020 à 17h45
...depuis Mandrake 7
Membre de l'April - « promouvoir et défendre le Logiciel Libre»
Soutien Framasoft - « Changer le monde, un octet à la fois»
Config n°1 : cpu=AMD64x6 mem=16G SSD=64G HDD=1T OS=Mageia8-64 DE=Xfce, Config n°2 : Dell Latitude E6410 SSD=120G OS=Mageia8 DE=Xfce, Config n°3 : ThinkpadR40 SSD=32G OS=[Manjaro, Parabola, Mageia6] DE=Xfce, Config n°4 : EeePC901 SSD=20Gb, OS=[SliTaz5/Lxde, Mageia8/Xfce]
Membre de l'April - « promouvoir et défendre le Logiciel Libre»
Soutien Framasoft - « Changer le monde, un octet à la fois»
Config n°1 : cpu=AMD64x6 mem=16G SSD=64G HDD=1T OS=Mageia8-64 DE=Xfce, Config n°2 : Dell Latitude E6410 SSD=120G OS=Mageia8 DE=Xfce, Config n°3 : ThinkpadR40 SSD=32G OS=[Manjaro, Parabola, Mageia6] DE=Xfce, Config n°4 : EeePC901 SSD=20Gb, OS=[SliTaz5/Lxde, Mageia8/Xfce]
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie