getInfo 2.11.0

This commit is contained in:
kyodev 2017-10-20 18:39:46 +02:00
parent ec01a208f7
commit 790cd190b3
2 changed files with 110 additions and 72 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.10.3
date="19/10/2017"
version=2.11.0
date="20/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -1448,59 +1448,69 @@ figet_gpu(){ # thanks neofetch, assigne $fget_gpu # 09/10/2017
fget_gpu="$gpu"
}
# acpi via kernel, hardware monitor, assigne $fget_hw_nb $fget_hw
figet_hw(){ # 14/10/2017
local ihw ihwx text core fan autre nbf nbc input crit hyst
fget_hw_nb=$(grep -c . <<< $(ls /sys/class/hwmon/ 2>/dev/null)) # nb de ressources gérées via acpi/kernel
if [ "$fget_hw_nb" -eq 0 ]; then
fget_hw="gestion ACPI non accessible"
# assigne $fget_hw
figet_hw(){ #v2 20/10/2017
local name labelF inputF labelT inputT critT hystT maxiT fan temp ihw
if [ ! -d /sys/class/hwmon/ ]; then
fget_hw="gestion acpi hwmon non accessible"
return 1
fi
unset fan core autre
nbf=0
nbc=0
unset fan temp
for ihw in $(ls /sys/class/hwmon/); do
if grep -Eq 'fan[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
nbf=$(( nbf+1 ))
fan+="fan$nbf $(cat /sys/class/hwmon/$ihw/fan*_input)t/mn"$' \n'
fi
[ -e /sys/class/hwmon/$ihw/name ] && name="$(cat /sys/class/hwmon/$ihw/name)" || name="indéfini"
## TEMPÉRATURE
if grep -Eq 'temp[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
input=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_input 2>/dev/null))
crit=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit 2>/dev/null))
hyst=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit_hyst 2>/dev/null))
max=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_max 2>/dev/null))
[ "$input" ] && input=${input::-1} # suppression espace de fin (nécessaire si multi-valeurs)
[ "$crit" ] && crit=${crit::-1}
[ "$hyst" ] && hyst=${hyst::-1}
[ "$max" ] && max=${max::-1}
if grep -q 'core' <<< $(cat /sys/class/hwmon/$ihw/name) ; then
nbc=$(( nbc+1 ))
core+="core$nbc: $input""°C "
[ "$max" ] && core+="(max: $max""°C) "
[ "$crit" ] && core+="(crit: $crit""°C) "
[ "$hyst" ] && core+="(hyst: $hyst""°C) "
[ "$core" ] && core+=$' \n'
else
autre+="$(cat /sys/class/hwmon/$ihw/name) $input""°C "
[ "$max" ] && autre+="(max: $max""°C) "
[ "$crit" ] && autre+="(crit: $crit""°C) "
[ "$hyst" ] && autre+="(hyst: $hyst""°C) "
[ "$autre" ] && autre+=$' \n'
fi
# extraction label
labelT=$(printf "%s/" "$(cat /sys/class/hwmon/$ihw/temp*_label 2>/dev/null)")
# extraction températures
inputT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_input 2>/dev/null))
critT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit 2>/dev/null))
hystT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit_hyst 2>/dev/null))
maxiT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_max 2>/dev/null))
# suppression doublons
critT=$(echo $critT | tr '/' '\n' | sort --unique | tr '\n' '/')
hystT=$(echo $hystT | tr '/' '\n' | sort --unique | tr '\n' '/')
maxiT=$(echo $maxiT | tr '/' '\n' | sort --unique | tr '\n' '/')
# suppression premier /
[ ${critT:0:1} == "/" ] && critT=${critT:1}
[ ${hystT:0:1} == "/" ] && hystT=${hystT:1}
[ ${maxiT:0:1} == "/" ] && maxiT=${maxiT:1}
# suppression dernier caractère (/) fin (nécessaire si multi-valeurs)
[ "$labelT" ] && labelT=${labelT::-1}
[ "$inputT" ] && inputT=${inputT::-1}
[ "$critT" ] && critT=${critT::-1}
[ "$hystT" ] && hystT=${hystT::-1}
[ "$maxiT" ] && maxiT=${maxiT::-1}
# formation affichage
temp+="$(printf "%-8s %s°C %s " "$name" "$inputT" "$labelT")"
[ "$critT" ] && temp+="(crit: $critT""°C) "
[ "$hystT" ] && temp+="(hyst: $hystT""°C) "
[ "$maxiT" ] && temp+="(maxi: $maxiT""°C) "
[ "$temp" ] && temp+=$' \n'
fi
## FAN
if grep -Eq 'fan[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
# extraction label
labelF=$(printf "%s/" $(cat /sys/class/hwmon/$ihw/fan*_label 2>/dev/null))
# extraction vitesse fan
inputF=$(printf "%'d/" $(cat /sys/class/hwmon/$ihw/fan*_input 2>/dev/null))
# suppression dernier caractère (/) fin (nécessaire si multi-valeurs)
[ "$labelF" ] && labelF=${labelF::-1}
[ "$inputF" ] && inputF=${inputF::-1}
# formation affichage
fan+="$(printf "%-8s %st/mn %s" "$name" "$inputF" "$labelF")"
fi
done
fget_hw="$core$autre$fan"
fget_hw=${fget_hw::-1} # suppression dernier $'\n'
fget_hw="$temp$fan"
}
figet_hw_test(){ # 18/10/2017
local text temp
figet_hw_test(){ # 20/10/2017
local text hw_test_temp hw_test_rep
text+="## hwmon test \n\n"
text+="\`/sys/class/hwmon/ 1\` \n"
text+='``` \n'
echo -e "$text" >> "$fileOutput" # flush avant scandir
f__scandir "/sys/class/hwmon/" 1
text='``` \n'
echo -e "$text" >> "$fileOutput" # flush
# sensors et acpi éventuel
unset text
if [ "$(which sensors)" ]; then
text+="\`sensors -u\` \n"
text+='``` \n'
@ -1513,33 +1523,57 @@ figet_hw_test(){ # 18/10/2017
text+="$(acpi -V) \n"
text+='``` \n'
fi
text+="\`/sys/class/thermal/ 1\` \n"
text+='```\n'
echo -e "$text" >> "$fileOutput" # flush avant scandir
f__scandir "/sys/class/thermal/" 1
text='``` \n'
text+="\`/sys/devices/virtual/thermal/ 1\` \n"
text+='``` \n'
echo -e "$text" >> "$fileOutput" # flush avant scandir
f__scandir "/sys/devices/virtual/thermal/" 1
text='``` \n'
echo -e "$text" >> "$fileOutput" # flush
hw_test_function(){
local text
text="\`$1 $2\` \n"
text+='``` '
echo -e "$text" >> "$fileOutput" # flush avant scandir
unset text
if [ -d "$1" ]; then
f__scandir $1 $2
else
text="$1 inexistant"
fi
text+='``` \n'
echo -e "$text" >> "$fileOutput" # flush
}
# /sys/class/hwmon/
hw_test_rep="/sys/class/hwmon/"
hw_test_function "$hw_test_rep" 1
# /sys/class/thermal/thermal_zone0/
hw_test_rep="/sys/class/thermal/thermal_zone0/"
hw_test_function "$hw_test_rep" 0
# /sys/devices/platform/coretemp.0/hwmon/
hw_test_rep="/sys/devices/platform/coretemp.0/hwmon/"
hw_test_function "$hw_test_rep" 1
# fonction script
figet_hw
text+="figet_hw \n"
text="figet_hw \n"
text+='```\n'
text+="$fget_hw \n"
text+='``` \n'
# tempo pour analyse méthode figet_cpu
if [ -f "/sys/class/hwmon/hwmon0/temp1_input" ]; then
temp="$(< "/sys/class/hwmon/hwmon0/temp1_input")"
temp="$((temp * 100 / 10000))" # 33000 x 100 / 10 000 = 330
temp="[${temp/${temp: -1}}.${temp: -1}°C]" # formatage 1 point décimal
fi
text+="hwmon0 temp1_input \n"
text+='``` \n'
text+="$temp \n"
text+='``` \n'
echo -e "$text" >> "$fileOutput" # flush
echo -e "$text" >> "$fileOutput"
# analyse méthode figet_cpu
unset hw_test_temp
if [ -f "/sys/class/hwmon/hwmon0/temp1_input" ]; then
hw_test_temp="$(< "/sys/class/hwmon/hwmon0/temp1_input")"
hw_test_temp="$((hw_test_temp * 100 / 10000))" # 33000 x 100 / 10 000 = 330
hw_test_temp="[${hw_test_temp/${hw_test_temp: -1}}.${hw_test_temp: -1}°C]" # formatage 1 point décimal
else
hw_test_temp=" non accessible"
fi
text="hwmon0/temp1_input ala neofetch \n"
text+='``` \n'
text+="$hw_test_temp \n"
text+='``` \n'
echo -e "$text" >> "$fileOutput" # flush
}
# assigne $ip_local, $gateways, $gateways_type, $gateway, $gateway_type, $if_prioritaire
@ -2051,7 +2085,7 @@ if [ "$retourFUser" -eq 2 ]; then
fi
[ "$(grep -o 'version 4' <<< $(bash --version) | sed 's/version //')" -ge "4" ] || f__error "bash version 4"
f__requis "gawk wget ip>iproute2 lspci>pciutils" # requis pour fonctionnement programme
f__requis "gawk wget ip>iproute2 lspci>pciutils wc>coreutils" # requis pour fonctionnement programme
prg_alert_crit
options=$@
# traitement option
@ -2095,7 +2129,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_reseau
fi_hw
prg_3
exit ;; # test seulement
-c* | all )

View File

@ -6,13 +6,17 @@
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
* réseau réviser
* figet_cpu, refaire
* bug temp cpu (neofetch)
* filtrer temperature 0 (sur i5: 6temp!)
* bug temp cpu (neofetch) temp supprimée temporairement
---
* f__requis f__wget_test fscript_get_version fscript_update fscript_cronAnacron
## 2.11.0 20/10/2017
* révision: figet_hw v2, name, label et filtrage 0°C
* révision: figet_hw_test
## 2.10.3 19/10/2017
* nouveau: fi_journal, journaux kernel et non-kernel via journalctl, dmesg en fallback, x premières lignes