getInfo 2.27.0

This commit is contained in:
kyodev 2017-11-09 07:00:30 +01:00
parent 5d1b5bc84c
commit 52ad6c664b
3 changed files with 169 additions and 87 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.26.1
date="07/11/2017"
version=2.27.0
date="08/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -320,28 +320,30 @@ f__wget_test(){ # 06/11/2017
# f_display: $1 variable à afficher, $2=var|cmd|sans (type titre) [$3 titre] [$4 commentaire en gras si cmd]
# f_display "variable" "type" "titrage" "titrage_commentaire"
# $2: cmd->`titre`, var->**titre**, sans: pas de titre
f_display(){ # 07/11/2017
[ "$text" ] && echo -en "$text" >> "$fileOutput" # flush, avant fonction, de text parent
f_display(){ # 08/11/2017
# flush, avant fonction, de text parent
[ "$text" ] && echo -en "$text" >> "$fileOutput"
unset text
# coeur fonction
local display=""
[[ "$2" =~ sans|var|cmd ]] || display="erreur script \$2 ($1 $2 $3) \n"
[ "$2" == "var" ] && display="**$3** \n"
[ "$2" == "cmd" ] && display="\`$3\` \n"
#echo $(sed -En 's/[^/]*(\/.*)$/\1/p' <<< "$3")
[[ "$2" == "cmd" && "$4" ]] && display="\`$3\`"$'\xc2\xa0'$'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0'" **$4** \n"
display+='``` \n'
display+="${!1} \n"
display+='``` \n'
[[ "$2" =~ sans|var|cmd ]] || display="erreur script \$2 ($1 $2 $3) \n" # test $2 valide
[ "$2" == "var" ] && display="**$3**" # type var, titre en gras
[ "$2" == "cmd" ] && display="\`$3\`" # type cms, titre entre `
[ "$4" ] && display+=$'\xc2\xa0'$'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0'" ($4)" # +$4 en gras avec 5 espaces insécables avant
[ "$2" == "sans" ] || display+=" \n"
display+='``` \n'
display+="${!1} \n"
display+='``` \n'
echo -en "$display \n" >> "$fileOutput" # flush fonction
}
# $1 fichier testé
f_display_file_absent(){ # 03/11/2017
f_dspl_file_ko(){ # 03/11/2017
echo -e "* fichier **$1** non trouvé ou absent \n" >> "$fileOutput"
}
# $$=liste fichiers à greper, [$2] largeur 1ere colonne
f_display_grep(){ # 07/11/2017
f_dspl_grep(){ # 07/11/2017
local file var_temp
for file in $1; do
var_temp="$(grep -Ersv '^#|^[[:space:]]*$' $file)"
@ -355,8 +357,45 @@ f_display_grep(){ # 07/11/2017
done
}
# $1 file à parser. tout en bash pour regex par défaut non-greedy (non gourmand) comme sed ou gawk
# traitement ligne par ligne, l'italique avec _ n'est pas géré
f_dspl_md(){ # 08/11/2017
local display display2
display=$(< $1)
display=${display//\`\`\`/~~~} # transforme ``` en ---, plus visibles
#DEFAUT: espaces en début de lignes bouffés
# traitement par lignes, ala sed, obligatoire pour les titres #
# plus simple pour les multi-patterns, sinon matches multilignes délicats à gérer en cas d'impairage
# while read ligne; do
while read ligne; do
# # TITRE 1 red
[[ "$ligne" =~ ^(#[^#].*)$ ]] && ligne="\x1B[31m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# ## TITRE 2 blue
[[ "$ligne" =~ ^(#{2}[^#].*)$ ]] && ligne="\x1B[34m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# ### TITRE 3 green
[[ "$ligne" =~ ^(#{3}[^#].*)$ ]] && ligne="\x1B[32m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# ### TITRE 4 yellow
[[ "$ligne" =~ ^(#{4}[^#].*)$ ]] && ligne="\x1B[33m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# **gras**
while [[ "$ligne" =~ (.*)\*{2}(.*)\*{2}(.*) ]]; do
ligne=${BASH_REMATCH[1]}'\x1B[1m'${BASH_REMATCH[2]}'\x1B(B\x1B[m'${BASH_REMATCH[3]}
done
# *italique*, _italique_ trop d'interférences avec sorties du rapport
while [[ "$ligne" =~ (.*)\*([^*].*)\*(.*) ]]; do
ligne=${BASH_REMATCH[1]}'\x1B[3m'${BASH_REMATCH[2]}'\x1B(B\x1B[m'${BASH_REMATCH[3]}
done
# ` backtick mis en gras
while [[ "$ligne" =~ (.*)\`([^\`].*)\`(.*) ]]; do
ligne=${BASH_REMATCH[1]}'\x1B[1m'${BASH_REMATCH[2]}'\x1B(B\x1B[m'${BASH_REMATCH[3]}
done
display2+="$ligne\n"
done <<< "$display"
echo -e "$display2"
}
# $1 répertoire à scanner, $2 profondeur
f_display_scandir(){ # 21/10/2017
f_dspl_scandir(){ # 21/10/2017
[ "$text" ] && echo -e "$text" >> "$fileOutput" # flush avant fonction
unset text
local text
@ -698,7 +737,7 @@ SMCA ⟷ Scalable MCA
"
}
fi_disk(){ # 31/10/2017
fi_disk(){ # 08/11/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)"
@ -735,9 +774,9 @@ fi_disk(){ # 31/10/2017
###
[ "$fg_nb_disk" -gt 1 ] && pluriel="s" || unset pluriel
text="## disque$pluriel \n\n"
text+='``` \n'
# espace des partitions fixes montées
text+="$fg_disk_part_fix_tot \n\n"
text+="* $fg_disk_part_fix_tot \n\n"
text+='``` \n'
# disques fixes et amovibles
[ "$(wc -w <<< $fg_disk_fixe)" -gt 1 ] && pluriel="s" || unset pluriel
text+="$(printf '%-17s: %s' "disque$pluriel fixe$pluriel" "$fg_disk_fixe") \n"
@ -763,7 +802,7 @@ fi_disk(){ # 31/10/2017
text+="| :---: | :---: | :---: | :---: | \n"
text+="| $fg_disk_ata | $fg_disk_usb | $fg_disk_mmc | $fg_disk_nvme | \n\n"
# éventuellement hddtemp
[ "$dd_temp" ] && f_display "dd_temp" "cmd" "hddtemp /dev/sd?" "(température disques)"
[ "$dd_temp" ] && f_display "dd_temp" "cmd" "hddtemp /dev/sd?" "température disques"
if [ "$dd_temp_alert" ]; then
text+="$dd_temp_alert \n"
text+="$dd_temp_alert_text \n\n"
@ -771,15 +810,17 @@ fi_disk(){ # 31/10/2017
# df, espaces des partitions montées seules
f_display "disk_df" "cmd" \
"df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs" \
"(utilisation disques)"
"utilisation disques"
# df -i, inoeuds
f_display "disk_df_i" "cmd" "df -i --exclude=tmpfs --exclude=devtmpfs" "(utilisation inoeuds)"
f_display "disk_df_i" "cmd" "df -i --exclude=tmpfs --exclude=devtmpfs" "utilisation inoeuds"
# lsblk
[ "$disk_lsblk" ] && f_display "disk_lsblk" "cmd" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" "(disques)"
[ "$disk_lsblk" ] && f_display "disk_lsblk" "cmd" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" \
"disques & partitions"
# fstab
f_display "fstab" "cmd" "grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/fstab" "(fstab)"
f_display "fstab" "cmd" "grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/fstab" "fstab"
# resume
f_display "resume" "cmd" "grep -Evs '^[[:blank:]]*#|^[[:space:]]*$' /etc/initramfs-tools/conf.d/resume" "(resume)"
f_display "resume" "cmd" "grep -Evs '^[[:blank:]]*#|^[[:space:]]*$' /etc/initramfs-tools/conf.d/resume" \
"resume"
if [ "$alert_uuidResume" ]; then
text+="$alert_uuidResume \n\n"
fi
@ -787,7 +828,7 @@ fi_disk(){ # 31/10/2017
unset text
}
fi_dmesg(){ # 30/10/2017
fi_dmesg(){ # 08/11/2017
local dmesg_err dmesg_warn dmesg_crit file text nb_lignes=25
file="/tmp/$$-$RANDOM-dmesg"
[ "$EUID" -eq 0 ] || echo
@ -818,17 +859,17 @@ fi_dmesg(){ # 30/10/2017
rm "$file-"*
###
text="## dmesg kernel (emergency, alerte, erreur, warning ou critique) \n\n"
f_display "dmesg_emerg" "cmd" "dmesg -l emerg" "(emergency, $nb_lignes premières lignes)"
f_display "dmesg_alert" "cmd" "dmesg -l alert" "(alerte, $nb_lignes premières lignes)"
f_display "dmesg_crit" "cmd" "dmesg -l crit" "(critique, $nb_lignes premières lignes)"
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)"
f_display "dmesg_emerg" "cmd" "dmesg -l emerg" "emergency, $nb_lignes premières lignes"
f_display "dmesg_alert" "cmd" "dmesg -l alert" "alerte, $nb_lignes premières lignes"
f_display "dmesg_crit" "cmd" "dmesg -l crit" "critique, $nb_lignes premières lignes"
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"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_graph(){ # 06/11/2017
fi_graph(){ # 08/11/2017
local slots cmd alert_hybrid alert_3D providers preferred current openGl resolutions text
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
@ -915,7 +956,8 @@ fi_graph(){ # 06/11/2017
[ "$providers" ] && f_display "providers" "cmd" "xrandr --listproviders"
# résolutions possibles, pas d'affichage si mode (ssh) ou xrandr pas accessible
if [ "$resolutions" ]; then
f_display "resolutions" "cmd" "xrandr --query | grep -A11 'Screen [0-9]'" "(10 premières résolutions possibles)"
f_display "resolutions" "cmd" "xrandr --query | grep -A11 'Screen [0-9]'" \
"10 premières résolutions possibles"
fi
# modules vidéo
text+="### modules video \n\n"
@ -939,12 +981,12 @@ fi_hw(){ # 03/11/2017
unset text
}
fi_journal(){ # 30/10/2017
fi_journal(){ # 08/11/2017
local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_size file text nb_lignes=25
[ "$(f__cmd_exist journalctl)" ] || fi_dmesg # pas systemd, appel dmesg
file="/tmp/$$-$RANDOM-journalctl"
[ "$EUID" -eq 0 ] || echo
f__sudo "LC_ALL=C journalctl --no-hostname --boot 0 | sed -E -n '/^-- Logs begin.*$/p' > $file-boot ; \
f__sudo "LC_ALL=C journalctl --no-hostname --boot 0 | sed -n '/^-- Logs begin.*$/p' > $file-boot ; \
LC_ALL=C journalctl --no-hostname --boot 0 -k -p 1 > $file-alert ; \
LC_ALL=C journalctl --no-hostname --boot 0 -k -p 2..2 > $file-crit ; \
LC_ALL=C journalctl --no-hostname --boot 0 -p 3..3 > $file-err ; \
@ -959,7 +1001,6 @@ fi_journal(){ # 30/10/2017
echo -e "$text" >> "$fileOutput"
return 0
fi
jctl_boot=$(cat $file-boot)
jctl_boot=$(gawk -F '--|,' '{ sub(/^ /,"",$2);print $2}' <<< $(cat $file-boot))
jctl_alert_k=$(sed '/kernel:/!d' $file-alert | sed -n 1,"$nb_lignes"p) # emergency & alert
jctl_crit_k=$(sed '/kernel:/!d' $file-crit | sed -n 1,"$nb_lignes"p)
@ -975,30 +1016,30 @@ fi_journal(){ # 30/10/2017
jctl_err_nok=$(sed '/-- Logs begin/d;/kernel:/d; s/-- No entries --/ <vide>/' $file-err | sed -n 1,"$nb_lignes"p)
jctl_warn_nok=$(sed '/-- Logs begin/d;/kernel:/d; s/-- No entries --/ <vide>/' $file-warn | sed -n 1,"$nb_lignes"p)
rm "$file-"*
###
###
# kernel
text="## journalctl kernel (emergency, alert, erreur, warning ou critique) \n\n"
text+="**$jctl_boot** \n\n"
text+="* $jctl_boot \n\n"
f_display "jctl_alert_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 1" \
"(kernel emergency 0 & alerte 1, $nb_lignes premières lignes)"
"kernel emergency 0 & alerte 1, $nb_lignes premières lignes"
f_display "jctl_crit_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 2..2" \
"(kernel critique, $nb_lignes premières lignes)"
"kernel critique, $nb_lignes premières lignes"
f_display "jctl_err_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 3..3" \
"(kernel erreur, $nb_lignes premières lignes)"
"kernel erreur, $nb_lignes premières lignes)"
f_display "jctl_warn_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 4..4" \
"(kernel warning, $nb_lignes premières lignes)"
"kernel warning, $nb_lignes premières lignes"
# non kernel
text+="## journalctl hors kernel (emergency, alert, erreur, warning ou critique) \n\n"
text+="**$jctl_boot** \n\n"
text+="* $jctl_boot \n\n"
f_display "jctl_alert_nok" "cmd" "journalctl --no-hostname --boot 0 -p 1 | grep -v kernel" \
"(hors kernel, emergency 0 & alerte 1, $nb_lignes premières lignes)"
"hors kernel, emergency 0 & alerte 1, $nb_lignes premières lignes"
f_display "jctl_crit_nok" "cmd" "journalctl --no-hostname --boot 0 -p 2..2 | grep -v kernel" \
"(hors kernel, critique, $nb_lignes premières lignes)"
"hors kernel, critique, $nb_lignes premières lignes"
f_display "jctl_err_nok" "cmd" "journalctl --no-hostname --boot 0 -p 3..3 | grep -v kernel" \
"(hors kernel, erreur, $nb_lignes premières lignes)"
"hors kernel, erreur, $nb_lignes premières lignes"
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"
"hors kernel, warning, $nb_lignes premières lignes"
text+="* les $nb_lignes premières lignes commencent à la date du dernier boot \n\n"
f_display "jctl_size" "cmd" "journalctl --disk-usage " "taille des journaux"
printf "$text\n" >> "$fileOutput"
unset text
@ -1008,10 +1049,10 @@ fi_locale(){ # 30/10/2017
local locale localectl timezone timedatectl
local xKeyboardMap keyboard alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
# locale
locale="$(f_display_grep "/etc/default/locale* /etc/locale.conf")"
locale="$(f_dspl_grep "/etc/default/locale* /etc/locale.conf")"
[ "$(f__cmd_exist localectl)" ] && localectl=$(localectl --no-pager status)
# timezone
timezone="$(f_display_grep "/etc/timezone*")"
timezone="$(f_dspl_grep "/etc/timezone*")"
if [ "$(f__cmd_exist timedatectl)" ]; then
timedatectl="$(timedatectl status --no-pager)"
grep -q 'RTC in local TZ: yes' <<< "$timedatectl" && alert_Rtc="Attention RTC in local TZ"
@ -1024,7 +1065,7 @@ activer le service: timedatectl set-ntp true
et/ou installer le démon Ntp: apt install ntp \n"
fi
# keyboard layout
keyboard="$(f_display_grep "/etc/default/keyboard*")"
keyboard="$(f_dspl_grep "/etc/default/keyboard*")"
[ "$(f__cmd_exist setxkbmap)" ] && xKeyboardMap="$(setxkbmap -query)"
###
text="## localisation \n\n"
@ -1033,19 +1074,19 @@ et/ou installer le démon Ntp: apt install ntp \n"
[ "$localectl" ] && f_display "localectl" "cmd" "localectl --no-pager status"
# timezone
[ "$timezone" ] && f_display "timezone" "cmd" "grep -EHsv '#|^[[:space:]]*$' /etc/timezone*"
[ "$timezone" ] || f_display_file_absent "/etc/timezone*"
[ "$timezone" ] || f_dspl_file_ko "/etc/timezone*"
[ "$timedatectl" ] && f_display "timedatectl" "cmd" "timedatectl status --no-pager"
[ "$alert_Rtc" ] && text+="$alert_Rtc_info \n"
[ "$alert_Ntp" ] && text+="$alert_Ntp_info \n"
# keyboard layout
[ "$keyboard" ] && f_display "keyboard" "cmd" "grep -EHv '#|^[[:space:]]*$' /etc/default/keyboard*"
[ "$keyboard" ] || f_display_file_absent "/etc/default/keyboard"
[ "$keyboard" ] || f_dspl_file_ko "/etc/default/keyboard"
[ "$xKeyboardMap" ] && f_display "xKeyboardMap" "cmd" "setxkbmap -query"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_log_xorg(){ # 07/11/2017
fi_log_xorg(){ # 08/11/2017
[ "$ENV_SSH" ] && return 0
local logXorg xfile extract dateFile text nb_lignes=50
# Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice,
@ -1074,22 +1115,23 @@ fi_log_xorg(){ # 07/11/2017
text="## journaux Xorg \n\n"
f_display "logXorg" "cmd" \
"grep -Es '\(WW\)|\(EE\)|\(\?\?\)' /var/log/Xorg.?.log /home/<user>/.local/share/xorg/Xorg.?.log" \
"(Xorg.log)"
"Xorg.log"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_mem(){ # 25/10/2017
local swappiness text var_temp
swappiness="$(cat /proc/sys/vm/swappiness 2>/dev/null)"
fi_mem(){ # 08/11/2017
local var_temp swappiness text
figet_mem "mem" #options possibles mem swap total notitle nocoltitle
var_temp="$fg_mem \n\n"
figet_mem "swap" "notitle"
var_temp+="$fg_mem \n\n"
var_temp+="swappiness: $swappiness"
var_temp+="$fg_mem"
# var_temp+="swappiness: $swappiness"
swappiness="$(cat /proc/sys/vm/swappiness 2>/dev/null)"
###
text="## mémoire \n\n"
f_display "var_temp" "sans"
f_display "var_temp" "cmd" "free -h"
f_display "swappiness" "cmd" "cat /proc/sys/vm/swappiness"
printf "$text\n" >> "$fileOutput"
unset text
}
@ -1104,9 +1146,9 @@ fi_nm(){ # 29/10/2017
###
text="## NetworkManager \n\n"
[ "$nm_etat" ] && f_display "nm_etat" "cmd" "grep -Ev '#|^[[:space:]]*$' /var/lib/NetworkManager/NetworkManager.state"
[ "$nm_etat" ] || f_display_file_absent "/var/lib/NetworkManager/NetworkManager.state"
[ "$nm_etat" ] || f_dspl_file_ko "/var/lib/NetworkManager/NetworkManager.state"
[ "$nm_conf" ] && f_display "nm_conf" "cmd" "grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/NetworkManager.conf"
[ "$nm_conf" ] || f_display_file_absent "/etc/NetworkManager/NetworkManager.conf"
[ "$nm_conf" ] || f_dspl_file_ko "/etc/NetworkManager/NetworkManager.conf"
if [ "$nm_wifis" ]; then
text+="## wifis à proximité \n\n"
f_display "nm_wifis" "cmd" "nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15"
@ -1115,7 +1157,7 @@ fi_nm(){ # 29/10/2017
unset text
}
fi_reseau(){ # 07/11/2017
fi_reseau(){ # 08/11/2017
local slots cards ip_a iwconfig interfaces route resolv canal_wifi ifx alert_wlx text pluriel
# cardsManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')"
# cardsManuel="$(lspci -nnv | grep -EiA 15 'network|ethernet')"
@ -1133,7 +1175,7 @@ fi_reseau(){ # 07/11/2017
ip_a="$(sed '/inet6.*/d' <<< $ip_a)" # filtre sur inet6)
route="$(ip route show)"
# interfaces & resolv
interfaces="$(f_display_grep "/etc/network/interfaces*")"
interfaces="$(f_dspl_grep "/etc/network/interfaces*")"
interfaces="$(sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )"
resolv="$(grep -Esv '#|^[[:space:]]*$' /etc/resolv.conf)"
# iwconfig
@ -1175,12 +1217,12 @@ fi_reseau(){ # 07/11/2017
# interface prioritaire
[ $(wc -w <<< $fg_ifn) -gt 1 ] && f_display "fg_ifn_prior" "var" "interface prioritaire"
# ip a & route & interface & resolv
f_display "ip_a" "cmd" "ip address" "(sans ipV6 et sans adresses MAC)"
f_display "ip_a" "cmd" "ip address" "sans ipV6 et sans adresses MAC"
f_display "route" "cmd" "ip route show"
[ "$interfaces" ] && f_display "interfaces" "cmd" "grep -EHrsv '#|^[[:space:]]*$' /etc/network/interfaces*"
[ "$interfaces" ] || f_display_file_absent "/etc/network/interfaces*"
[ "$resolv" ] && f_display "resolv" "cmd" "cat /etc/resolv.conf" "(serveurs de noms DNS utilisés)"
[ "$resolv" ] || f_display_file_absent "/etc/resolv.conf"
[ "$interfaces" ] && f_display "interfaces" "cmd" "grep -EHrsv '#|^[[:space:]]*$' /etc/network/interfaces*"
[ "$interfaces" ] || f_dspl_file_ko "/etc/network/interfaces*"
[ "$resolv" ] && f_display "resolv" "cmd" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés"
[ "$resolv" ] || f_dspl_file_ko "/etc/resolv.conf"
# iwconfig & iwlist
[ "$iwconfig" ] && f_display "iwconfig" "cmd" "iwconfig" "état carte wifi"
if [ "$canal_wifi" ]; then
@ -1238,7 +1280,7 @@ fi_sources(){ #v2 07/11/2017
local alert_httpredir alert_upgrade alert_full_upgrade alert_upgrade_titre
local alert_remove alert_remove_titre alert_non_ii alert_non_ii_titre
# sources & divers
sources=$(f_display_grep "/etc/apt/sources.list /etc/apt/sources.list.d/*.list" 8)
sources=$(f_dspl_grep "/etc/apt/sources.list /etc/apt/sources.list.d/*.list" 8)
dateMaj="$(date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z')" # /var/lib/dpkg/
nb_packages="$(dpkg -l | grep -c '^ii')"
if [ $(grep -c 'httpredir' <<< $sources) -ne 0 ]; then
@ -1252,7 +1294,7 @@ fi_sources(){ #v2 07/11/2017
upgrade_qte=($(gawk '/ newly installed/{print $1" "$10}' <<< $upgrade))
if [ "${upgrade_qte[0]}" -gt 0 ]; then # upgrade
[ "${upgrade_qte[0]}" -gt 1 ] && pluriel="s" || unset pluriel
alert_upgrade_titre="${upgrade_qte[0]} paquet$pluriel à mettre à jour:"
alert_upgrade_titre="${upgrade_qte[0]} paquet$pluriel à mettre à jour"
alert_upgrade=$(gawk '/Inst /{
sub(/\(/,"",$4); sub(/\/.*/,"",$5); sub(/\[/,"",$3); sub(/\]/,"",$3);
printf "%-25s source: %-25s %-20s ⇉ %-20s\n",$2,$5,$3,$4 }' <<< $upgrade)
@ -1269,7 +1311,7 @@ fi_sources(){ #v2 07/11/2017
remove_qte=$(gawk '/ newly installed/{print $6}' <<< $remove)
if [ "$remove_qte" -gt 0 ]; then
[ "$remove_qte" -gt 1 ] && pluriel="s" || unset pluriel
alert_remove_titre="$remove_qte paquet$pluriel non nécessaire$pluriel:"
alert_remove_titre="$remove_qte paquet$pluriel non nécessaire$pluriel"
alert_remove="$(sed -En 's/Remv (.*)\[[0-9.-]*\]/\1/p' <<< $remove | tr '\n' ' ')"
alert_remove+="\n\n pour corriger: apt autoremove --purge"
alert_remove+="\n\nvérifier que la liste ne contient pas des applications devenues importantes \n"
@ -1283,7 +1325,7 @@ fi_sources(){ #v2 07/11/2017
non_ii_qte=$( f__wcv -l "$alert_non_ii" )
if [ "$non_ii_qte" -gt 0 ]; then
[ "$non_ii_qte" -gt 1 ] && pluriel="s" || unset pluriel
alert_non_ii_titre="$non_ii_qte paquet$pluriel dans un état non installé:"
alert_non_ii_titre="$non_ii_qte paquet$pluriel dans un état non installé"
[[ ${alert_non_ii,,} =~ ^. ]] && alert_non_ii+=" ‣ État souhaité "$'\n'
[[ ${alert_non_ii,,} =~ ^h ]] && alert_non_ii+=" h.. hold (à garder) "$'\n'
[[ ${alert_non_ii,,} =~ ^i ]] && alert_non_ii+=" i.. install (à installer) "$'\n'
@ -1338,14 +1380,17 @@ fi_ssid(){ # 06/11/2017
unset text
}
fi_system_analyse(){ # 25/10/2017
fi_system_analyse(){ # 08/11/2017
[ "$(f__cmd_exist systemd-analyze)" ] || return 0 # pas systemd
local bootTime bootBlame text
bootTime="$(systemd-analyze time)"
bootTime="$(sed ' # non traduit kernel firmware loader=chargeur?
s/Startup finished in /durée de boot: /; s/userspace/espace utilisateur/
' <<< $bootTime)"
bootBlame="$(systemd-analyze blame | head -n 20)"
###
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 "bootTime" "cmd" "systemd-analyze time"
f_display "bootBlame" "cmd" "systemd-analyze blame | head -n 20"
printf "$text\n" >> "$fileOutput"
unset text
@ -2137,6 +2182,7 @@ figet_ip_pub(){ # 27/10/2017
}
# $1=mem|swap [total|notitle|nocoltitle], assigne $fg_mem ($2=debug all cols + free)
# indépendant de procps, affichage plus clair que free, mais résultats identiques
figet_mem(){ # 31/10/2017
local freeDebug MemTotal MemFree MemAvailable Buffers Cached SReclaimable Shmem MemUsed
local SwapTotal SwapFree SwapCached col
@ -2175,11 +2221,11 @@ figet_mem(){ # 31/10/2017
totalAvailable=$( printf '%10s' $(f__unit_human $totalAvailable) )
unset fg_mem
if [[ ! "$*" =~ notitle ]]; then
[[ "$*" =~ nocoltitle ]] || col="mém.:"
fg_mem="$col totale utilisée disponible"$'\n'
[[ "$*" =~ nocoltitle ]] || col="mémoire"
fg_mem="$col totale utilisée disponible"$'\n'
fi
if [[ "$*" =~ mem ]]; then
[[ "$*" =~ nocoltitle ]] || col="ram :"
[[ "$*" =~ nocoltitle ]] || col="vive:"
fg_mem+="$col$MemTotal$MemUsed$MemAvailable"$'\n'
fi
if [[ "$*" =~ swap ]]; then
@ -2193,7 +2239,7 @@ figet_mem(){ # 31/10/2017
if [ "$2" == "debug" ]; then
local espace=$(printf '% 6s')
fg_mem="$espace""mém.: totale utilisée libre shared buffers cache disponible"$'\n'
fg_mem+="$espace""ram :$MemTotal$MemUsed$MemFree$Shmem$Buffers$Cached$MemAvailable"$'\n'
fg_mem+="$espace""vive:$MemTotal$MemUsed$MemFree$Shmem$Buffers$Cached$MemAvailable"$'\n'
[ "$fg_mem" ] && fg_mem=${fg_mem::-1} # suppression dernier $'\n'
echo "$fg_mem"
echo "$freeDebug"
@ -2269,7 +2315,7 @@ figet_test_batt(){ # 23/10/2017
f_display "var_temp" "cmd" "upower -i $objet"
fi
# scandir
[ -d /sys/class/power_supply/BAT* ] && f_display_scandir "/sys/class/power_supply/" 1
[ -d /sys/class/power_supply/BAT* ] && f_dspl_scandir "/sys/class/power_supply/" 1
# fonction script
f_display "fg_batt" "var" "figet_batt"
}
@ -2292,7 +2338,7 @@ figet_test_dmi(){ # 21/10/2017
text+="## dmi test \n\n"
# /sys/class/dmi/
var_temp="/sys/class/dmi/"
f_display_scandir "$var_temp" 1
f_dspl_scandir "$var_temp" 1
# fonction script
figet_dmi
f_display "fg_dmi" "var" "figet_dmi"
@ -2326,13 +2372,13 @@ figet_test_hw(){ # 22/10/2017
fi
# /sys/class/hwmon/
var_temp="/sys/class/hwmon/"
f_display_scandir "$var_temp" 1
f_dspl_scandir "$var_temp" 1
# /sys/class/thermal/thermal_zone0/
var_temp="/sys/class/thermal/thermal_zone0/"
f_display_scandir "$var_temp" 0
f_dspl_scandir "$var_temp" 0
# /sys/devices/platform/coretemp.0/hwmon/
var_temp="/sys/devices/platform/coretemp.0/hwmon/"
f_display_scandir "$var_temp" 1
f_dspl_scandir "$var_temp" 1
# analyse méthode neofetch
if [ -f "/sys/class/hwmon/hwmon0/temp1_input" ]; then
var_temp="$(< "/sys/class/hwmon/hwmon0/temp1_input")"
@ -2550,7 +2596,7 @@ 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 "> $script sur *$(uname -n)* \n" > "$fileOutput"
echo -e "$ligneRapport \n\n" >> "$fileOutput"
}
prg_2(){ # traitements principaux
@ -2713,7 +2759,7 @@ for j in $options; do
-t | --test )
prg_1 "$*"
fi_log_xorg
exit ;; # test seulement
exit ;; # test
-c* | all )
[ "$j" == "-c" ] && exec $0 "menu"
prg_1 "$*"
@ -2726,7 +2772,7 @@ for j in $options; do
prg_2 "a"
exit ;; # exporte le rapport existant
-l )
[ -e $fileOutput ] && cat $fileOutput || f__info "pas de rapport à afficher" \
[ -e $fileOutput ] && f_dspl_md "$fileOutput" || f__info "pas de rapport à afficher" \
"vous devez lancer une analyse auparavant: $GREEN$script -l" \
"ou afficher l'aide $GREEN$script -h"
exit ;; # afficher le rapport existant

View File

@ -3,6 +3,12 @@
* f__wcv, f_display_grep, f__wget_test, fscript_get_version, fscript_update
## 2.27.0 08/11/2017
* nouveau: moteur d'affiche console (md2console)
* renommage fonction display, révision affichage f_display
* révision: fi_system_analyse, fi_mem: affichage
## 2.26.1 07/11/2017
* révision: fi_sources v2

View File

@ -0,0 +1,30 @@
> getInfo sur *1101HA*
# titre 1
## journaux Xorg
### titre 3
#### titre 4
`grep -Es /var/log`
`du code entre backticks` abc `test`  abc   **(Xorg.log)** # backticks && gras
(WW) **warning**, (EE) **erreur**, (??) inconnu
ligne avec * une seule étoile
ligne avec ** deux étoiles
ligne avec ` un seul backtick
caractères **jhg ege ejg eesj ** gras
caractères *AZVVE ddd G EGRR* italiques
caractères AZVVE ddd G EGRR italiques (ligne de comparaison)
```
code
ligne avec * ` ** # ## ### ####
fin de code
```