import paramiko
import json

c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('160.187.143.253', username='root', password=';ur7n)LC1BQ;')

_, so, _ = c.exec_command('pm2 jlist')
output = so.read().decode('utf-8', 'ignore').strip()
try:
    data = json.loads(output)
    print("PM2 Processes:")
    for proc in data:
        print(f"- {proc['name']} (ID: {proc['pm_id']}, Status: {proc['pm2_env']['status']})")
except Exception as e:
    print("Failed to parse JSON:", str(e))
    print("RAW:", output)

c.close()
