Chuyển đến nội dung chính

Mô tả

Probe custom_check chạy một executable đã phê duyệt và đánh giá kết quả dựa trên exit code, stdout content, hoặc JSON output. Đây là probe duy nhất sinh process mới — được compile riêng bằng build tag vms_custom_check.
Yêu cầu bảo mật:
  • Executable phải là absolute path (không dùng PATH lookup → không bị PATH hijack).
  • Probe từ chối chạy khi agent là root (uid 0) hoặc Windows LocalSystem.
  • Không dùng shell — binary được gọi trực tiếp với argv.
  • Hard timeout = probe timeout từ scheduler.
  • Stdout capped 1 MiB.

Config fields

FieldTypeBắt buộcDefaultMô tả
typestringPhải là "custom_check"
executablestringAbsolute path tới executable. Phải là absolute path
argsstring[]KhôngDanh sách argument truyền cho executable
expectedExitCodeintKhông0Exit code kỳ vọng. Khác → status down
expectedStdoutContainsstringKhôngChuỗi stdout cần chứa. Không tìm thấy → status down
parseJsonOutputboolKhôngfalseParse stdout như JSON object. Các field numeric/boolean được emit thành gauge metric

Metrics

MetricTypeUnitLabelsMô tả
vms.custom_check.statusstatusup hoặc down
vms.custom_check.valuegaugekeyEmit khi parseJsonOutput = true — mỗi field numeric/boolean trong JSON stdout
Check result value là exit code.

Ví dụ config

{
  "type": "custom_check",
  "executable": "/opt/vms/checks/check-core.sh",
  "args": ["--quick"],
  "expectedExitCode": 0
}
Parse JSON output:
{
  "type": "custom_check",
  "executable": "/opt/vms/checks/db-health.sh",
  "parseJsonOutput": true
}
Nếu script trả {"connections": 42, "healthy": true}, probe emit:
  • vms.custom_check.value{key="connections"} = 42
  • vms.custom_check.value{key="healthy"} = 1

Lưu ý

  • Build tag vms_custom_check — package agent mặc định không bao gồm probe này. Cần dùng build có tag riêng.
  • Nếu agent chạy root → probe trả down với message “refuses to run as root”. Tương tự Windows LocalSystem.
  • Timeout do scheduler quản lý — process bị kill khi timeout, kèm 1 giây chờ drain I/O.
  • JSON parse chỉ hỗ trợ top-level object với field numeric (float64) và boolean. String và nested object bị bỏ qua.