getInfo 2.16.0

This commit is contained in:
kyodev 2017-10-25 10:03:56 +02:00
parent fc5511c83e
commit 579ee481a9
2 changed files with 102 additions and 63 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.15.0
date="24/10/2017"
version=2.16.0
date="25/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -307,18 +307,18 @@ f__wget_test(){ # 17/10/2017
# f_display: $1 variable à afficher, $2=var|cmd|sans (type titrage) [$3 titrage] [$4 commentaire titrage dans cmd]
# f_display "variable" "type" "titrage" "titrage_commentaire"
f_display(){ # 21/10/2017
[ "$text" ] && echo -e "$text" >> "$fileOutput" # flush avant fonction
f_display(){ # 25/10/2017
[ "$text" ] && printf "$text" >> "$fileOutput" # flush avant fonction de text parent
unset text
local text
[[ "$2" == "sans" || "$2" == "var" || "$2" == "cmd" ]] || text="erreur script \$2 ($1 $2 $3)"
[ "$2" == "var" ] && text="**$3** \n"
[ "$2" == "cmd" ] && text="\`$3\` \n"
[[ "$2" == "cmd" && "$4" ]] && text="\`$3\` **$4** \n"
text+='``` \n'
text+="${!1} \n"
text+='``` \n\n'
echo -e "$text" >> "$fileOutput" # flush fonction
local display=""
[[ "$2" == "sans" || "$2" == "var" || "$2" == "cmd" ]] || display="erreur script \$2 ($1 $2 $3)"
[ "$2" == "var" ] && display="**$3** \n"
[ "$2" == "cmd" ] && display="\`$3\` \n"
[[ "$2" == "cmd" && "$4" ]] && display="\`$3\` **$4** \n"
display+='``` \n'
display+="${!1} \n"
display+='``` \n'
echo -e "$display" >> "$fileOutput" # flush fonction
}
# $1 répertoire à scanner, $2 profondeur
@ -372,7 +372,7 @@ EOF
echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
}
fi_batt(){ # 22/10/2017
fi_batt(){ # 25/10/2017
local pluriel
[ "$fget_batt_nb" ] || figet_batt # appel figet_battery si pas déjà fait par fi_systeme
[[ "$fget_batt_nb" == "-1" || "$fget_batt_nb" -gt 0 ]] || return 0 # pas de batterie
@ -380,9 +380,11 @@ fi_batt(){ # 22/10/2017
[ "$fget_batt_nb" -gt 1 ] && pluriel="s" || unset pluriel
text="## batterie$pluriel \n\n"
f_display "fget_batt" "sans"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_cpu(){ # 22/10/2017
fi_cpu(){ # 25/10/2017
#manuellement: lscpu (util-linux)
local cpu_flags text pluriel
cpu_flags="$(sed -n 's/^flags.*: \(.*\)$/\1/p;' /proc/cpuinfo | sed -n '1p')"
@ -392,9 +394,11 @@ fi_cpu(){ # 22/10/2017
text="## processeur$pluriel \n\n"
f_display "fget_cpu" "sans"
f_display "cpu_flags" "var" "flags cpu:"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_disk(){ # 22/10/2017
fi_disk(){ # 25/10/2017
local disk_lsblk disk_df disk_df_i fstab resume idResume idSwap alert_uuidResume text pluriel
local dd_temp dd_temp_alert dd_temp idisk tempodd
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
@ -455,9 +459,9 @@ fi_disk(){ # 22/10/2017
text+="$fget_disk_detail \n"
text+='``` \n\n'
text+="**types de disque** \n\n"
text+="| ata | usb | mmc | nvme | \n"
text+="| sata | usb | mmc | nvme | \n"
text+="| :---: | :---: | :---: | :---: | \n"
text+="| $fget_disk_sata | $fget_disk_usb | $fget_disk_mmc | $fget_disk_nvme | \n\n"
text+="| $fget_disk_ata | $fget_disk_usb | $fget_disk_mmc | $fget_disk_nvme | \n\n"
# éventuellement hddtemp
[ "$dd_temp" ] && f_display "dd_temp" "cmd" "hddtemp /dev/sd?" "(température disques)"
if [ "$dd_temp_alert" ]; then
@ -479,10 +483,11 @@ fi_disk(){ # 22/10/2017
if [ "$alert_uuidResume" ]; then
text+="$alert_uuidResume \n\n"
fi
echo -e "$text" >> "$fileOutput"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_dmesg(){ # 22/10/2017
fi_dmesg(){ # 25/10/2017
local dmesg_err dmesg_warn dmesg_crit file text nb_lignes=25
file="/tmp/$$-$RANDOM-dmesg"
[ "$EUID" -eq 0 ] || echo
@ -519,10 +524,11 @@ fi_dmesg(){ # 22/10/2017
f_display "dmesg_err" "cmd" "dmesg -l err" "(erreur, $nb_lignes premières lignes)"
f_display "dmesg_warn" "cmd" "dmesg -l warn" "(warning, $nb_lignes premières lignes)"
text+="**les $nb_lignes premières lignes commencent à la date la plus ancienne encore dans les logs kernel** \n\n"
echo -e "$text" >> "$fileOutput"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_graph(){ # 24/10/2017
fi_graph(){ # 25/10/2017
local slotGraphCards graphCards openGl resolutions logXorg modules ig text
# graphCardsManuel="$(lspci -nnk | grep -EiA 3 'vga|display|3d')"
# graphCardsManuel="$(lspci -nnv | grep -iEA 13 'vga|display|3d)"
@ -567,10 +573,11 @@ fi_graph(){ # 24/10/2017
text+="Modules non reconnus. Il serait bien de communiquer le retour de \`lsmod\` pour mettre "
text+="à jour le script. Merci de contacter $projet: \n$contact "
fi
echo -e "$text" >> "$fileOutput" # flush fonction
printf "$text\n" >> "$fileOutput"
unset text
}
fi_hw(){ # 24/10/2017
fi_hw(){ # 25/10/2017
figet_hw
###
text="## hardware monitor ACPI \n\n"
@ -578,11 +585,12 @@ fi_hw(){ # 24/10/2017
f_display "fget_hw" "sans"
else
text+="**pas d'informations détectées** \n\n"
echo -e "$text" >> "$fileOutput"
fi
printf "$text\n" >> "$fileOutput"
unset text
}
fi_journal(){ # 24/10/2017
fi_journal(){ # 25/10/2017
local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok file text nb_lignes=25
[ "$(f__cmd_exist journalctl)" ] || fi_dmesg # pas systemd, appel dmesg
file="/tmp/$$-$RANDOM-journalctl"
@ -640,10 +648,11 @@ fi_journal(){ # 24/10/2017
f_display "jctl_warn_nok" "cmd" "journalctl --no-hostname --boot 0 -p 4..4 | grep -v kernel" \
"(hors kernel, warning, $nb_lignes premières lignes)"
text+="**les $nb_lignes premières lignes commencent à la date du dernier boot** \n\n"
echo -e "$text" >> "$fileOutput"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_locale(){ # 22/10/2017
fi_locale(){ # 25/10/2017
local locale timezone xKeyboardMap keyboard timedatectl alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
locale="$(grep -Ev '#|^$' /etc/default/locale)"
timezone="$(< /etc/timezone)"
@ -669,9 +678,11 @@ et/ou installer le démon Ntp: apt install ntp \n"
[ "$alert_Ntp" ] && text+="$alert_Ntp_info \n"
[ "$xKeyboardMap" ] && f_display "xKeyboardMap" "cmd" "setxkbmap -query"
f_display "keyboard" "cmd" "grep -Ev '#|^$' /etc/default/keyboard"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_log_xorg(){ # 24/10/2017
fi_log_xorg(){ # 25/10/2017
[ "$ENV_SSH" ] && return 0
local logXorg xfile extract text nb_lignes=50
# Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice,
@ -699,9 +710,11 @@ fi_log_xorg(){ # 24/10/2017
f_display "logXorg" "cmd" \
"grep -Es '\(WW\)|\(EE\)|\(\?\?\)' /var/log/Xorg.?.log /home/<user>/.local/share/xorg/Xorg.?.log" \
"(Xorg.log)"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_mem(){ # 24/10/2017
fi_mem(){ # 25/10/2017
local swappiness text var_temp
swappiness="$(cat /proc/sys/vm/swappiness 2>/dev/null)"
figet_mem "mem" #options possibles mem swap total notitle nocoltitle
@ -712,9 +725,11 @@ fi_mem(){ # 24/10/2017
###
text="## mémoire \n\n"
f_display "var_temp" "sans"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_nm(){ # 22/10/2017
fi_nm(){ # 25/10/2017
[ "$(f__cmd_exist nmcli)" ] || return 0
local nm_etat nm_conf text
nm_etat="$(grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state)"
@ -723,9 +738,11 @@ fi_nm(){ # 22/10/2017
text="## NetworkManager \n\n"
f_display "nm_etat" "cmd" "grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"
f_display "nm_conf" "cmd" "grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_nm_wifis(){ # 22/10/2017
fi_nm_wifis(){ # 25/10/2017
[ "$(f__cmd_exist nmcli)" ] || return 0
local nm_wifis nm_connected text
nm_wifis="$(nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list)"
@ -734,9 +751,11 @@ fi_nm_wifis(){ # 22/10/2017
[ "$nm_wifis" ] || return 0
text="## wifis à proximité \n\n"
f_display "nm_wifis" "cmd" "nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_nonFree(){ # 22/09/2017
fi_nonFree(){ # 25/09/2017
local vrms text tempo tempo1 tempo2 pluriel
if [ "$(f__cmd_exist vrms)" ]; then
vrms="$(vrms)"
@ -750,9 +769,11 @@ fi_nonFree(){ # 22/09/2017
# [[ "$tempo1" && "$tempo" -gt 1 ]] && pluriel="s" || unset pluriel
text="## paquets$pluriel non-libres$pluriel \n\n"
f_display "vrms" "cmd" "vrms"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_reseau(){ # 24/10/2017
fi_reseau(){ # 25/10/2017
local slotNetCard netCard ip_a iwconfig interfaces route resolv liste_canaux_wifi ifx text pluriel
# netCardManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')"
# netCardManuel="$(lspci -nnv | grep -EiA 15 'network|ethernet')"
@ -831,10 +852,11 @@ fi_reseau(){ # 24/10/2017
else
text+="**Modules chargés non reconnus**"
fi
echo -e "$text" >> "$fileOutput" # flush fonction
printf "$text\n" >> "$fileOutput"
unset text
}
fi_sources(){ # 24/10/2017
fi_sources(){ # 25/10/2017
[ "$(f__cmd_exist dpkg)" ] || return 0
local sources dateMaj nb_packages apt text pluriel
local alert_autoremove alert_nbAutoremove alert_paquetToRemove alert_httpredir alert_httpredir_text
@ -903,10 +925,11 @@ fi_sources(){ # 24/10/2017
f_display "alert_paquetBiz" "var" "$alert_paquetBiz_text0"
text+="$alert_paquetBiz_text"' \n\n'
fi
echo -e "$text" >> "$fileOutput" # flush fonction
printf "$text\n" >> "$fileOutput"
unset text
}
fi_ssid(){ # 22/10/2017
fi_ssid(){ # 25/10/2017
[ "$(f__cmd_exist nmcli)" ] || f__error "NetworkManager requis"
local nm_ssid file="/tmp/$$-$RANDOM-fi_ssid" text
# nm_ssid="$(grep -Ev '#|^$' /etc/NetworkManager/system-connections/*)"
@ -927,10 +950,11 @@ fi_ssid(){ # 22/10/2017
text="## configuration(s) ssid networkmanager \n\n"
text+="$GREEN""grep -Ev '#|^$' /etc/NetworkManager/system-connections/*$STD \n\n"
text+="$nm_ssid \n\n"
echo -e "$text"
printf "$text" >> "$fileOutput"
unset text
}
fi_system_analyse(){ # 22/10/2017
fi_system_analyse(){ # 25/10/2017
[ "$(f__cmd_exist systemd-analyze)" ] || return 0 # pas systemd
local bootTime bootBlame text
bootTime="$(systemd-analyze time)"
@ -939,9 +963,11 @@ fi_system_analyse(){ # 22/10/2017
text="## analyse boot \n\n"
text+="$(sed 's/Startup finished in /**durée de boot:** /; s/userspace/espace utilisateur/; s/= \(.*\)$/= **\1**/' <<< $bootTime) \n\n"
f_display "bootBlame" "cmd" "systemd-analyze blame | head -n 20"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_systeme(){ # 23/10/2017
fi_systeme(){ # 25/10/2017
local mbr description uname bootImage initDaemon xorg shells lastboot uptime charge pluriel text
local alim_total alimentation
[ -d /sys/firmware/efi ] && mbr="EFI" || mbr="Legacy (mbr)"
@ -983,7 +1009,7 @@ fi_systeme(){ # 23/10/2017
f__architecture || f__info "Architecture non supportée" "vous pouvez contacter $projet, $contact " \
"pour aider à parfaire le script"
text="## système \n\n"
text+="$fget_dmi \n\n"
text+="> **$fget_dmi** \n\n"
text+="* CPU \n"
text+=" * **$(sed -n '1p' <<< $fget_cpu)** \n"
text+="* GPU \n"
@ -1012,10 +1038,11 @@ fi_systeme(){ # 23/10/2017
text+="dernier boot: $lastboot, uptime: $uptime \n"
text+="charge système depuis les 1, 5 et 15 dernières minutes: $charge \n"
text+='``` \n\n'
echo -e "$text" >> "$fileOutput"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_usb(){ # 22/10/2017
fi_usb(){ # 25/10/2017
local lsusb lsusb_t text
lsusb="$(lsusb)"
lsusb_t="$(lsusb -t)"
@ -1023,10 +1050,12 @@ fi_usb(){ # 22/10/2017
text="## USB \n\n"
f_display "lsusb" "cmd" "lsusb"
f_display "lsusb_t" "cmd" "lsusb -t"
printf "$text\n" >> "$fileOutput"
unset text
}
# informations batterie(s), assigne $fget_batt_nb $fget_batt
figet_batt(){ #v2 23/10/2017
figet_batt(){ #v2 25/10/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
@ -1053,11 +1082,16 @@ figet_batt(){ #v2 23/10/2017
batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_CHARGE_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_conso="$(gawk -F '=' '/POWER_SUPPLY_CURRENT_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
elif grep -q 'POWER_SUPPLY_ENERGY_' <<< $uevent ; then
batt_unit="mWh"
batt_capa_design="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL_DESIGN=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_capa_full="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_conso="$(gawk -F '=' '/POWER_SUPPLY_POWER_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
# batt_unit="mWh"
# batt_capa_design="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL_DESIGN=/ {printf "%d", $2/1000}' <<< $uevent)" # mW
# batt_capa_full="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL=/ {printf "%d", $2/1000}' <<< $uevent)" # mW
# batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mW
# batt_conso="$(gawk -F '=' '/POWER_SUPPLY_POWER_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mW
batt_unit="Wh"
batt_capa_design="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL_DESIGN=/ {printf "%.3f", $2/1000000}' <<< $uevent)" # W
batt_capa_full="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL=/ {printf "%.3f", $2/1000000}' <<< $uevent)" # W
batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_NOW=/ {printf "%.3f", $2/1000000}' <<< $uevent)" # W
batt_conso="$(gawk -F '=' '/POWER_SUPPLY_POWER_NOW=/ {printf "%.3f", $2/1000000}' <<< $uevent)" # W
else
batt_capa_design="na"
fi
@ -1116,7 +1150,7 @@ figet_batt(){ #v2 23/10/2017
}
# assigne $fget_cpu (3 lignes description cpu)
figet_cpu(){ #v2 23/10/2017
figet_cpu(){ #v2 25/10/2017
local cpuinfo speedNom speedMax speedMin speedCpu cpu1 cpu2 cpu3
cpuinfo="$(cat /proc/cpuinfo)"
# speed
@ -1144,7 +1178,7 @@ figet_cpu(){ #v2 23/10/2017
gawk -F ':' '
/^vendor_id/{gsub(/ /,"",$2);vendor=$2}; /^cpu family/{family=$2};
/^model[^ ]/{model=$2}; /^stepping/{rev=$2}
END {print vendor" famille" family", modèle"model", révision" rev}
END {print "{fréq. mini/nominale/maxi} " vendor" famille" family", modèle"model", révision" rev}
' <<< "$cpuinfo"
)
cpu3=$(
@ -1738,7 +1772,7 @@ fipaste(){
}
# $1 fichier à exporter, $2 durée de conservation en jour; $3 debug
fipaste_curl_pastery(){ # 19/10/2017
fipaste_curl_pastery(){ # 25/10/2017
[ -e "$1" ] || f__error "fichier $1 inexistant"
local curl id pluriel
# curl -X POST "https://www.pastery.net/api/paste/?title=getInfo&language=markdown" -F file=@$1
@ -1750,7 +1784,7 @@ fipaste_curl_pastery(){ # 19/10/2017
else
id="$(echo $curl | cut -d '"' -f 4)"
[ "$pasteDuration" -gt 1 ] && pluriel="s" || unset pluriel
f__info "\n votre paste:$GREEN https://www.pastery.net/$id/" \
f__info "votre paste:$GREEN https://www.pastery.net/$id/" \
"(valide pendant $RED$pasteDuration jour$pluriel)"
echo -e "exporté sur https://www.pastery.net/$id/ \n\n" >> "$fileOutput"
fi
@ -1907,34 +1941,34 @@ prg_1(){ # début
echo > "$fileOutput"
chown $user_: "$fileOutput" &>/dev/null
chmod 666 "$fileOutput" &>/dev/null # rw-rw-rw-, si root permet écriture & effacement à tous
echo -e "# $script sur $(uname -n) \n" > "$fileOutput"
echo -e "$ligneRapport \n" >> "$fileOutput"
echo -e "> **$script** sur $(uname -n) \n" > "$fileOutput"
echo -e "$ligneRapport \n\n" >> "$fileOutput"
}
prg_2(){ # traitements principaux
printf " ."
if [[ "$1" == all || "$1" =~ s ]]; then #systeme, matériel -cs
echo -e "# Système et matériel \n" >> "$fileOutput"
echo -e "# Système et matériel \n\n" >> "$fileOutput"
for i in fi_systeme fi_cpu fi_mem fi_hw fi_batt fi_graph fi_disk fi_usb ; do
$i
printf "."
done
fi
if [[ "$1" == all || "$1" =~ c ]]; then #configuration #debian, packages -cc
echo -e "# Configuration et packages \n" >> "$fileOutput"
echo -e "# Configuration et packages \n\n" >> "$fileOutput"
for i in fi_locale fi_nonFree fi_sources ; do
$i
printf "."
done
fi
if [[ "$1" == all || "$1" =~ r ]]; then #reseau -cr
echo -e "# Réseau \n" >> "$fileOutput"
echo -e "# Réseau \n\n" >> "$fileOutput"
for i in fi_reseau fi_nm fi_nm_wifis ; do
$i
printf "."
done
fi
if [[ "$1" == all || "$1" =~ a ]]; then #analyse -ca
echo -e "# Analyse \n" >> "$fileOutput"
echo -e "# Analyse \n\n" >> "$fileOutput"
for i in fi_system_analyse fi_log_xorg fi_journal ; do
$i
done
@ -1943,7 +1977,7 @@ prg_2(){ # traitements principaux
prg_3(){ # fin de traitements
echo -e "--- \n" >> "$fileOutput"
echo -e "$ligneRapport \n" >> "$fileOutput"
f__dialog_oui_non "non" "\n\n exporter sur le pastebin par défaut?" && fipaste
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" \
"vous pouvez le visualiser ultérieurement avec $GREEN$script -l" \
"vous pourrez l'exporter ultérieurement avec $BLUE$script -p"
@ -2064,8 +2098,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_sources
fi_reseau
fi_disk
prg_3
exit ;; # test seulement
-c* | all )

View File

@ -15,6 +15,12 @@
* f__requis f__wget_test fscript_get_version fscript_update fscript_cronAnacron
* f__cmd_exist f__sudo f__requis
## 2.16.0 25/10/2017
* révision: batterie, unité en W au lieu de mW, mA inchangé
* fix, révision: modification complète des séquences peuplement rapport et modules fi_* autonomes
* fix: bug affichage disque sata
## 2.15.0 24/10/2017
* nouveau: début support Bumblebee