# healthcheck-node — Agent usage Configure a coding agent for @nexload-sdk/healthcheck-node. **Topic:** agents **Package:** `@nexload-sdk/healthcheck-node` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/node/agents/ ## Install matching skills Install the skills whose triggers match the task. ### healthcheck-container-resources [Trigger](https://github.com/gecut/nexload-sdk/blob/main/skills/healthcheck/container-resources/SKILL.md) ```text Use when implementing, debugging, or reviewing @nexload-sdk/healthcheck-node container resource detection and policy across Docker, Kubernetes, Dokploy, Linux cgroup v1/v2, memory and swap limits, CPU quota/cpuset, fractional CPU, source/confidence evidence, readiness thresholds, collector selection, or cgroup test fixtures. ``` ```bash npx skills add gecut/nexload-sdk --skill healthcheck-container-resources ``` ## Project AGENTS.md ```markdown For @nexload-sdk/healthcheck-node, load healthcheck-container-resources when its trigger matches. Read the package bundle and check public exports against the installed version before editing. ``` ## Package context [Scoped Markdown bundle](/nexload-sdk/packages/healthcheck/node/llms.txt). ## Prompts ```text Inspect Node processes and container limits. Use @nexload-sdk/healthcheck-node and healthcheck-container-resources. Inspect the installed version and show a minimal typed example for my project. ``` ```text Review my @nexload-sdk/healthcheck-node integration against the optimization page. Identify the relevant source for each finding and one test for the highest-risk behavior. ``` --- # API Reference & Compatibility Public API symbol reference, functions, and compatibility matrix for Healthcheck Node. **Topic:** api **Package:** `@nexload-sdk/healthcheck-node` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/node/api/ The complete public API symbol inventory is generated automatically from package source exports: ## Functions ### `containerMetricsCollector` ```ts containerMetricsCollector(options?: ContainerResourceOptions & { scopes?: readonly HealthScope[]; }) => MetricCollectorDefinition<"container.metrics"> ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/index.ts#L174) ### `containerResourceCheck` ```ts containerResourceCheck(options?: { scopes?: readonly HealthScope[]; memory?: { usageRatio?: { degraded: number; unhealthy: number; }; }; root?: string; critical?: boolean | Partial>; }) => HealthCheckDefinition<"container.resources"> ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/index.ts#L107) ### `dnsCheck` ```ts dnsCheck(name: string, options: { hostname: string; recordType?: "A" | "AAAA" | "CNAME" | "TXT" | "MX"; scopes?: readonly HealthScope[]; timeoutMs?: number; }) => HealthCheckDefinition ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/index.ts#L256) ### `nodeRuntimeAdapter` ```ts nodeRuntimeAdapter() => RuntimeAdapter ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/index.ts#L60) ### `parseCpuList` ```ts parseCpuList(value: string | null) => number | null ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/cgroup.ts#L84) ### `processMetricsCollector` ```ts processMetricsCollector(options?: { scopes?: readonly HealthScope[]; }) => MetricCollectorDefinition<"process.metrics"> ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/index.ts#L149) ### `readContainerResourceSnapshot` ```ts readContainerResourceSnapshot(options?: ContainerResourceOptions) => Promise ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/cgroup.ts#L313) ### `tcpCheck` ```ts tcpCheck(name: string, options: { host: string; port: number; scopes?: readonly HealthScope[]; timeoutMs?: number; }) => HealthCheckDefinition ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public function exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/index.ts#L198) ## Interfaces ### `ContainerCpuSnapshot` ```ts interface ContainerCpuSnapshot { quotaMicros: number | null periodMicros: number | null quotaCpus: number | null cpusetCpus: number | null availableParallelism: number | null hostCpuCount: number | null effectiveCpuCount: number | null isLimited: boolean source: string } ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public interface exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/cgroup.ts#L15) ### `ContainerMemorySnapshot` ```ts interface ContainerMemorySnapshot { currentBytes: number | null limitBytes: number | null highBytes: number | null swapCurrentBytes: number | null swapLimitBytes: number | null isLimited: boolean usageRatio: number | null source: string } ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public interface exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/cgroup.ts#L4) ### `ContainerResourceOptions` ```ts interface ContainerResourceOptions { root?: string platform?: string } ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public interface exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/cgroup.ts#L39) ### `ContainerResourceSnapshot` ```ts interface ContainerResourceSnapshot { detected: boolean platform: string cgroupVersion: 1 | 2 | null isContainerLikely: boolean | null memory: ContainerMemorySnapshot cpu: ContainerCpuSnapshot source: "cgroup-v2" | "cgroup-v1" | "node" | "os" | "none" confidence: "high" | "medium" | "low" warnings: string[] } ``` **Exported from:** `@nexload-sdk/healthcheck-node` Public interface exported by @nexload-sdk/healthcheck-node. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/cgroup.ts#L27) *** ## Runtime Compatibility Matrix | Runtime / Engine | Version Requirement | Verification Status | |---|---|---| | **Node.js** | `>=20.9.0` | Verified on Node 20 & 22 | | **Linux Cgroups** | v1 & v2 | Verified in Docker & Kubernetes | | **Module Format** | ESM only | Native ECMAScript Modules | | **Side Effects** | `false` | Fully tree-shakeable | --- # Production Guides & Recipes Configuring container resource checks in Docker/Kubernetes, TCP/DNS network probes, and troubleshooting. **Topic:** guides **Package:** `@nexload-sdk/healthcheck-node` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/node/guides/ ## Container Resource Checks in Kubernetes / Docker When running inside containers, Node's `os.totalmem()` reports the host machine's total RAM rather than the container's cgroup memory limit. `@nexload-sdk/healthcheck-node` automatically inspects Linux cgroups to prevent silent out-of-memory (OOM) kills: ```ts import { containerResourceCheck } from "@nexload-sdk/healthcheck-node"; const check = containerResourceCheck({ memory: { usageRatio: { degraded: 0.8, unhealthy: 0.95 }, // share of the cgroup memory limit }, }); ``` *** ## TCP & DNS Dependency Probes Verify external database and downstream microservice reachability during readiness probes: ```ts import { dnsCheck, tcpCheck } from "@nexload-sdk/healthcheck-node"; // 1. Verify TCP port connectivity (e.g. Postgres or Redis) const redisTcp = tcpCheck("redis.connection", { host: process.env.REDIS_HOST ?? "localhost", port: 6379, timeoutMs: 2000, scopes: ["readiness"], }); // 2. Verify external DNS resolution const stripeDns = dnsCheck("dns.stripe", { hostname: "api.stripe.com", timeoutMs: 1500, scopes: ["readiness"], }); ``` *** ## Troubleshooting & Common Pitfalls ### 1. `cgroup` Resource Check Reports "Degraded" on Non-Linux Hosts On macOS or Windows development machines, Linux cgroup controllers do not exist. `@nexload-sdk/healthcheck-node` safely falls back to host OS metrics and reports a low-confidence degraded flag in dev environments. In production Linux containers, full cgroup v1/v2 metrics are parsed automatically. ### 2. TCP Probe Leaks Sockets `tcpCheck` immediately destroys the created socket once the TCP handshake completes or times out. Ensure external firewalls allow transient health check connection attempts. --- # Overview & Quick Start Node.js runtime adapter, cgroup v1/v2 container metrics, process metrics, and TCP/DNS health checks. **Topic:** overview **Package:** `@nexload-sdk/healthcheck-node` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/node/ **Package:** `@nexload-sdk/healthcheck-node` **Workspace version:** `3.0.1` Node.js runtime, process, cgroup, TCP, and DNS adapters for @nexload-sdk/healthcheck. [npm](https://www.npmjs.com/package/@nexload-sdk/healthcheck-node) · [Source](https://github.com/gecut/nexload-sdk/tree/main/packages/healthcheck/node) `@nexload-sdk/healthcheck-node` equips `@nexload-sdk/healthcheck` with Node.js runtime introspection, process telemetry, Linux cgroup v1/v2 container resource limits, and TCP/DNS dependency checks. *** ## 10-Second Code Snippet ```ts import { createHealthManager, memoryCheck, shutdownCheck } from "@nexload-sdk/healthcheck"; import { containerResourceCheck, nodeRuntimeAdapter, processMetricsCollector, } from "@nexload-sdk/healthcheck-node"; export const health = createHealthManager({ service: { name: "node-service" }, runtime: nodeRuntimeAdapter(), checks: [shutdownCheck(), memoryCheck(), containerResourceCheck()], collectors: [processMetricsCollector()], }); const report = await health.run("readiness"); console.log(report.status, report.runtime.name); // "ok", "node" ``` *** ## What You Get * **Node.js Runtime Adapter**: Exposes V8 heap memory stats, event loop delays, process uptime, and active handle counts. * **Linux Container & Cgroup Detection**: Autodetects Linux cgroup v1 and cgroup v2 memory limits and CPU quotas inside Docker, Kubernetes, or Dokploy containers. * **Network Dependency Probes**: Built-in non-blocking `tcpCheck()` and `dnsCheck()` to verify database reachability and DNS resolution. * **Process & Container Collectors**: Observational collectors that append telemetry without failing deployment health probes. *** ## Installation & Requirements ```bash pnpm add @nexload-sdk/healthcheck-node @nexload-sdk/healthcheck ``` With alternative package managers: ```bash # npm npm install @nexload-sdk/healthcheck-node @nexload-sdk/healthcheck # bun bun add @nexload-sdk/healthcheck-node @nexload-sdk/healthcheck ``` Requires Node.js `>=20.9.0`. *** ## Next Steps * Explore [Production Guides & Container Recipes](./guides/) for Docker limits, TCP checks, and troubleshooting. * Check the [API Reference & Signatures](./api/) for all exported checks and adapters. ## Next steps [Optimization](./optimization/) [Agent usage](./agents/) --- # healthcheck-node — Optimization Production choices for @nexload-sdk/healthcheck-node. **Topic:** optimization **Package:** `@nexload-sdk/healthcheck-node` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/node/optimization/ ## Restrict container details Use private or authenticated endpoints for process metrics and container resources. Reports can include process identifiers and cgroup paths. ## Check deployment platform Use container limits only where the platform supplies the required cgroup data. ## Keep network probes in readiness `tcpCheck` and `dnsCheck` default to readiness. Container checks and process and container collectors default to diagnostics. ## Respect the runtime boundary This adapter uses Node.js APIs and Linux cgroup files. On non-Linux hosts, container detection reports low confidence and the container check is degraded. ## Sources [Package guidance](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/README.md) · [Implementation](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/node/src/index.ts). · [Matching skill](https://github.com/gecut/nexload-sdk/blob/main/skills/healthcheck/container-resources/SKILL.md).