organzation
This commit is contained in:
parent
f7430627d4
commit
a9fd5b4eb3
21
gbapp/Dockerfile
Normal file
21
gbapp/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
FROM python:3.13
|
||||
WORKDIR /opt
|
||||
|
||||
COPY requirements.txt ./
|
||||
COPY app.py ./
|
||||
COPY models.py ./
|
||||
COPY templates ./templates
|
||||
COPY static ./static
|
||||
|
||||
RUN apt-get update && apt-get -y install sqlite3
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
RUN useradd app
|
||||
RUN chown -R app:app .
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
USER app
|
||||
|
||||
CMD ["sh", "-c", "sleep 10 && uvicorn app:app --host 0.0.0.0 --port 8000"]
|
||||
BIN
gbapp/__pycache__/app.cpython-313.pyc
Normal file
BIN
gbapp/__pycache__/app.cpython-313.pyc
Normal file
Binary file not shown.
BIN
gbapp/__pycache__/forms.cpython-313.pyc
Normal file
BIN
gbapp/__pycache__/forms.cpython-313.pyc
Normal file
Binary file not shown.
BIN
gbapp/__pycache__/models.cpython-313.pyc
Normal file
BIN
gbapp/__pycache__/models.cpython-313.pyc
Normal file
Binary file not shown.
BIN
gbapp/__pycache__/ordinateur.cpython-313.pyc
Normal file
BIN
gbapp/__pycache__/ordinateur.cpython-313.pyc
Normal file
Binary file not shown.
@ -19,9 +19,16 @@ templates = Jinja2Templates(directory="templates")
|
||||
|
||||
#sqlitemodel
|
||||
sqlite_file_name = "mydb.db"
|
||||
sqlite_url = f"sqlite:///mydb.db"
|
||||
|
||||
engine = create_engine(sqlite_url)
|
||||
import os
|
||||
pg_url = (
|
||||
f"postgresql+psycopg://"
|
||||
f"{os.getenv('POSTGRES_USER')}:"
|
||||
f"{os.getenv('POSTGRES_PASSWORD')}"
|
||||
f"@db:5432/"
|
||||
f"{os.getenv('POSTGRES_DB')}"
|
||||
)
|
||||
print(f"URL PGDB: {pg_url}")
|
||||
engine = create_engine(pg_url)
|
||||
|
||||
def create_db_and_tables():
|
||||
SQLModel.metadata.create_all(engine)
|
||||
20
gbapp/gbcompose.yml
Normal file
20
gbapp/gbcompose.yml
Normal file
@ -0,0 +1,20 @@
|
||||
services:
|
||||
grabber:
|
||||
build: .
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_started
|
||||
ports:
|
||||
- "8080:80"
|
||||
environment:
|
||||
POSTGRES_USER: gb
|
||||
POSTGRES_PASSWORD: gbpwd
|
||||
POSTGRES_DB: gbdb
|
||||
db:
|
||||
image: postgres:18
|
||||
environment:
|
||||
POSTGRES_USER: gb
|
||||
POSTGRES_PASSWORD: gbpwd
|
||||
POSTGRES_DB: gbdb
|
||||
|
||||
|
||||
@ -33,10 +33,7 @@ class ordinateur(SQLModel, table=True):
|
||||
cpu_freq_max: str = Field(index=True)
|
||||
cpu_id: str = Field(index=True)
|
||||
mb_serial: str = Field(index=True)
|
||||
ram_size: str = Field(index=True)
|
||||
ram_gen: str = Field(index=True)
|
||||
sizes: str = Field(index=True)
|
||||
memory_mb: str = Field(index=True)
|
||||
ram: str = Field(index=True)
|
||||
gpu_model: str = Field(index=True)
|
||||
chassis_serial: str = Field(index=True)
|
||||
cpu_cores_nb: str = Field(index=True)
|
||||
@ -9,7 +9,9 @@ greenlet==3.3.1
|
||||
h11==0.16.0
|
||||
idna==3.11
|
||||
Jinja2==3.1.6
|
||||
lastapi==0.2
|
||||
MarkupSafe==3.0.3
|
||||
psycopg[binary]
|
||||
pydantic==2.12.5
|
||||
pydantic_core==2.41.5
|
||||
python-multipart==0.0.22
|
||||
@ -36,20 +36,8 @@
|
||||
<td>{{ordi.cpu_id}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Memory mb</td>
|
||||
<td>{{ordi.memory_mb}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ram size</td>
|
||||
<td>{{ordi.ram_size}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ram gen</td>
|
||||
<td>{{ordi.ram_gen}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sizes</td>
|
||||
<td>{{ordi.sizes}}</td>
|
||||
<td>Ram</td>
|
||||
<td>{{ordi.ram}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Mb serial</td>
|
||||
@ -83,11 +71,6 @@
|
||||
<td>CPU threads number</td>
|
||||
<td>{{ordi.cpu_threads_nb}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ram number</td>
|
||||
<td>{{ordi.ram_number}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ram slots number</td>
|
||||
<td>{{ordi.ram_slots_nb}}</td>
|
||||
</tr>
|
||||
@ -127,4 +110,4 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</body>
|
||||
47
grabber.sh
47
grabber.sh
@ -11,7 +11,7 @@ OS=$(lsb_release -a |grep Description |cut -f2)
|
||||
CPU_ID=$(sudo dmidecode -t processor |grep ID |cut -d: -f2)
|
||||
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/\ //')
|
||||
SIZES=$(lsblk -dnb | grep -v loop | grep -v boot | tr -s " " | cut -d' ' -f4)
|
||||
RAM="$RAM_SIZE $RAM_GEN"
|
||||
MB_SERIAL=$(sudo dmidecode | grep -A 4 "Base Board" | tail -n1 | cut -d: -f2 | sed 's/\ //')
|
||||
CPU_FREQUENCY_MIN=$(lscpu | grep MHz | cut -d: -f2 | sed -n '3p' | tr -s " " | sed 's/\ //' | cut -d, -f1)
|
||||
CPU_FREQUENCY_CUR=$(sudo dmidecode | grep "MHz" | cut -d: -f2 | sed -n '3p' | sed 's/\ //')
|
||||
@ -41,9 +41,9 @@ MAC_ADDRESS=$(cat /sys/class/net/$(ls /sys/class/net | grep -vE '^(lo|docker|vet
|
||||
USED_SPACE=$(lsblk -nr -o FSUSED| sed -n 2p)
|
||||
|
||||
#LISTE D'INFO PAR DISK
|
||||
DISK_NAMES=$(lsblk -nr -o PKNAME,PATH $disk_path |grep -vE "^ " |cut -d \ -f3)
|
||||
DISK_NAMES=$(lsblk -nr -o NAME)
|
||||
FSTYPES=$(lsblk -nr -o FSTYPE)
|
||||
ALL_SIZES=$(lsblk -nr -o size)
|
||||
ALL_SIZES=$(lsblk -nr -o SIZE)
|
||||
ALL_USED=$(lsblk -nr -o FSUSED)
|
||||
|
||||
######################################################
|
||||
@ -53,10 +53,7 @@ json_data=$(jq -n \
|
||||
--arg host "$HOSTNAME" \
|
||||
--arg cpu "$CPU" \
|
||||
--arg cpu_id "$CPU_ID" \
|
||||
--arg mem "$MEM" \
|
||||
--arg ram_size "$RAM_SIZE" \
|
||||
--arg ram_gen "$RAM_GEN" \
|
||||
--arg sizes "$SIZES" \
|
||||
--arg ram "$RAM" \
|
||||
--arg mb_serial "$MB_SERIAL" \
|
||||
--arg cpu_freq_min "$CPU_FREQUENCY_MIN" \
|
||||
--arg cpu_freq_cur "$CPU_FREQUENCY_CUR" \
|
||||
@ -81,23 +78,26 @@ json_data=$(jq -n \
|
||||
'{
|
||||
HARDWARE: {
|
||||
hostname:$host,
|
||||
ipv4:$ipv4,
|
||||
mac:$mac_address,
|
||||
partitions: {
|
||||
nom:$nom_disk,
|
||||
fstype:$fstype,
|
||||
total_size:$total_size,
|
||||
used_space:$used_space
|
||||
},
|
||||
cpu:$cpu,
|
||||
cpu_id:$cpu_id,
|
||||
memory_mb:$mem,
|
||||
ram_size:$ram_size,
|
||||
ram_gen: $ram_gen,
|
||||
sizes:$sizes,
|
||||
ram:$ram,
|
||||
mb_serial:$mb_serial,
|
||||
cpu_freq_min:$cpu_freq_min,
|
||||
cpu_freq_cur:$cpu_freq_cur,
|
||||
cpu_freq_max:$cpu_freq_max,
|
||||
gpu_model:$gpu_model,
|
||||
chassis_serial:$chassis_serial,
|
||||
cpu_cores_nb:$cpu_cores_nb,
|
||||
cpu_threads_nb:$cpu_threads_nb,
|
||||
ram_number:$ram_number,
|
||||
ram_slots_nb:$ram_slots_nb,
|
||||
mac_address:$mac_address,
|
||||
gpu_model:$gpu_model,
|
||||
chassis_serial:$chassis_serial,
|
||||
ram_slots_nb:$ram_slots_nb,
|
||||
},
|
||||
|
||||
SOFTWARE: {
|
||||
@ -107,23 +107,12 @@ json_data=$(jq -n \
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
}')
|
||||
|
||||
|
||||
echo "arg1=$1"
|
||||
curl -X POST http://$1:8000/endpoint \
|
||||
curl -X POST -k http://$1:8000/endpoint \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$json_data"
|
||||
|
||||
|
||||
2
wp/Dockerfile
Normal file
2
wp/Dockerfile
Normal file
@ -0,0 +1,2 @@
|
||||
FROM php
|
||||
RUN wget wp.zip
|
||||
29
wp/compose.yml
Normal file
29
wp/compose.yml
Normal file
@ -0,0 +1,29 @@
|
||||
services:
|
||||
|
||||
wordpress:
|
||||
image: wordpress:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 80:80
|
||||
environment:
|
||||
WORDPRESS_DB_HOST: db
|
||||
WORDPRESS_DB_USER: exampleuser
|
||||
WORDPRESS_DB_PASSWORD: examplepass
|
||||
WORDPRESS_DB_NAME: exampledb
|
||||
volumes:
|
||||
- wordpress:/var/www/html
|
||||
|
||||
db:
|
||||
image: mysql:8.0
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_DATABASE: exampledb
|
||||
MYSQL_USER: exampleuser
|
||||
MYSQL_PASSWORD: examplepass
|
||||
MYSQL_RANDOM_ROOT_PASSWORD: '1'
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
|
||||
volumes:
|
||||
wordpress:
|
||||
db:
|
||||
Loading…
x
Reference in New Issue
Block a user