|
|
@ -3,18 +3,21 @@ local function scrape() |
|
|
|
local stat = get_contents("/proc/stat") |
|
|
|
|
|
|
|
-- system boot time, seconds since epoch |
|
|
|
metric("node_boot_time", "gauge", nil, string.match(stat, "btime ([0-9]+)")) |
|
|
|
metric("node_boot_time_seconds", "gauge", nil, |
|
|
|
string.match(stat, "btime ([0-9]+)")) |
|
|
|
|
|
|
|
-- context switches since boot (all CPUs) |
|
|
|
metric("node_context_switches", "counter", nil, string.match(stat, "ctxt ([0-9]+)")) |
|
|
|
metric("node_context_switches_total", "counter", nil, |
|
|
|
string.match(stat, "ctxt ([0-9]+)")) |
|
|
|
|
|
|
|
-- cpu times, per CPU, per mode |
|
|
|
local cpu_mode = {"user", "nice", "system", "idle", "iowait", "irq", |
|
|
|
"softirq", "steal", "guest", "guest_nice"} |
|
|
|
local i = 0 |
|
|
|
local cpu_metric = metric("node_cpu", "counter") |
|
|
|
local cpu_metric = metric("node_cpu_seconds_total", "counter") |
|
|
|
while true do |
|
|
|
local cpu = {string.match(stat, "cpu"..i.." (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+)")} |
|
|
|
local cpu = {string.match(stat, |
|
|
|
"cpu"..i.." (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+)")} |
|
|
|
if #cpu ~= 10 then |
|
|
|
break |
|
|
|
end |
|
|
@ -25,16 +28,20 @@ local function scrape() |
|
|
|
end |
|
|
|
|
|
|
|
-- interrupts served |
|
|
|
metric("node_intr", "counter", nil, string.match(stat, "intr ([0-9]+)")) |
|
|
|
metric("node_intr_total", "counter", nil, |
|
|
|
string.match(stat, "intr ([0-9]+)")) |
|
|
|
|
|
|
|
-- processes forked |
|
|
|
metric("node_forks", "counter", nil, string.match(stat, "processes ([0-9]+)")) |
|
|
|
metric("node_forks_total", "counter", nil, |
|
|
|
string.match(stat, "processes ([0-9]+)")) |
|
|
|
|
|
|
|
-- processes running |
|
|
|
metric("node_procs_running", "gauge", nil, string.match(stat, "procs_running ([0-9]+)")) |
|
|
|
metric("node_procs_running_total", "gauge", nil, |
|
|
|
string.match(stat, "procs_running ([0-9]+)")) |
|
|
|
|
|
|
|
-- processes blocked for I/O |
|
|
|
metric("node_procs_blocked", "gauge", nil, string.match(stat, "procs_blocked ([0-9]+)")) |
|
|
|
metric("node_procs_blocked_total", "gauge", nil, |
|
|
|
string.match(stat, "procs_blocked ([0-9]+)")) |
|
|
|
end |
|
|
|
|
|
|
|
return { scrape = scrape } |