OS and Case minor change

This commit is contained in:
pporcheret 2025-04-07 13:51:23 +02:00
parent 96e92f5805
commit 61ed2159be
2 changed files with 24 additions and 1 deletions

22
app.py
View File

@ -9,6 +9,12 @@ import json
app = Flask(__name__) app = Flask(__name__)
def get_remote(hostname, port, username, password, local_script_path, remote_script_path): def get_remote(hostname, port, username, password, local_script_path, remote_script_path):
push_agent(hostname, port, username, password, local_script_path, remote_script_path)
output = pull_agent(hostname, port, username, password, remote_script_path)
return(output)
def push_agent(hostname, port, username, password, local_script_path, remote_script_path):
ssh = paramiko.SSHClient() ssh = paramiko.SSHClient()
try: try:
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@ -23,6 +29,22 @@ def get_remote(hostname, port, username, password, local_script_path, remote_scr
finally: finally:
ssh.close() ssh.close()
def pull_agent(hostname, port, username, password, remote_script_path):
ssh = paramiko.SSHClient()
try:
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname, port, username, password)
stdin, stdout, stderr = ssh.exec_command(f"python3 {remote_script_path}")
output = stdout.read().decode()
return(output)
finally:
ssh.close()
def get_boot_time(psboot): def get_boot_time(psboot):
boot_time = datetime.fromtimestamp(psboot - 60) boot_time = datetime.fromtimestamp(psboot - 60)
return str(boot_time) return str(boot_time)

View File

@ -53,7 +53,8 @@
Environnement Environnement
</div> </div>
<div class="card-body"> <div class="card-body">
<h5 class="display-6">{{ full['hostname'] }}</h5> <h5 class="display-6">{{ full['hostname'].capitalize() }}</h5>
<br> OS : {{ full['os'].capitalize() }}
<br> CPU : {{ full['cpu_number'] }} <br> CPU : {{ full['cpu_number'] }}
<br> vCPU : {{ full['vcpu'] }} <br> vCPU : {{ full['vcpu'] }}
<br> Memory : {{ full['mem_max']}} <br> Memory : {{ full['mem_max']}}