getInfo 2.42.0

This commit is contained in:
kyodev 2017-11-21 22:44:56 +01:00
parent 6993802ecc
commit 45c22973ce
2 changed files with 139 additions and 89 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
version=2.41.5
version=2.42.0
date="21/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
@ -357,13 +357,13 @@ f_display(){ # 20/11/2017
# $1 variable à afficher en alerte/info, [$2 alert|info] type de message, alert par défaut
# passage en paramètre variable et pas $variable
# un test si variable $1 est vide ou non est fait
f_dspl_alert(){ # 19/11/2017
f_dspl_alert(){ # 21/11/2017
[ "${!1}" ] || return 0 # test si contenu dans $1
local display type
# flush, avant fonction, de $text parent
[ "$text" ] && echo -en "$text\n" >> "$fileOutput"
unset text
# coeur fonction
[[ "$2" =~ info ]] && type="info"
[[ "$2" =~ alert ]] && type="alert"
[ "$2" ] || type="alert" # alert par défaut
@ -1055,10 +1055,16 @@ fi_graph(){ # 21/11/2017
openGl=${openGl// string:/:} # suppression chaîne ' string'
openGl=${openGl% } # suppression espace final éventuel
fi
# xrandr: résolutionS & providers & preferred/current
[ $( f__which xrandr ) ] && resolutions="$( xrandr --query | grep -A11 'Screen [0-9]' )"
[ $( f__which xrandr ) ] && providers="$( xrandr --listproviders )" # DRI: ok, sort 2 fournisseurs
[ $( f__which xrandr ) ] && current_preferred="$( xrandr --verbose | grep -EA2 'current|preferred' )"
# xrandr: résolutionS & providers & preferred/current
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # évite erreur $DISPLAY en root wayland
resolutions="n/a en root sous wayland"
providers="n/a en root sous wayland"
current_preferred="n/a en root sous wayland"
else
[ $( f__which xrandr ) ] && resolutions="$( xrandr --query | grep -A11 'Screen [0-9]' )"
[ $( f__which xrandr ) ] && providers="$( xrandr --listproviders )" # DRI: ok, sort 2 fournisseurs
[ $( f__which xrandr ) ] && current_preferred="$( xrandr --verbose | grep -EA2 'current|preferred' )"
fi
# modules
modules="$(lsmod | grep -Ei 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')"
cmt_modules="modules recherchés: amdgpu, ati, i915, nouveau, nvidia, radeon, video, gma"
@ -1831,12 +1837,12 @@ fi_ssid(){ # 09/11/2017
unset text
}
fi_system_analyse(){ # 20/11/2017
fi_system_analyse(){ #v 21/11/2017
[ $( f__which systemd ) ] || return 0 # pas systemd
local bootTime cmd_bootTime cmt_bootTime pluriel text
local srvcFail cmd_srvcFail cmt_srvcFail qte_srvcFail isrvc srvcFail_list
local bootBlame cmd_bootBlame cmt_bootBlame bootCritic cmd_bootCritic cmt_bootCritic
local bootGraph cmd_bootGraph cmt_bootGraph
local bootGraph cmd_bootGraph cmt_bootGraph file="/tmp/getInfo-graph-$RANDOM.svg"
local alert_srvcFail
# durée du précédent boot
bootTime=$( systemd-analyze time )
@ -1875,16 +1881,19 @@ fi_system_analyse(){ # 20/11/2017
bootCritic=${bootCritic/The time the unit takes to start is printed after the \"+\" character./ +: temps que l\'unité prend pour démarrer}
cmd_bootCritic="systemd-analyze critical-chain"
cmt_bootCritic="services critiques ralentisseurs"
# génération graphique
systemd-analyze plot > "/tmp/getInfo-graph.svg" 2>/dev/null
bootGraph="en console: \`xdg-open /tmp/getInfo-graph.svg\` \n"
bootGraph+="* dans un navigateur: copier/coller ce lien dans la barre d'adresses "
bootGraph+="file:///tmp/getInfo-graph.svg \n"
# un lien local ne s'ouvrira pas automatiquement :( : http://kb.mozillazine.org/Links_to_local_pages_do_not_work
# génération graphique
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # évite erreur $DISPLAY en root wayland
bootGraph="n/a en root sous wayland"
else
systemd-analyze plot > "$file" 2>/dev/null
chown $user_: "$file"
bootGraph="en console: **xdg-open $file** \n"
bootGraph+="* dans un navigateur: copier/coller ce lien dans la barre d'adresses "
bootGraph+="file:///$file \n"
fi
# un lien local ne s'ouvrira pas automatiquement :( : http://kb.mozillazine.org/Links_to_local_pages_do_not_work
cmd_bootGraph="systemd-analyze plot > graph.svg ; xdg-open graph.svg"
cmt_bootGraph="graph durées et ordre de chargement des services"
# workaround, erreur buster en root, fichier non crée
[ -e "/tmp/getInfo-graph.svg" ] || unset bootGraph
###
text="## analyse boot systemd \n\n"
[ "$srvcFail" ] || text+="* pas de service en erreur \n\n"
@ -1898,7 +1907,7 @@ fi_system_analyse(){ # 20/11/2017
unset text
}
fi_systeme(){ # 19/11/2017
fi_systeme(){ # 21/11/2017
local mbr uname bootImage initDaemon serverX shells lastboot uptime charge pluriel text
local alimentation alim_total ish ifs_origin ligne date_install microcode
local alert_SLiM alert_microcode
@ -1910,10 +1919,9 @@ fi_systeme(){ # 19/11/2017
[ "$initDaemon" == "systemd" ] && initDaemon=$( systemd --version )
initDaemon=${initDaemon%%[[:space:]]+*}
initDaemon=${initDaemon/systemd/systemd version}
[ "$ENV_SSH" ] && serverX="n/a (ssh)" || serverX="$XDG_SESSION_TYPE"
if [ -z "$serverX" ]; then
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && serverX="wayland" || serverX="indéterminé"
fi
[ "$ENV_SSH" ] && serverX="n/a (ssh)" || serverX="$XDG_SESSION_TYPE" # normalement retourne wayland
[ "$wayland" ] && serverX="$wayland"
[ "$serverX" ] || serverX="n/a"
for ish in $(f_grep_file "/etc/shells" "nofile"); do
shells+=${ish##*/}" " # conservation dernier "champs", ifs '/'
done
@ -2155,7 +2163,7 @@ figet_batt(){ #v2 11/11/2017
}
# assigne $fg_cpu (3 lignes description cpu), fg_nb_threads, $fg_cpu_arch, $fg_uarch, $fg_vendor=amd|intel
figet_cpu(){ #v2 05/11/2017
figet_cpu(){ #v2 21/11/2017
local cpuinfo speedNom speedMax speedMin speedCpu cpu1 cpu2 cpu3
cpuinfo="$(cat /proc/cpuinfo)"
# speed
@ -2205,7 +2213,7 @@ figet_cpu(){ #v2 05/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
[ "$fg_uarch" ] || figet_cpu_uarch
[[ ${fg_cpu,,} =~ amd ]] && fg_vendor="amd"
[[ ${fg_cpu,,} =~ intel ]] && fg_vendor="intel"
}
@ -2338,36 +2346,38 @@ figet_cpu_uarch(){ # 05/11/2017
[ "$fg_uarch" ] && fg_uarch+=" {0x$family|0x$model}"
}
figet_de(){ # thanks neofetch, assigne $fg_de #20/11/2017
fg_de="n/a (ssh)"
[ "$ENV_SSH" ] && return 0 || fg_de="n/a"
[ $( f__which xprop ) ] || return 0
# assigne $fg_de
figet_de(){ #v 21/11/2017 # thanks neofetch
local de="n/a"
fg_de="n/a"
[ "$ENV_SSH" ] && fg_de+=": ssh"
[[ "$fg_de" =~ : ]] && return 0 # retourne n/a: xprop ou n/a: ssh
de="$XDG_CURRENT_DESKTOP"
de="${de/'X-'}"
de="${de/Budgie:GNOME/Budgie}"
# Fallback to using xprop.
if [[ -n "$DISPLAY" && "$de" == "n/a" ]]; then
de="$(xprop -root | gawk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5|TDE_FULL_SESSION/')" #ajout TDE_FULL_SESSION, oubli?à tester
[ "$de" ] || "$DESKTOP_SESSION"
de=${DESKTOP_SESSION##*/} # suppression plus grande chaine au début jusqu'à /, pour $DESKTOP_SESSION
de=${de/X-} # supression de X-
de=${de/Budgie:GNOME/Budgie} # remplacement Budgie:GNOME par Budgie
# fallback to using xprop
if [[ "$wayland" && "$EUID" -eq 0 && "$de" == "n/a" ]]; then
fg_de+=": wayland root"
return 0
elif [[ "$de" == "n/a" ]]; then
de=$( xprop -root | gawk 'IGNORECASE = 1;/KDE_SESSION_VERSION|^_MUFFIN|xfce/' )
fi
# Format strings
case "$de" in
"KDE_SESSION_VERSION"* )
de="KDE${de/* = }"
;;
*"TDE_FULL_SESSION"* )
de="Trinity"
;;
*"MUFFIN"* | "Cinnamon" )
de="$(cinnamon --version)"
de="${de:-Cinnamon}"
;;
*"xfce"*)
de="xfce" # suppression xfce4 ou xfce5 (la version ne sort pas dans xprop ou $XDG_
;;
esac
fg_de="${de,,}" # minuscule
fg_de="${fg_de^}" # car 1 en majuscule
if [[ "${de,,}" =~ kde_session_version ]]; then
de="KDE"${de/* = }
elif [[ "${de,,}" =~ tde_full_session ]]; then
de="Trinity" # fork kde 3.5
elif [[ "${de,,}" =~ muffin || "$de" =~ Cinnamon ]]; then
de=$( cinnamon --version )
de=${de:-cinnamon}
elif [[ "${de,,}" =~ xfce ]]; then
de="xfce" # suppression xfce4 ou xfce5 (la version ne sort pas dans xprop ou $XDG_
fi
fg_de=${de,,} # minuscule
fg_de=${fg_de^} # car 1 en majuscule
}
# $fg_nb_disk : nb disk fixe & amovible, $fg_disk_table : tableau sommaire, fg_disk_serial
@ -2861,12 +2871,17 @@ figet_mod_net(){ # thanks wireless-info
}
# assigne $fg_nb_screen, $fg_resolution. return fg_resolution=n/a[ (ssh)] & fg_nb_screen=n/a ou valeurs
figet_screen(){ #v2 20/11/2017
figet_screen(){ #v2 21/11/2017
fg_nb_screen="n/a"
fg_resolution="n/a"
[ "$ENV_SSH" ] && fg_resolution+=" (ssh)"
[ "$ENV_SSH" ] && return 0
# xrandr & et xdpyinfo ne retourne pas de nombre écrans correct (multiplex? hybrid?)
[ "$ENV_SSH" ] && fg_nb_screen+=": ssh"
[ "$ENV_SSH" ] && fg_resolution+=": ssh"
[ $( f__which xrandr ) ] || fg_resolution+=": xrandr absent"
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_nb_screen+=": wayland root"
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_resolution+=": wayland root"
[[ "$fg_resolution" =~ : ]] && return 0 # retourne n/a: xprop ou n/a: ssh
##
# xrandr & et xdpyinfo ne retourne pas de nombre écrans correct (multiplex? hybrid?)
if [ $( f__which xrandr ) ]; then
fg_resolution=$( gawk '/[0-9]\*/ {gsub(/\*\+/,"",$2); printf "%s pixels (%dHz), ", $1, $2}' <<< $( xrandr --query ) )
elif [ $( f__which xdpyinfo ) ]; then
@ -2999,23 +3014,45 @@ figet_test_hw(){ # 20/11/2017
f_display "fg_hw" "var" "figet_hw"
}
figet_wm(){ # thanks neofetch, assigne $fg_wm # 30/10/2017
fg_wm="n/a (ssh)"
[ "$ENV_SSH" ] && return 0 || fg_wm="n/a"
[ $( f__which xprop ) ] || return 0
local id wm
if [ -n "$DISPLAY" ]; then
id="$(xprop -root -notype _NET_SUPPORTING_WM_CHECK | cut -d' ' -f5)"
wm="$(xprop -id "$id" -notype -f _NET_WM_NAME 8t) "
wm="${wm/*_NET_WM_NAME = }"
wm="${wm/\"}"
wm="${wm/\"*}"
# Fallback for Wayland wms
[[ "$wm" == "xwlc" ]] && wm="$(ps -e | grep -m 1 -o -F -e "sway" -e "orbment" -e "velox" -e "orbital")"
else
wm="indéterminé"
# assigne $fg_wm
figet_wm(){ #v 21/11/2017 thanks neofetch
local id wm_brut compositor
fg_wm="n/a"
[ "$ENV_SSH" ] && fg_wm+=": ssh"
[ $( f__which xprop ) ] || fg_wm+=": xprop absent"
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_wm+=": wayland root"
[[ "$fg_wm" =~ : ]] && return 0 # retourne n/a: xprop ou n/a: ssh
##
id=$( xprop -root -notype _NET_SUPPORTING_WM_CHECK )
id=${id##* } # suppression plus grande chaîne au début jusqu"à ' '
wm_brut=$( xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t )
[ "$debug" ] && echo "$wm_brut"
fg_wm=${wm_brut/*_NET_WM_NAME = } # suppression jusqu'à 'NAME = '
fg_wm=${fg_wm/\"} # suppression premier"
fg_wm=${fg_wm/\"*} # suppression 2e " avec éventuels caractères suivants
# Window Maker does not set _NET_WM_NAME
[[ "$fg_wm" =~ "WINDOWMAKER" ]] && fg_wm="wmaker"
# Fallback for Wayland wms (sway)
[[ "$fg_wm" == "xwlc" ]] && fg_wm=$( ps -e | grep -m1 -Eo 'sway|orbment|velox|orbital' )
if [[ "$wm_brut" =~ MUTTER_VERSION ]]; then
compositor=${wm_brut/*_MUTTER_VERSION = } # suppression jusqu'à ...
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
compositor="(Mutter version $compositor)"
fi
fg_wm="$wm"
if [[ "$wm_brut" =~ MUFFIN_VERSION ]]; then # en aveugle, jamais vu d'essai
compositor=${wm_brut/*MUFFIN_VERSION = } # suppression jusqu'à ...
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
compositor="(Muffin version $compositor)"
fi
if [[ "$wm_brut" =~ MARCO_VERSION ]]; then
compositor=${wm_brut/*_MARCO_VERSION = } # suppression jusqu'à ...
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
compositor="(Marco version $compositor)"
fi
[ "$compositor" ] && fg_wm="$fg_wm $compositor"
}
# aiguillage export paste
@ -3210,12 +3247,7 @@ prg_1(){ # début
echo -e "> $script sur *$(uname -n)* \n" > "$fileOutput"
echo -e "$ligneRapport \n\n" >> "$fileOutput"
}
prg_2(){ # traitements principaux 20/11/2017
# essai détection erreur No protocol specified, Can't open display :0 (root Fedora)
if [ -z "$DISPLAY" ]; then
f__info "des erreurs$YELLOW Can't open display$BLUE peut indiquer une nouvelle fonctionnalité Wayland" \
"lancer le script en utilisateur pour avoir toutes les informations"
fi
prg_2(){ # traitements principaux 21/11/2017
if [[ "$1" == all || "$1" =~ s ]]; then #systeme, matériel -cs
echo -e "# ▷ Système \n\n" >> "$fileOutput"
for i in fi_systeme fi_cpu fi_mem fi_hw fi_batt fi_graph fi_disk fi_usb ; do
@ -3284,13 +3316,20 @@ function display_menu {
reply="$(sed 's/-call/all/' <<< $reply)"
exec $0 "$reply"
}
prg_alert_init(){ # 11/10/2017
bashVersion=($(grep -o 'version 4' <<< $(bash --version)))
prg_init(){ # 21/11/2017
PATH='/usr/sbin:/usr/bin:/sbin:/bin'
TERM=xterm
IFS=$' \t\n'
export PATH TERM IFS
# aucune erreur visible, prévoir option --debug
# exec 2>/dev/null
# exec 2>"$script.log" # à tester
# test bash v4
bashVersion=( $( grep -o 'version 4' <<< $( bash --version ) ) )
[ ${bashVersion[1]} -ge 4 ] || f__error "bash v4 requis" \
"version installée: $(sed -n '1p' <<< $(bash --version))"
"version installée: $( grep -m1 'version' <<< $(bash --version) )"
# test /proc
[ -e /proc/cpuinfo ] || f__error "/proc/cpuinfo non trouvé" "/proc ne doit pas être monté"
# test OS
OS=$(uname -s)
[[ ${OS,,} =~ linux || ${OS,,} =~ gnu ]] && OS="linux"
@ -3299,7 +3338,17 @@ prg_alert_init(){ # 11/10/2017
[ "$OS" == "bsd" ] && f__info "ce script pour Linux n'est pas prévu de fonctionner sur BSD..."
[ "$OS" == "windows" ] && f__info "ce script pour Linux n'est pas prévu de fonctionner sous windows..."
[ "$OS" != "linux" ] && f__error "Linux requis"
# recherche wayland
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && wayland="wayland"
# essai détection erreur No protocol specified, Can't open display :0 (root Fedora)
if [[ "$wayland" && "$EUID" -eq 0 ]]; then
f__info "Wayland ne permet pas de lancer des applications graphiques en Root" \
"seul l'utilisateur ayant démarré le serveur X peut permettre des connexions à celui-ci" \
"le plus simple est de redémarrer le script en utilisateur pour déterminer certaines propriétés graphiques" \
"ou essayer xhost si:localuser:root pour autoriser, xhost -si:localuser:root pour enlever cette autorisation"
fi
# test SSH
[[ "$SSH_CLIENT" || "$SSH_CLIENT" || "$SSH_CLIENT" ]] && ENV_SSH="ssh"
# détermination user derrière root
f__user
retourFUser="$?"
@ -3312,16 +3361,12 @@ prg_alert_init(){ # 11/10/2017
}
######## début script / initialisation
PATH='/usr/sbin:/usr/bin:/sbin:/bin'; TERM=xterm ; IFS=$' \t\n'
export PATH TERM IFS
[[ "$SSH_CLIENT" || "$SSH_CLIENT" || "$SSH_CLIENT" ]] && ENV_SSH="ssh"
# logo et définition couleurs
f__affichage
# tests au démarrage
prg_alert_init
prg_init
# requis pour fonctionnement programme
f__requis "gawk wget ip>iproute2 lspci>pciutils wc>coreutils" || exit 1
@ -3372,7 +3417,8 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_log_xorg
echo -n "."
fi_systeme
exit ;; # test
-c* | all )
[ "$j" == "-c" ] && exec $0 "menu"

View File

@ -3,9 +3,13 @@
* f__wcv, f_display_grep, f_dspl_md, f__wget_test, fscript_get_version, fscript_update
* ! f__requis, fscript_install, f__scandir
## 2.41.5 21/11/2017
## 2.42.0 21/11/2017
* révision: wayland, wayland/root, évolution wayland si plus de xprop, xrandr, xdpyinfo...
* révision: fi_system, figet_de, fi_graph, figet_screen, fi_system_analyse prise en compte wayland
* révision: figet_wm, + compositor si connu
* révision: fi_log_xorg, + emplacement log sous gdm3 X11 (nouveau sous buster?), cmd et info adaptés
* fix, fi_system_analyse si graph généré par root
## 2.41.3 20/11/2017