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
|
||||
|
||||
version=2.56.0
|
||||
date="5/12/2017"
|
||||
version=2.57.0
|
||||
date="6/12/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getInfo"
|
||||
|
@ -557,8 +557,8 @@ toDisplay=(
|
|||
|
||||
# f_pr "1|1|2|l1|l2|l3|titre1|titre2|hl|quote|flush" "texte" '[CONDITION test]'
|
||||
# $1:
|
||||
# 1|2|3 indentation, liste à puce
|
||||
# l1|l2|l3 indentation, avec espaces
|
||||
# 1|2|3 indentation, liste à puce, une puce par ligne
|
||||
# l1|l2|l3 ligne, indentation, avec espaces
|
||||
# titre1|titre2|titre3
|
||||
# quote|hl|flush
|
||||
# $2 texte à afficher
|
||||
|
@ -736,7 +736,7 @@ fi_conf(){ # 3/12/2017
|
|||
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 alert_microcode
|
||||
|
||||
|
@ -749,11 +749,11 @@ fi_cpu(){ # 5/12/2017
|
|||
BEGIN { IGNORECASE=1; pattern = "^"motif"[[:blank:]]" }
|
||||
$0 ~ pattern { $1 = motif; exit }
|
||||
END { if( $1 != motif ) {$1 = motif; $2 = "?"}
|
||||
printf ("%-15s %s",$1,$2 ) #ligne
|
||||
printf ("%-20s %s",$1,$2 ) #ligne
|
||||
}' <<< $CPU_FLAGS
|
||||
)"$'\n'
|
||||
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 )
|
||||
[ "$fg_cpu" ] || figet_cpu
|
||||
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"
|
||||
}
|
||||
|
||||
fi_locale(){ # 1/12/2017
|
||||
local locale localectl timezone timedatectl xKeyboardMap keyboard text
|
||||
fi_locale(){ # 6/12/2017
|
||||
local localeConf localeCtl locale timezone timedatectl xKeyboardMap keyboard text
|
||||
local alert_rtc alert_ntp
|
||||
|
||||
# locale
|
||||
locale="$(f_grep_file "/etc/default/locale* /etc/locale.conf")"
|
||||
[ $( f__which localectl ) ] && localectl=$( localectl --no-pager status )
|
||||
localeConf=$(f_grep_file "/etc/default/locale* /etc/locale.conf")
|
||||
[ $( f__which localectl ) ] && localeCtl=$( localectl --no-pager status )
|
||||
locale=$( locale )
|
||||
# timezone
|
||||
timezone="$(f_grep_file "/etc/timezone*")"
|
||||
if [ $( f__which timedatectl ) ]; then
|
||||
|
@ -1297,8 +1298,9 @@ fi_locale(){ # 1/12/2017
|
|||
###
|
||||
f_pr titre2 "localisation"
|
||||
# locale
|
||||
f_di cmd "$locale" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
|
||||
f_di cmd "$localectl" "localectl --no-pager status"
|
||||
f_di cmd "$localeConf" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
|
||||
f_di cmd "$localeCtl" "localectl status"
|
||||
f_di cmd "$locale" "locale"
|
||||
# timezone
|
||||
f_di cmd "$timezone" "grep -EHsv '#|^$' /etc/timezone*"
|
||||
f_di cmd "$timedatectl" "timedatectl status --no-pager"
|
||||
|
@ -1368,7 +1370,7 @@ fi_mem(){ # 5/12/2017
|
|||
###
|
||||
f_pr titre2 "mémoire"
|
||||
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
|
||||
|
@ -1952,8 +1954,8 @@ fi_ssid(){ #v2 1/12/2017
|
|||
rm "$fileOutput"
|
||||
}
|
||||
|
||||
fi_system(){ # 2/12/2017
|
||||
local mbr uname bootImage initDaemon date_install ligne lastboot uptime charge serverX pluriel text
|
||||
fi_system(){ # 6/12/2017
|
||||
local mbr uname bootImage initDaemon date_install ligne lastboot uptime uptimePure loadAverage serverX pluriel text
|
||||
local alimentation alim_total
|
||||
|
||||
# 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]}
|
||||
# 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' )
|
||||
uptime=$( LC_ALL=C uptime )
|
||||
charge=${uptime/*average: } # suppression jusqu'à 'average: '
|
||||
charge=${charge//, / } # remplacement global ', ' par ' '
|
||||
charge=${charge//,/.} # remplacement global , par .
|
||||
uptime=${uptime%%, *} # uptime -p parfois inexistant (alpine), suppression à la fin de ',[blancs]*' -> conservation premier 'champs' ifs ', '
|
||||
uptime=${uptime/*up } # suppression jusqu'à 'up '
|
||||
uptime=${uptime//weeks/semaines} # remplacement global
|
||||
uptime=${uptime//week/semaine} # remplacement global
|
||||
uptime=${uptime//days/jours} # remplacement global
|
||||
uptime=${uptime//day/jour} # remplacement global
|
||||
uptime=${uptime//hours/h} # remplacement global
|
||||
uptime=${uptime//hour/h} # remplacement global
|
||||
uptime=${uptime//minutes/mn} # remplacement global
|
||||
uptime=${uptime//minute/mn} # remplacement global
|
||||
uptimePure="OUI" # si pas vide, pas d'affichage des valeurs Zéro (avec unité) dans uptime
|
||||
uptime=$(
|
||||
gawk -v uptimePure="$uptimePure" -F'( |,|:)+' '{
|
||||
# extraction selon format de sortie
|
||||
if ( $7 ~ /^day/ && $9 ~ /^min/ ) { j=$6; h=0; m=$8 } # up 25 days, 30 min,
|
||||
else if ( $7 ~ /^day/ ) { j=$6; h=$8; m=$9 } # up 25 days, 21:30,
|
||||
else if ( $7 ~ /^min/ ) { j=0; h=0; m=$6 } # up 15 min,
|
||||
else { j=0; h=$6; m=$7 } # up 12:30,
|
||||
if ( j > 1 ) { pluriel="s" }
|
||||
# 3 parties à afficher ou pas
|
||||
groupe1 = sprintf( "%d jour%s", j,pluriel )
|
||||
groupe2 = sprintf( "%02d h", h )
|
||||
groupe3 = sprintf( "%02d mn", m )
|
||||
# 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
|
||||
serverX="${XDG_SESSION_TYPE^}" # retourne wayland normalement si c'est la cas
|
||||
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 "dernier boot: **$lastboot**, il y a **$uptime**"
|
||||
[ "$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
|
||||
}
|
||||
|
||||
|
@ -3464,7 +3486,7 @@ figet_ucode(){ # 29/11/2017
|
|||
}
|
||||
|
||||
# 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
|
||||
|
||||
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" =~ weston ]] && compositor+='weston'
|
||||
compositor=${compositor^} # caractère 1 en majuscule
|
||||
compositor="{$compositor}"
|
||||
[ "$compositor" ] && compositor="{$compositor}"
|
||||
#final
|
||||
fg_wm="$fg_wm $compositor"
|
||||
}
|
||||
|
@ -3710,7 +3732,6 @@ fscript_update(){ # 6/12/2017
|
|||
mkdir -p "$dirTemp"
|
||||
wget -q --tries=2 --timeout=15 -O "$dirTemp/$script" "$urlScript"
|
||||
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
|
||||
cp -d "$dirTemp/$script" "$scriptInstall"
|
||||
chmod 775 "$scriptInstall" # rwx rwx r-x, proprio fu_user
|
||||
|
@ -3861,12 +3882,12 @@ function display_menu {
|
|||
|
||||
######## début script / initialisation
|
||||
|
||||
# logo et définition couleurs
|
||||
f_affichage
|
||||
|
||||
# tests au démarrage
|
||||
prg_init
|
||||
|
||||
# logo et définition couleurs
|
||||
f_affichage
|
||||
|
||||
options=$@
|
||||
# traitement option paramètres
|
||||
for j in $options; do
|
||||
|
@ -3915,7 +3936,7 @@ for j in $options; do
|
|||
ORIGIN='test'
|
||||
prg_1 "$*"
|
||||
echo -n "•"
|
||||
fi_disk
|
||||
fi_system
|
||||
echo; f_dspl_md "$fileOutput"
|
||||
exit ;; # test
|
||||
-c* | all )
|
||||
|
@ -3998,9 +4019,10 @@ done
|
|||
|
||||
exit 0
|
||||
|
||||
### END CONTROL (contrôle chargement)
|
||||
|
||||
wget -nv -O getInfo https://frama.link/getinfo
|
||||
chmod +x getInfo && ./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
|
||||
|
||||
* révision: syncro fonctions communes
|
||||
|
|
Loading…
Reference in New Issue