From 21112b4df77d8bb66aec85eafb0f5514cf5a5aa2 Mon Sep 17 00:00:00 2001 From: tenzi Date: Mon, 23 Feb 2026 17:03:25 +0100 Subject: [PATCH] =?UTF-8?q?sql=20=C3=A0=20faire,=20grabber=20=C3=A0=20voir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- grabber.sh | 43 ++++++++++++++++++++++++++++++++++++++++++- models.py | 11 +++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/grabber.sh b/grabber.sh index ddbd856..7f3f9e1 100755 --- a/grabber.sh +++ b/grabber.sh @@ -28,6 +28,30 @@ WM=$XDG_SESSION_TYPE KERNEL=$(uname -r) MAC_ADDRESS=$(cat /sys/class/net/$(ls /sys/class/net | grep -vE '^(lo|docker|veth|br)' | head -n 1)/address) +#PARTIE EVAL################################### + +#COMMANDES QUI RÉCUPÈRE INFO +HOSTNAME=$(hostname) +IPV4=$(ip -4 a | grep inet | head -n2 | tail -n1 | cut -d' ' -f6 | cut -d'/' -f1) +MAC_ADDRESS=$(cat /sys/class/net/$(ls /sys/class/net | grep -vE '^(lo|docker|veth|br)' | head -n 1)/address) +#PARTITIONS +declare -A PARTITIONS +for nom in ${DISK_NAMES}; do + echo "$name" +done + NOM_DISK=${DISK_NAMES[$1]} + FSTYPE=${FSTYPES[$1]} + TOTAL_SIZE=${ALL_SIZES[$1]} + USED_SPACE=${ALL_USED[$1]} + +#LISTE D'INFO PAR DISK +DISK_NAMES=$(lsblk -nr -o PKNAME,PATH $disk_path |grep -vE "^ " |cut -d \ -f3) +FSTYPES=$(lsblk -nr -o FSTYPE) +ALL_SIZES=$(lsblk -nr -o size) +ALL_USED=$(lsblk -nr -o FSUSED) + +###################################################### + # Construire le JSON json_data=$(jq -n \ --arg host "$HOSTNAME" \ @@ -53,6 +77,11 @@ json_data=$(jq -n \ --arg wm "$WM" \ --arg kernel "$KERNEL" \ --arg mac_address "$MAC_ADDRESS" \ + --arg nom_disk "$NOM_DISK" \ + --arg fstype "$FSTYPE" \ + --arg total_size "$TOTAL_SIZE" \ + --arg used_space "$USED_SPACE" \ + --arg ipv4 "$IPV4"\ '{ HARDWARE: { hostname:$host, @@ -81,7 +110,19 @@ json_data=$(jq -n \ desktop:$desktop, wm:$wm, kernel:$kernel, - } + }, + + EVALUATION: { + hostname:$host, + ipv4:$ipv4, + mac:$mac_address, + partitions: { + nom:$nom_disk, + fstype:$fstype, + total_size:$total_size, + used_space:$used_space + } + } }') diff --git a/models.py b/models.py index da47cf6..522291a 100644 --- a/models.py +++ b/models.py @@ -15,6 +15,15 @@ class employee(SQLModel, table=True): ordinateurs: list["ordinateur"] = Relationship(back_populates="employees", link_model=employee_ordinateur) +'''PARTIE EVAL class partition''' +class Partition(SQLModel, table=True): + id: int | None = Field(default=None, primary_key=True) + nom: set[str] = set() + fstype: set[str] = set() + total_size: set[str] = set() + used_space: set[str] = set() + + class ordinateur(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) hostname: str = Field(index=True) @@ -41,6 +50,8 @@ class ordinateur(SQLModel, table=True): wm: str = Field(index=True) kernel: str = Field(index=True) + partitions: list[Partition] | None = None + employees: list["employee"] = Relationship(back_populates="ordinateurs", link_model=employee_ordinateur) def shutdown():