|
| 1 | +import subprocess |
| 2 | + |
1 | 3 | with open("/etc/hostname") as f: |
2 | 4 | hostname = f.read().strip() |
3 | 5 |
|
|
11 | 13 |
|
12 | 14 | print(f"Mémoire totale : {ram_info}") |
13 | 15 |
|
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