exec

Reference for the `exec` collector.

exec · collector · run nanook doc exec for the same content in your terminal.

Runs a shell command and captures its first line of output as a metric.

Options

OptionTypeDefaultDescription
cmdstringrequiredshell command to execute
metricstringexecbase metric name

Metrics

MetricKindUnitDescription
exec.valnumericfirst line of output parsed as f64

Examples

Disk usage as a number

[[collectors]]
name = "disk-pct"
kind = "exec"
interval = 30
[collectors.opts]
cmd = "df / --output=pcent | tail -1 | tr -d ' %'"

Custom backlog probe

[[collectors]]
name = "queue-depth"
kind = "exec"
interval = 15
[collectors.opts]
cmd = "redis-cli LLEN jobs"

Alert on backlog growth

[[alerts]]
expr = "queue-depth::exec.val > 1000"
count = 3
channel = "ops"
body = "jobs queue at {{ value }}"