getInfo 1.34.0

This commit is contained in:
kyodev 2017-10-04 23:26:27 +02:00
parent 8dfa7ca6a3
commit 4707cb8011
2 changed files with 131 additions and 78 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=1.33.0
date="03/10/2017"
version=1.34.0
date="04/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -77,6 +77,15 @@ f__error() { # 22/09/2017
exit 1
}
# conversion human, source ko, $1=nombre à convertir, affiche ko ou Mo ou Go
f__unit_human(){ # 04/10/2017
printf "$( awk ' {
if ( $1<1024 ) {unit="ko"; printf "%8d%s", $1, unit; exit}
if ( $1<1024*1024 && $1>=1024 ) {unit="Mo"; printf "%8d%s", $1/1024, unit}
else {unit="Go"; printf "%8.1f%s", $1/1024/1024, unit}
}' <<< $1 )"
}
# affichage des paramètres en bleu, si $1=raw pas de ligne vide à la fin, si $1=log uniquement $2 logué
f__info() { # 22/09/2017
local depart=1
@ -137,7 +146,7 @@ f__requis(){ # 22/09/2017
# user ayant initié la session graphique, assigne $user_
# return 1 sur échec identification user, return 2 sur absence home/
# gestion variable environnement user avec: USER_INSTALL=user script
f__user(){ # 02/10/2017-4
f__user(){ # 02/10/2017
if [ "$USER_INSTALL" ]; then # user_ via variable environnement, moyen d'injecter root
user_="$USER_INSTALL";
return 0
@ -148,7 +157,6 @@ f__user(){ # 02/10/2017-4
user_="root"
return 0
fi
echo "test \$TERM:$TERM"
fi
local user_id test root_login
root_login="$(grep ':0:' /etc/passwd | cut -d':' -f1)" || root_login="root"
@ -266,16 +274,16 @@ fi_batt(){ # 28/09/2017
echo -e "$text" >> "$fileOutput"
}
fi_cpu(){ # 03/10/2017
fi_cpu(){ # 04/10/2017
local cpu_addr cpu_bogomips cpu_flags text
cpu_addr="$(sed -n 's/^address sizes.*: \(.*\)$/\1/p' /proc/cpuinfo | sed -n '1p')"
cpu_bogomips="$(sed -n 's/^bogomips.*: \(.*\)$/\1/p' /proc/cpuinfo | sed -n '1p')"
cpu_flags="$(sed -n 's/^flags.*: \(.*\)$/\1/p;' /proc/cpuinfo | sed -n '1p')"
###
text="## processeur / mémoire \n\n"
figet_cpu
text="## processeur \n\n"
text+='```\n'
text+="CPU: $figet_cpu \n"
[ "$fget_cpu" ] || figet_cpu
text+="CPU: $fget_cpu \n"
text+="adressage: $cpu_addr \n"
text+="bogomips: $cpu_bogomips \n"
text+='```\n\n'
@ -286,20 +294,6 @@ fi_cpu(){ # 03/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_mem(){ # 03/10/2017
local memsys swappiness text
memsys="$(free -hwt)"
swappiness="$(cat /proc/sys/vm/swappiness)"
###
figet_memory
text+='```\n'
text+="mémoire Ram utilisée/totale: $figet_memory \n\n"
text+="$memsys \n\n"
text+="swappiness: $swappiness \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
}
fi_disk(){ # 02/10/2017
local fstab resume idResume idSwap alert_uuidResume text
fstab="$(grep -vE '^[[:blank:]]*#|^$' /etc/fstab)"
@ -387,7 +381,7 @@ fi_dmesg(){ # root only, si $1=dmesg rapport dmesg only # 27/09/2017
echo -e "$text" >> "$fileOutput"
}
fi_gpu(){ # 01/10/2017
fi_graph(){ # 04/10/2017
local slotGraphCards graphCards openGl resolutions logXorg modules text
# graphCards="$(lspci -nnk | grep -iEA 3 'vga|display|3d')"
# graphCards="$(lspci -nnv | grep -iEA 13 '^[0-9]+.*vga|display|3d')"
@ -404,10 +398,10 @@ fi_gpu(){ # 01/10/2017
text="## graphisme \n\n"
text+="| | | \n"
text+=" --- | --- \n"
figet_gpu
text+="GPU | **$figet_gpu** \n\n"
[ "$figet_resolution" ] || figet_resolution
text+="**résolution: $figet_resolution** \n\n"
[ "$fget_resolution" ] || figet_gpu
text+="GPU | **$fget_gpu** \n\n"
[ "$fget_resolution" ] || figet_resolution
text+="**résolution: $fget_resolution** \n\n"
text+='`'"lspci -nnv | grep -iEA 13 'vga|display|3d'"'` \n'
text+='```\n'
text+="$graphCards"
@ -480,6 +474,21 @@ et/ou installer le démon Ntp: apt install ntp \n"
echo -e "$text" >> "$fileOutput"
}
fi_mem(){ # 04/10/2017
local swappiness text
swappiness="$(cat /proc/sys/vm/swappiness)"
###
text="## processeur / mémoire \n\n"
text+='```\n'
figet_mem "mem" #options possibles mem swaptotal notitle nocoltitle
text+="$fget_mem \n"
figet_mem "swap"
text+="$fget_mem"
text+="swappiness: $swappiness \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
}
fi_nm(){ # 25/09/2017
[ -x "$(which nmcli)" ] || return 0 # nécessite root sur autre que debian?
local nm_etat nm_conf text
@ -714,7 +723,7 @@ fi_system_analyse(){ # 25/09/2017
echo -e "$text" >> "$fileOutput"
}
fi_systeme(){ # 02/10/2017
fi_systeme(){ # 04/10/2017
local mbr description uname bootImage xorg shells lastboot uptime text pluriel
[ -d /sys/firmware/efi ] && mbr="**EFI**" || mbr="**Legacy (mbr)**"
[ -x "/usr/bin/lsb_release" ] && description="$(lsb_release -ds)" #dépend de apt install lsb-release, sur debian, en standard, juste : lsb-base
@ -735,12 +744,12 @@ fi_systeme(){ # 02/10/2017
text+="| | | \n"
text+=" --- | --- \n"
figet_cpu
text+="CPU | **$figet_cpu** \n"
text+="CPU | **$fget_cpu** \n"
figet_gpu
text+="GPU | **$figet_gpu** \n"
text+="GPU | **$fget_gpu** \n"
text+="boot | $mbr \n"
figet_distro
text+="distribution | **$figet_distro** \n\n"
text+="distribution | **$fget_distro** \n"
f__architecture || f__info "Architecture non supportée" "vous pouvez contacter contacter $projet $contact si vous voulez aider à parfaire le script"
text+='```\n'
text+="architecture: $architecture \n"
@ -749,14 +758,14 @@ fi_systeme(){ # 02/10/2017
text+="$bootImage \n"
text+="démon d'initialisation: $initDaemon \n"
figet_resolution
text+="résolution: $figet_resolution \n"
text+="résolution: $fget_resolution \n"
text+="serveur d'affichage: $xorg \n"
figet_de
text+="desktop (DE): $figet_de \n"
text+="desktop (DE): $fget_de \n"
figet_wm
text+="window manager: $figet_wm \n"
text+="window manager: $fget_wm \n"
figet_shell
text+="shell actif: $figet_shell \n"
text+="shell actif: $fget_shell \n"
text+="shells installés: $shells \n"
figet_disk
text+="$part_fix_tot \n"
@ -866,7 +875,7 @@ figet_battery(){ # 02/10/2017
fi
}
figet_cpu() { # thanks neofetch, assigne $figet_cpu # 02/10/2017
figet_cpu() { # thanks neofetch, assigne $fget_cpu # 04/10/2017
local cpu speed_dir temp_dir speedMin speed speedMin speed temp cores
cpu="$(awk -F ': | @' '/model name|Processor/ {printf $2; exit}' /proc/cpuinfo)"
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
@ -909,10 +918,10 @@ figet_cpu() { # thanks neofetch, assigne $figet_cpu # 02/10/2017
cpu="${cpu//with Radeon * Graphics}"
# Add cpu cores to output
cpu="${cpu/@/(${cores})phys. (${coresT})logi. @}"
figet_cpu="$cpu"
fget_cpu="$cpu"
}
figet_de() { # thanks neofetch, assigne $figet_de #03/10/2017
figet_de() { # thanks neofetch, assigne $fget_de #04/10/2017
# local de="${XDG_CURRENT_DESKTOP/i3}" #supprime i3??...
local de="$XDG_CURRENT_DESKTOP"
de="${de/'X-'}"
@ -937,8 +946,8 @@ figet_de() { # thanks neofetch, assigne $figet_de #03/10/2017
de="xfce" # suppression xfce4 ou xfce5 (la version ne sort pas dans xprop ou $XDG_
;;
esac
figet_de="${de,,}"
figet_de="${figet_de^}"
fget_de="${de,,}"
fget_de="${figet_de^}"
}
# assigne $disk_lsblk $disk_utilisation $disk_detail $disk_hotplug $disk_fix $part_fix
@ -993,7 +1002,7 @@ figet_disk(){ # 02/10/2017
[ "$disk_nvme" ] || disk_nvme="-"
}
figet_distro() { # thanks neofetch, assigne $figet_distro # 02/10/2017
figet_distro() { # thanks neofetch, assigne $fget_distro # 02/10/2017
local distro file
if type -p lsb_release >/dev/null; then distro="$(lsb_release -sd)";
elif type -p guix >/dev/null; then distro="GuixSD";
@ -1010,10 +1019,10 @@ figet_distro() { # thanks neofetch, assigne $figet_distro # 02/10/2017
grep -qi 'Debian' /etc/issue && distro="$(sed 's/"//g' <<< $distro) $(cat /etc/debian_version)"
fi
[[ -z "$distro" ]] && distro="$os (Unknown)"
figet_distro="$distro"
fget_distro="$distro"
}
figet_gpu() { # thanks neofetch, assigne $figet_gpu # 02/10/2017
figet_gpu() { # thanks neofetch, assigne $fget_gpu # 04/10/2017
local gpu="$(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')"
case "$gpu" in
*"advanced"*)
@ -1034,7 +1043,7 @@ figet_gpu() { # thanks neofetch, assigne $figet_gpu # 02/10/2017
gpu="VirtualBox Graphics Adapter" ;;
esac
[[ "$gpu" =~ "intel" ]] && gpu="Intel Integrated Graphics"
figet_gpu="$gpu"
fget_gpu="$gpu"
}
# assigne $ip_local, $gateway, $gateway_type, $gateway_one, $ip_local, $ip_local_type
@ -1149,28 +1158,58 @@ figet_ip_public(){ # 02/10/2017
fi
}
figet_memory() { # thanks neofetch, assigne $figet_memory # 03/10/2017
# MemUsed = Memtotal + Shmem - MemFree - Buffers - Cached - SReclaimable
# Source: https://github.com/KittyKatt/screenFetch/issues/386#issuecomment-249312716
local mem_used mem_total a b
while IFS=":" read -r a b; do
case "$a" in
"MemTotal" )
mem_used="$((mem_used+=${b/kB}))"
mem_total="${b/kB}"
;;
"Shmem" )
mem_used="$((mem_used+=${b/kB}))"
;;
"MemFree" | "Buffers" | "Cached" | "SReclaimable" )
mem_used="$((mem_used-=${b/kB}))"
;;
esac
# $1=mem&|swap&|total&|notitle&|nocoltitle, assigne $fget_mem
figet_mem(){ # 04/10/2017
local MemTotal MemFree MemAvailable Buffers Cached SReclaimable Shmem MemUsed SwapTotal SwapFree SwapCached col
while IFS=':' read a b; do
[ "$a" == "MemTotal" ] && MemTotal="${b/kB}" #echo "$a $((${b/kB}/1024))" ! partie entière !
[ "$a" == "MemFree" ] && MemFree="${b/kB}"
[ "$a" == "MemAvailable" ] && MemAvailable="${b/kB}"
[ "$a" == "Buffers" ] && Buffers="${b/kB}"
[ "$a" == "Cached" ] && Cached="${b/kB}"
[ "$a" == "SReclaimable" ] && SReclaimable="${b/kB}"
[[ "$a" =~ Shmem$|MemShared$ ]] && Shmem="${b/kB}" # free shared
[ "$a" == "SwapTotal" ] && SwapTotal="${b/kB}"
[ "$a" == "SwapFree" ] && SwapFree="${b/kB}"
[ "$a" == "SwapCached" ] && SwapCached="${b/kB}"
done < /proc/meminfo
mem_used="$((mem_used / 1024))"
mem_total="$((mem_total / 1024))"
memory="${mem_used}Mo / ${mem_total}Mo"
figet_memory="$memory"
MemUsed=$(( $MemTotal-($MemFree+$Buffers+$Cached+$SReclaimable) ))
SwapUsed=$(( $SwapTotal-$SwapFree ))
totalTotal=$(( $MemTotal+$SwapTotal ))
totalUsed=$(( $MemUsed+$SwapUsed ))
totalAvailable=$(( $MemAvailable+$SwapFree ))
MemTotal=$(f__unit_human $MemTotal)
MemUsed=$(f__unit_human $MemUsed)
MemFree=$(f__unit_human $MemFree)
MemAvailable=$(f__unit_human $MemAvailable)
Buffers=$(f__unit_human $Buffers)
Cached=$(f__unit_human $Cached)
Cached=$(f__unit_human $SReclaimable)
Shmem=$(f__unit_human $Shmem)
SwapTotal=$(f__unit_human $SwapTotal)
SwapFree=$(f__unit_human $SwapFree)
SwapUsed=$(f__unit_human $SwapUsed)
SwapCached=$(f__unit_human $SwapCached)
totalTotal=$(f__unit_human $totalTotal)
totalUsed=$(f__unit_human $totalUsed)
totalAvailable=$(f__unit_human $totalAvailable)
unset fget_mem
if [[ ! "$*" =~ notitle ]]; then
[[ "$*" =~ nocoltitle ]] || col="mém.:"
fget_mem="$col totale utilisée disponible"$'\n'
fi
if [[ "$*" =~ mem ]]; then
[[ "$*" =~ nocoltitle ]] || col="ram :"
fget_mem+="$col$MemTotal$MemUsed$MemAvailable"$'\n'
fi
if [[ "$*" =~ swap ]]; then
[[ "$*" =~ nocoltitle ]] || col="swap:"
fget_mem+="$col$SwapTotal$SwapUsed$SwapFree"$'\n'
fi
if [[ "$*" =~ total ]]; then
[[ "$*" =~ nocoltitle ]] || col="tot.:"
fget_mem+="$col$totalTotal$totalUsed$totalAvailable"$'\n'
fi
}
figet_mod_net(){ # thanks wireless-info, assigne $modules_net # 01/10/2017
@ -1180,7 +1219,7 @@ figet_mod_net(){ # thanks wireless-info, assigne $modules_net # 01/10/2017
modules_net="$(lsmod | grep -E "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")"
}
figet_resolution() { # thanks neofetch, assigne $figet_resolution # 02/10/2017
figet_resolution() { # thanks neofetch, assigne $fget_resolution # 04/10/2017
local resolution
if type -p xrandr >/dev/null; then
resolution="$(xrandr --nograb --current | awk 'match($0,/[0-9]*\.[0-9]*\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}')"
@ -1188,10 +1227,10 @@ figet_resolution() { # thanks neofetch, assigne $figet_resolution # 02/10/2017
resolution="${resolution//\.[0-9][0-9]}"
elif type -p xdpyinfo >/dev/null; then resolution="$(xdpyinfo | awk '/dimensions:/ {printf $2}')"; fi
resolution="${resolution%,*}"
figet_resolution="$resolution"
fget_resolution="$resolution"
}
figet_shell(){ # thanks neofetch, assigne $figet_shell # 02/10/2017
figet_shell(){ # thanks neofetch, assigne $fget_shell # 04/10/2017
local shell
shell="${SHELL##*/}"
case "${SHELL##*/}" in
@ -1210,10 +1249,10 @@ figet_shell(){ # thanks neofetch, assigne $figet_shell # 02/10/2017
"fish")
shell+="$(fish -c 'printf "%s" "$FISH_VERSION"')" ;;
esac
figet_shell="$shell"
fget_shell="$shell"
}
figet_wm() { # thanks neofetch, assigne $figet_wm # 02/10/2017
figet_wm() { # thanks neofetch, assigne $fget_wm # 04/10/2017
local id wm
if [ -n "$DISPLAY" ]; then
id="$(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}')"
@ -1223,8 +1262,10 @@ figet_wm() { # thanks neofetch, assigne $figet_wm # 02/10/2017
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="pas de windows manager détecté"
fi
figet_wm="$wm"
fget_wm="$wm"
}
fipaste(){
@ -1385,9 +1426,12 @@ fscript_update(){ # 06/09/2017
PATH='/usr/sbin:/usr/bin:/sbin:/bin'; TERM=xterm ; IFS=$' \t\n'
export PATH TERM IFS
urlScript="https://frama.link/getinfo"
f__wget_test "$urlScript" "test" || urlScript="https://framagit.org/kyodev/kyopages/raw/master/scripts/$script"
urlNotice="https://frama.link/doc-getinfo"
f__wget_test "$urlNotice" test || urlNotice="https://kyodev.frama.io/kyopages/scripts/getInfo/"
if f__wget_test "$urlScript" "test"; then
urlNotice="https://frama.link/doc-getinfo"
else
urlScript="https://framagit.org/kyodev/kyopages/raw/master/scripts/$script"
urlNotice="https://kyodev.frama.io/kyopages/scripts/getInfo/"
fi
fileOutput="getInfo_rapport.md"
fileLogs="/var/log/sdeb_$script.log"
fileDev="/opt/bin/fileDev"
@ -1413,11 +1457,17 @@ prg_1(){ # début
echo -e "# $script sur $hote \n" > "$fileOutput"
echo -e "Rapport du $dateRapport -- [$script $version]($urlNotice) \n" >> "$fileOutput"
}
prg_2t(){ # traitements tests
printf " ."
fi_systeme; printf "."
fi_cpu; printf "."
fi_mem; printf "."
}
prg_2(){ # traitements principaux
printf " ."
fi_systeme; printf "."
fi_cpu; printf "."
fi_gpu; printf "."
fi_graph; printf "."
fi_batt; printf "."
fi_localisation; printf "."
fi_sources; printf "."

View File

@ -16,8 +16,11 @@
## 1.34.0 04/10/2017
* révision figet_memory
* swap
* suppression figet_memory neofetch
* nouveau figet_mem
* révision fi_mem, affichage mémoire expurgé comparé à free
* révision nommage variables fonctions neofetch
* test une seule fois frama.link
## 1.33.0 03/10/2017
@ -29,7 +32,7 @@
* révision sed s/
* fi_systeme: boot image avec options
* révision fi_disk
* révision nommage variable fonction neofetch
* révision nommage variables fonctions neofetch
* variables de boucles en local
* f__user, premier essai root only, fonctionnement en root, function à réviser
* figet_battery, alim, correction si AC au lieu de AC0