sql à faire, grabber à voir
This commit is contained in:
parent
3df8aedbd4
commit
21112b4df7
43
grabber.sh
43
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
|
||||
}
|
||||
}
|
||||
}')
|
||||
|
||||
|
||||
|
||||
11
models.py
11
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():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user