From 0b80c142305881c0a68a4f06bf443bc6164a9569 Mon Sep 17 00:00:00 2001 From: tenzi Date: Sat, 6 Dec 2025 13:40:50 +0100 Subject: [PATCH] summary --- grabber.sh | 85 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 23 deletions(-) diff --git a/grabber.sh b/grabber.sh index 2b93cc3..22e36e1 100755 --- a/grabber.sh +++ b/grabber.sh @@ -2,6 +2,7 @@ DIR=/opt/grabber SUCCESS_LOG=/var/log/grabber/grabber-success.log ERROR_LOG=/var/log/grabber/grabber-error.log +SUM="$DIR/summary.txt" # Affichage du texte de démarrage tee $SUCCESS_LOG $ERROR_LOG <>$DIR/$1 +} + +treat_cmd() { + + + +treat_file sources_list.file /etc/apt/sources.list + +for file in ${!FILES[@]}; do + treat_file $file ${FILES[$file]} +done +#cat /etc/ssh/ssh_config > $DIR/ssh_config.file +#cat /etc/passwd > $DIR/passwd.file +#cat /etc/group > $DIR/group.file +#lspci -nn > $DIR/lspci.cmd +#lsusb > $DIR/lsusb.cmd +#apt list --installed > $DIR/apt.cmd +#systemd-analyze > $DIR/systemd-analyze.cmd +#systemd-analyze blame | head -n 10 > $DIR/systemd-blame.cmd +#lscpu > $DIR/lscpu.cmd +#lshw-gtk > $DIR/lshw-gtk.cmd +#inxi > $DIR/inxi.cmd +#lsmem > $DIR/lsmem.cmd + +hardware() { + declare -A PARTITIONS_BY_DISK for disk in ${DEVICES[@]}; do disk_path=$(printf '/dev/%s' "$disk") @@ -66,33 +97,41 @@ echo "Combien de disques sur l'ordinateur ? ${#DEVICES[@]}" echo "keys: ${!PARTITIONS_BY_DISK[@]}" echo "values: ${PARTITIONS_BY_DISK[@]}" -echo DEVICES=${DEVICES[@]} >$DIR/status.log +echo DEVICES=${DEVICES[@]} >$SUM for disk in ${!PARTITIONS_BY_DISK[@]}; do - echo "PARTS_$disk=$(printf '%s ' ${PARTITIONS_BY_DISK[$disk]})" >>$DIR/status.log + echo "PARTS_$disk=$(printf '%s ' ${PARTITIONS_BY_DISK[$disk]})" >>$SUM done -treat_file() { - echo "Les arguments: $@" - echo "Argument 1: $1" - cat $2 >>$DIR/$1 - + echo "[HARDWARE]" >>$SUM + echo "CPU=$(lscpu -eMODELNAME |tail -n1)" >>$SUM + echo "CPU_ID=$(sudo dmidecode -t processor |grep ID |cut -d: -f2)" >>$SUM + RAM_SIZE=$(lsmem |grep "Mémoire partagée" |cut -d: -f2 |sed 's/\ //g') + RAM_GEN=$(sudo dmidecode -t memory |grep Type: |grep -v Unknown |tail -n1 |cut -d: -f2 |sed 's/\ //') + echo "RAM=$RAM_SIZE $RAM_GEN" >>$SUM + echo "RAM_SIZE=$RAM_SIZE" >>$SUM + echo "RAM_GEN=$RAM_GEN" >>$SUM + + sizes=$(lsblk -dnb |grep -v loop |grep -v boot |tr -s " " |cut -d \ -f4) >>$SUM + STOCKAGE_TOTAL=0 + for SIZE in ${sizes[@]};do + STOCKAGE_TOTAL+=$SIZE + done + STOCKAGE_TOTAL=$(numfmt --to iec $STOCKAGE_TOTAL) + echo "STOCKAGE_TOTAL=$STOCKAGE_TOTAL" >>$SUM } -treat_file sources_list.file /etc/apt/sources.list +hardware -for file in ${!FILES[@]}; do - treat_file $file ${FILES[$file]} -done +software() { + echo " " >>$SUM + echo "[SOFTWARE]" >>$SUM + echo "OS=$(lsb_release -a |grep Description |cut -f2)" >>$SUM + echo "ARCH=$(uname -m)" >>$SUM + echo "DESKTOP=$XDG_CURRENT_DESKTOP" >>$SUM + echo "WM=$XDG_SESSION_TYPE" >>$SUM + echo "KERNEL=$(uname -r)" >>$SUM +} + +software -#cat /etc/passwd > $DIR/passwd.file -#cat /etc/group > $DIR/group.file -#lspci -nn > $DIR/lspci.cmd -#lsusb > $DIR/lsusb.cmd -#apt list --installed > $DIR/apt.cmd -#systemd-analyze > $DIR/systemd-analyze.cmd -#systemd-analyze blame | head -n 10 > $DIR/systemd-blame.cmd -#lscpu > $DIR/lscpu.cmd -#lshw-gtk > $DIR/lshw-gtk.cmd -#inxi > $DIR/inxi.cmd -#lsmem > $DIR/lsmem.cmd