import { requestClient } from '#/api/request';

export interface ServerHealthOverview {
  basic_info: {
    hostname: string;
    ip_address: string;
    platform: string;
  };
  boot_time: {
    uptime_formatted: string;
  };
  cpu_info: {
    cpu_percent: number;
    total_cores: number;
  };
  disk_info: {
    total_read_bytes: number;
    total_write_bytes: number;
  };
  memory_info: {
    virtual: {
      percent: number;
      total: number;
      used: number;
    };
  };
  network_info: {
    total: {
      bytes_recv: number;
      bytes_sent: number;
    };
  };
}

export interface ServerRealtimeStats {
  cpu_percent: number;
  disk_io: {
    read_speed: number;
    write_speed: number;
  };
  memory_details: {
    total: number;
    used: number;
  };
  memory_percent: number;
  network_io: {
    download_speed: number;
    upload_speed: number;
  };
}

export async function getServerHealthOverviewApi() {
  return requestClient.get<ServerHealthOverview>(
    '/api/core/server_monitor/overview',
  );
}

export async function getServerHealthRealtimeApi() {
  return requestClient.get<ServerRealtimeStats>(
    '/api/core/server_monitor/realtime',
  );
}
