Skip to content

Commit 5f65e43

Browse files
committed
feat(core): ajouter l'extraction du cpu, des processus et de l'arborescence
1 parent 7170aae commit 5f65e43

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

Vagrantfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Vagrant.configure("2") do |config|
33
config.vbguest.auto_update = false
44
config.vm.provision "shell", inline: <<-SHELL
55
apt-get update
6-
apt-get install -y python3 python3-pip
7-
apt-get install -y nano
6+
apt-get install -y python3 python3-pip nano tree
87
SHELL
98
end

lsit.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import subprocess
2+
13
with open("/etc/hostname") as f:
24
hostname = f.read().strip()
35

@@ -11,6 +13,30 @@
1113

1214
print(f"Mémoire totale : {ram_info}")
1315

14-
with open("rapport_lsit.txt", "a") as rapport:
15-
rapport.write(f"La cible a été identifiée. Nom de la machine : {hostname}\n")
16-
rapport.write(f"Mémoire totale : {ram_info}\n")
16+
cpu_info = "Inconnu"
17+
with open("/proc/cpuinfo", "r") as f:
18+
for ligne in f:
19+
if "model name" in ligne:
20+
cpu_info = ligne.split(":")[1].strip()
21+
break
22+
23+
cmd_ps = subprocess.run(["ps", "aux"], capture_output=True, text=True)
24+
processus_actifs = cmd_ps.stdout
25+
26+
cmd_tree = subprocess.run(["tree", "-L", "2", "/home/vagrant"], capture_output=True, text=True)
27+
arborescence = cmd_tree.stdout
28+
29+
with open("rapport_lsit.txt", "a") as f:
30+
f.write(f"La cible a été identifiée. Nom de la machine : {hostname}\n")
31+
f.write(f"Mémoire totale : {ram_info}\n")
32+
f.write(f"Modèle du CPU : {cpu_info}\n")
33+
34+
f.write("\n===================================\n")
35+
f.write(" PROCESSUS ACTIFS \n")
36+
f.write("===================================\n")
37+
f.write(processus_actifs)
38+
39+
f.write("\n===================================\n")
40+
f.write(" ARBORESCENCE DOSSIERS \n")
41+
f.write("===================================\n")
42+
f.write(arborescence)

0 commit comments

Comments
 (0)