mirror of https://framagit.org/kyodev/kyopages.git
getInfo 2.10.0
This commit is contained in:
parent
923b692e38
commit
d6fe206cdc
189
scripts/getInfo
189
scripts/getInfo
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=2.8.8
|
||||
date="17/10/2017"
|
||||
version=2.10.0
|
||||
date="19/10/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getInfo"
|
||||
|
@ -190,9 +190,9 @@ f__scandir(){ # 17/10/2017
|
|||
[ "$fileOutput" ] || echo -e "$text" # affichage si $fileOutput non défini
|
||||
}
|
||||
|
||||
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 1 tentative par défaut
|
||||
f__sudo(){ # 11/10/2017
|
||||
local nb=1 sudo isudo
|
||||
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 2 tentatives par défaut
|
||||
f__sudo(){ # 19/10/2017
|
||||
local nb=2 sudo isudo
|
||||
# sudo --shell bash équivalent su ?
|
||||
if sudo -v &>/dev/null && [ $EUID -ne 0 ] ; then
|
||||
sudo="sudo su --shell $(which bash) --preserve-environment -c "
|
||||
|
@ -293,22 +293,23 @@ f__wget_test(){ # 17/10/2017
|
|||
exit 0
|
||||
}
|
||||
|
||||
f_help(){ # 13/10/2017
|
||||
f_help(){ # 19/10/2017
|
||||
printf "$BLUE"
|
||||
cat << 'EOF'
|
||||
----------------------------------------------------------------------
|
||||
./getInfo : exécution normale, rapport markdown de la configuration
|
||||
getInfo : exécution normale si script installé dans le système
|
||||
|
||||
options:
|
||||
-c : (catégorie) menu sélection catégorie d'analyse
|
||||
-cs : catégorie système -cs : catégorie configuration
|
||||
-cr : catégorie réseau -ca : catégorie analyse
|
||||
-h : (help) affichage aide
|
||||
-j : (journaux) analyse démarrage système, log Xorg, kernel et système, catégorie -ca
|
||||
-l : (list) afficher le rapport markdown existant
|
||||
-p : (paste) exporte le rapport markdown existant, durée standard du paste 7 jours
|
||||
-tn : durée du paste de n jour(s)
|
||||
|
||||
--dmesg : dmesg {erreur & warning & critique} et journaux Xorg, root requis, rapport markdown créé
|
||||
--ip : affiche ip(s) publique(s) (ipv4 / ipv6), infos confidentielles, pas de rapport markdown
|
||||
--ip : affiche ip publique (ipv4/ipv6), infos confidentielles, pas de rapport markdown
|
||||
--mac : affiche les adresses Mac, infos confidentielles, pas de rapport markdown
|
||||
--ssid : affiche configurations ssid, infos confidentielles, pas de rapport markdown,
|
||||
root et NetworkManager requis
|
||||
|
@ -316,7 +317,6 @@ cat << 'EOF'
|
|||
--debug-batt : scan valeurs power_supply et rapport markdown
|
||||
--debug-hw : scan valeurs hwmon et rapport markdown
|
||||
--debug-dmi : scan valeurs dmi et rapport markdown
|
||||
--debug-paste : le résultat json du paste sera affiché après export
|
||||
|
||||
-i, --install : installation du script dans le système, root requis
|
||||
-r, --remove : suppression du script dans le système, root requis
|
||||
|
@ -448,49 +448,57 @@ fi_disk(){ # 18/10/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_dmesg(){ # 18/10/2017
|
||||
local dmesg_err dmesg_warn dmesg_crit file text
|
||||
fi_dmesg(){ # v2 19/10/2017
|
||||
local dmesg_err dmesg_warn dmesg_crit file text nb_lignes=25
|
||||
file="/tmp/$$-$RANDOM-dmesg"
|
||||
[ "$EUID" -eq 0 ] || echo
|
||||
f__sudo "dmesg -Hk --nopager -l err > $file-err ; \
|
||||
dmesg -Hk --nopager -l warn > $file-warn ; \
|
||||
dmesg -Hk --nopager -l crit > $file-crit ; \
|
||||
f__sudo "dmesg -Hk --nopager -l emerg > $file-emerg ; \
|
||||
dmesg -Hk --nopager -l alert > $file-alert ; \
|
||||
dmesg -Hk --nopager -l crit > $file-crit ; \
|
||||
dmesg -Hk --nopager -l warn > $file-err ; \
|
||||
dmesg -Hk --nopager -l warn > $file-warn ; \
|
||||
chown $user_: $file-*"
|
||||
if [ "$?" != "0" ]; then
|
||||
f__info "raw" "\n la commande$GREEN dmesg$RED a échoué $BLUE(droits root requis, échec authentification?)" \
|
||||
f__info "\n les commandes$GREEN dmesg$RED ont échoué $BLUE(droits root requis, échec authentification?)" \
|
||||
"vous pouvez relancer le script complet$RED en root$BLUE pour voir les erreurs du noyau via dmesg" \
|
||||
"ou juste la partie dmesg avec $GREEN./getInfo -d$BLUE ou$GREEN getInfo -d$BLUE (script installé)"
|
||||
text+="la commande \`dmesg\` a échoué, relancer avec les droits root \n"
|
||||
"ou juste la partie journaux avec $GREEN./getInfo -j$BLUE ou$GREEN getInfo -j$BLUE (script installé)"
|
||||
text+="les commandes \`dmesg\` ont échoué, relancer avec les droits root \n\n"
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
return 0
|
||||
fi
|
||||
dmesg_err="$(< $file-err)"
|
||||
dmesg_warn="$(< $file-warn)"
|
||||
dmesg_crit="$(< $file-crit)"
|
||||
dmesg_emerg=$(sed -n 1,"$nb_lignes"p $file-emerg)
|
||||
dmesg_alert=$(sed -n 1,"$nb_lignes"p $file-alert)
|
||||
dmesg_crit=$(sed -n 1,"$nb_lignes"p $file-crit)
|
||||
dmesg_err=$(sed -n 1,"$nb_lignes"p $file-err)
|
||||
dmesg_warn=$(sed -n 1,"$nb_lignes"p $file-warn)
|
||||
[ "$dmesg_emerg" ] || dmesg_emerg="<vide>"
|
||||
[ "$dmesg_alert" ] || dmesg_alert="<vide>"
|
||||
[ "$dmesg_crit" ] || dmesg_crit="<vide>"
|
||||
[ "$dmesg_err" ] || dmesg_err="<vide>"
|
||||
[ "$dmesg_warn" ] || dmesg_warn="<vide>"
|
||||
rm "$file-"*
|
||||
###
|
||||
text="## dmesg (erreur, warning ou critique) \n\n"
|
||||
if [ "$dmesg_warn" ]; then
|
||||
text+='`dmesg -l warn` (warning) \n'
|
||||
text+='```\n'
|
||||
text+="$dmesg_warn \n"
|
||||
text+='```\n\n'
|
||||
fi
|
||||
if [ "$dmesg_err" ]; then
|
||||
text+='`dmesg -l err` (erreur) \n'
|
||||
text+='```\n'
|
||||
text+="$dmesg_err \n"
|
||||
text+='```\n\n'
|
||||
fi
|
||||
if [ "$dmesg_crit" ]; then
|
||||
text+='`dmesg -l crit` (critique) \n'
|
||||
text+='```\n'
|
||||
text+="$dmesg_crit \n"
|
||||
text+='```\n\n'
|
||||
fi
|
||||
if [ -z "$dmesg_crit" ] && [ -z "$dmesg_warn" ] && [ -z "$dmesg_err" ]; then
|
||||
text+="pas de messages à afficher \n\n"
|
||||
fi
|
||||
text="## dmesg kernel (emergency, alerte, erreur, warning ou critique) \n\n"
|
||||
text+='`dmesg -l emerg`'" (emergency, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$dmesg_emerg \n"
|
||||
text+='```\n\n'
|
||||
text+='`dmesg -l alert`'" (alerte, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$dmesg_alert \n"
|
||||
text+='```\n\n'
|
||||
text+='`dmesg -l crit`'" (critique, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$dmesg_crit \n"
|
||||
text+='```\n\n'
|
||||
text+='`dmesg -l err`'" (erreur, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$dmesg_err \n"
|
||||
text+='```\n\n'
|
||||
text+='`dmesg -l warn`'" (warning, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$dmesg_warn \n"
|
||||
text+='```\n\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
|
@ -546,6 +554,78 @@ fi_hw(){ # 12/10/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_journal(){ # 19/10/2017
|
||||
local jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k file text nb_lignes=25
|
||||
local jctl_warn_nok
|
||||
[ -x "$(which 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 -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 ; \
|
||||
LC_ALL=C journalctl --no-hostname --boot 0 -p 4..4 > $file-warn ; \
|
||||
chown $user_: $file-*"
|
||||
if [ "$?" != "0" ]; then
|
||||
f__info "\n les commandes$GREEN journalctl$RED ont échoué $BLUE(droits root requis, échec authentification?)" \
|
||||
"vous pouvez relancer le script complet$RED en root$BLUE pour voir les erreurs des journaux" \
|
||||
"ou juste la partie journaux avec $GREEN./getInfo -j$BLUE ou$GREEN getInfo -j$BLUE (script installé)"
|
||||
text+="les commandes \`journalctl\` ont échoué, relancer avec les droits root \n\n"
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
return 0
|
||||
fi
|
||||
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)
|
||||
jctl_err_k=$(sed '/kernel:/!d' $file-err | sed -n 1,"$nb_lignes"p)
|
||||
jctl_warn_k=$(sed '/kernel:/!d' $file-warn | sed -n 1,"$nb_lignes"p)
|
||||
[ "$jctl_alert_k" ] || jctl_alert_k="<vide>"
|
||||
[ "$jctl_crit_k" ] || jctl_crit_k="<vide>"
|
||||
[ "$jctl_err_k" ] || jctl_err_k="<vide>"
|
||||
[ "$jctl_warn_k" ] || jctl_warn_k="<vide>"
|
||||
jctl_alert_nok=$(sed '/kernel:/d; s/-- No entries --/<vide>/' $file-alert | sed -n 1,"$nb_lignes"p)
|
||||
jctl_crit_nok=$(sed '/kernel:/d; s/-- No entries --/<vide>/' $file-crit | sed -n 1,"$nb_lignes"p)
|
||||
jctl_err_nok=$(sed '/kernel:/d; s/-- No entries --/<vide>/' $file-err | sed -n 1,"$nb_lignes"p)
|
||||
jctl_warn_nok=$(sed '/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+='`journalctl --no-hostname --boot 0 -k -p 1`'" (emergency 0 & alerte 1, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_alert_k \n"
|
||||
text+='```\n\n'
|
||||
text+='`journalctl --no-hostname --boot 0 -k -p 2..2`'" (critique, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_crit_k \n"
|
||||
text+='```\n\n'
|
||||
text+='`journalctl --no-hostname --boot 0 -k -p 3..3`'" (erreur, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_err_k \n"
|
||||
text+='```\n\n'
|
||||
text+='`journalctl --no-hostname --boot 0 -k -p 4..4`'" (warning, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_warn_k \n"
|
||||
text+='```\n\n'
|
||||
# non kernel
|
||||
text+="## journalctl hors kernel (emergency, alert, erreur, warning ou critique) \n\n"
|
||||
text+='`journalctl --no-hostname --boot 0 -p 1 | grep -v kernel:`'" (emergency 0 & alerte 1, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_alert_nok \n"
|
||||
text+='```\n\n'
|
||||
text+='`journalctl --no-hostname --boot 0 -p 2..2 | grep -v kernel:`'" (critique, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_crit_nok \n"
|
||||
text+='```\n\n'
|
||||
text+='`journalctl --no-hostname --boot 0 -p 3..3 | grep -v kernel:`'" (erreur, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_err_nok \n"
|
||||
text+='```\n\n'
|
||||
text+='`journalctl --no-hostname --boot 0 -p 4..4 | grep -v kernel:`'" (warning, $nb_lignes lignes maxi) \n"
|
||||
text+='```\n'
|
||||
text+="$jctl_warn_nok \n"
|
||||
text+='```\n\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_localisation(){ # 11/10/2017
|
||||
local locale timezone keymap keyboard timedatectl alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
|
||||
locale="$(grep -Ev '#|^$' /etc/default/locale)"
|
||||
|
@ -1668,7 +1748,7 @@ fipaste(){
|
|||
}
|
||||
|
||||
# $1 fichier à exporter, $2 durée de conservation en jour; $3 debug
|
||||
fipaste_curl_pastery(){ # 14/10/2017
|
||||
fipaste_curl_pastery(){ # 19/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
|
||||
|
@ -1682,6 +1762,7 @@ fipaste_curl_pastery(){ # 14/10/2017
|
|||
[ "$pasteDuration" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
f__info "\n 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
|
||||
[ "$3" == "debugPaste" ] && f__info "$curl"
|
||||
# UTF-8
|
||||
|
@ -1850,7 +1931,7 @@ prg_2(){ # traitements principaux
|
|||
fi
|
||||
if [[ "$1" == all || "$1" =~ c ]]; then #configuration #debian, packages -cc
|
||||
echo -e "# Configuration et packages \n" >> "$fileOutput"
|
||||
for i in fi_localisation fi_sources ; do
|
||||
for i in fi_localisation fi_nonFree fi_sources ; do
|
||||
$i
|
||||
printf "."
|
||||
done
|
||||
|
@ -1864,9 +1945,8 @@ prg_2(){ # traitements principaux
|
|||
fi
|
||||
if [[ "$1" == all || "$1" =~ a ]]; then #analyse -ca
|
||||
echo -e "# Analyse \n" >> "$fileOutput"
|
||||
for i in fi_nonFree fi_system_analyse fi_log_xorg fi_dmesg ; do
|
||||
for i in fi_system_analyse fi_log_xorg fi_journal ; do
|
||||
$i
|
||||
printf "."
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
@ -1916,7 +1996,6 @@ prg_alert_crit(){ # 11/10/2017
|
|||
# initialisation
|
||||
PATH='/usr/sbin:/usr/bin:/sbin:/bin'; TERM=xterm ; IFS=$' \t\n'
|
||||
export PATH TERM IFS
|
||||
ligneRapport="Rapport du $(date '+%d/%m/%Y %H:%M %z') - $0 $* - [$script $version]($urlNotice)"
|
||||
|
||||
f__affichage
|
||||
|
||||
|
@ -1960,6 +2039,7 @@ if [[ "$options" =~ all|-d|-h|-c ]]; then
|
|||
urlNotice="https://kyodev.frama.io/kyopages/scripts/getInfo/"
|
||||
fi
|
||||
fi
|
||||
ligneRapport="Rapport du $(date '+%d/%m/%Y %H:%M %z') - $0 $* - [$script $version]($urlNotice)"
|
||||
|
||||
for k in $options; do
|
||||
categorie+="$(sed -En 's/-c([a-z]+)/\1/p' <<< $k)"
|
||||
|
@ -1973,8 +2053,7 @@ for j in $options; do
|
|||
case $j in
|
||||
-t | --test )
|
||||
prg_1 "$*"
|
||||
# fi_dmesg
|
||||
fi_batt
|
||||
fi_journal
|
||||
prg_3
|
||||
exit ;; # test seulement
|
||||
-c* | all )
|
||||
|
@ -1984,6 +2063,10 @@ for j in $options; do
|
|||
prg_2 "$j"
|
||||
prg_3
|
||||
exit ;; # rapport complet ou par catégorie
|
||||
-j )
|
||||
prg_1 "$*"
|
||||
prg_2 "a"
|
||||
exit ;; # exporte le rapport existant
|
||||
-l )
|
||||
[ -e $fileOutput ] && cat $fileOutput || f__info "pas de rapport à afficher" \
|
||||
"vous devez lancer une analyse auparavant: $GREEN$script -l" \
|
||||
|
@ -2017,12 +2100,6 @@ for j in $options; do
|
|||
figet_hw_test
|
||||
prg_3
|
||||
exit ;; # test hwmon avec affichage /sys/class/hwmon/
|
||||
--dmesg )
|
||||
prg_1 "$*"
|
||||
fi_log_xorg
|
||||
fi_dmesg "dmesg"
|
||||
prg_3
|
||||
exit ;; # rapport dmesg & log xorg, root requis
|
||||
--ip )
|
||||
if figet_ip_public "4" ; then
|
||||
f__info "raw" " ipv4 publique: $GREEN$ip_public"
|
||||
|
|
|
@ -8,12 +8,20 @@
|
|||
* figet_cpu, refaire
|
||||
* bug temp cpu (neofetch)
|
||||
* filtrer temperature 0 (sur i5: 6temp!)
|
||||
|
||||
---
|
||||
|
||||
* f__requis f__wget_test fscript_get_version fscript_update fscript_cronAnacron
|
||||
|
||||
## 2.9.0 18/10/2017
|
||||
## 2.10.0 19/10/2017
|
||||
|
||||
* nouveau: fi_journal, journaux kernel et non-kernel via journalctl, dmesg en fallback
|
||||
* révision: fi_dmesg
|
||||
* révision: suppression option --dmesg, journaux via option -ca (fi_system_analyse fi_log_xorg fi_journal)
|
||||
+ option -j
|
||||
* fi_nonFree passsé en catégorie configuration (-cc), option équivalente -j
|
||||
* fix: fi_dmesg, niveau emergency & alerte oublié
|
||||
|
||||
## 2.9.1 18/10/2017
|
||||
|
||||
* révision: réécriture figet_disk, renommage variables publiques
|
||||
* fix: dmesg, variable locale
|
||||
|
|
Loading…
Reference in New Issue