Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

1.1 KB
Raw Blame
import { unwrap } from 'solid-js/store';
import type { Resource } from '@/types/resource';

export interface ProxmoxPlatformData {
  nodeName?: string;
  clusterName?: string;
  instance?: string;
  uptime?: number;
  temperature?: number;
  pveVersion?: string;
  cpuInfo?: { cores?: number; model?: string; sockets?: number };
}

export interface AgentPlatformData {
  agentId?: string;
  hostname?: string;
  uptimeSeconds?: number;
  temperature?: number;
}

export function getProxmoxData(r: Resource): ProxmoxPlatformData | undefined {
  const pd = r.platformData ? (unwrap(r.platformData) as Record<string, unknown>) : undefined;
  return pd?.proxmox as ProxmoxPlatformData | undefined;
}

export function getAgentData(r: Resource): AgentPlatformData | undefined {
  const pd = r.platformData ? (unwrap(r.platformData) as Record<string, unknown>) : undefined;
  return pd?.agent as AgentPlatformData | undefined;
}

/** Get agentId for a node resource — works for merged (proxmox+agent) resources */
export function getLinkedAgentId(r: Resource): string | undefined {
  return getAgentData(r)?.agentId;
}