mirror of https://framagit.org/kyodev/kyopages.git
getInfo 2.57.0
This commit is contained in:
parent
e8bc32d593
commit
85088d80aa
100
scripts/getInfo
100
scripts/getInfo
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
version=2.56.0
|
version=2.57.0
|
||||||
date="5/12/2017"
|
date="6/12/2017"
|
||||||
projet="simpledeb"
|
projet="simpledeb"
|
||||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||||
script="getInfo"
|
script="getInfo"
|
||||||
|
@ -557,8 +557,8 @@ toDisplay=(
|
||||||
|
|
||||||
# f_pr "1|1|2|l1|l2|l3|titre1|titre2|hl|quote|flush" "texte" '[CONDITION test]'
|
# f_pr "1|1|2|l1|l2|l3|titre1|titre2|hl|quote|flush" "texte" '[CONDITION test]'
|
||||||
# $1:
|
# $1:
|
||||||
# 1|2|3 indentation, liste à puce
|
# 1|2|3 indentation, liste à puce, une puce par ligne
|
||||||
# l1|l2|l3 indentation, avec espaces
|
# l1|l2|l3 ligne, indentation, avec espaces
|
||||||
# titre1|titre2|titre3
|
# titre1|titre2|titre3
|
||||||
# quote|hl|flush
|
# quote|hl|flush
|
||||||
# $2 texte à afficher
|
# $2 texte à afficher
|
||||||
|
@ -736,7 +736,7 @@ fi_conf(){ # 3/12/2017
|
||||||
f_di cmd "$confs" "grep -Ersv '^#|^$' <fichiers désirés>"
|
f_di cmd "$confs" "grep -Ersv '^#|^$' <fichiers désirés>"
|
||||||
}
|
}
|
||||||
|
|
||||||
fi_cpu(){ # 5/12/2017
|
fi_cpu(){ # 6/12/2017
|
||||||
local cpu_flags text iflag qte_flags text_flags="" pluriel
|
local cpu_flags text iflag qte_flags text_flags="" pluriel
|
||||||
local alert_microcode
|
local alert_microcode
|
||||||
|
|
||||||
|
@ -749,11 +749,11 @@ fi_cpu(){ # 5/12/2017
|
||||||
BEGIN { IGNORECASE=1; pattern = "^"motif"[[:blank:]]" }
|
BEGIN { IGNORECASE=1; pattern = "^"motif"[[:blank:]]" }
|
||||||
$0 ~ pattern { $1 = motif; exit }
|
$0 ~ pattern { $1 = motif; exit }
|
||||||
END { if( $1 != motif ) {$1 = motif; $2 = "?"}
|
END { if( $1 != motif ) {$1 = motif; $2 = "?"}
|
||||||
printf ("%-15s %s",$1,$2 ) #ligne
|
printf ("%-20s %s",$1,$2 ) #ligne
|
||||||
}' <<< $CPU_FLAGS
|
}' <<< $CPU_FLAGS
|
||||||
)"$'\n'
|
)"$'\n'
|
||||||
done
|
done
|
||||||
text_flags=${text_flags%[[:cntrl:]]} # suppression \n final
|
text_flags=${text_flags%[[:cntrl:]]} # suppression \n final
|
||||||
[ "$cpu_flags" ] && qte_flags=$( f__wcv -w "$cpu_flags" flags )
|
[ "$cpu_flags" ] && qte_flags=$( f__wcv -w "$cpu_flags" flags )
|
||||||
[ "$fg_cpu" ] || figet_cpu
|
[ "$fg_cpu" ] || figet_cpu
|
||||||
if ! figet_ucode ; then # retour fonction en erreur => pas d'installation mais possible
|
if ! figet_ucode ; then # retour fonction en erreur => pas d'installation mais possible
|
||||||
|
@ -1262,13 +1262,14 @@ fi_journal(){ # 2/12/2017
|
||||||
f_dspl_alrt "$info_ucode" "info"
|
f_dspl_alrt "$info_ucode" "info"
|
||||||
}
|
}
|
||||||
|
|
||||||
fi_locale(){ # 1/12/2017
|
fi_locale(){ # 6/12/2017
|
||||||
local locale localectl timezone timedatectl xKeyboardMap keyboard text
|
local localeConf localeCtl locale timezone timedatectl xKeyboardMap keyboard text
|
||||||
local alert_rtc alert_ntp
|
local alert_rtc alert_ntp
|
||||||
|
|
||||||
# locale
|
# locale
|
||||||
locale="$(f_grep_file "/etc/default/locale* /etc/locale.conf")"
|
localeConf=$(f_grep_file "/etc/default/locale* /etc/locale.conf")
|
||||||
[ $( f__which localectl ) ] && localectl=$( localectl --no-pager status )
|
[ $( f__which localectl ) ] && localeCtl=$( localectl --no-pager status )
|
||||||
|
locale=$( locale )
|
||||||
# timezone
|
# timezone
|
||||||
timezone="$(f_grep_file "/etc/timezone*")"
|
timezone="$(f_grep_file "/etc/timezone*")"
|
||||||
if [ $( f__which timedatectl ) ]; then
|
if [ $( f__which timedatectl ) ]; then
|
||||||
|
@ -1297,8 +1298,9 @@ fi_locale(){ # 1/12/2017
|
||||||
###
|
###
|
||||||
f_pr titre2 "localisation"
|
f_pr titre2 "localisation"
|
||||||
# locale
|
# locale
|
||||||
f_di cmd "$locale" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
|
f_di cmd "$localeConf" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
|
||||||
f_di cmd "$localectl" "localectl --no-pager status"
|
f_di cmd "$localeCtl" "localectl status"
|
||||||
|
f_di cmd "$locale" "locale"
|
||||||
# timezone
|
# timezone
|
||||||
f_di cmd "$timezone" "grep -EHsv '#|^$' /etc/timezone*"
|
f_di cmd "$timezone" "grep -EHsv '#|^$' /etc/timezone*"
|
||||||
f_di cmd "$timedatectl" "timedatectl status --no-pager"
|
f_di cmd "$timedatectl" "timedatectl status --no-pager"
|
||||||
|
@ -1368,7 +1370,7 @@ fi_mem(){ # 5/12/2017
|
||||||
###
|
###
|
||||||
f_pr titre2 "mémoire"
|
f_pr titre2 "mémoire"
|
||||||
f_di cmd "$memoire" "free -h"
|
f_di cmd "$memoire" "free -h"
|
||||||
f_di cmd "$swappiness" "cat /proc/sys/vm/swappiness" "% \"d'utilisation\" du swap"
|
f_di cmd "$swappiness" "cat /proc/sys/vm/swappiness" "Seuil bas de RAM libre où le swap est utilisé"
|
||||||
}
|
}
|
||||||
|
|
||||||
# [$1=silent], assigne fe_nb_reseau, fe_cards_reseau
|
# [$1=silent], assigne fe_nb_reseau, fe_cards_reseau
|
||||||
|
@ -1952,8 +1954,8 @@ fi_ssid(){ #v2 1/12/2017
|
||||||
rm "$fileOutput"
|
rm "$fileOutput"
|
||||||
}
|
}
|
||||||
|
|
||||||
fi_system(){ # 2/12/2017
|
fi_system(){ # 6/12/2017
|
||||||
local mbr uname bootImage initDaemon date_install ligne lastboot uptime charge serverX pluriel text
|
local mbr uname bootImage initDaemon date_install ligne lastboot uptime uptimePure loadAverage serverX pluriel text
|
||||||
local alimentation alim_total
|
local alimentation alim_total
|
||||||
|
|
||||||
# appels fonctions externes
|
# appels fonctions externes
|
||||||
|
@ -1990,20 +1992,40 @@ fi_system(){ # 2/12/2017
|
||||||
[[ "$date_install" =~ .*([0-9]{2}/[0-9]{2}/[0-9]{4}).* ]] && date_install=${BASH_REMATCH[1]}
|
[[ "$date_install" =~ .*([0-9]{2}/[0-9]{2}/[0-9]{4}).* ]] && date_install=${BASH_REMATCH[1]}
|
||||||
# lastboot="$(last -n 1 --time-format iso reboot | gawk 'FNR==1 {sub(/T/," ",$5);print $5}')" # remis à jours en début de mois ?!!
|
# lastboot="$(last -n 1 --time-format iso reboot | gawk 'FNR==1 {sub(/T/," ",$5);print $5}')" # remis à jours en début de mois ?!!
|
||||||
lastboot=$( date -r /var/run/utmp '+%d/%m/%Y %H:%M %z' )
|
lastboot=$( date -r /var/run/utmp '+%d/%m/%Y %H:%M %z' )
|
||||||
uptime=$( LC_ALL=C uptime )
|
uptimePure="OUI" # si pas vide, pas d'affichage des valeurs Zéro (avec unité) dans uptime
|
||||||
charge=${uptime/*average: } # suppression jusqu'à 'average: '
|
uptime=$(
|
||||||
charge=${charge//, / } # remplacement global ', ' par ' '
|
gawk -v uptimePure="$uptimePure" -F'( |,|:)+' '{
|
||||||
charge=${charge//,/.} # remplacement global , par .
|
# extraction selon format de sortie
|
||||||
uptime=${uptime%%, *} # uptime -p parfois inexistant (alpine), suppression à la fin de ',[blancs]*' -> conservation premier 'champs' ifs ', '
|
if ( $7 ~ /^day/ && $9 ~ /^min/ ) { j=$6; h=0; m=$8 } # up 25 days, 30 min,
|
||||||
uptime=${uptime/*up } # suppression jusqu'à 'up '
|
else if ( $7 ~ /^day/ ) { j=$6; h=$8; m=$9 } # up 25 days, 21:30,
|
||||||
uptime=${uptime//weeks/semaines} # remplacement global
|
else if ( $7 ~ /^min/ ) { j=0; h=0; m=$6 } # up 15 min,
|
||||||
uptime=${uptime//week/semaine} # remplacement global
|
else { j=0; h=$6; m=$7 } # up 12:30,
|
||||||
uptime=${uptime//days/jours} # remplacement global
|
if ( j > 1 ) { pluriel="s" }
|
||||||
uptime=${uptime//day/jour} # remplacement global
|
# 3 parties à afficher ou pas
|
||||||
uptime=${uptime//hours/h} # remplacement global
|
groupe1 = sprintf( "%d jour%s", j,pluriel )
|
||||||
uptime=${uptime//hour/h} # remplacement global
|
groupe2 = sprintf( "%02d h", h )
|
||||||
uptime=${uptime//minutes/mn} # remplacement global
|
groupe3 = sprintf( "%02d mn", m )
|
||||||
uptime=${uptime//minute/mn} # remplacement global
|
# sortie
|
||||||
|
if ( uptimePure != "" ) {
|
||||||
|
printf ( j != 0 ) ? "%s " : "" , groupe1
|
||||||
|
printf ( h != 0 ) ? "%s " : "" , groupe2
|
||||||
|
printf ( m != 0 ) ? "%s" : "" , groupe3
|
||||||
|
} else {
|
||||||
|
print groupe1,groupe2,groupe3
|
||||||
|
}
|
||||||
|
}' <<< $( LC_ALL=C uptime ) )
|
||||||
|
loadAverage=$(
|
||||||
|
gawk -v threads="$fg_nb_threads" -F'(, )' '{
|
||||||
|
gsub(/ load average: /,"")
|
||||||
|
if ( threads > 1 ) th="threads"; else th="thread"
|
||||||
|
la1 = $(NF-2)
|
||||||
|
la5 = $(NF-1)
|
||||||
|
la15 = $NF
|
||||||
|
print "charge système depuis les 1, 5 et 15 dernières minutes:", la1, la5, la15, " "
|
||||||
|
printf "%s %s %s %s", "soit avec", threads, th, ":"
|
||||||
|
printf "%d%% %d%% %d%% %s", la1/2*100, la5/2*100, la15/2*100, "d\047occupation du système (en temps)"
|
||||||
|
}' <<< $( LC_ALL=C uptime )
|
||||||
|
)
|
||||||
# server X
|
# server X
|
||||||
serverX="${XDG_SESSION_TYPE^}" # retourne wayland normalement si c'est la cas
|
serverX="${XDG_SESSION_TYPE^}" # retourne wayland normalement si c'est la cas
|
||||||
serverX+=" $fe_Xorg"
|
serverX+=" $fe_Xorg"
|
||||||
|
@ -2073,7 +2095,7 @@ fi_system(){ # 2/12/2017
|
||||||
f_pr 1 "$( sed -E 's/^(.*: )(.*)/\1**\2**/' <<<$fg_disk_part_fix_tot )" '[ "$fg_disk_part_fix_tot" ]'
|
f_pr 1 "$( sed -E 's/^(.*: )(.*)/\1**\2**/' <<<$fg_disk_part_fix_tot )" '[ "$fg_disk_part_fix_tot" ]'
|
||||||
f_pr 1 "dernier boot: **$lastboot**, il y a **$uptime**"
|
f_pr 1 "dernier boot: **$lastboot**, il y a **$uptime**"
|
||||||
[ "$fg_nb_threads" -gt "1" ] && pluriel="s" || unset pluriel
|
[ "$fg_nb_threads" -gt "1" ] && pluriel="s" || unset pluriel
|
||||||
f_pr 1 "charge système depuis les 1, 5 et 15 dernières minutes: **$charge** ($fg_nb_threads thread"$pluriel")"
|
f_pr 1 "$loadAverage"
|
||||||
f_pr flush
|
f_pr flush
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3464,7 +3486,7 @@ figet_ucode(){ # 29/11/2017
|
||||||
}
|
}
|
||||||
|
|
||||||
# assigne $fg_wm (compositor non publique, pas fiabilisé)
|
# assigne $fg_wm (compositor non publique, pas fiabilisé)
|
||||||
figet_wm(){ #v 2/12/2017 base départ neofetch
|
figet_wm(){ #v 6/12/2017 base départ neofetch
|
||||||
local id wm_brut compositor
|
local id wm_brut compositor
|
||||||
|
|
||||||
fg_wm="n/a"
|
fg_wm="n/a"
|
||||||
|
@ -3530,7 +3552,7 @@ figet_wm(){ #v 2/12/2017 base départ neofetch
|
||||||
[[ "$wm_brut" =~ westford ]] && compositor+='westford'
|
[[ "$wm_brut" =~ westford ]] && compositor+='westford'
|
||||||
[[ "$wm_brut" =~ weston ]] && compositor+='weston'
|
[[ "$wm_brut" =~ weston ]] && compositor+='weston'
|
||||||
compositor=${compositor^} # caractère 1 en majuscule
|
compositor=${compositor^} # caractère 1 en majuscule
|
||||||
compositor="{$compositor}"
|
[ "$compositor" ] && compositor="{$compositor}"
|
||||||
#final
|
#final
|
||||||
fg_wm="$fg_wm $compositor"
|
fg_wm="$fg_wm $compositor"
|
||||||
}
|
}
|
||||||
|
@ -3710,7 +3732,6 @@ fscript_update(){ # 6/12/2017
|
||||||
mkdir -p "$dirTemp"
|
mkdir -p "$dirTemp"
|
||||||
wget -q --tries=2 --timeout=15 -O "$dirTemp/$script" "$urlScript"
|
wget -q --tries=2 --timeout=15 -O "$dirTemp/$script" "$urlScript"
|
||||||
if [ "$?" != "0" ]; then f__wget_test "$urlScript"; fi
|
if [ "$?" != "0" ]; then f__wget_test "$urlScript"; fi
|
||||||
# if grep -q '#!/bin/bash' "$dirTemp/$script" ; then
|
|
||||||
if grep -q '#!/bin/bash' "$dirTemp/$script" && grep -q '^### END CONTROL' "$dirTemp/$script"; then
|
if grep -q '#!/bin/bash' "$dirTemp/$script" && grep -q '^### END CONTROL' "$dirTemp/$script"; then
|
||||||
cp -d "$dirTemp/$script" "$scriptInstall"
|
cp -d "$dirTemp/$script" "$scriptInstall"
|
||||||
chmod 775 "$scriptInstall" # rwx rwx r-x, proprio fu_user
|
chmod 775 "$scriptInstall" # rwx rwx r-x, proprio fu_user
|
||||||
|
@ -3861,12 +3882,12 @@ function display_menu {
|
||||||
|
|
||||||
######## début script / initialisation
|
######## début script / initialisation
|
||||||
|
|
||||||
# logo et définition couleurs
|
|
||||||
f_affichage
|
|
||||||
|
|
||||||
# tests au démarrage
|
# tests au démarrage
|
||||||
prg_init
|
prg_init
|
||||||
|
|
||||||
|
# logo et définition couleurs
|
||||||
|
f_affichage
|
||||||
|
|
||||||
options=$@
|
options=$@
|
||||||
# traitement option paramètres
|
# traitement option paramètres
|
||||||
for j in $options; do
|
for j in $options; do
|
||||||
|
@ -3915,7 +3936,7 @@ for j in $options; do
|
||||||
ORIGIN='test'
|
ORIGIN='test'
|
||||||
prg_1 "$*"
|
prg_1 "$*"
|
||||||
echo -n "•"
|
echo -n "•"
|
||||||
fi_disk
|
fi_system
|
||||||
echo; f_dspl_md "$fileOutput"
|
echo; f_dspl_md "$fileOutput"
|
||||||
exit ;; # test
|
exit ;; # test
|
||||||
-c* | all )
|
-c* | all )
|
||||||
|
@ -3998,9 +4019,10 @@ done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
### END CONTROL (contrôle chargement)
|
||||||
|
|
||||||
wget -nv -O getInfo https://frama.link/getinfo
|
wget -nv -O getInfo https://frama.link/getinfo
|
||||||
chmod +x getInfo && ./getInfo
|
chmod +x getInfo && ./getInfo
|
||||||
|
|
||||||
wget -nv -O getInfo https://framagit.org/kyodev/kyopages/raw/master/scripts/getInfo
|
wget -nv -O getInfo https://framagit.org/kyodev/kyopages/raw/master/scripts/getInfo
|
||||||
|
|
||||||
### END CONTROL (contrôle chargement)
|
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## getInfo 2.57.0 6/12/2017
|
||||||
|
|
||||||
|
* révision: fi_locale, oublié locale
|
||||||
|
* révision: fi_system, uptime avec gawk et selon formats possibles
|
||||||
|
loadAverage, avec calcul fonction threads
|
||||||
|
* révision: fscript_update, controle chargement début et fin
|
||||||
|
* révision: changement séquence start pour éviter erreur cron
|
||||||
|
|
||||||
## 2.56.0 5/12/2017
|
## 2.56.0 5/12/2017
|
||||||
|
|
||||||
* révision: syncro fonctions communes
|
* révision: syncro fonctions communes
|
||||||
|
|
Loading…
Reference in New Issue