Skip to main content

NodeService

Node management, network configuration, and command execution. This is the largest service -- it combines node info, network, and command operations that all target a specific host.

Methods

Node Info

MethodDescription
Status(ctx, target)Full node status (OS, disk, memory, load)
Hostname(ctx, target)Get system hostname
Disk(ctx, target)Get disk usage
Memory(ctx, target)Get memory statistics
Load(ctx, target)Get load averages
OS(ctx, target)Get operating system info
Uptime(ctx, target)Get uptime

Network

MethodDescription
GetDNS(ctx, target, iface)Get DNS config
UpdateDNS(ctx, target, iface, servers, search)Update DNS servers
Ping(ctx, target, address)Ping a host

Command

MethodDescription
Exec(ctx, req)Execute a command directly (no shell)
Shell(ctx, req)Execute via /bin/sh -c (pipes, redirects)

File

MethodDescription
FileDeploy(ctx, opts)Deploy file to agent with SHA check
FileStatus(ctx, target, path)Check deployed file status

See FileService for Object Store operations (upload, list, get, delete) and FileDeployOpts details.

Usage

// Get hostname
resp, err := client.Node.Hostname(ctx, "_any")

// Get disk usage from all hosts
resp, err := client.Node.Disk(ctx, "_all")

// Update DNS
resp, err := client.Node.UpdateDNS(
ctx, "web-01", "eth0",
[]string{"8.8.8.8", "8.8.4.4"},
nil,
)

// Execute a command
resp, err := client.Node.Exec(ctx, client.ExecRequest{
Command: "apt",
Args: []string{"install", "-y", "nginx"},
Target: "_all",
})

// Execute a shell command
resp, err := client.Node.Shell(ctx, client.ShellRequest{
Command: "ps aux | grep nginx",
Target: "_any",
})

// Deploy a file
resp, err := client.Node.FileDeploy(ctx, client.FileDeployOpts{
ObjectName: "nginx.conf",
Path: "/etc/nginx/nginx.conf",
ContentType: "raw",
Mode: "0644",
Target: "web-01",
})

// Check file status
resp, err := client.Node.FileStatus(
ctx, "web-01", "/etc/nginx/nginx.conf",
)

Examples

See examples/sdk/client/node.go for node info, and examples/sdk/client/network.go and examples/sdk/client/command.go for network and command examples.

Permissions

Node info requires node:read. Network read requires network:read. DNS updates require network:write. Commands require command:execute. File deploy requires file:write. File status requires file:read.