mirror of https://framagit.org/kyodev/kyopages.git
getInfo 2.35.0
This commit is contained in:
parent
df1977d57a
commit
120ec9e67b
130
scripts/getInfo
130
scripts/getInfo
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=2.34.1
|
||||
date="14/11/2017"
|
||||
version=2.35.0
|
||||
date="15/11/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getInfo"
|
||||
|
@ -318,50 +318,55 @@ f__wget_test(){ # 06/11/2017
|
|||
exit 0
|
||||
}
|
||||
|
||||
# $1 variable à afficher, $2=var|cmd|sans (type titre) [$3 titre] [$4 commentaire en () si cmd]
|
||||
# $1 variable à afficher, $2=var|cmd|sans[:text] (type titre) [$3 titre] [$4 commentaire en () si cmd]
|
||||
# $2: cmd->`titre`, var->**titre**, sans: pas de titre
|
||||
# "variable" "var" "" "comment" -> pas de titre mais commentaire encadré
|
||||
# :text ajouté, affiche le text en liste (avec puce)
|
||||
# passage en paramètre variable et pas $variable
|
||||
# un test si variable $1 est vide est fait
|
||||
# un test si variable $1 contient 'nofile', non trouvé par f_grep_file
|
||||
# f_display "variable" "type" "titrage" "titrage_commentaire"
|
||||
f_display(){ # 10/11/2017
|
||||
# flush, avant fonction, de text parent
|
||||
f_display(){ # 15/11/2017
|
||||
[ "${!1}" ] || return 0 # test si contenu dans $1
|
||||
local display=""
|
||||
# flush, avant fonction, de $text parent
|
||||
[ "$text" ] && echo -en "$text" >> "$fileOutput"
|
||||
unset text
|
||||
# coeur fonction
|
||||
local display=""
|
||||
[ "${!1}" ] || return 0 # test si contenu dans $1
|
||||
[[ "$2" =~ sans|var|cmd ]] || display=" **⚡ erreur f_display \$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 `
|
||||
[[ "$2" =~ "var" ]] && display="**$3**" # type var, titre en gras
|
||||
[[ "$2" =~ "cmd" ]] && display="\`$3\`" # type cmd, titre entre backtick
|
||||
[ "$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"
|
||||
if [[ "${!1}" =~ "nofile" ]]; then
|
||||
display+="\n* fichier $1 non trouvé \n"
|
||||
elif [[ "$2" =~ :text ]]; then
|
||||
display+='\n'
|
||||
display+="* ${!1} \n\n"
|
||||
else
|
||||
display+='``` \n'
|
||||
display+="${!1} \n"
|
||||
display+='``` \n'
|
||||
display+='``` \n\n'
|
||||
fi
|
||||
echo -en "$display \n" >> "$fileOutput" # flush fonction
|
||||
echo -en "$display" >> "$fileOutput" # flush fonction
|
||||
}
|
||||
|
||||
# $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(){ # 10/11/2017
|
||||
# flush, avant fonction, de text parent
|
||||
f_dspl_alert(){ # 15/11/2017
|
||||
[ "${!1}" ] || return 0 # test si contenu dans $1
|
||||
local display type
|
||||
# flush, avant fonction, de $text parent
|
||||
[ "$text" ] && echo -en "$text" >> "$fileOutput"
|
||||
unset text
|
||||
# coeur fonction
|
||||
local display type
|
||||
[ "${!1}" ] || return 0 # test si contenu dans $1
|
||||
[[ "$2" =~ "info" ]] && type="info"
|
||||
[[ "$2" =~ alert ]] && type="alert"
|
||||
[ "$type" == "alert" ] && display="\n> ❗ ${!1} \n"
|
||||
[ "$type" == "info" ] && display="\n ☛ ${!1} \n"
|
||||
echo -en "\n$display \n" >> "$fileOutput" # flush fonction
|
||||
[[ "$2" =~ info ]] && type="info"
|
||||
[[ "$2" =~ alert ]] && type="alert"
|
||||
[ "$2" ] || type="alert" # alert par défaut
|
||||
[ "$type" == "alert" ] && display="> ❗ ${!1} \n\n"
|
||||
[ "$type" == "info" ] && display=" ☛ ${!1} \n\n"
|
||||
echo -en "$display" >> "$fileOutput" # flush fonction
|
||||
}
|
||||
|
||||
# conversion markdown pour affichage en console, $1 file à parser
|
||||
|
@ -1047,7 +1052,7 @@ fi_hw(){ # 10/11/2017
|
|||
unset text
|
||||
}
|
||||
|
||||
fi_journal(){ # 14/11/2017
|
||||
fi_journal(){ # 15/11/2017
|
||||
local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_last jctl_size file
|
||||
local text nb_lignes=25
|
||||
local alert_jctl_persist
|
||||
|
@ -1071,8 +1076,8 @@ fi_journal(){ # 14/11/2017
|
|||
return 0
|
||||
fi
|
||||
# début des logs, extraction à partir de file-last (toujours lignes) pour début des logs
|
||||
jctl_boot=$(gawk -F '--|,' 'FNR==1 {sub(/^ /,"",$2);sub(/Logs begin at/,"Début des logs:",$2);print $2}' $file-last)
|
||||
jctl_boot=$( date -d "${jctl_boot##*logs: }" ) # passage en langue locale
|
||||
jctl_boot=$(gawk -F '--|,' 'FNR==1 {print $2}' $file-last)
|
||||
jctl_boot="Début des log: **$( date -d "${jctl_boot##*begin at }" )**" # passage en date locale
|
||||
# test persistance
|
||||
if grep -iq 'no persistent journal' "$file-persistant"; then
|
||||
alert_jctl_persist="les journaux ne sont pas persistants, revoir les logs du précédent boot "
|
||||
|
@ -1690,23 +1695,47 @@ fi_ssid(){ # 09/11/2017
|
|||
unset text
|
||||
}
|
||||
|
||||
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)"
|
||||
fi_system_analyse(){ # 15/11/2017
|
||||
[ "$(f__cmd_exist systemd)" ] || return 0 # pas systemd
|
||||
local bootTime bootBlame bootCritic bootGraph srvcFail text
|
||||
local alert_srvcFail
|
||||
# durée du précédent boot
|
||||
bootTime=$( systemd-analyze time )
|
||||
bootTime=${bootTime/Startup finished in /Durée de boot: }
|
||||
bootTime=${bootTime/userspace/espace utilisateur}
|
||||
# détail par service
|
||||
bootBlame=$( systemd-analyze blame | head -n 20 )
|
||||
# services critiques ralentisseurs
|
||||
bootCritic=$( systemd-analyze critical-chain )
|
||||
bootCritic="${bootCritic/The time after the unit is active or started is printed after the \"@\" character./@: temps pour que l\'unité soit active ou démarrée}"
|
||||
bootCritic="${bootCritic/The time the unit takes to start is printed after the \"+\" character./+: temps que l\'unité prend pour démarrer}"
|
||||
# génération graphique
|
||||
systemd-analyze plot > /tmp/getInfo-graph.svg
|
||||
bootGraph="[file:///tmp/getInfo-graph.svg](file:///tmp/getInfo-graph.svg) \n"
|
||||
bootGraph+=" * en console: \`xdg-open /tmp/getInfo-graph.svg\` \n"
|
||||
bootGraph+=" * copier/coller le lien dans la barre d'adresses, l'ouverture automatique ne devrait pas fonctionner dans un navigateur \n"
|
||||
# un lien local ne s'ouvrira pas automatiquement :( : http://kb.mozillazine.org/Links_to_local_pages_do_not_work
|
||||
# srvcFail=$( systemctl --state=active,failed | grep -cE 'error|not-found|failed' )
|
||||
srvcFail=$( systemctl --state=active,failed | gawk '/error|not-found|failed/ { sub(/●/,"");
|
||||
printf "%-40s%-11s%-8s%-8s%s",$1,$2,$3,$4,$5; $1=$2=$3=$4=$5=""; print $0}' )
|
||||
if [ $(f__wcv -l $srvcFail) -gt 0 ]; then
|
||||
alert_srvcFail="des services sont en erreur"
|
||||
srvcFail=$( printf "%-40s%-11s%-8s%-8s%s" Unit Load Active Sub Description )"\n$srvcFail"
|
||||
fi
|
||||
###
|
||||
text="## analyse boot \n\n"
|
||||
f_display "bootTime" "cmd" "systemd-analyze time"
|
||||
f_display "bootBlame" "cmd" "systemd-analyze blame | head -n 20"
|
||||
text="## analyse boot systemd \n\n"
|
||||
f_display "bootTime" "cmd" "systemd-analyze time" "durée du précédent boot avant interface graphique"
|
||||
f_display "srvcFail" "cmd" "systemctl --state=active,failed | grep -E 'error|not-found|failed'" "services en erreur"
|
||||
f_dspl_alert "alert_srvcFail" "alert"
|
||||
f_display "bootBlame" "cmd" "systemd-analyze blame | head -n 20" "détail par service"
|
||||
f_display "bootCritic" "cmd" "systemd-analyze critical-chain" "services critiques ralentisseurs"
|
||||
f_display "bootGraph" "cmd:text" "systemd-analyze plot > graph.svg ; xdg-open graph.svg" \
|
||||
"graph durées et ordre de chargement des services"
|
||||
printf "$text\n" >> "$fileOutput"
|
||||
unset text
|
||||
}
|
||||
|
||||
fi_systeme(){ # 13/11/2017
|
||||
fi_systeme(){ # 15/11/2017
|
||||
local mbr uname bootImage initDaemon xorg shells lastboot uptime charge pluriel text
|
||||
local alimentation alim_total ish ifs_origin ligne date_install
|
||||
local alert_SLiM alert_microcode microcode
|
||||
|
@ -1715,6 +1744,8 @@ fi_systeme(){ # 13/11/2017
|
|||
bootImage="$(gawk '/BOOT_IMAGE/ {print $1}' /proc/cmdline)"
|
||||
bootImage="$(gawk '{print $1}{i=2; while (i <= NF-1) { print " ",$i; i++}}' /proc/cmdline)"
|
||||
initDaemon="$(ps -p1 | gawk 'FNR==2 {print $4}')" #? ps -ax | gawk '$1==1' ou ps -p1 | gawk '$1==1'
|
||||
[ "$initDaemon" == "systemd" ] && initDaemon=$( systemd --version)
|
||||
initDaemon=${initDaemon%%[[:space:]]+*}
|
||||
[ "$ENV_SSH" ] && xorg="n/a (ssh)" || xorg="$XDG_SESSION_TYPE"
|
||||
if [ -z "$xorg" ]; then
|
||||
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && xorg="wayland" || xorg="indéterminé"
|
||||
|
@ -1834,27 +1865,28 @@ fi_usb(){ # 25/10/2017
|
|||
unset text
|
||||
}
|
||||
|
||||
fi_vrms(){ # 11/11/2017
|
||||
fi_vrms(){ # 15/11/2017
|
||||
local vrms non_free contrib total text pluriel tempo
|
||||
[ "$(f__cmd_exist vrms)" ] && vrms="$(vrms)"
|
||||
if [ "$vrms" ]; then
|
||||
non_free=$( sed -En 's/([0-9]+) non-free packages,.*/\1/p' <<< "$vrms" )
|
||||
contrib=$( sed -En 's/([0-9]+) contrib packages,.*/\1/p' <<< "$vrms" )
|
||||
if [[ "$non_free" && "$contrib" ]]; then
|
||||
total=$(( $non_free + $contrib ))
|
||||
if [ "$(f__cmd_exist vrms)" ]; then
|
||||
vrms="$(vrms)"
|
||||
non_free=$(($( sed -En 's/([0-9]+) non-free packages,.*/\1/p' <<< "$vrms" )))
|
||||
contrib=$(($( sed -En 's/([0-9]+) contrib packages,.*/\1/p' <<< "$vrms" )))
|
||||
if [[ "$non_free" -gt 0 || "$contrib" -gt 0 ]]; then
|
||||
[ "$non_free" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
vrms=$( sed -E "s/Non-free packages installed on.*/$non_free paquets non libre$pluriel installé$pluriel:/" <<< "$vrms" )
|
||||
vrms=$( sed -E "s/Non-free packages installed on.*/$non_free paquet$pluriel non libre$pluriel installé$pluriel:/
|
||||
" <<< "$vrms" )
|
||||
[ "$contrib" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
vrms=$( sed -E "s/Contrib packages installed on.*/$contrib paquets contrib installés:/" <<< "$vrms" )
|
||||
vrms=$( sed -E '/[0-9]+ non-free packages,/d; /[0-9]+ contrib packages,/d; ' <<< $vrms )
|
||||
[ "$total" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
vrms=$( sed -E "s/Contrib packages installed on.*/$contrib paquet$pluriel contrib installé$pluriel:/
|
||||
" <<< "$vrms" )
|
||||
vrms=$( sed -E '/[0-9]+ non-free packages,/d; /[0-9]+ contrib packages,/d;
|
||||
/^[[:space:]]*$/d' <<< $vrms )
|
||||
elif grep -iq 'proud' <<< "$vrms" ; then
|
||||
tempo="Aucun paquet non libre ou contrib installé sur ce système \n\t\t **rms serait fier ☺**"
|
||||
vrms=$( sed -E "s/.*rms would be proud.*/$tempo/" <<< "$vrms" )
|
||||
fi
|
||||
fi
|
||||
### No non-free or contrib packages installed on xxx! rms would be proud
|
||||
text="## paquet"$pluriel" non-libre"$pluriel" \n\n"
|
||||
###
|
||||
text="## paquets non-libres \n\n"
|
||||
if [ "$vrms" ]; then
|
||||
f_display "vrms" "cmd" "vrms" "détection des paquets non libres par Richard M. Stallman"
|
||||
else
|
||||
|
@ -3175,7 +3207,7 @@ for j in $options; do
|
|||
case $j in
|
||||
-t | --test )
|
||||
prg_1 "$*"
|
||||
fi_graph
|
||||
fi_vrms
|
||||
exit ;; # test
|
||||
-c* | all )
|
||||
[ "$j" == "-c" ] && exec $0 "menu"
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
|
||||
|
||||
|
||||
## 2.35.0 15/11/2017
|
||||
|
||||
* nouveau, révision : f_display, fi_system_analyse, affichage + services critiques, graphique services au chargement
|
||||
* nouveau: fi_systeme, version systemd
|
||||
* nouveau: fi_system_analyse, alerte services en erreur
|
||||
* fix: fi_vrms
|
||||
|
||||
## 2.34.1 14/11/2017
|
||||
|
||||
* nouveau, deborphan dans fi_pkg_apt
|
||||
|
|
Loading…
Reference in New Issue