openwrt / openwrt/packages

prometheus-node-exporter-lua: Disk space metric

Open
#14,358 8 comments 0 reactions 1 assignee View on GitHub

@champtar is already working on this.

Since Dec 29, 2020.

Dominant language
Makefile
Stars
4.6k
Forks
4k
Avg merge
3d 12h
Merged PRs (30d)
134

Description

Maintainer: @champtar
Environment: all arch/versions

Description:
To get the disk size and available space please add this code to
/usr/lib/lua/prometheus-collectors/disk.lua

local function scrape()
  local df = io.popen("df -T")

  local line = df:read("*l")
  line = df:read("*l")
  while (line ~= nil)
  do
    local size = space_split(line)[3] * 1024
    local available = space_split(line)[5] * 1024

    local labels = {
      fstype = space_split(line)[2],
      mountpoint = space_split(line)[7]
    }

    metric("node_filesystem_avail_bytes", "gauge", labels, available)
    metric("node_filesystem_size_bytes", "gauge", labels, size)
    line = df:read("*l")
  end

  df:close()
end

return { scrape = scrape }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.