getInfo 2.24.0

This commit is contained in:
kyodev 2017-11-06 09:24:58 +01:00
parent d55318c277
commit 3c790b4ad5
2 changed files with 117 additions and 87 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.23.1
date="05/11/2017"
version=2.24.0
date="06/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -386,7 +386,7 @@ echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
fi_batt(){ # 25/10/2017
local pluriel
[ "$fg_nb_batt" ] || figet_batt # appel figet_battery si pas déjà fait par fi_systeme
[ "$fg_nb_batt" ] || figet_batt
[[ "$fg_nb_batt" == "-1" || "$fg_nb_batt" -gt 0 ]] || return 0 # pas de batterie
###
[ "$fg_nb_batt" -gt 1 ] && pluriel="s" || unset pluriel
@ -702,7 +702,7 @@ fi_disk(){ # 31/10/2017
alert_uuidResume+="**vérifier la config resume**, l'UUID ne correspond pas à celui du swap. \n"
alert_uuidResume+="vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_, voir supprimer ce fichier"
fi
[ "$fg_nb_disk" ] || figet_disk # appel figet_disk si pas déjà fait par fi_systeme
[ "$fg_nb_disk" ] || figet_disk
if [ "$(f__cmd_exist hddtemp)" ]; then
unset dd_temp dd_temp_alert
for idisk in $fg_disk_fixe; do
@ -810,20 +810,22 @@ fi_dmesg(){ # 30/10/2017
unset text
}
fi_graph(){ # 31/10/2017
fi_graph(){ # 06/11/2017
local slots cmd alert_hybrid alert_3D providers preferred current openGl resolutions text
local ig modules glx_dev glx_temp cards="fg_gpu"
local ig modules glx_dev glx_temp cards
# cardsManuel="$(lspci -nnk | grep -EiA 3 'vga|display|3d')" # -nn: textual and numeric ID's, k kernel
# cardsManuel="$(lspci -nnv | grep -iEA11 'vga|display|3d)" # v=verbose
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )" si plusieurs devices possibles??
[ "$fg_nb_gpu" ] || figet_gpu # peut retourner "n/a"/-1
# slots pci video
[ "$fg_nb_gpu" ] || figet_gpu
# bus slots pci video
slots="$(lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1)"
# lspci
if [ "$fg_nb_gpu" -eq 0 ]; then
cmd="lspci -nnv | grep -iEA11 'vga|display|3d'" # commande par défaut à afficher dans le rapport
if ! lspci -nnv &>/dev/null ; then # commande/option indisponible
cards="lspci -nnv non disponible"$'\n'
elif [ "$fg_nb_gpu" -eq 0 ]; then # 0 cartes
cards="pas de carte graphique"$'\n'
elif [ "$fg_nb_gpu" -gt 1 ]; then
elif [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, essai optirun et prime
if [ $(f__cmd_exist optirun) ]; then
for ig in $slots; do
cards+="$(optirun lspci -nnv -s $ig)"$'\n'
@ -835,14 +837,12 @@ fi_graph(){ # 31/10/2017
done
cmd="DRI_PRIME=1 lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport
fi
else
else # une seule carte, ras
for ig in $slots; do
cards+="$(lspci -nnv -s $ig)"$'\n'
done
cmd="lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport
fi
[ "$cards" ] && cards=${cards::-1} # suppression dernier $'\n'
[ "$cards" ] || cards="lspci -nnv non disponible"
cards=${cards::-1} # suppression dernier $'\n'
if [ $(grep -c 'Unknown header type 7f' <<< "$cards") -gt 0 ]; then
alert_hybrid="Une carte graphique est désactivée actuellement, lspci n'est pas complet. \n"
alert_hybrid+="Voir DRI_PRIME, vga-switcheroo, Bumbledee...? \n"
@ -878,14 +878,14 @@ fi_graph(){ # 31/10/2017
# fonctions externes
[ "$fg_resolution" ] || figet_screen
###
[ "$fg_gpu" ] && text="## graphisme \n\n" || text="## graphisme (incomplet) \n\n"
[[ ! "$fg_gpu" =~ lspci ]] && text="## graphisme \n\n" || text="## graphisme (incomplet) \n\n"
# cartes graphiques
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n"
[[ ! "$fg_gpu" =~ lspci ]] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n" || text+="* $fg_gpu \n\n"
# nb écran & résolution(s) active(s)
text+="nombre d'écrans: **$fg_nb_screen** \n"
text+="résolution: **$fg_resolution** \n\n"
# lspci
[ "$cards" ] && f_display "cards" "cmd" "$cmd"
# lspci -nnv
f_display "cards" "cmd" "$cmd"
[ "$alert_hybrid" ] && text+="$alert_hybrid \n\n"
# openGl
[ "$glx_dev" ] && f_display "glx_dev" "sans"
@ -1303,7 +1303,7 @@ fi_system_analyse(){ # 25/10/2017
unset text
}
fi_systeme(){ # 31/10/2017
fi_systeme(){ # 06/11/2017
local mbr uname bootImage initDaemon xorg shells lastboot uptime charge pluriel text
local alim_total alimentation
[ -d /sys/firmware/efi ] && mbr="EFI" || mbr="Legacy (mbr)"
@ -1333,16 +1333,16 @@ fi_systeme(){ # 31/10/2017
uptime=${uptime%%,[[:blank:]]*} # uptime -p parfois inexistant (alpine), suppression depuis ,[blancs]* (fin)
uptime="$( sed 's/up/depuis/; s/week/semaine/; s/weeks/semaines/; s/days/jours/; s/day/jour/;
s/hour[s]*/h/; s/minute[s]*/mn/' <<< $uptime )"
figet_batt
figet_cpu
figet_de
figet_dmi
figet_disk
figet_distrib
[ "$fg_nb_batt" ] || figet_batt
[ "$fg_cpu" ] || figet_cpu
[ "$fg_de" ] || figet_de
[ "$fg_dmi" ] || figet_dmi
[ "$fg_nb_disk" ] || figet_disk
[ "$fg_distrib" ] || figet_distrib
[ "$fg_nb_gpu" ] || figet_gpu
figet_screen
figet_shell
figet_wm
[ "$fg_resolution" ] || figet_screen
[ "$fg_shell" ] || figet_shell
[ "$fg_wm" ] || figet_wm
###
f__architecture || f__info "Architecture non supportée" "vous pouvez contacter $projet, $contact " \
"pour aider à parfaire le script"
@ -1351,7 +1351,7 @@ fi_systeme(){ # 31/10/2017
text+="* CPU \n"
text+=" * **$(sed -n '1p' <<< $fg_cpu)** \n"
text+="* GPU \n"
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/ \* \*\*\1\*\*/' <<<$fg_gpu) \n" || text+="* **n/a** \n"
[[ ! "$fg_gpu" =~ lspci ]] && text+="$(sed -E 's/(.*)/ * **\1**/' <<<$fg_gpu) \n" || text+=" * n/a \n"
text+="* boot **$mbr** \n"
text+="* distribution **$fg_distrib** \n\n"
text+='``` \n'
@ -1412,7 +1412,7 @@ fi_vrms(){ # 03/11/2017
}
# informations batterie(s), assigne $fg_nb_batt $fg_batt
figet_batt(){ #v2 01/11/2017
figet_batt(){ #v2 06/11/2017
local batt_detail batt_nb batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
local batt_volt_min batt_volt_now batt_status batt_cycle batt_sn alert_batt_alarm
local batt_sante batt_restant tempo batRep ibat uevent
@ -1472,6 +1472,7 @@ figet_batt(){ #v2 01/11/2017
batt_capa_design="$(printf "%'d" $batt_capa_design)"
batt_capa_full="$(printf "%'d" $batt_capa_full)"
batt_conso="$(printf "%'d" $batt_conso)"
batt_capa_now="$(printf "%'d" $batt_capa_now)"
fi
# sortie
batt_detail+="$ibat: $(cat $batRep/$ibat/manufacturer 2>/dev/null) "
@ -1482,18 +1483,8 @@ figet_batt(){ #v2 01/11/2017
[ "$batt_capa_full" ] && batt_detail+="pleine charge effective: $batt_capa_full$batt_unit, "
batt_detail+="pleine charge théorique: $batt_capa_design$batt_unit => "
if [[ "$batt_conso" != "0" && "$batt_conso" != "0.00" ]]; then # conso éventuelle
if [ "$batt_unit" == "mAh" ]; then
batt_restant+="(consommation en cours: $(printf "%'d" $batt_conso)$(sed 's/h//' <<< $batt_unit), "
[ "$?" -ne 0 ] && debugBatt="todo"
batt_restant+="charge actuelle: $(printf "%'d" $batt_capa_now)$batt_unit)"
[ "$?" -ne 0 ] && debugBatt="todo"
else
batt_restant+="(consommation en cours: $(printf "%s" $batt_conso)$(sed 's/h//' <<< $batt_unit), "
[ "$?" -ne 0 ] && debugBatt="todo"
batt_restant+="charge actuelle: $(printf "%s" $batt_capa_now)$batt_unit)"
[ "$?" -ne 0 ] && debugBatt="todo"
fi
[ "debugBatt" ] && debugBatt="batt_conso:$batt_conso - batt_capa_now:$batt_capa_now"
batt_restant+="(consommation en cours: $batt_conso$(sed 's/h//' <<< $batt_unit), "
batt_restant+="charge actuelle: $batt_capa_now$batt_unit)"
fi
[ "$batt_sante" ] && batt_detail+="$batt_sante% (indicateur)"$'\n' #ln 2fin
[ "$batt_restant" ] && batt_detail+="$batt_restant"$'\n' #ln 3fin
@ -1512,10 +1503,8 @@ figet_batt(){ #v2 01/11/2017
}
# assigne $fg_cpu (3 lignes description cpu), fg_nb_threads, $fg_cpu_arch, $fg_uarch
figet_cpu(){ #v2 03/11/2017
local cpuinfo speedNom speedMax speedMin speedCpu cpu1 cpu2 cpu3 var_temp vendor family model
local defaut_model="modèle non répertorié" defaut_family="famille non répertoriée"
local defaut_vendor="fabricant non répertorié"
figet_cpu(){ #v2 05/11/2017
local cpuinfo speedNom speedMax speedMin speedCpu cpu1 cpu2 cpu3
cpuinfo="$(cat /proc/cpuinfo)"
# speed
speedNom=$(gawk -F ':' '/cpu MHz/ {printf "%.2f", $2/1000;exit}' <<< "$cpuinfo")
@ -1564,6 +1553,14 @@ figet_cpu(){ #v2 03/11/2017
# arch processeur
[ $(grep -cm1 'flags.* lm ' /proc/cpuinfo) -ge 1 ] && fg_cpu_arch="64bits" || fg_cpu_arch="32bits"
# traitement µarchitecture
figet_cpu_uarch
}
# dépend de figet_cpu ($cpuinfo), appel via figet_cpu, assigne $fg_uarch
figet_cpu_uarch(){ # 05/11/2017
local var_temp vendor family model
local defaut_model="modèle non répertorié" defaut_family="famille non répertoriée"
local defaut_vendor="fabricant non répertorié"
vendor=$(grep -m1 '^vendor_id' /proc/cpuinfo) # vendor cpuinfo
vendor=${vendor#*: } # extraction valeur vendor
var_temp=$(grep -m1 '^cpu family' /proc/cpuinfo) # family cpuinfo
@ -1670,16 +1667,17 @@ figet_cpu(){ #v2 03/11/2017
esac ;;
*) fg_uarch="AMD $defaut_family";;
esac ;;
*Centaur*) fg_uarch="Centaur (avec quelques processeurs VIA) $defaut_vendor";;
*Cyrix*) fg_uarch="Cyrix $defaut_vendor";;
*TransmetaU* | *TMx86*) fg_uarch="Transmeta $defaut_vendor";;
*NSC*) fg_uarch="National Semiconductor $defaut_vendor";;
*NexGen*) fg_uarch="NexGen $defaut_vendor";;
*Rise*) fg_uarch="Rise $defaut_vendor";;
*SiS*) fg_uarch="SiS $defaut_vendor";;
*UMC*) fg_uarch="UMC $defaut_vendor";;
*VIA*) fg_uarch="VIA $defaut_vendor";;
*Vortex*) fg_uarch="Vortex $defaut_vendor";;
*arm*) fg_uarch="ARM (avec quelques processeurs VIA) $defaut_vendor";; # à vérifier, info kernel, récente fonctionnalité 2016?
*centaur*) fg_uarch="Centaur (avec quelques processeurs VIA) $defaut_vendor";;
*cyrix*) fg_uarch="Cyrix $defaut_vendor";;
*nexgen*) fg_uarch="NexGen $defaut_vendor";;
*nsc*) fg_uarch="National Semiconductor $defaut_vendor";;
*rise*) fg_uarch="Rise $defaut_vendor";;
*sis*) fg_uarch="SiS $defaut_vendor";;
*transmeta* | *TMx86*) fg_uarch="Transmeta $defaut_vendor";;
*umc*) fg_uarch="UMC $defaut_vendor";;
*via*) fg_uarch="VIA $defaut_vendor";;
*vortex*) fg_uarch="Vortex $defaut_vendor";;
*) fg_uarch="$defaut_vendor";;
esac
}
@ -1824,50 +1822,76 @@ figet_distrib(){ # 01/11/2017
}
# informations DMI, (firmware partie matériel), assigne $fg_dmi
figet_dmi(){ # 30/10/2017
# lors révision tester $(grep -s . /sys/class/dmi/id/*)
# ex: /sys/class/dmi/id/bios_vendor:American Megatrends Inc.
local product board bios tempo idmi indic1 indic2
unset indic1 indic2
# ligne1 Pc/produit
figet_dmi(){ #v2 06/11/2017
local product board bios tempo idmi indic1="" indic2=""
local chassis_type=( # type de chassis selon smbios janvier 2017
# http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf
# DSP0134 version: 3.1.1, janvier 2017, $ 7.4.1 System Enclosure or Chassis Types, table 17
'Other' #01h
'Unknown' #02h
'Desktop' #03h
'Low Profile Desktop' #04h
'Pizza Box' #05h
'Mini Tower' #06h
'Tower' #07h
'Portable' #08h
'Laptop' #09h
'Notebook' #0Ah
'Hand Held' #0Bh
'Docking Station' #0Ch
'All in One' #0Dh
'Sub Notebook' #0Eh
'Space-saving' #0Fh
'Lunch Box' #10h
'Main Server Chassis' #11h
'Expansion Chassis' #12h
'SubChassis' #13h
'Bus Expansion Chassis' #14h
'Peripheral Chassis' #15h
'RAID Chassis' #16h
'Rack Mount Chassis' #17h
'Sealed-case PC' #18h
'Multi-system chassis' #19h
'Compact PCI' #1Ah
'Advanced TCA' #1Bh
'Blade' #1Ch
'Blade Enclosure' #1Dh
'Tablet' #1Eh
'Convertible' #1Fh
'Detachable' #20h
)
# ligne1 $product
for idmi in sys_vendor product_name product_version chassis_type; do
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
tempo=$(sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< $tempo | xargs)
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null) # extraction valeur
tempo=$(sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< $tempo | xargs) # ménage
if [ "$idmi" == "chassis_type" ]; then
[ "$tempo" == "10" ] && tempo="(Notebook)" || tempo="($tempo)"
tempo="(${chassis_type[ $(( ${tempo##0} - 1 )) ]})" # valeur tableau après mise en forme index
fi
# indic1 pour tester égalité avec board
# indic1 pour tester égalité avec $board
[[ "$idmi" == "sys_vendor" || "$idmi" == "product_name" ]] && indic1+="$tempo "
product+="$tempo "
product+="$tempo "
done
# ligne2 carte mère
# ligne2 $board (carte mère) éventuellement pas affiché
for idmi in board_vendor board_name board_version; do
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
tempo=$(sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< $tempo | xargs)
# indic2 pour tester égalité avec product
# indic2 pour tester égalité avec $product
[[ "$idmi" == "board_vendor" || "$idmi" == "board_name" ]] && indic2+="$tempo "
board+="$tempo "
board+="$tempo "
done
# ligne3 bios
# ligne3 $bios
for idmi in bios_vendor bios_version bios_date; do
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
tempo=$(sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< $tempo | xargs)
bios+="$tempo "
bios+="$tempo "
done
fg_dmi=$(printf '%7s: %s' "produit" "$product")$'\n'
[ "$indic1" != "$indic2" ] && fg_dmi+=$(printf '%7s: %s' "board" "$board")$'\n'
fg_dmi+=$(printf '%7s: %s' "bios" "$bios")
# chassis, pas utilisé
# for idmi in chassis_vendor chassis_version chassis_type; do
# tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
# tempo=$(sed 's/x.xx*//' <<< $tempo)
# [[ "$idmi" == "chassis_type" && "$tempo" == "10" ]] && tempo="Notebook"
# chassis+="$tempo "
# done
[ "$product" ] && fg_dmi=$(printf "%s: %s " "prod." "$product")$'\n'
[[ "$board" && "$indic1" != "$indic2" ]] && fg_dmi+=$(printf "%s: %s " "board" "$board")$'\n'
[ "$bios" ] && fg_dmi+=$(printf "%s : %s" "bios" "$bios")
}
# assigne $fg_gpu, $fg_nb_gpu peut retourner "n/a"/-1
figet_gpu(){ # 31/10/2017
# assigne $fg_gpu (liste des gpu), $fg_nb_gpu peut retourner -1 si détection impossible (lspci -mm en erreur?)
figet_gpu(){ #v2 31/10/2017
fg_gpu="lspci -mm non disponible" fg_nb_gpu=-1
local lspci="$(lspci -mm)"
[ "$?" -gt 0 ] && return 1
@ -2500,7 +2524,6 @@ prg_2(){ # traitements principaux
}
prg_3(){ # fin de traitements
echo -e "--- \n" >> "$fileOutput"
[ "$debugBatt" ] && echo -e "$debugBatt \n" >> "$fileOutput"
echo -e "$ligneRapport \n" >> "$fileOutput"
f__dialog_oui_non "non" "\n exporter sur le pastebin par défaut?" && fipaste
f__info "le rapport est disponible en local, fichier:$YELLOW $fileOutput" \
@ -2624,7 +2647,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_cpu
fi_batt
prg_3
exit ;; # test seulement
-c* | all )

View File

@ -3,8 +3,15 @@
* f__wcv
## 2.24.0 06/11/2017
* nouveau: type de chassis selon smbios janvier 2017
* révision: fi_graph, fi_systeme (alpine linux, busybox) options lspci absentes
* révision: figet_batt
## 2.23.1 05/11/2017
* figet_cpu scindé, appel figet_cpu_uarch
* fix: flags cpu
## 2.23.0 04/11/2017