Files
egutierrez 477bcd00f0 chore: auto-commit (13 archivos)
- CMakeLists.txt
- agent_protocol.cpp
- agent_protocol.h
- app.md
- appicon.ico
- hosts_db.cpp
- hosts_db.h
- http_client.cpp
- http_client.h
- main.cpp
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 00:31:32 +02:00

86 lines
2.8 KiB
C++

#pragma once
#include <string>
#include <vector>
#include <cstdint>
namespace pex {
struct ProcInfo {
int32_t pid = 0;
int32_t ppid = 0;
std::string name;
std::string user;
float cpu_pct = 0.0f;
float ram_mb = 0.0f;
float disk_read_kb_s = 0.0f;
float disk_write_kb_s = 0.0f;
int32_t threads = 0;
std::string state; // R/S/D/Z/T (Linux) o running/suspended (Win)
std::string cmdline;
};
struct StatsSnapshot {
int64_t unix_ts = 0;
float cpu_pct = 0.0f;
float ram_used_mb = 0.0f;
float ram_total_mb = 0.0f;
float disk_read_mb_s = 0.0f;
float disk_write_mb_s = 0.0f;
float net_rx_mb_s = 0.0f;
float net_tx_mb_s = 0.0f;
float gpu_pct = 0.0f;
};
struct DeviceInfo {
std::string kind; // disk | gpu | usb | sensor
std::string name;
std::string detail;
float usage_pct = 0.0f; // -1 si no aplica
};
struct ServiceInfo {
std::string name;
std::string state; // running | stopped | failed
std::string description;
std::string runtime; // systemd | sc | docker | other
};
struct NetConn {
int32_t pid = 0;
std::string proto; // tcp | udp
std::string local; // ip:port
std::string remote;
std::string state; // ESTABLISHED, LISTEN, ...
};
// Stubs: parsean JSON del agente o devuelven vacios si no esta disponible.
// Implementacion real cuando el agente Go exista (issue 0111).
std::vector<ProcInfo> fetch_processes(const std::string& base_url, const std::string& token);
StatsSnapshot fetch_stats (const std::string& base_url, const std::string& token);
std::vector<DeviceInfo> fetch_devices (const std::string& base_url, const std::string& token);
std::vector<ServiceInfo> fetch_services (const std::string& base_url, const std::string& token);
std::vector<NetConn> fetch_netconns (const std::string& base_url, const std::string& token);
// Local del host donde corre el binario.
// - Linux: lee /proc.
// - Windows: WinAPI (psapi, GetSystemTimes, GlobalMemoryStatusEx).
std::vector<ProcInfo> fetch_processes_local();
StatsSnapshot fetch_stats_local();
// WSL desde un binario Windows — trampoline via `wsl.exe -e ...`.
// En Linux son aliases a fetch_*_local.
std::vector<ProcInfo> fetch_processes_wsl();
StatsSnapshot fetch_stats_wsl();
// Network/Devices/Services para el host LOCAL (binario corriendo aqui).
std::vector<NetConn> fetch_netconns_local();
std::vector<DeviceInfo> fetch_devices_local();
std::vector<ServiceInfo> fetch_services_local();
// Idem WSL — trampoline desde un binario Windows. En Linux son aliases local.
std::vector<NetConn> fetch_netconns_wsl();
std::vector<DeviceInfo> fetch_devices_wsl();
std::vector<ServiceInfo> fetch_services_wsl();
} // namespace pex