diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7d81d9e7c1..5427560093 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,6 +7,8 @@ updates: directory: "/" schedule: interval: "monthly" + cooldown: + default-days: 7 groups: aws: patterns: @@ -20,10 +22,15 @@ updates: k8s.io: patterns: - "k8s.io/*" + prometheus: + patterns: + - "github.com/prometheus/*" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "monthly" + cooldown: + default-days: 7 groups: promci: patterns: @@ -39,3 +46,4 @@ updates: - .github/workflows/govulncheck.yml - .github/workflows/scorecards.yml - .github/workflows/stale.yml + - .github/workflows/zizmor.yml diff --git a/.github/workflows/approve-workflows.yml b/.github/workflows/approve-workflows.yml index adbcb48175..cfbb86eafa 100644 --- a/.github/workflows/approve-workflows.yml +++ b/.github/workflows/approve-workflows.yml @@ -5,7 +5,8 @@ name: Approve pending workflows on: - issue_comment: + # The pinned action requires triage access or higher and only calls GitHub APIs. + issue_comment: # zizmor: ignore[dangerous-triggers] types: [created] permissions: read-all @@ -15,13 +16,13 @@ jobs: if: >- github.event.issue.pull_request && github.event.comment.body == '/workflow-approve' && - github.repository_owner == 'prometheus' + (github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community') runs-on: ubuntu-latest permissions: actions: write contents: read pull-requests: write steps: - - uses: prometheus/promci/approve_workflows@370e8c15dcec50043cbe66f2f34633d9efc0a190 + - uses: prometheus/promci/approve_workflows@872d318d090d73df349cb6ed90aadd072ca478f7 # v0.10.0 with: github_token: ${{ github.token }} diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 5df620ee38..afb8a65862 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -13,7 +13,7 @@ permissions: env: GNU_TAR_VERSION: "1.35" - GO_VERSION: "1.26.0" + GO_VERSION: "1.27.1" # To spin up one of the VMs below, see the "Debug Shell" section here: https://github.com/vmactions jobs: @@ -22,13 +22,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: test-e2e - uses: vmactions/freebsd-vm@5a72679103d223925653750faa878a143340fbd0 # v1.5.0 + uses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc # v1.5.9 with: - release: "15.0" + release: "15" copyback: false envs: 'GO_VERSION GNU_TAR_VERSION' usesh: true @@ -76,11 +76,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: test-e2e - uses: vmactions/openbsd-vm@18edb32f4e48dae5865d7b8b3a9587bc01218a20 # v1.4.4 + uses: vmactions/openbsd-vm@f1ca8bc8ecc5b6ef7218e5b914836e067e1546d3 # v1.4.9 with: copyback: false envs: 'GO_VERSION GNU_TAR_VERSION' @@ -129,11 +129,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: test-e2e - uses: vmactions/netbsd-vm@1d9767765fd3f986e6de3aff4b1148f0c3a45f01 # v1.4.1 + uses: vmactions/netbsd-vm@c8a0d7ddb84619a7a8cc4e652efa7950b3fd9f92 # v1.5.2 with: copyback: false envs: 'GO_VERSION GNU_TAR_VERSION' @@ -180,11 +180,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: test-e2e - uses: vmactions/dragonflybsd-vm@b4468429bb9ab60b14600c6eeeb6464427f29391 # v1.2.9 + uses: vmactions/dragonflybsd-vm@4ab776fa9f914fbea72f13715b451e77e7ef5c41 # v1.3.4 with: copyback: false envs: 'GO_VERSION' @@ -234,11 +234,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: test-e2e - uses: vmactions/solaris-vm@d30dd6c228c8661ade859e36ead7660b9a62efcc # v1.3.7 + uses: vmactions/solaris-vm@1c166978f5a2c1f87f1c9d4d8dd85ae3d1eff6f7 # v1.4.2 with: copyback: false envs: 'GO_VERSION' @@ -296,7 +296,7 @@ jobs: runs-on: macos-latest steps: - name: Checkout the repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Install dependencies @@ -330,11 +330,15 @@ jobs: echo "::group::Print environment information" uname -a + sw_vers + sysctl hw.memsize hw.ncpu + diskutil list + ifconfig -l echo "GOOS: $(go env GOOS)" echo "GOARCH: $(go env GOARCH)" echo "::endgroup::" echo "::group::Run End-to-End Tests" git config --global --add safe.directory $(pwd) - make test-e2e E2E_EXTRA_FLAGS='--collector.diskstats.device-include=disk[04]' + make test-e2e E2E_EXTRA_FLAGS='--collector.diskstats.device-include=disk0' echo "::endgroup::" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b2104a1f8..edd002a4d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,24 +16,25 @@ jobs: container: # Whenever the Go version is updated here, .promu.yml and .promu-cgo.yml # should also be updated. - image: quay.io/prometheus/golang-builder:1.26-base + image: quay.io/prometheus/golang-builder:1.27-base steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - run: go mod download - - run: make + - run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1 + - run: git diff --exit-code test_go_arm: name: Go ARM tests runs-on: ubuntu-24.04-arm steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: - go-version: 1.26.x + go-version: 1.27.x + cache: false - run: uname -a - run: make test-e2e @@ -43,9 +44,9 @@ jobs: container: # Whenever the Go version is updated here, .promu.yml and .promu-cgo.yml # should also be updated. - image: quay.io/prometheus/golang-builder:1.26-base + image: quay.io/prometheus/golang-builder:1.27-base steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - run: go install github.com/google/go-jsonnet/cmd/jsonnet@latest @@ -64,10 +65,10 @@ jobs: matrix: thread: [ 0, 1, 2 ] steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: prometheus/promci-setup@3e5cd31b34b8ae19efa8f071c5e3cdb44884a7f8 # v0.2.1 + - uses: prometheus/promci-setup@55bd31fe92710532260eb57c554f2697363285c5 # v0.2.2 - name: Crossbuild run: ~/go/bin/promu crossbuild -v --parallelism 3 --parallelism-thread ${{ matrix.thread }} - name: CGO crossbuild @@ -80,7 +81,7 @@ jobs: if [[ -f "$(pwd)/.build/darwin-amd64/node_exporter" ]]; then ~/go/bin/promu codesign "$(pwd)/.build/darwin-amd64/node_exporter" fi - - uses: prometheus/promci-artifacts/save@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 + - uses: prometheus/promci-artifacts/save@9ca3252d07f230d5f923452b4df5697eba4a5bee # v0.1.1 with: directory: .build @@ -89,17 +90,17 @@ jobs: runs-on: ubuntu-latest needs: [test_go, build] env: - DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.26-base + DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.27-base REPO_PATH: github.com/prometheus/node_exporter steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: prometheus/promci-artifacts/restore@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 + - uses: prometheus/promci-artifacts/restore@9ca3252d07f230d5f923452b4df5697eba4a5bee # v0.1.1 - name: Build docker image run: | - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - make docker DOCKER_IMAGE_TAG=${{ github.ref_name }} + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + make docker DOCKER_IMAGE_TAG="${GITHUB_REF_NAME}" else make docker fi @@ -107,8 +108,8 @@ jobs: - run: docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T - name: Test docker image run: | - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - make test-docker DOCKER_IMAGE_TAG=${{ github.ref_name }} + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + make test-docker DOCKER_IMAGE_TAG="${GITHUB_REF_NAME}" else make test-docker fi @@ -121,7 +122,7 @@ jobs: needs: [test_go, test_go_arm, build] if: github.event_name == 'push' && github.event.ref == 'refs/heads/master' steps: - - uses: prometheus/promci/publish_main@13941414d409d227afd67544e5d306827db5a1a2 # v0.8.5 + - uses: prometheus/promci/publish_main@872d318d090d73df349cb6ed90aadd072ca478f7 # v0.10.0 with: docker_hub_login: ${{ secrets.docker_hub_login }} docker_hub_password: ${{ secrets.docker_hub_password }} @@ -138,7 +139,7 @@ jobs: needs: [test_go, test_go_arm, build] if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') steps: - - uses: prometheus/promci/publish_release@13941414d409d227afd67544e5d306827db5a1a2 # v0.8.5 + - uses: prometheus/promci/publish_release@872d318d090d73df349cb6ed90aadd072ca478f7 # v0.10.0 with: docker_hub_login: ${{ secrets.docker_hub_login }} docker_hub_password: ${{ secrets.docker_hub_password }} diff --git a/.github/workflows/container_description.yml b/.github/workflows/container_description.yml index 591a4d687f..ed4ada556d 100644 --- a/.github/workflows/container_description.yml +++ b/.github/workflows/container_description.yml @@ -21,7 +21,7 @@ jobs: if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. steps: - name: git checkout - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Set docker hub repo name @@ -45,7 +45,7 @@ jobs: if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. steps: - name: git checkout - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Set quay.io org name diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 83241e2d0b..d6bad9764b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -26,13 +26,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - name: Install Go - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 + # Go caching is acceptable here because this workflow has a read-only + # token, uses no secrets and publishes nothing. + - name: Install Go # zizmor: ignore[cache-poisoning] + uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: - go-version: 1.26.x + go-version: 1.27.x - name: Install snmp_exporter/generator dependencies run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 374df32baf..8c4deff9f8 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -28,6 +28,6 @@ jobs: run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' - id: govulncheck - uses: golang/govulncheck-action@3fa7bd9cee2cfdf3499a8803b226e43de7b7cdb4 # master + uses: golang/govulncheck-action@032d45514ae346b1db93c04b0c90b841c370344f # master env: GOOS: ${{ contains(github.repository, 'windows_exporter') && 'windows' || '' }} diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml new file mode 100644 index 0000000000..ac67240fbf --- /dev/null +++ b/.github/workflows/zizmor.yml @@ -0,0 +1,84 @@ +--- +# This workflow runs zizmor to find security issues in GitHub Actions workflows. +# It is synchronized from https://github.com/prometheus/prometheus. +# +# If the "GitHub Actions Security" check fails: +# +# 1. Open the "Run zizmor" step in the failed job. Each finding identifies +# a rule, the affected file and line, and the reason for the finding. +# The scan can report existing issues in files your PR did not change. +# +# 2. Find guidance for the reported rule at https://docs.zizmor.sh/audits/. +# Fix the affected workflow and push your changes to rerun the check. +# +# 3. To reproduce locally, install the zizmor version specified below using +# the instructions at https://docs.zizmor.sh/installation/. +# From the repository root, run `zizmor .`. +# Some findings can be fixed with `zizmor --fix=safe .`. +# Review the resulting diff and verify that the workflows still work. +# +# If a finding appears incorrect or a fix is unclear, ask the repository +# maintainers before adding an exception. Document the reason for any exception +# and keep it scoped to the specific finding. See the configuration reference +# at https://docs.zizmor.sh/configuration/. +# +# Propose changes to this shared workflow in prometheus/prometheus so they +# can be synchronized across repositories. +name: GitHub Actions Security + +on: + pull_request: + push: + branches: + - main + - master + +permissions: + contents: read + actions: read + +jobs: + zizmor: + name: Run zizmor + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Run zizmor + id: zizmor + uses: zizmorcore/zizmor-action@85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e # v0.7.1 + with: + advanced-security: false + version: 1.31.1 + + - name: Explain how to resolve findings + if: failure() && steps.zizmor.outcome == 'failure' + run: | + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ### Troubleshooting GitHub Actions Security + + Open the **Run zizmor** step for the findings or execution error. + Each finding identifies the affected file, line, and rule. + The scan can report existing issues in files your PR did not change. + + 1. Follow the [guidance for the reported rule](https://docs.zizmor.sh/audits/). + 2. Fix the affected workflow and push your changes to rerun the check. + + To reproduce locally, [install zizmor](https://docs.zizmor.sh/installation/) + using the version specified in this workflow and run `zizmor .` from + the repository root. Some findings can be fixed with `zizmor --fix=safe .`. + Review the resulting diff and verify that the workflows still work. + + If a finding appears incorrect or a fix is unclear, ask the repository + maintainers before adding an exception. Document the reason and keep + the exception scoped to the specific finding. See the + [configuration reference](https://docs.zizmor.sh/configuration/). + + This workflow is synchronized from [prometheus/prometheus](https://github.com/prometheus/prometheus). + Propose shared workflow changes there so they can reach all repositories. + EOF diff --git a/.golangci.yml b/.golangci.yml index 4cb6899c98..4cd685f728 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,10 +31,12 @@ linters: path: _test.go formatters: enable: + - gofumpt - goimports - exclusions: - generated: lax settings: + gofumpt: + extra: + group-params: true goimports: local-prefixes: - github.com/prometheus/node_exporter diff --git a/.promu-cgo.yml b/.promu-cgo.yml index aa40105c4f..8de883c699 100644 --- a/.promu-cgo.yml +++ b/.promu-cgo.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu.yml should also be updated. - version: 1.25 + version: 1.27 cgo: true repository: path: github.com/prometheus/node_exporter diff --git a/.promu.yml b/.promu.yml index d0d602b6a6..9c03a2f5d7 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu-cgo.yml should also be updated. - version: 1.26 + version: 1.27 repository: path: github.com/prometheus/node_exporter build: diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000000..3c3f28cac1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,34 @@ +# AGENTS.md + +## Rules +- Collector availability is controlled by Go build tags and OS-specific filenames; check `//go:build` lines before assuming a collector exists on the current OS. +- Use `kingpin.Flag()`, never `kingpin.Flag().Envar()`: the project has a "one-way-to-configure" policy of CLI flags only. Runtime env vars (`GOMAXPROCS`) and deprecated collectors are the only historical exceptions; maintainers have rejected env var flags for new code. +- Collector code must not shell out: `.golangci.yml` denies `os/exec` outside tests, and `CONTRIBUTING.md` says collectors may read `/proc`, `/sys`, use syscalls, or local sockets only. +- Keep metrics in the `node` namespace, follow the [Prometheus metric naming conventions](https://prometheus.io/docs/practices/naming/), and update README collector tables when adding, removing, enabling, disabling, or changing collector flags. +- Parse `/proc` files via the [`procfs`](https://github.com/prometheus/procfs) dependency rather than adding ad-hoc parsing in a collector; extend `procfs` upstream if a needed file isn't covered yet. + +## Build And Test Commands +- Full CI-like local check is `make`; it runs vet, metric/rule checks, shared Prometheus checks, 32-bit tests when supported, and Linux e2e only. +- Focused unit tests: `go test ./collector -run TestName` or `go test ./... -run TestName`; use `make test` when tests need unpacked fixtures. +- `make test` unpacks `collector/fixtures/sys.ttar` and `collector/fixtures/udev.ttar`, then runs `go test -short $(test-flags) ./...`. +- `make build` uses `promu` and writes `./node_exporter`, which `make test-e2e` expects; root tests in `node_exporter_test.go` skip unless a binary exists at `$GOPATH/bin/node_exporter`. +- `make test-e2e` is Linux-only from the main Makefile path; it depends on `make build`, fixture unpacking, and `make tools`. +- `make checkmetrics` downloads/uses `promtool` and checks `collector/fixtures/e2e-output*.txt`; run it after metric output changes. +- Lint/format shortcuts: `make format`, `make lint`, `make lint-fix`, `make yamllint`, `make unused`. + +## Fixtures And Generated Outputs +- Tests that only read filesystem data must use checked-in fixtures instead of creating static input files with `os.WriteFile` or similar APIs. Extend existing fixture-driven test tables where possible. +- Parser tests accepting `io.Reader` should use in-memory readers. Reserve temporary filesystem setup for tests that require isolation or exercise filesystem changes; explain why checked-in fixtures are insufficient. +- Do not edit unpacked `collector/fixtures/sys/` or `collector/fixtures/udev/` as source of truth; update `collector/fixtures/sys.ttar` and `collector/fixtures/udev.ttar` with `make update_fixtures`. +- To refresh e2e metric golden files, run `make build tools` first, then `./end-to-end-test.sh -u`; it writes the appropriate `collector/fixtures/e2e-output*.txt`. +- `end-to-end-test.sh` filters collector flags by OS/build context using `tools/tools match`, so an ignored flag in e2e may mean the collector is build-tag-gated for that platform rather than broken (see `Rules`). + +## Toolchain Notes +- `go.mod`'s Go directive is not the source of truth for the toolchain version CI actually uses; check the workflow's `setup-go` step and `.promu.yml`/`.promu-cgo.yml`, which can each pin a different version. +- `Makefile.common` is shared Prometheus infrastructure; comments say to open PRs against `prometheus/prometheus/Makefile.common` for generic changes. +- golangci-lint version comes from `make print-golangci-lint-version` (`GOLANGCI_LINT_VERSION` in `Makefile.common`), not from a locally installed default. +- Docker builds produce per-arch images named `$(DOCKER_REPO)/node-exporter-linux-:$(DOCKER_IMAGE_TAG)` and cover `Dockerfile` plus `Dockerfile.*` variants. + +## Node Mixin +- Mixin checks are separate: CI runs `make promtool`, `make -C docs/node-mixin clean`, `make -C docs/node-mixin jb_install`, then `make -C docs/node-mixin` and expects `git diff --exit-code`. +- `docs/node-mixin` requires `jsonnet`, `jsonnetfmt`, and `jb`; generated files are `node_alerts.yaml`, `node_rules.yaml`, and `dashboards_out/`. diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f6040344b..e76c1a5935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,42 @@ ## master / unreleased +## 1.13.1 / 2026-11-19 + +* [BUGFIX] btrfs: Fix device_unused_bytes wrapping around during shrink #3827 +* [BUGFIX] textfile: fix panic on a metric without HELP after inconsistent help texts #3866 + +## 1.13.0 / 2026-11-18 + +NOTE: + +The behavior of `node_cpu_frequency_hertz` has changed. There are two different sources +of data for this metric. One from the `cpu` collector, one from the `cpufreq` collector. +Due to historical feature migrations the `cpufreq` collector shares the same subsystem +as the `cpu` collector. This caused conflicting data behavior. An attempt to fix this +was introduced in #3318. This behavior has been reverted to the previous behavior in #3795. + +A new flag (`--collector.cpufreq.enable-cpufreq-prefix`) has been introduced that gives +the `cpufreq` a dedicated metric name subsystem (`node_cpufreq_...`). This will likely +be the default in v2. + +* [CHANGE] netstat: Use procfs parsers for netstat, snmp and snmp6 #3796 +* [CHANGE] edac: Fix no data results #3863 +* [CHANGE] nvme: Deprecate metric nvme_namespace_capacity_bytes #3899 +* [FEATURE] Add tainted collector for /proc/sys/kernel/tainted #3745 +* [FEATURE] Add resctrl collector #3797 +* [ENHANCEMENT] netstat: Add new FreeBSD metrics #3334 +* [ENHANCEMENT] Add `chip` label to DRM metrics #3572 +* [ENHANCEMENT] diskstats: add device-mapper backing device info metric #3676 +* [ENHANCEMENT] textfile: support UTF-8 metric and label names #3729 +* [ENHANCEMENT] ksmd: add general_profit metric #3778 #3894 +* [BUGFIX] edac: Fix printf-style formatting in slog call #3759 +* [BUGFIX] fibre_channel: fix crash when attempting to dereference invalid counters #3573 +* [BUGFIX] thermal: Fix collecting Darwin temperatures without CPU power status #3767 +* [BUGFIX] fibrechannel: Fix for ppc64le #3769 +* [BUGFIX] cpu: Revert dup cpu frequency, add node_cpufreq flag #3795 +* [BUGFIX] infiniband: skip sysfs reads for excluded devices #3824 +* [BUGFIX] bcache: Fix btree_read_average_duration_seconds unit #3828 + ## 1.12.1 / 2026-07-14 * [BUGFIX] perf: Fix perf profiler flag handling #3731 diff --git a/CLAUDE.md b/CLAUDE.md index eff4b2121f..98b8b91ede 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,12 +7,16 @@ consumed internally by the `cl_plus` telemetry stack. Upstream `master` is merged in periodically; all CloudLinux-specific changes live on top of the upstream history. +**Current upstream base:** `v1.13.1` (`0192dd89`), merged in CLOS-9230. +Update this line with every upstream sync. + ## What the fork adds The fork is deliberately small. Out of the box upstream, plus: 1. A unix-socket transport for `/metrics` (`--web.socket-path`, - `--web.socket-permissions`). + `--web.socket-permissions`), hooked into upstream's exporter-toolkit + `bootstrap` startup through the metrics handler factory. 2. CloudLinux packaging recipes (`node_exporter.spec`, `debian/`). 3. A versioned tests subpackage at `/opt/node_exporter_tests/` used by the CloudLinux QA pipeline. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46f65e80c6..1eee7e9d26 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,3 +46,8 @@ dedicated exporter instead or gather the metrics via the textfile collector. The Node Exporter tries to support the most common machine metrics. For more exotic metrics, use the textfile collector or a dedicated Exporter. + +Collectors should return `ErrNoData` when they can not find any metrics to collect. +This is intentional as it provides a means for users to differentiate between +the desired system configuration and the running configuration. For example if +a system has a piece of hardware but the driver fails to load. diff --git a/MAINTAINERS.md b/MAINTAINERS.md index ffe90361c3..7750e9e2af 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -1,2 +1,4 @@ -* Ben Kochie @SuperQ + + * Johannes 'fish' Ziemke @discordianfish +* Ben Kochie @superq diff --git a/Makefile b/Makefile index 0c46c08820..77a72a43eb 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,9 @@ # Ensure that 'all' is the default target otherwise it will be the first target from Makefile.common. all:: -# Needs to be defined before including Makefile.common to auto-generate targets -DOCKER_ARCHS ?= amd64 arm64 armv7 ppc64le riscv64 s390x - include Makefile.common -PROMTOOL_VERSION ?= 2.30.0 +PROMTOOL_VERSION ?= 3.15.0 PROMTOOL_URL ?= https://github.com/prometheus/prometheus/releases/download/v$(PROMTOOL_VERSION)/prometheus-$(PROMTOOL_VERSION).$(GO_BUILD_PLATFORM).tar.gz PROMTOOL ?= $(FIRST_GOPATH)/bin/promtool E2E_EXTRA_FLAGS ?= @@ -96,7 +93,7 @@ test: collector/fixtures/sys/.unpacked collector/fixtures/udev/.unpacked .PHONY: test-32bit test-32bit: collector/fixtures/sys/.unpacked collector/fixtures/udev/.unpacked @echo ">> running tests in 32-bit mode" - @env GOARCH=$(GOARCH_CROSS) $(GO) test $(pkgs) + @env GOARCH=$(GOARCH_CROSS) $(GO) test -tags noethtool $(pkgs) .PHONY: skip-test-32bit skip-test-32bit: diff --git a/Makefile.common b/Makefile.common index a7c5f553e1..bd5230e4b0 100644 --- a/Makefile.common +++ b/Makefile.common @@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_ SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v2.11.4 +GOLANGCI_LINT_VERSION ?= v2.14.0 GOLANGCI_FMT_OPTS ?= # golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64. # windows isn't included here because of the path separator being different. @@ -165,8 +165,9 @@ common-deps: .PHONY: update-go-deps update-go-deps: @echo ">> updating Go dependencies" + # GOTOOLCHAIN prevents go get from pulling deps that require a newer Go version. @for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \ - $(GO) get $$m; \ + GOTOOLCHAIN=go$$($(GO) mod edit -json | jq -r .Go) $(GO) get $$m; \ done $(GO) mod tidy @@ -246,6 +247,12 @@ common-docker-repo-name: .PHONY: common-docker $(BUILD_DOCKER_ARCHS) common-docker: $(BUILD_DOCKER_ARCHS) + +.PHONY: common-docker-current-arch +common-docker-current-arch: + $(MAKE) common-docker-$(GOHOSTARCH) + +# DOCKER_ARCHS holds promu architecture names, which are not OCI platform strings. $(BUILD_DOCKER_ARCHS): common-docker-%: @for variant in $(DOCKERFILE_VARIANTS_WITH_NAMES); do \ dockerfile=$${variant#*:}; \ @@ -254,10 +261,16 @@ $(BUILD_DOCKER_ARCHS): common-docker-%: if [ "$*" = "armv7" ]; then \ distroless_arch="arm"; \ fi; \ + arch="$*"; \ + case "$$arch" in \ + armv*) docker_platform="linux/arm/v$${arch#armv}";; \ + *) docker_platform="linux/$$arch";; \ + esac; \ if [ "$$dockerfile" = "Dockerfile" ]; then \ echo "Building default variant ($$variant_name) for linux-$* using $$dockerfile"; \ docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" \ -f $$dockerfile \ + --platform "$$docker_platform" \ --build-arg ARCH="$*" \ --build-arg OS="linux" \ --build-arg DISTROLESS_ARCH="$$distroless_arch" \ @@ -271,6 +284,7 @@ $(BUILD_DOCKER_ARCHS): common-docker-%: echo "Building $$variant_name variant for linux-$* using $$dockerfile"; \ docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name" \ -f $$dockerfile \ + --platform "$$docker_platform" \ --build-arg ARCH="$*" \ --build-arg OS="linux" \ --build-arg DISTROLESS_ARCH="$$distroless_arch" \ @@ -338,8 +352,7 @@ common-docker-manifest: echo "Skipping manifest for $$variant_name variant (no supported architectures)"; \ continue; \ fi; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name" $$refs; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name"; \ + docker buildx imagetools create -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name" $$refs; \ fi; \ if [ "$$dockerfile" = "Dockerfile" ]; then \ echo "Creating default variant ($$variant_name) manifest"; \ @@ -351,8 +364,7 @@ common-docker-manifest: echo "Skipping default variant manifest (no supported architectures)"; \ continue; \ fi; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" $$refs; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)"; \ + docker buildx imagetools create -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" $$refs; \ fi; \ if [ "$(DOCKER_IMAGE_TAG)" = "latest" ]; then \ if [ "$$dockerfile" != "Dockerfile" ] || [ "$$variant_name" != "default" ]; then \ @@ -365,8 +377,7 @@ common-docker-manifest: echo "Skipping version-tag manifest for $$variant_name variant (no supported architectures)"; \ continue; \ fi; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):v$(DOCKER_MAJOR_VERSION_TAG)-$$variant_name" $$refs; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):v$(DOCKER_MAJOR_VERSION_TAG)-$$variant_name"; \ + docker buildx imagetools create -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):v$(DOCKER_MAJOR_VERSION_TAG)-$$variant_name" $$refs; \ fi; \ if [ "$$dockerfile" = "Dockerfile" ]; then \ echo "Creating default variant version tag manifest"; \ @@ -378,8 +389,7 @@ common-docker-manifest: echo "Skipping default variant version-tag manifest (no supported architectures)"; \ continue; \ fi; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):v$(DOCKER_MAJOR_VERSION_TAG)" $$refs; \ - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):v$(DOCKER_MAJOR_VERSION_TAG)"; \ + docker buildx imagetools create -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):v$(DOCKER_MAJOR_VERSION_TAG)" $$refs; \ fi; \ fi; \ done diff --git a/README.md b/README.md index 8abf2cdf0f..673ad34153 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ the `node_exporter` access to the host namespaces. Be aware that any non-root mount points you want to monitor will need to be bind-mounted into the container. -If you start container for host monitoring, specify `path.rootfs` argument. +If you start a container for host monitoring, specify the `path.rootfs` argument. This argument must match path in bind-mount of host root. The node\_exporter will use `path.rootfs` as prefix to access host filesystem. @@ -84,6 +84,15 @@ Collectors are enabled by providing a `--collector.` flag. Collectors that are enabled by default can be disabled by providing a `--no-collector.` flag. To enable only some specific collector(s), use `--collector.disable-defaults --collector. ...`. +There are two meta-monitoring metrics available for checking the status of collectors. + + node_scrape_collector_success + node_scrape_collector_duration_seconds + +Note that if a configured collector reads no data because it can't find a file in `/proc` or `/sys`, +the success status will be 0. This is intentional to provide a way to detect faild drivers and similar +problems. + ### Include & Exclude flags A few collectors can be configured to include or exclude certain patterns using dedicated flags. The exclude flags are used to indicate "all except", while the include flags are used to say "none except". Note that these flags are mutually exclusive on collectors that support both. @@ -213,11 +222,13 @@ pcidevice | Exposes pci devices' information including their link status and par perf | Exposes perf based metrics (Warning: Metrics are dependent on kernel configuration and settings). | Linux processes | Exposes aggregate process statistics from `/proc`. | Linux qdisc | Exposes [queuing discipline](https://en.wikipedia.org/wiki/Network_scheduler#Linux_kernel) statistics | Linux +resctrl | Exposes Intel RDT / AMD PQoS / ARM MPAM memory bandwidth and cache occupancy monitoring counters from the resctrl filesystem root group (must be mounted, see [below](#resctrl-collector)). | Linux slabinfo | Exposes slab statistics from `/proc/slabinfo`. Note that permission of `/proc/slabinfo` is usually 0400, so set it appropriately. | Linux softirqs | Exposes detailed softirq statistics from `/proc/softirqs`. | Linux sysctl | Expose sysctl values from `/proc/sys`. Use `--collector.sysctl.include(-info)` to configure. | Linux swap | Expose swap information from `/proc/swaps`. | Linux systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux +tainted | Exposes kernel taint flags from `/proc/sys/kernel/tainted`. | Linux tcpstat | Exposes TCP connection status information from `/proc/net/tcp` and `/proc/net/tcp6`. (Warning: the current version has potential performance issues in high load situations.) | Linux wifi | Exposes WiFi device and station statistics. | Linux xfrm | Exposes statistics from `/proc/net/xfrm_stat` | Linux @@ -270,6 +281,24 @@ found using [`perf list`](http://man7.org/linux/man-pages/man1/perf.1.html) or from debugfs. And example usage of this would be `--collector.perf.tracepoint="sched:sched_process_exec"`. +### Resctrl Collector + +The `resctrl` collector is disabled by default because the filesystem it reads is usually not mounted. +To enable it, first mount the filesystem and then start `node_exporter` with the collector enabled: +``` +mount -t resctrl resctrl /sys/fs/resctrl +node_exporter --collector.resctrl +``` + +From Linux 6.19 a CPU with assignable bandwidth monitoring counters comes up in `mbm_event` mode. +The classic mode (required by this collector) can be enabled with: + +``` +echo default > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode # fails harmlessly on older kernels +``` + +See the [kernel documentation](https://docs.kernel.org/filesystems/resctrl.html) for more details. + ### Sysctl Collector The `sysctl` collector can be enabled with `--collector.sysctl`. It supports exposing numeric sysctl values diff --git a/VERSION b/VERSION index f8f4f03b3d..b50dd27dd9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.12.1 +1.13.1 diff --git a/collector/arp_linux.go b/collector/arp_linux.go index 84d8920ad5..9278d46110 100644 --- a/collector/arp_linux.go +++ b/collector/arp_linux.go @@ -42,12 +42,10 @@ func init() { registerCollector("arp", defaultEnabled, NewARPCollector) } -var ( - arpEntries = prometheus.NewDesc( - prometheus.BuildFQName(namespace, "arp", "entries"), - "ARP entries by device", - []string{"device"}, nil, - ) +var arpEntries = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "arp", "entries"), + "ARP entries by device", + []string{"device"}, nil, ) // NewARPCollector returns a new Collector exposing ARP stats. diff --git a/collector/bcache_linux.go b/collector/bcache_linux.go index 90366cc32a..6b7d20954e 100644 --- a/collector/bcache_linux.go +++ b/collector/bcache_linux.go @@ -24,9 +24,7 @@ import ( "github.com/prometheus/procfs/bcache" ) -var ( - priorityStats = kingpin.Flag("collector.bcache.priorityStats", "Expose expensive priority stats.").Bool() -) +var priorityStats = kingpin.Flag("collector.bcache.priorityStats", "Expose expensive priority stats.").Bool() func init() { registerCollector("bcache", defaultEnabled, NewBcacheCollector) @@ -152,7 +150,6 @@ func bcachePeriodStatsToMetric(ps *bcache.PeriodStats, labelValue string) []bcac // UpdateBcacheStats collects statistics for one bcache ID. func (c *bcacheCollector) updateBcacheStats(ch chan<- prometheus.Metric, s *bcache.Stats) { - const ( subsystem = "bcache" ) @@ -217,7 +214,7 @@ func (c *bcacheCollector) updateBcacheStats(ch chan<- prometheus.Metric, s *bcac { name: "btree_read_average_duration_seconds", desc: "Average btree read duration.", - value: float64(s.Bcache.Internal.BtreeReadAverageDurationNanoSeconds) * 1e-9, + value: float64(s.Bcache.Internal.BtreeReadAverageDurationMicroSeconds) * 1e-6, metricType: prometheus.GaugeValue, }, { diff --git a/collector/boot_time_solaris.go b/collector/boot_time_solaris.go index 4b2ef4577c..345eea90d9 100644 --- a/collector/boot_time_solaris.go +++ b/collector/boot_time_solaris.go @@ -38,7 +38,8 @@ func newBootTimeCollector(logger *slog.Logger) (Collector, error) { prometheus.BuildFQName(namespace, "", "boot_time_seconds"), "Unix time of last boot, including microseconds.", nil, nil, - ), prometheus.GaugeValue}, + ), prometheus.GaugeValue, + }, logger: logger, }, nil } diff --git a/collector/btrfs_linux.go b/collector/btrfs_linux.go index bc6fb6048d..cdb21144d2 100644 --- a/collector/btrfs_linux.go +++ b/collector/btrfs_linux.go @@ -68,7 +68,7 @@ func (c *btrfsCollector) Update(ch chan<- prometheus.Metric) error { for _, s := range stats { // match up procfs and ioctl info by filesystem UUID (without dashes) - var fsUUID = strings.ReplaceAll(s.UUID, "-", "") + fsUUID := strings.ReplaceAll(s.UUID, "-", "") ioctlStats := ioctlStatsMap[fsUUID] c.updateBtrfsStats(ch, s, ioctlStats) } @@ -176,7 +176,6 @@ func (c *btrfsCollector) getIoctlDeviceStats(fs *dennwc.FS, fsInfo *dennwc.Info) for i := uint64(0); i <= fsInfo.MaxID; i++ { deviceInfo, err := fs.GetDevInfo(i) - if err != nil { if errno, ok := err.(syscall.Errno); ok && errno == syscall.ENODEV { // Device IDs do not consistently start at 0, nor are ranges contiguous, so we expect this. @@ -340,12 +339,15 @@ func (c *btrfsCollector) getMetrics(s *btrfs.Stats, ioctlStats *btrfsIoctlFsStat // A bytes available metric is probably more useful than a // bytes used metric, because large numbers of bytes will // suffer from floating point representation issues - // and we probably care more about the number when it's low anyway + // and we probably care more about the number when it's low anyway. + // While a device is being shrunk, its size is already reduced but + // the extents beyond it are still allocated, so bytesUsed can exceed + // totalBytes and the unsigned subtraction would wrap around. btrfsMetric{ name: "device_unused_bytes", desc: "Unused bytes unused on a device that is part of the filesystem.", metricType: prometheus.GaugeValue, - value: float64(dev.totalBytes - dev.bytesUsed), + value: float64(int64(dev.totalBytes) - int64(dev.bytesUsed)), extraLabel: extraLabels, extraLabelValue: extraLabelValues, }) diff --git a/collector/btrfs_linux_test.go b/collector/btrfs_linux_test.go index 7be7bc39bb..0013d6d3bc 100644 --- a/collector/btrfs_linux_test.go +++ b/collector/btrfs_linux_test.go @@ -127,3 +127,33 @@ func TestBtrfs(t *testing.T) { } } } + +func TestBtrfsDeviceUnusedBytesDuringShrink(t *testing.T) { + fs, err := btrfs.NewFS("fixtures/sys") + if err != nil { + t.Fatal(err) + } + collector := &btrfsCollector{fs: fs} + + stats, err := collector.fs.Stats() + if err != nil { + t.Fatalf("Failed to retrieve Btrfs stats: %v", err) + } + + ioctlStats := &btrfsIoctlFsStats{ + devices: []btrfsIoctlFsDevStats{ + {path: "/dev/sda", uuid: "dev-uuid", totalBytes: 10 << 30, bytesUsed: 12 << 30}, + }, + } + + for _, m := range collector.getMetrics(stats[0], ioctlStats) { + if m.name != "device_unused_bytes" { + continue + } + if want := -float64(2 << 30); m.value != want { + t.Errorf("Incorrect device_unused_bytes: expected %v, got %v", want, m.value) + } + return + } + t.Error("device_unused_bytes metric not found") +} diff --git a/collector/buddyinfo.go b/collector/buddyinfo.go index 82c58c32f2..4afdbda416 100644 --- a/collector/buddyinfo.go +++ b/collector/buddyinfo.go @@ -37,12 +37,10 @@ func init() { registerCollector("buddyinfo", defaultDisabled, NewBuddyinfoCollector) } -var ( - buddyinfoBlocks = prometheus.NewDesc( - prometheus.BuildFQName(namespace, buddyInfoSubsystem, "blocks"), - "Count of free blocks according to size.", - []string{"node", "zone", "size"}, nil, - ) +var buddyinfoBlocks = prometheus.NewDesc( + prometheus.BuildFQName(namespace, buddyInfoSubsystem, "blocks"), + "Count of free blocks according to size.", + []string{"node", "zone", "size"}, nil, ) // NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats. diff --git a/collector/cpu_aix.go b/collector/cpu_aix.go index 1368f1b368..8782ec37b3 100644 --- a/collector/cpu_aix.go +++ b/collector/cpu_aix.go @@ -20,6 +20,7 @@ package collector #include // For errno */ import "C" + import ( "fmt" "log/slog" @@ -82,7 +83,6 @@ func NewCpuCollector(logger *slog.Logger) (Collector, error) { } pconfig, err := perfstat.PartitionStat() - if err != nil { return nil, err } diff --git a/collector/cpu_common.go b/collector/cpu_common.go index cb34facbfa..eceffe21c7 100644 --- a/collector/cpu_common.go +++ b/collector/cpu_common.go @@ -23,10 +23,8 @@ const ( cpuCollectorSubsystem = "cpu" ) -var ( - nodeCPUSecondsDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "seconds_total"), - "Seconds the CPUs spent in each mode.", - []string{"cpu", "mode"}, nil, - ) +var nodeCPUSecondsDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "seconds_total"), + "Seconds the CPUs spent in each mode.", + []string{"cpu", "mode"}, nil, ) diff --git a/collector/cpu_dragonfly.go b/collector/cpu_dragonfly.go index 3571f436d5..4ae34f1641 100644 --- a/collector/cpu_dragonfly.go +++ b/collector/cpu_dragonfly.go @@ -122,7 +122,7 @@ func getDragonFlyCPUTimes() ([]float64, error) { // Expose CPU stats using sysctl. func (c *statCollector) Update(ch chan<- prometheus.Metric) error { - var fieldsCount = 5 + fieldsCount := 5 cpuTimes, err := getDragonFlyCPUTimes() if err != nil { return err diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index f7b0c3ef1f..a4bbab01dc 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go @@ -219,10 +219,13 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error { cpu.CacheSize) } + // The cpufreq collector exports the same metric name with a different + // help string and label set. Only export the /proc/cpuinfo frequency + // when cpufreq is disabled or uses its own metric prefix. cpuFreqEnabled, ok := collectorState["cpufreq"] if !ok || cpuFreqEnabled == nil { c.logger.Debug("cpufreq key missing or nil value in collectorState map") - } else if *cpuFreqEnabled { + } else if !*cpuFreqEnabled || *useCPUFreqPrefix { for _, cpu := range info { ch <- prometheus.MustNewConstMetric(c.cpuFrequencyHz, prometheus.GaugeValue, @@ -407,7 +410,6 @@ func (c *cpuCollector) updateStat(ch chan<- prometheus.Metric) error { // updateCPUStats updates the internal cache of CPU stats. func (c *cpuCollector) updateCPUStats(newStats map[int64]procfs.CPUStat) { - // Acquire a lock to update the stats. c.cpuStatsMutex.Lock() defer c.cpuStatsMutex.Unlock() diff --git a/collector/cpu_linux_test.go b/collector/cpu_linux_test.go index 6d4bc4506d..04b823c583 100644 --- a/collector/cpu_linux_test.go +++ b/collector/cpu_linux_test.go @@ -53,7 +53,8 @@ func TestCPU(t *testing.T) { Steal: 100.0, Guest: 100.0, GuestNice: 100.0, - }} + }, + } c := makeTestCPUCollector(firstCPUStat) want := map[int64]procfs.CPUStat{ @@ -68,7 +69,8 @@ func TestCPU(t *testing.T) { Steal: 101.0, Guest: 101.0, GuestNice: 101.0, - }} + }, + } c.updateCPUStats(want) got := c.cpuStats if !reflect.DeepEqual(want, got) { @@ -88,7 +90,8 @@ func TestCPU(t *testing.T) { Steal: 99.9, Guest: 99.9, GuestNice: 99.9, - }} + }, + } c.updateCPUStats(jumpBack) got = c.cpuStats if reflect.DeepEqual(jumpBack, got) { @@ -108,7 +111,8 @@ func TestCPU(t *testing.T) { Steal: 102.0, Guest: 102.0, GuestNice: 102.0, - }} + }, + } c.updateCPUStats(resetIdle) got = c.cpuStats if !reflect.DeepEqual(resetIdle, got) { @@ -198,5 +202,4 @@ func TestCPUOffline(t *testing.T) { if !reflect.DeepEqual(want, got) { t.Fatalf("should have %v CPU Stat: got %v", want, got) } - } diff --git a/collector/cpu_netbsd.go b/collector/cpu_netbsd.go index 49051a6efd..35f0155d87 100644 --- a/collector/cpu_netbsd.go +++ b/collector/cpu_netbsd.go @@ -73,7 +73,7 @@ type sysmonProperty []sysmonValues type sysmonProperties map[string]sysmonProperty func _IOC(inout uint, group byte, num uint, len uintptr) uint { - return ((inout) | ((uint(len) & _IOCPARM_MASK) << _IOCPARM_SHIFT) | (uint(group) << _IOCGROUP_SHIFT) | (num)) + return (inout | ((uint(len) & _IOCPARM_MASK) << _IOCPARM_SHIFT) | (uint(group) << _IOCGROUP_SHIFT) | num) } func _IOWR(group byte, num uint, len uintptr) uint { @@ -128,7 +128,6 @@ func sortFilterSysmonProperties(props sysmonProperties, prefix string) []string } func convertTemperatures(prop sysmonProperty, res map[int]float64) error { - for _, val := range prop { if val.State == "invalid" || val.State == "unknown" || val.State == "" { continue @@ -137,14 +136,13 @@ func convertTemperatures(prop sysmonProperty, res map[int]float64) error { re := regexp.MustCompile("^cpu([0-9]+) temperature$") core := re.FindStringSubmatch(val.Description)[1] ncore, _ := strconv.Atoi(core) - temperature := ((float64(uint64(val.CurValue))) / 1000000) - 273.15 + temperature := (float64(uint64(val.CurValue)) / 1000000) - 273.15 res[ncore] = temperature } return nil } func getCPUTemperatures() (map[int]float64, error) { - res := make(map[int]float64) // Read all properties diff --git a/collector/cpu_openbsd.go b/collector/cpu_openbsd.go index 2c8ce9a81f..3c8e64e0e9 100644 --- a/collector/cpu_openbsd.go +++ b/collector/cpu_openbsd.go @@ -33,6 +33,7 @@ const ( CP_IDLE CPUSTATES ) + const ( CP_USER_O63 = iota CP_NICE_O63 diff --git a/collector/cpu_vulnerabilities_linux.go b/collector/cpu_vulnerabilities_linux.go index 155253b5f4..217e5e7a4a 100644 --- a/collector/cpu_vulnerabilities_linux.go +++ b/collector/cpu_vulnerabilities_linux.go @@ -25,13 +25,11 @@ const ( cpuVulnerabilitiesCollectorSubsystem = "cpu_vulnerabilities" ) -var ( - vulnerabilityDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuVulnerabilitiesCollectorSubsystem, "info"), - "Details of each CPU vulnerability reported by sysfs. The value of the series is an int encoded state of the vulnerability. The same state is stored as a string in the label", - []string{"codename", "state", "mitigation"}, - nil, - ) +var vulnerabilityDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, cpuVulnerabilitiesCollectorSubsystem, "info"), + "Details of each CPU vulnerability reported by sysfs. The value of the series is an int encoded state of the vulnerability. The same state is stored as a string in the label", + []string{"codename", "state", "mitigation"}, + nil, ) type cpuVulnerabilitiesCollector struct{} diff --git a/collector/cpufreq_common.go b/collector/cpufreq_common.go index d9d5108bb4..64cbe7e4f0 100644 --- a/collector/cpufreq_common.go +++ b/collector/cpufreq_common.go @@ -16,48 +16,74 @@ package collector import ( + "github.com/alecthomas/kingpin/v2" "github.com/prometheus/client_golang/prometheus" ) -var ( - cpuFreqHertzDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"), - "Current CPU thread frequency in hertz.", - []string{"cpu"}, nil, - ) - cpuFreqAvgDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_avg_hertz"), - "Average CPU thread frequency in hertz.", - []string{"cpu"}, nil, - ) - cpuFreqMinDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_min_hertz"), - "Minimum CPU thread frequency in hertz.", - []string{"cpu"}, nil, - ) - cpuFreqMaxDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_max_hertz"), - "Maximum CPU thread frequency in hertz.", - []string{"cpu"}, nil, - ) - cpuFreqScalingFreqDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_hertz"), - "Current scaled CPU thread frequency in hertz.", - []string{"cpu"}, nil, - ) - cpuFreqScalingFreqMinDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_min_hertz"), - "Minimum scaled CPU thread frequency in hertz.", - []string{"cpu"}, nil, - ) - cpuFreqScalingFreqMaxDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_max_hertz"), - "Maximum scaled CPU thread frequency in hertz.", - []string{"cpu"}, nil, - ) - cpuFreqScalingGovernorDesc = prometheus.NewDesc( - prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_governor"), - "Current enabled CPU frequency governor.", - []string{"cpu", "governor"}, nil, - ) -) +const cpuFreqCollectorSubsystem = "cpufreq" + +var useCPUFreqPrefix = kingpin.Flag("collector.cpufreq.enable-cpufreq-prefix", + "Expose cpufreq metrics with the node_cpufreq_ prefix instead of node_cpu_. This avoids a metric name collision with the cpu collector and will be the default behavior in 2.x.").Bool() + +type cpuFreqDescs struct { + hertz *prometheus.Desc + avgHertz *prometheus.Desc + minHertz *prometheus.Desc + maxHertz *prometheus.Desc + scalingHertz *prometheus.Desc + scalingMinHertz *prometheus.Desc + scalingMaxHertz *prometheus.Desc + scalingGovernor *prometheus.Desc +} + +// newCPUFreqDescs builds the cpufreq metric descriptions. It must run after +// flag parsing because the metric prefix depends on +// --collector.cpufreq.enable-cpufreq-prefix. +func newCPUFreqDescs() cpuFreqDescs { + subsystem := cpuCollectorSubsystem + if *useCPUFreqPrefix { + subsystem = cpuFreqCollectorSubsystem + } + return cpuFreqDescs{ + hertz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "frequency_hertz"), + "Current CPU thread frequency in hertz.", + []string{"cpu"}, nil, + ), + avgHertz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "frequency_avg_hertz"), + "Average CPU thread frequency in hertz.", + []string{"cpu"}, nil, + ), + minHertz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "frequency_min_hertz"), + "Minimum CPU thread frequency in hertz.", + []string{"cpu"}, nil, + ), + maxHertz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "frequency_max_hertz"), + "Maximum CPU thread frequency in hertz.", + []string{"cpu"}, nil, + ), + scalingHertz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "scaling_frequency_hertz"), + "Current scaled CPU thread frequency in hertz.", + []string{"cpu"}, nil, + ), + scalingMinHertz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "scaling_frequency_min_hertz"), + "Minimum scaled CPU thread frequency in hertz.", + []string{"cpu"}, nil, + ), + scalingMaxHertz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "scaling_frequency_max_hertz"), + "Maximum scaled CPU thread frequency in hertz.", + []string{"cpu"}, nil, + ), + scalingGovernor: prometheus.NewDesc( + prometheus.BuildFQName(namespace, subsystem, "scaling_governor"), + "Current enabled CPU frequency governor.", + []string{"cpu", "governor"}, nil, + ), + } +} diff --git a/collector/cpufreq_linux.go b/collector/cpufreq_linux.go index fbefdcf899..3c759d55e5 100644 --- a/collector/cpufreq_linux.go +++ b/collector/cpufreq_linux.go @@ -26,6 +26,7 @@ import ( type cpuFreqCollector struct { fs sysfs.FS + descs cpuFreqDescs logger *slog.Logger } @@ -42,6 +43,7 @@ func NewCPUFreqCollector(logger *slog.Logger) (Collector, error) { return &cpuFreqCollector{ fs: fs, + descs: newCPUFreqDescs(), logger: logger, }, nil } @@ -58,7 +60,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { for _, stats := range cpuFreqs { if stats.CpuinfoCurrentFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqHertzDesc, + c.descs.hertz, prometheus.GaugeValue, float64(*stats.CpuinfoCurrentFrequency)*1000.0, stats.Name, @@ -66,7 +68,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { } if stats.CpuinfoAverageFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqAvgDesc, + c.descs.avgHertz, prometheus.GaugeValue, float64(*stats.CpuinfoAverageFrequency)*1000.0, stats.Name, @@ -74,7 +76,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { } if stats.CpuinfoMinimumFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqMinDesc, + c.descs.minHertz, prometheus.GaugeValue, float64(*stats.CpuinfoMinimumFrequency)*1000.0, stats.Name, @@ -82,7 +84,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { } if stats.CpuinfoMaximumFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqMaxDesc, + c.descs.maxHertz, prometheus.GaugeValue, float64(*stats.CpuinfoMaximumFrequency)*1000.0, stats.Name, @@ -90,7 +92,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { } if stats.ScalingCurrentFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqScalingFreqDesc, + c.descs.scalingHertz, prometheus.GaugeValue, float64(*stats.ScalingCurrentFrequency)*1000.0, stats.Name, @@ -98,7 +100,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { } if stats.ScalingMinimumFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqScalingFreqMinDesc, + c.descs.scalingMinHertz, prometheus.GaugeValue, float64(*stats.ScalingMinimumFrequency)*1000.0, stats.Name, @@ -106,7 +108,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { } if stats.ScalingMaximumFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqScalingFreqMaxDesc, + c.descs.scalingMaxHertz, prometheus.GaugeValue, float64(*stats.ScalingMaximumFrequency)*1000.0, stats.Name, @@ -120,7 +122,7 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { state = 1 } ch <- prometheus.MustNewConstMetric( - cpuFreqScalingGovernorDesc, + c.descs.scalingGovernor, prometheus.GaugeValue, float64(state), stats.Name, diff --git a/collector/cpufreq_linux_test.go b/collector/cpufreq_linux_test.go new file mode 100644 index 0000000000..0b2a782ccb --- /dev/null +++ b/collector/cpufreq_linux_test.go @@ -0,0 +1,106 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !nocpu + +package collector + +import ( + "fmt" + "io" + "log/slog" + "strings" + "testing" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/testutil" +) + +type testCPUFreqCollector struct { + mc Collector +} + +func (c testCPUFreqCollector) Collect(ch chan<- prometheus.Metric) { + c.mc.Update(ch) +} + +func (c testCPUFreqCollector) Describe(ch chan<- *prometheus.Desc) { + prometheus.DescribeByCollect(c, ch) +} + +func newTestCPUFreqCollector(logger *slog.Logger) (prometheus.Collector, error) { + mc, err := NewCPUFreqCollector(logger) + if err != nil { + return testCPUFreqCollector{}, err + } + return &testCPUFreqCollector{mc}, nil +} + +const cpuFreqFixtureMetrics = `# HELP node_%[1]s_scaling_frequency_hertz Current scaled CPU thread frequency in hertz. +# TYPE node_%[1]s_scaling_frequency_hertz gauge +node_%[1]s_scaling_frequency_hertz{cpu="0"} 1.699981e+09 +node_%[1]s_scaling_frequency_hertz{cpu="1"} 1.699981e+09 +node_%[1]s_scaling_frequency_hertz{cpu="2"} 8e+06 +node_%[1]s_scaling_frequency_hertz{cpu="3"} 8e+06 +# HELP node_%[1]s_scaling_frequency_max_hertz Maximum scaled CPU thread frequency in hertz. +# TYPE node_%[1]s_scaling_frequency_max_hertz gauge +node_%[1]s_scaling_frequency_max_hertz{cpu="0"} 3.7e+09 +node_%[1]s_scaling_frequency_max_hertz{cpu="1"} 3.7e+09 +node_%[1]s_scaling_frequency_max_hertz{cpu="2"} 4.2e+09 +node_%[1]s_scaling_frequency_max_hertz{cpu="3"} 4.2e+09 +# HELP node_%[1]s_scaling_frequency_min_hertz Minimum scaled CPU thread frequency in hertz. +# TYPE node_%[1]s_scaling_frequency_min_hertz gauge +node_%[1]s_scaling_frequency_min_hertz{cpu="0"} 8e+08 +node_%[1]s_scaling_frequency_min_hertz{cpu="1"} 8e+08 +node_%[1]s_scaling_frequency_min_hertz{cpu="2"} 1e+06 +node_%[1]s_scaling_frequency_min_hertz{cpu="3"} 1e+06 +# HELP node_%[1]s_scaling_governor Current enabled CPU frequency governor. +# TYPE node_%[1]s_scaling_governor gauge +node_%[1]s_scaling_governor{cpu="0",governor="performance"} 0 +node_%[1]s_scaling_governor{cpu="0",governor="powersave"} 1 +node_%[1]s_scaling_governor{cpu="1",governor="performance"} 0 +node_%[1]s_scaling_governor{cpu="1",governor="powersave"} 1 +node_%[1]s_scaling_governor{cpu="2",governor="performance"} 0 +node_%[1]s_scaling_governor{cpu="2",governor="powersave"} 1 +node_%[1]s_scaling_governor{cpu="3",governor="performance"} 0 +node_%[1]s_scaling_governor{cpu="3",governor="powersave"} 1 +` + +func TestCPUFreqMetrics(t *testing.T) { + *sysPath = "fixtures/sys" + + for _, tc := range []struct { + name string + cpufreqPrefix bool + subsystem string + }{ + {name: "cpu prefix", cpufreqPrefix: false, subsystem: "cpu"}, + {name: "cpufreq prefix", cpufreqPrefix: true, subsystem: "cpufreq"}, + } { + t.Run(tc.name, func(t *testing.T) { + *useCPUFreqPrefix = tc.cpufreqPrefix + defer func() { *useCPUFreqPrefix = false }() + + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + collector, err := newTestCPUFreqCollector(logger) + if err != nil { + t.Fatal(err) + } + + expected := fmt.Sprintf(cpuFreqFixtureMetrics, tc.subsystem) + if err := testutil.CollectAndCompare(collector, strings.NewReader(expected)); err != nil { + t.Fatal(err) + } + }) + } +} diff --git a/collector/cpufreq_solaris.go b/collector/cpufreq_solaris.go index 41826a999c..69b7c57400 100644 --- a/collector/cpufreq_solaris.go +++ b/collector/cpufreq_solaris.go @@ -28,6 +28,7 @@ import ( import "C" type cpuFreqCollector struct { + descs cpuFreqDescs logger *slog.Logger } @@ -37,6 +38,7 @@ func init() { func NewCpuFreqCollector(logger *slog.Logger) (Collector, error) { return &cpuFreqCollector{ + descs: newCPUFreqDescs(), logger: logger, }, nil } @@ -68,14 +70,14 @@ func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { lcpu := strconv.Itoa(cpu) ch <- prometheus.MustNewConstMetric( - cpuFreqHertzDesc, + c.descs.hertz, prometheus.GaugeValue, float64(cpuFreqV.UintVal), lcpu, ) // Multiply by 1e+6 to convert MHz to Hz. ch <- prometheus.MustNewConstMetric( - cpuFreqMaxDesc, + c.descs.maxHertz, prometheus.GaugeValue, float64(cpuFreqMaxV.IntVal)*1e+6, lcpu, diff --git a/collector/diskstats_darwin.go b/collector/diskstats_darwin.go index abcf854083..3fc2ced9d1 100644 --- a/collector/diskstats_darwin.go +++ b/collector/diskstats_darwin.go @@ -43,7 +43,7 @@ func init() { // NewDiskstatsCollector returns a new Collector exposing disk device stats. func NewDiskstatsCollector(logger *slog.Logger) (Collector, error) { - var diskLabelNames = []string{"device"} + diskLabelNames := []string{"device"} deviceFilter, err := newDiskstatsDeviceFilter(logger) if err != nil { diff --git a/collector/diskstats_linux.go b/collector/diskstats_linux.go index 3794349725..3e388dc7f0 100644 --- a/collector/diskstats_linux.go +++ b/collector/diskstats_linux.go @@ -17,9 +17,11 @@ package collector import ( "bufio" + "errors" "fmt" "log/slog" "os" + "sort" "strconv" "strings" @@ -74,6 +76,7 @@ type diskstatsCollector struct { descs []typedDesc filesystemInfoDesc typedDesc deviceMapperInfoDesc typedDesc + deviceMapperBackingDesc typedDesc ataDescs map[string]typedDesc logger *slog.Logger getUdevDeviceProperties func(uint32, uint32) (udevInfo, error) @@ -86,7 +89,7 @@ func init() { // NewDiskstatsCollector returns a new Collector exposing disk device stats. // Docs from https://www.kernel.org/doc/Documentation/iostats.txt func NewDiskstatsCollector(logger *slog.Logger) (Collector, error) { - var diskLabelNames = []string{"device"} + diskLabelNames := []string{"device"} fs, err := blockdevice.NewFS(*procPath, *sysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) @@ -224,6 +227,13 @@ func NewDiskstatsCollector(logger *slog.Logger) (Collector, error) { nil, ), valueType: prometheus.GaugeValue, }, + deviceMapperBackingDesc: typedDesc{ + desc: prometheus.NewDesc(prometheus.BuildFQName(namespace, diskSubsystem, "device_mapper_backing_device_info"), + "Info about the underlying block devices of a device mapper device.", + []string{"device", "backing_device"}, + nil, + ), valueType: prometheus.GaugeValue, + }, ataDescs: map[string]typedDesc{ udevIDATAWriteCache: { desc: prometheus.NewDesc(prometheus.BuildFQName(namespace, diskSubsystem, "ata_write_cache"), @@ -351,6 +361,7 @@ func (c *diskstatsCollector) Update(ch chan<- prometheus.Metric) error { info[udevDMLVName], info[udevDMLVLayer], ) + c.updateDeviceMapperBackingDevices(ch, dev) } if ata := info[udevIDATA]; ata != "" { @@ -397,6 +408,23 @@ func rotationalLabel(fs blockdevice.FS, dev string) string { return "0" } +func (c *diskstatsCollector) updateDeviceMapperBackingDevices(ch chan<- prometheus.Metric, dev string) { + underlying, err := c.fs.SysBlockDeviceUnderlyingDevices(dev) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + c.logger.Debug("Failed to get device mapper backing devices", "device", dev, "err", err) + } + return + } + + sort.Strings(underlying.DeviceNames) + for _, backingDevice := range underlying.DeviceNames { + ch <- c.deviceMapperBackingDesc.mustNewConstMetric(1.0, dev, + backingDevice, + ) + } +} + func getUdevDeviceProperties(major, minor uint32) (udevInfo, error) { filename := udevDataFilePath(fmt.Sprintf("b%d:%d", major, minor)) diff --git a/collector/diskstats_linux_test.go b/collector/diskstats_linux_test.go index 44f86c35bf..782832e35f 100644 --- a/collector/diskstats_linux_test.go +++ b/collector/diskstats_linux_test.go @@ -19,8 +19,6 @@ import ( "fmt" "io" "log/slog" - "os" - "path/filepath" "strings" "testing" @@ -71,6 +69,17 @@ node_disk_ata_write_cache{device="sdc"} 1 node_disk_ata_write_cache_enabled{device="sda"} 0 node_disk_ata_write_cache_enabled{device="sdb"} 1 node_disk_ata_write_cache_enabled{device="sdc"} 0 +# HELP node_disk_device_mapper_backing_device_info Info about the underlying block devices of a device mapper device. +# TYPE node_disk_device_mapper_backing_device_info gauge +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-1"} 1 +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-2"} 1 +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-3"} 1 +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-4"} 1 +node_disk_device_mapper_backing_device_info{backing_device="nvme0n1p3",device="dm-0"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdi",device="dm-5"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdj",device="dm-5"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdk",device="dm-5"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdl",device="dm-5"} 1 # HELP node_disk_device_mapper_info Info about disk device mapper. # TYPE node_disk_device_mapper_info gauge node_disk_device_mapper_info{device="dm-0",lv_layer="",lv_name="",name="nvme0n1_crypt",uuid="CRYPT-LUKS2-jolaulot80fy9zsiobkxyxo7y2dqeho2-nvme0n1_crypt",vg_name=""} 1 @@ -339,6 +348,10 @@ node_disk_written_bytes_total{device="vda"} 1.0938236928e+11 } close(sink) }() + // Drain the sink so the Update goroutine ends before the test does and + // cannot race with flag parsing in the next test. + for range sink { + } err = testutil.GatherAndCompare(reg, strings.NewReader(testcase)) if err != nil { @@ -352,30 +365,7 @@ node_disk_written_bytes_total{device="vda"} 1.0938236928e+11 // not exist (preserving backward compatibility with the previous // SysBlockDeviceQueueStats zero-value behaviour, issue #3282). func TestRotationalLabel(t *testing.T) { - tempProc := t.TempDir() - tempSys := t.TempDir() - - // Create a valid rotational=1 file (HDD). - err := os.MkdirAll(filepath.Join(tempSys, "block/sda/queue"), 0755) - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(filepath.Join(tempSys, "block/sda/queue/rotational"), []byte("1\n"), 0644) - if err != nil { - t.Fatal(err) - } - - // Create a rotational=0 file (SSD). - err = os.MkdirAll(filepath.Join(tempSys, "block/sdb/queue"), 0755) - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(filepath.Join(tempSys, "block/sdb/queue/rotational"), []byte("0\n"), 0644) - if err != nil { - t.Fatal(err) - } - - fs, err := blockdevice.NewFS(tempProc, tempSys) + fs, err := blockdevice.NewFS("fixtures/proc", "fixtures/sys/diskstats") if err != nil { t.Fatal(err) } diff --git a/collector/drm_linux.go b/collector/drm_linux.go index 6c19514c4f..1739bc3d54 100644 --- a/collector/drm_linux.go +++ b/collector/drm_linux.go @@ -40,7 +40,7 @@ var ( drmCardInfo = prometheus.NewDesc( prometheus.BuildFQName(namespace, drmCollectorSubsystem, "card_info"), "Card information", - []string{"card", "memory_vendor", "power_performance_level", "unique_id", "vendor"}, nil, + []string{"card", "memory_vendor", "power_performance_level", "unique_id", "chip", "vendor"}, nil, ) drmGPUBusyPercent = prometheus.NewDesc( prometheus.BuildFQName(namespace, drmCollectorSubsystem, "gpu_busy_percent"), @@ -96,6 +96,17 @@ func (c *drmCollector) Update(ch chan<- prometheus.Metric) error { return c.updateAMDCards(ch) } +func chipName(s sysfs.ClassDRMCardAMDGPUStats) string { + // generate a chip name based on the deviceType and devName + cleanDevName := cleanMetricName(s.DevName) + cleanDevType := cleanMetricName(s.DevType) + + if cleanDevType != "" && cleanDevName != "" { + return cleanDevType + "_" + cleanDevName + } + return cleanDevName +} + func (c *drmCollector) updateAMDCards(ch chan<- prometheus.Metric) error { vendor := "amd" stats, err := c.fs.ClassDRMCardAMDGPUStats() @@ -106,7 +117,7 @@ func (c *drmCollector) updateAMDCards(ch chan<- prometheus.Metric) error { for _, s := range stats { ch <- prometheus.MustNewConstMetric( drmCardInfo, prometheus.GaugeValue, 1, - s.Name, s.MemoryVRAMVendor, s.PowerDPMForcePerformanceLevel, s.UniqueID, vendor) + s.Name, s.MemoryVRAMVendor, s.PowerDPMForcePerformanceLevel, s.UniqueID, chipName(s), vendor) ch <- prometheus.MustNewConstMetric( drmGPUBusyPercent, prometheus.GaugeValue, float64(s.GPUBusyPercent), s.Name) diff --git a/collector/edac_linux.go b/collector/edac_linux.go index 784d8c1095..c0d83540c0 100644 --- a/collector/edac_linux.go +++ b/collector/edac_linux.go @@ -102,6 +102,10 @@ func (c *edacCollector) Update(ch chan<- prometheus.Metric) error { if err != nil { return err } + if len(memControllers) == 0 { + c.logger.Debug("edac collector metrics are not available for this system") + return ErrNoData + } for _, controller := range memControllers { controllerMatch := edacMemControllerRE.FindStringSubmatch(controller) if controllerMatch == nil { @@ -201,7 +205,7 @@ func (c *edacCollector) Update(ch chan<- prometheus.Metric) error { label, ) } else { - c.logger.Debug("couldn't get ue_count for controller/csrow/channel %s/%s/%s: %w", controllerNumber, csrowNumber, channelNumber, err) + c.logger.Debug("couldn't get ue_count", "controller", controllerNumber, "csrow", csrowNumber, "channel", channelNumber, "err", err) } } } diff --git a/collector/ethtool_linux.go b/collector/ethtool_linux.go index e4d86bcd8c..f0ed3162a6 100644 --- a/collector/ethtool_linux.go +++ b/collector/ethtool_linux.go @@ -228,7 +228,7 @@ func NewEthtoolCollector(logger *slog.Logger) (Collector, error) { // updatePortCapabilities generates metrics for autonegotiate, pause and asymmetricpause. // The bit offsets here correspond to ethtool_link_mode_bit_indices in linux/include/uapi/linux/ethtool.h // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ethtool.h -func (c *ethtoolCollector) updatePortCapabilities(ch chan<- prometheus.Metric, prefix string, device string, linkModes uint32) { +func (c *ethtoolCollector) updatePortCapabilities(ch chan<- prometheus.Metric, prefix, device string, linkModes uint32) { var ( autonegotiate = 0.0 pause = 0.0 @@ -263,14 +263,13 @@ func (c *ethtoolCollector) updatePortInfo(ch chan<- prometheus.Metric, device st if linkModes&(1<, value is always 1. # TYPE node_fibrechannel_info gauge -node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 +node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="Online",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1 +node_fibrechannel_info{dev_loss_tmo="300",fabric_name="c050760aab8f2cff",fc_host="host2",port_id="0b19e2",port_name="c050760aab8f2cff",port_state="Online",port_type="NPIV VPORT",speed="unknown",supported_classes="Class 3",supported_speeds="",symbolic_name=""} 1 # HELP node_fibrechannel_invalid_crc_total Invalid Cyclic Redundancy Check count # TYPE node_fibrechannel_invalid_crc_total counter node_fibrechannel_invalid_crc_total{fc_host="host0"} 2 node_fibrechannel_invalid_crc_total{fc_host="host1"} 32 +node_fibrechannel_invalid_crc_total{fc_host="host2"} 0 # HELP node_fibrechannel_invalid_tx_words_total Number of invalid words transmitted by host port # TYPE node_fibrechannel_invalid_tx_words_total counter node_fibrechannel_invalid_tx_words_total{fc_host="host0"} 8 node_fibrechannel_invalid_tx_words_total{fc_host="host1"} 128 +node_fibrechannel_invalid_tx_words_total{fc_host="host2"} 0 # HELP node_fibrechannel_link_failure_total Number of times the host port link has failed # TYPE node_fibrechannel_link_failure_total counter node_fibrechannel_link_failure_total{fc_host="host0"} 9 node_fibrechannel_link_failure_total{fc_host="host1"} 144 +node_fibrechannel_link_failure_total{fc_host="host2"} 0 # HELP node_fibrechannel_loss_of_signal_total Number of times signal has been lost # TYPE node_fibrechannel_loss_of_signal_total counter node_fibrechannel_loss_of_signal_total{fc_host="host0"} 17 node_fibrechannel_loss_of_signal_total{fc_host="host1"} 272 +node_fibrechannel_loss_of_signal_total{fc_host="host2"} 0 # HELP node_fibrechannel_loss_of_sync_total Number of failures on either bit or transmission word boundaries # TYPE node_fibrechannel_loss_of_sync_total counter node_fibrechannel_loss_of_sync_total{fc_host="host0"} 16 node_fibrechannel_loss_of_sync_total{fc_host="host1"} 256 +node_fibrechannel_loss_of_sync_total{fc_host="host2"} 0 # HELP node_fibrechannel_nos_total Number Not_Operational Primitive Sequence received by host port # TYPE node_fibrechannel_nos_total counter node_fibrechannel_nos_total{fc_host="host0"} 18 node_fibrechannel_nos_total{fc_host="host1"} 288 +node_fibrechannel_nos_total{fc_host="host2"} 0 # HELP node_fibrechannel_rx_frames_total Number of frames received # TYPE node_fibrechannel_rx_frames_total counter node_fibrechannel_rx_frames_total{fc_host="host0"} 3 node_fibrechannel_rx_frames_total{fc_host="host1"} 48 +node_fibrechannel_rx_frames_total{fc_host="host2"} 0 # HELP node_fibrechannel_rx_words_total Number of words received by host port # TYPE node_fibrechannel_rx_words_total counter node_fibrechannel_rx_words_total{fc_host="host0"} 4 node_fibrechannel_rx_words_total{fc_host="host1"} 64 +node_fibrechannel_rx_words_total{fc_host="host2"} 0 # HELP node_fibrechannel_seconds_since_last_reset_total Number of seconds since last host port reset # TYPE node_fibrechannel_seconds_since_last_reset_total counter node_fibrechannel_seconds_since_last_reset_total{fc_host="host0"} 7 node_fibrechannel_seconds_since_last_reset_total{fc_host="host1"} 112 +node_fibrechannel_seconds_since_last_reset_total{fc_host="host2"} 0 # HELP node_fibrechannel_tx_frames_total Number of frames transmitted by host port # TYPE node_fibrechannel_tx_frames_total counter node_fibrechannel_tx_frames_total{fc_host="host0"} 5 node_fibrechannel_tx_frames_total{fc_host="host1"} 80 +node_fibrechannel_tx_frames_total{fc_host="host2"} 0 # HELP node_fibrechannel_tx_words_total Number of words transmitted by host port # TYPE node_fibrechannel_tx_words_total counter node_fibrechannel_tx_words_total{fc_host="host0"} 6 node_fibrechannel_tx_words_total{fc_host="host1"} 96 +node_fibrechannel_tx_words_total{fc_host="host2"} 0 # HELP node_filefd_allocated File descriptor statistics: allocated. # TYPE node_filefd_allocated gauge node_filefd_allocated 1024 @@ -1987,31 +2013,34 @@ node_ipvs_outgoing_packets_total 0 # HELP node_kernel_hung_tasks_total Total number of tasks that have been detected as hung since the system booted. # TYPE node_kernel_hung_tasks_total counter node_kernel_hung_tasks_total 42 -# HELP node_ksmd_full_scans_total ksmd 'full_scans' file. +# HELP node_ksmd_full_scans_total How many times all mergeable areas have been scanned. # TYPE node_ksmd_full_scans_total counter node_ksmd_full_scans_total 323 -# HELP node_ksmd_merge_across_nodes ksmd 'merge_across_nodes' file. +# HELP node_ksmd_general_profit_bytes How effective is KSM. ksm_saved_pages * sizeof(page) - (all_rmap_items) * sizeof(rmap_item) +# TYPE node_ksmd_general_profit_bytes gauge +node_ksmd_general_profit_bytes -81920 +# HELP node_ksmd_merge_across_nodes Specifies if pages from different NUMA nodes can be merged. # TYPE node_ksmd_merge_across_nodes gauge node_ksmd_merge_across_nodes 1 -# HELP node_ksmd_pages_shared ksmd 'pages_shared' file. +# HELP node_ksmd_pages_shared How many shared pages are being used. # TYPE node_ksmd_pages_shared gauge node_ksmd_pages_shared 1 -# HELP node_ksmd_pages_sharing ksmd 'pages_sharing' file. +# HELP node_ksmd_pages_sharing How many more sites are sharing them i.e. how much saved. # TYPE node_ksmd_pages_sharing gauge node_ksmd_pages_sharing 255 -# HELP node_ksmd_pages_to_scan ksmd 'pages_to_scan' file. +# HELP node_ksmd_pages_to_scan How many pages to scan before ksmd goes to sleep. # TYPE node_ksmd_pages_to_scan gauge node_ksmd_pages_to_scan 100 -# HELP node_ksmd_pages_unshared ksmd 'pages_unshared' file. +# HELP node_ksmd_pages_unshared How many pages unique but repeatedly checked for merging. # TYPE node_ksmd_pages_unshared gauge node_ksmd_pages_unshared 0 -# HELP node_ksmd_pages_volatile ksmd 'pages_volatile' file. +# HELP node_ksmd_pages_volatile How many pages changing too fast to be placed in a tree. # TYPE node_ksmd_pages_volatile gauge node_ksmd_pages_volatile 0 -# HELP node_ksmd_run ksmd 'run' file. +# HELP node_ksmd_run The status of ksmd. stopped = 0, running = 1 # TYPE node_ksmd_run gauge node_ksmd_run 1 -# HELP node_ksmd_sleep_seconds ksmd 'sleep_millisecs' file. +# HELP node_ksmd_sleep_seconds How many seconds ksmd should sleep before next scan. # TYPE node_ksmd_sleep_seconds gauge node_ksmd_sleep_seconds 0.02 # HELP node_lnstat_allocs_total linux network cache stats @@ -3485,9 +3514,9 @@ node_nfsd_server_threads 8 # HELP node_nvme_info Non-numeric data from /sys/class/nvme/, value is always 1. # TYPE node_nvme_info gauge node_nvme_info{cntlid="1997",device="nvme0",firmware_revision="1B2QEXP7",model="Samsung SSD 970 PRO 512GB",serial="S680HF8N190894I",state="live"} 1 -# HELP node_nvme_namespace_capacity_bytes Capacity of the NVMe namespace in bytes. Computed as namespace_size * namespace_logical_block_size +# HELP node_nvme_namespace_capacity_bytes Size of the NVMe namespace in bytes. DEPRECATED: please use nvme_namespace_size_bytes instead. # TYPE node_nvme_namespace_capacity_bytes gauge -node_nvme_namespace_capacity_bytes{device="nvme0",nsid="1"} 1.6e+13 +node_nvme_namespace_capacity_bytes{device="nvme0",nsid="1"} 2e+12 # HELP node_nvme_namespace_info Information about NVMe namespaces. Value is always 1 # TYPE node_nvme_namespace_info gauge node_nvme_namespace_info{ana_state="optimized",device="nvme0",nsid="1"} 1 @@ -3496,7 +3525,7 @@ node_nvme_namespace_info{ana_state="optimized",device="nvme0",nsid="1"} 1 node_nvme_namespace_logical_block_size_bytes{device="nvme0",nsid="1"} 4096 # HELP node_nvme_namespace_size_bytes Size of the NVMe namespace in bytes. Available in /sys/class/nvme///size # TYPE node_nvme_namespace_size_bytes gauge -node_nvme_namespace_size_bytes{device="nvme0",nsid="1"} 1.6e+13 +node_nvme_namespace_size_bytes{device="nvme0",nsid="1"} 2e+12 # HELP node_nvme_namespace_used_bytes Used space of the NVMe namespace in bytes. Available in /sys/class/nvme///nuse # TYPE node_nvme_namespace_used_bytes gauge node_nvme_namespace_used_bytes{device="nvme0",nsid="1"} 2e+12 @@ -3690,6 +3719,15 @@ node_rapl_core_joules_total{index="0",path="collector/fixtures/sys/class/powerca # HELP node_rapl_package_joules_total Current RAPL package value in joules # TYPE node_rapl_package_joules_total counter node_rapl_package_joules_total{index="0",path="collector/fixtures/sys/class/powercap/intel-rapl:0"} 240422.366267 +# HELP node_resctrl_llc_occupancy_bytes Last level cache bytes occupied in this domain. +# TYPE node_resctrl_llc_occupancy_bytes gauge +node_resctrl_llc_occupancy_bytes{domain="0"} 4.4040192e+07 +node_resctrl_llc_occupancy_bytes{domain="1"} 8.388608e+06 +# HELP node_resctrl_memory_bandwidth_bytes_total Bytes moved between the last level cache and memory. scope=total includes remote sockets, scope=local is memory attached to this domain. +# TYPE node_resctrl_memory_bandwidth_bytes_total counter +node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="local"} 2.10196273664e+11 +node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="total"} 3.15294410752e+11 +node_resctrl_memory_bandwidth_bytes_total{domain="1",scope="total"} 1.05098136832e+11 # HELP node_schedstat_running_seconds_total Number of seconds CPU spent running a process. # TYPE node_schedstat_running_seconds_total counter node_schedstat_running_seconds_total{cpu="0"} 2.045936778163039e+06 @@ -3750,6 +3788,7 @@ node_scrape_collector_success{collector="pressure"} 1 node_scrape_collector_success{collector="processes"} 1 node_scrape_collector_success{collector="qdisc"} 1 node_scrape_collector_success{collector="rapl"} 1 +node_scrape_collector_success{collector="resctrl"} 1 node_scrape_collector_success{collector="schedstat"} 1 node_scrape_collector_success{collector="slabinfo"} 1 node_scrape_collector_success{collector="sockstat"} 1 diff --git a/collector/fixtures/e2e-output-darwin.txt b/collector/fixtures/e2e-output-darwin.txt index cf29fb473c..4b585f45d4 100644 --- a/collector/fixtures/e2e-output-darwin.txt +++ b/collector/fixtures/e2e-output-darwin.txt @@ -94,19 +94,15 @@ node_buddyinfo_blocks{node="0",size="9",zone="Normal"} 0 # HELP node_disk_read_errors_total The total number of read errors. # TYPE node_disk_read_errors_total counter node_disk_read_errors_total{device="disk0"} 0 -node_disk_read_errors_total{device="disk4"} 0 # HELP node_disk_read_retries_total The total number of read retries. # TYPE node_disk_read_retries_total counter node_disk_read_retries_total{device="disk0"} 0 -node_disk_read_retries_total{device="disk4"} 0 # HELP node_disk_write_errors_total The total number of write errors. # TYPE node_disk_write_errors_total counter node_disk_write_errors_total{device="disk0"} 0 -node_disk_write_errors_total{device="disk4"} 0 # HELP node_disk_write_retries_total The total number of write retries. # TYPE node_disk_write_retries_total counter node_disk_write_retries_total{device="disk0"} 0 -node_disk_write_retries_total{device="disk4"} 0 # HELP node_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which node_exporter was built, and the goos and goarch for the build. # TYPE node_exporter_build_info gauge # HELP node_memory_swap_total_bytes Memory information field swap_total_bytes. @@ -115,9 +111,6 @@ node_memory_swap_total_bytes 0 # HELP node_memory_swap_used_bytes Memory information field swap_used_bytes. # TYPE node_memory_swap_used_bytes gauge node_memory_swap_used_bytes 0 -# HELP node_memory_total_bytes Memory information field total_bytes. -# TYPE node_memory_total_bytes gauge -node_memory_total_bytes 7.516192768e+09 # HELP node_network_noproto_total Network device statistic noproto. # TYPE node_network_noproto_total counter node_network_noproto_total{device="lo0"} 0 @@ -159,7 +152,7 @@ node_scrape_collector_success{collector="netdev"} 1 node_scrape_collector_success{collector="os"} 1 node_scrape_collector_success{collector="powersupplyclass"} 1 node_scrape_collector_success{collector="textfile"} 1 -node_scrape_collector_success{collector="thermal"} 0 +node_scrape_collector_success{collector="thermal"} 1 node_scrape_collector_success{collector="time"} 1 node_scrape_collector_success{collector="xfrm"} 1 # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. diff --git a/collector/fixtures/e2e-output-freebsd.txt b/collector/fixtures/e2e-output-freebsd.txt index cfa355a8ad..edb677760d 100644 --- a/collector/fixtures/e2e-output-freebsd.txt +++ b/collector/fixtures/e2e-output-freebsd.txt @@ -258,9 +258,6 @@ node_xfrm_out_state_proto_error_packets_total 4542 # HELP node_xfrm_out_state_seq_error_packets_total Sequence error i.e. Sequence number overflow # TYPE node_xfrm_out_state_seq_error_packets_total counter node_xfrm_out_state_seq_error_packets_total 543 -# HELP node_zfs_arcstats_c_min_bytes ZFS ARC minimum size -# TYPE node_zfs_arcstats_c_min_bytes gauge -node_zfs_arcstats_c_min_bytes 1.99743232e+08 # HELP node_zfs_arcstats_mfu_ghost_size ZFS ARC MFU ghost size # TYPE node_zfs_arcstats_mfu_ghost_size gauge node_zfs_arcstats_mfu_ghost_size 0 diff --git a/collector/fixtures/e2e-output-netbsd.txt b/collector/fixtures/e2e-output-netbsd.txt index 2419e8578d..6cc7882e9f 100644 --- a/collector/fixtures/e2e-output-netbsd.txt +++ b/collector/fixtures/e2e-output-netbsd.txt @@ -178,8 +178,12 @@ node_xfrm_out_state_proto_error_packets_total 4542 # HELP node_xfrm_out_state_seq_error_packets_total Sequence error i.e. Sequence number overflow # TYPE node_xfrm_out_state_seq_error_packets_total counter node_xfrm_out_state_seq_error_packets_total 543 +# HELP process_max_fds Maximum number of open file descriptors. +# TYPE process_max_fds gauge # HELP process_open_fds Number of open file descriptors. # TYPE process_open_fds gauge +# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes. +# TYPE process_virtual_memory_max_bytes gauge # HELP promhttp_metric_handler_errors_total Total number of internal errors encountered by the promhttp metric handler. # TYPE promhttp_metric_handler_errors_total counter promhttp_metric_handler_errors_total{cause="encoding"} 0 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index f121daacbc..1956e7496f 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -74,7 +74,7 @@ node_bcache_btree_cache_size_bytes{uuid="deaddd54-c735-46d5-868e-f331c5fd7c74"} node_bcache_btree_nodes{uuid="deaddd54-c735-46d5-868e-f331c5fd7c74"} 0 # HELP node_bcache_btree_read_average_duration_seconds Average btree read duration. # TYPE node_bcache_btree_read_average_duration_seconds gauge -node_bcache_btree_read_average_duration_seconds{uuid="deaddd54-c735-46d5-868e-f331c5fd7c74"} 1.305e-06 +node_bcache_btree_read_average_duration_seconds{uuid="deaddd54-c735-46d5-868e-f331c5fd7c74"} 0.001305 # HELP node_bcache_bypassed_bytes_total Amount of IO (both reads and writes) that has bypassed the cache. # TYPE node_bcache_bypassed_bytes_total counter node_bcache_bypassed_bytes_total{backing_device="bdev0",uuid="deaddd54-c735-46d5-868e-f331c5fd7c74"} 0 @@ -902,16 +902,6 @@ node_cpu_flag_info{flag="aes"} 1 node_cpu_flag_info{flag="avx"} 1 node_cpu_flag_info{flag="avx2"} 1 node_cpu_flag_info{flag="constant_tsc"} 1 -# HELP node_cpu_frequency_hertz CPU frequency in hertz from /proc/cpuinfo. -# TYPE node_cpu_frequency_hertz gauge -node_cpu_frequency_hertz{core="0",cpu="0",package="0"} 7.99998e+08 -node_cpu_frequency_hertz{core="0",cpu="4",package="0"} 7.99989e+08 -node_cpu_frequency_hertz{core="1",cpu="1",package="0"} 8.00037e+08 -node_cpu_frequency_hertz{core="1",cpu="5",package="0"} 8.00083e+08 -node_cpu_frequency_hertz{core="2",cpu="2",package="0"} 8.0001e+08 -node_cpu_frequency_hertz{core="2",cpu="6",package="0"} 8.00017e+08 -node_cpu_frequency_hertz{core="3",cpu="3",package="0"} 8.00028e+08 -node_cpu_frequency_hertz{core="3",cpu="7",package="0"} 8.0003e+08 # HELP node_cpu_guest_seconds_total Seconds the CPUs spent in guests (VMs) for each mode. # TYPE node_cpu_guest_seconds_total counter node_cpu_guest_seconds_total{cpu="0",mode="nice"} 0.01 @@ -1067,6 +1057,17 @@ node_disk_ata_write_cache{device="sdc"} 1 node_disk_ata_write_cache_enabled{device="sda"} 0 node_disk_ata_write_cache_enabled{device="sdb"} 1 node_disk_ata_write_cache_enabled{device="sdc"} 0 +# HELP node_disk_device_mapper_backing_device_info Info about the underlying block devices of a device mapper device. +# TYPE node_disk_device_mapper_backing_device_info gauge +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-1"} 1 +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-2"} 1 +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-3"} 1 +node_disk_device_mapper_backing_device_info{backing_device="dm-0",device="dm-4"} 1 +node_disk_device_mapper_backing_device_info{backing_device="nvme0n1p3",device="dm-0"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdi",device="dm-5"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdj",device="dm-5"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdk",device="dm-5"} 1 +node_disk_device_mapper_backing_device_info{backing_device="sdl",device="dm-5"} 1 # HELP node_disk_device_mapper_info Info about disk device mapper. # TYPE node_disk_device_mapper_info gauge node_disk_device_mapper_info{device="dm-0",lv_layer="",lv_name="",name="nvme0n1_crypt",uuid="CRYPT-LUKS2-jolaulot80fy9zsiobkxyxo7y2dqeho2-nvme0n1_crypt",vg_name=""} 1 @@ -1438,61 +1439,76 @@ node_entropy_pool_size_bits 4096 # HELP node_fibrechannel_dumped_frames_total Number of dumped frames # TYPE node_fibrechannel_dumped_frames_total counter node_fibrechannel_dumped_frames_total{fc_host="host1"} 0 +node_fibrechannel_dumped_frames_total{fc_host="host2"} 0 # HELP node_fibrechannel_error_frames_total Number of errors in frames # TYPE node_fibrechannel_error_frames_total counter node_fibrechannel_error_frames_total{fc_host="host0"} 0 node_fibrechannel_error_frames_total{fc_host="host1"} 19 +node_fibrechannel_error_frames_total{fc_host="host2"} 0 # HELP node_fibrechannel_fcp_packet_aborts_total Number of aborted packets # TYPE node_fibrechannel_fcp_packet_aborts_total counter node_fibrechannel_fcp_packet_aborts_total{fc_host="host0"} 19 +node_fibrechannel_fcp_packet_aborts_total{fc_host="host2"} 0 # HELP node_fibrechannel_info Non-numeric data from /sys/class/fc_host/, value is always 1. # TYPE node_fibrechannel_info gauge -node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 +node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="Online",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1 +node_fibrechannel_info{dev_loss_tmo="300",fabric_name="c050760aab8f2cff",fc_host="host2",port_id="0b19e2",port_name="c050760aab8f2cff",port_state="Online",port_type="NPIV VPORT",speed="unknown",supported_classes="Class 3",supported_speeds="",symbolic_name=""} 1 # HELP node_fibrechannel_invalid_crc_total Invalid Cyclic Redundancy Check count # TYPE node_fibrechannel_invalid_crc_total counter node_fibrechannel_invalid_crc_total{fc_host="host0"} 2 node_fibrechannel_invalid_crc_total{fc_host="host1"} 32 +node_fibrechannel_invalid_crc_total{fc_host="host2"} 0 # HELP node_fibrechannel_invalid_tx_words_total Number of invalid words transmitted by host port # TYPE node_fibrechannel_invalid_tx_words_total counter node_fibrechannel_invalid_tx_words_total{fc_host="host0"} 8 node_fibrechannel_invalid_tx_words_total{fc_host="host1"} 128 +node_fibrechannel_invalid_tx_words_total{fc_host="host2"} 0 # HELP node_fibrechannel_link_failure_total Number of times the host port link has failed # TYPE node_fibrechannel_link_failure_total counter node_fibrechannel_link_failure_total{fc_host="host0"} 9 node_fibrechannel_link_failure_total{fc_host="host1"} 144 +node_fibrechannel_link_failure_total{fc_host="host2"} 0 # HELP node_fibrechannel_loss_of_signal_total Number of times signal has been lost # TYPE node_fibrechannel_loss_of_signal_total counter node_fibrechannel_loss_of_signal_total{fc_host="host0"} 17 node_fibrechannel_loss_of_signal_total{fc_host="host1"} 272 +node_fibrechannel_loss_of_signal_total{fc_host="host2"} 0 # HELP node_fibrechannel_loss_of_sync_total Number of failures on either bit or transmission word boundaries # TYPE node_fibrechannel_loss_of_sync_total counter node_fibrechannel_loss_of_sync_total{fc_host="host0"} 16 node_fibrechannel_loss_of_sync_total{fc_host="host1"} 256 +node_fibrechannel_loss_of_sync_total{fc_host="host2"} 0 # HELP node_fibrechannel_nos_total Number Not_Operational Primitive Sequence received by host port # TYPE node_fibrechannel_nos_total counter node_fibrechannel_nos_total{fc_host="host0"} 18 node_fibrechannel_nos_total{fc_host="host1"} 288 +node_fibrechannel_nos_total{fc_host="host2"} 0 # HELP node_fibrechannel_rx_frames_total Number of frames received # TYPE node_fibrechannel_rx_frames_total counter node_fibrechannel_rx_frames_total{fc_host="host0"} 3 node_fibrechannel_rx_frames_total{fc_host="host1"} 48 +node_fibrechannel_rx_frames_total{fc_host="host2"} 0 # HELP node_fibrechannel_rx_words_total Number of words received by host port # TYPE node_fibrechannel_rx_words_total counter node_fibrechannel_rx_words_total{fc_host="host0"} 4 node_fibrechannel_rx_words_total{fc_host="host1"} 64 +node_fibrechannel_rx_words_total{fc_host="host2"} 0 # HELP node_fibrechannel_seconds_since_last_reset_total Number of seconds since last host port reset # TYPE node_fibrechannel_seconds_since_last_reset_total counter node_fibrechannel_seconds_since_last_reset_total{fc_host="host0"} 7 node_fibrechannel_seconds_since_last_reset_total{fc_host="host1"} 112 +node_fibrechannel_seconds_since_last_reset_total{fc_host="host2"} 0 # HELP node_fibrechannel_tx_frames_total Number of frames transmitted by host port # TYPE node_fibrechannel_tx_frames_total counter node_fibrechannel_tx_frames_total{fc_host="host0"} 5 node_fibrechannel_tx_frames_total{fc_host="host1"} 80 +node_fibrechannel_tx_frames_total{fc_host="host2"} 0 # HELP node_fibrechannel_tx_words_total Number of words transmitted by host port # TYPE node_fibrechannel_tx_words_total counter node_fibrechannel_tx_words_total{fc_host="host0"} 6 node_fibrechannel_tx_words_total{fc_host="host1"} 96 +node_fibrechannel_tx_words_total{fc_host="host2"} 0 # HELP node_filefd_allocated File descriptor statistics: allocated. # TYPE node_filefd_allocated gauge node_filefd_allocated 1024 @@ -2019,31 +2035,34 @@ node_ipvs_outgoing_packets_total 0 # HELP node_kernel_hung_tasks_total Total number of tasks that have been detected as hung since the system booted. # TYPE node_kernel_hung_tasks_total counter node_kernel_hung_tasks_total 42 -# HELP node_ksmd_full_scans_total ksmd 'full_scans' file. +# HELP node_ksmd_full_scans_total How many times all mergeable areas have been scanned. # TYPE node_ksmd_full_scans_total counter node_ksmd_full_scans_total 323 -# HELP node_ksmd_merge_across_nodes ksmd 'merge_across_nodes' file. +# HELP node_ksmd_general_profit_bytes How effective is KSM. ksm_saved_pages * sizeof(page) - (all_rmap_items) * sizeof(rmap_item) +# TYPE node_ksmd_general_profit_bytes gauge +node_ksmd_general_profit_bytes -81920 +# HELP node_ksmd_merge_across_nodes Specifies if pages from different NUMA nodes can be merged. # TYPE node_ksmd_merge_across_nodes gauge node_ksmd_merge_across_nodes 1 -# HELP node_ksmd_pages_shared ksmd 'pages_shared' file. +# HELP node_ksmd_pages_shared How many shared pages are being used. # TYPE node_ksmd_pages_shared gauge node_ksmd_pages_shared 1 -# HELP node_ksmd_pages_sharing ksmd 'pages_sharing' file. +# HELP node_ksmd_pages_sharing How many more sites are sharing them i.e. how much saved. # TYPE node_ksmd_pages_sharing gauge node_ksmd_pages_sharing 255 -# HELP node_ksmd_pages_to_scan ksmd 'pages_to_scan' file. +# HELP node_ksmd_pages_to_scan How many pages to scan before ksmd goes to sleep. # TYPE node_ksmd_pages_to_scan gauge node_ksmd_pages_to_scan 100 -# HELP node_ksmd_pages_unshared ksmd 'pages_unshared' file. +# HELP node_ksmd_pages_unshared How many pages unique but repeatedly checked for merging. # TYPE node_ksmd_pages_unshared gauge node_ksmd_pages_unshared 0 -# HELP node_ksmd_pages_volatile ksmd 'pages_volatile' file. +# HELP node_ksmd_pages_volatile How many pages changing too fast to be placed in a tree. # TYPE node_ksmd_pages_volatile gauge node_ksmd_pages_volatile 0 -# HELP node_ksmd_run ksmd 'run' file. +# HELP node_ksmd_run The status of ksmd. stopped = 0, running = 1 # TYPE node_ksmd_run gauge node_ksmd_run 1 -# HELP node_ksmd_sleep_seconds ksmd 'sleep_millisecs' file. +# HELP node_ksmd_sleep_seconds How many seconds ksmd should sleep before next scan. # TYPE node_ksmd_sleep_seconds gauge node_ksmd_sleep_seconds 0.02 # HELP node_lnstat_allocs_total linux network cache stats @@ -3517,9 +3536,9 @@ node_nfsd_server_threads 8 # HELP node_nvme_info Non-numeric data from /sys/class/nvme/, value is always 1. # TYPE node_nvme_info gauge node_nvme_info{cntlid="1997",device="nvme0",firmware_revision="1B2QEXP7",model="Samsung SSD 970 PRO 512GB",serial="S680HF8N190894I",state="live"} 1 -# HELP node_nvme_namespace_capacity_bytes Capacity of the NVMe namespace in bytes. Computed as namespace_size * namespace_logical_block_size +# HELP node_nvme_namespace_capacity_bytes Size of the NVMe namespace in bytes. DEPRECATED: please use nvme_namespace_size_bytes instead. # TYPE node_nvme_namespace_capacity_bytes gauge -node_nvme_namespace_capacity_bytes{device="nvme0",nsid="1"} 1.6e+13 +node_nvme_namespace_capacity_bytes{device="nvme0",nsid="1"} 2e+12 # HELP node_nvme_namespace_info Information about NVMe namespaces. Value is always 1 # TYPE node_nvme_namespace_info gauge node_nvme_namespace_info{ana_state="optimized",device="nvme0",nsid="1"} 1 @@ -3528,7 +3547,7 @@ node_nvme_namespace_info{ana_state="optimized",device="nvme0",nsid="1"} 1 node_nvme_namespace_logical_block_size_bytes{device="nvme0",nsid="1"} 4096 # HELP node_nvme_namespace_size_bytes Size of the NVMe namespace in bytes. Available in /sys/class/nvme///size # TYPE node_nvme_namespace_size_bytes gauge -node_nvme_namespace_size_bytes{device="nvme0",nsid="1"} 1.6e+13 +node_nvme_namespace_size_bytes{device="nvme0",nsid="1"} 2e+12 # HELP node_nvme_namespace_used_bytes Used space of the NVMe namespace in bytes. Available in /sys/class/nvme///nuse # TYPE node_nvme_namespace_used_bytes gauge node_nvme_namespace_used_bytes{device="nvme0",nsid="1"} 2e+12 @@ -3722,6 +3741,15 @@ node_rapl_core_joules_total{index="0",path="collector/fixtures/sys/class/powerca # HELP node_rapl_package_joules_total Current RAPL package value in joules # TYPE node_rapl_package_joules_total counter node_rapl_package_joules_total{index="0",path="collector/fixtures/sys/class/powercap/intel-rapl:0"} 240422.366267 +# HELP node_resctrl_llc_occupancy_bytes Last level cache bytes occupied in this domain. +# TYPE node_resctrl_llc_occupancy_bytes gauge +node_resctrl_llc_occupancy_bytes{domain="0"} 4.4040192e+07 +node_resctrl_llc_occupancy_bytes{domain="1"} 8.388608e+06 +# HELP node_resctrl_memory_bandwidth_bytes_total Bytes moved between the last level cache and memory. scope=total includes remote sockets, scope=local is memory attached to this domain. +# TYPE node_resctrl_memory_bandwidth_bytes_total counter +node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="local"} 2.10196273664e+11 +node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="total"} 3.15294410752e+11 +node_resctrl_memory_bandwidth_bytes_total{domain="1",scope="total"} 1.05098136832e+11 # HELP node_schedstat_running_seconds_total Number of seconds CPU spent running a process. # TYPE node_schedstat_running_seconds_total counter node_schedstat_running_seconds_total{cpu="0"} 2.045936778163039e+06 @@ -3782,6 +3810,7 @@ node_scrape_collector_success{collector="pressure"} 1 node_scrape_collector_success{collector="processes"} 1 node_scrape_collector_success{collector="qdisc"} 1 node_scrape_collector_success{collector="rapl"} 1 +node_scrape_collector_success{collector="resctrl"} 1 node_scrape_collector_success{collector="schedstat"} 1 node_scrape_collector_success{collector="slabinfo"} 1 node_scrape_collector_success{collector="sockstat"} 1 diff --git a/collector/fixtures/proc/10/net b/collector/fixtures/proc/10/net new file mode 120000 index 0000000000..f1e889e8e3 --- /dev/null +++ b/collector/fixtures/proc/10/net @@ -0,0 +1 @@ +../net \ No newline at end of file diff --git a/collector/fixtures/proc/sys/kernel/tainted b/collector/fixtures/proc/sys/kernel/tainted new file mode 100644 index 0000000000..63fce6863a --- /dev/null +++ b/collector/fixtures/proc/sys/kernel/tainted @@ -0,0 +1 @@ +12288 diff --git a/collector/fixtures/resctrl/mon_data/mon_L3_00/llc_occupancy b/collector/fixtures/resctrl/mon_data/mon_L3_00/llc_occupancy new file mode 100644 index 0000000000..317ea811d9 --- /dev/null +++ b/collector/fixtures/resctrl/mon_data/mon_L3_00/llc_occupancy @@ -0,0 +1 @@ +44040192 diff --git a/collector/fixtures/resctrl/mon_data/mon_L3_00/mbm_local_bytes b/collector/fixtures/resctrl/mon_data/mon_L3_00/mbm_local_bytes new file mode 100644 index 0000000000..5cb8136235 --- /dev/null +++ b/collector/fixtures/resctrl/mon_data/mon_L3_00/mbm_local_bytes @@ -0,0 +1 @@ +210196273664 diff --git a/collector/fixtures/resctrl/mon_data/mon_L3_00/mbm_total_bytes b/collector/fixtures/resctrl/mon_data/mon_L3_00/mbm_total_bytes new file mode 100644 index 0000000000..d91f52ebae --- /dev/null +++ b/collector/fixtures/resctrl/mon_data/mon_L3_00/mbm_total_bytes @@ -0,0 +1 @@ +315294410752 diff --git a/collector/fixtures/resctrl/mon_data/mon_L3_01/llc_occupancy b/collector/fixtures/resctrl/mon_data/mon_L3_01/llc_occupancy new file mode 100644 index 0000000000..16edb4cc19 --- /dev/null +++ b/collector/fixtures/resctrl/mon_data/mon_L3_01/llc_occupancy @@ -0,0 +1 @@ +8388608 diff --git a/collector/fixtures/resctrl/mon_data/mon_L3_01/mbm_local_bytes b/collector/fixtures/resctrl/mon_data/mon_L3_01/mbm_local_bytes new file mode 100644 index 0000000000..ba54161f35 --- /dev/null +++ b/collector/fixtures/resctrl/mon_data/mon_L3_01/mbm_local_bytes @@ -0,0 +1 @@ +Unavailable diff --git a/collector/fixtures/resctrl/mon_data/mon_L3_01/mbm_total_bytes b/collector/fixtures/resctrl/mon_data/mon_L3_01/mbm_total_bytes new file mode 100644 index 0000000000..47cf3d0c1b --- /dev/null +++ b/collector/fixtures/resctrl/mon_data/mon_L3_01/mbm_total_bytes @@ -0,0 +1 @@ +105098136832 diff --git a/collector/fixtures/sys.ttar b/collector/fixtures/sys.ttar index d6829754d6..038b28e569 100644 --- a/collector/fixtures/sys.ttar +++ b/collector/fixtures/sys.ttar @@ -5,6 +5,153 @@ Mode: 755 Directory: sys/block Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-0 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-0/slaves +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-0/slaves/nvme0n1p3 +SymlinkTo: ../nvme0n1p3 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-1 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-1/slaves +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-1/slaves/dm-0 +SymlinkTo: ../dm-0 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-2 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-2/slaves +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-2/slaves/dm-0 +SymlinkTo: ../dm-0 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-3 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-3/slaves +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-3/slaves/dm-0 +SymlinkTo: ../dm-0 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-4 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-4/slaves +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-4/slaves/dm-0 +SymlinkTo: ../dm-0 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-5 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-5/dm +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-5/dm/name +Lines: 1 +mpathAEOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-5/dm/suspended +Lines: 1 +0EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-5/dm/uuid +Lines: 1 +mpath-3600508b1001c1234567890abcdef1234EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-5/size +Lines: 1 +104857600EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-5/slaves +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-5/slaves/sdi +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-5/slaves/sdj +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-5/slaves/sdk +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-5/slaves/sdl +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-6 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-6/dm +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-6/dm/name +Lines: 1 +mpathBEOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-6/dm/suspended +Lines: 1 +0EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-6/dm/uuid +Lines: 1 +mpath-3600508b1001cabcdef4567890123456EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-6/size +Lines: 1 +209715200EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-6/slaves +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-6/slaves/sdm +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-6/slaves/sdn +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-7 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/block/dm-7/dm +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-7/dm/name +Lines: 1 +vg0-rootEOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-7/dm/suspended +Lines: 1 +0EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-7/dm/uuid +Lines: 1 +LVM-abcdef1234567890abcdef1234567890EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/block/dm-7/size +Lines: 1 +41943040EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/block/md0 Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -826,108 +973,6 @@ Lines: 1 none Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-5 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-5/dm -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-5/dm/name -Lines: 1 -mpathAEOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-5/dm/suspended -Lines: 1 -0EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-5/dm/uuid -Lines: 1 -mpath-3600508b1001c1234567890abcdef1234EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-5/size -Lines: 1 -104857600EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-5/slaves -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-5/slaves/sdi -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-5/slaves/sdj -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-5/slaves/sdk -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-5/slaves/sdl -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-6 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-6/dm -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-6/dm/name -Lines: 1 -mpathBEOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-6/dm/suspended -Lines: 1 -0EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-6/dm/uuid -Lines: 1 -mpath-3600508b1001cabcdef4567890123456EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-6/size -Lines: 1 -209715200EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-6/slaves -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-6/slaves/sdm -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-6/slaves/sdn -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-7 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/block/dm-7/dm -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-7/dm/name -Lines: 1 -vg0-rootEOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-7/dm/suspended -Lines: 1 -0EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-7/dm/uuid -Lines: 1 -LVM-abcdef1234567890abcdef1234567890EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/block/dm-7/size -Lines: 1 -41943040EOF -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/block/sdi Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1298,6 +1343,11 @@ Mode: 644 Directory: sys/class/fc_host/host1 Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/port_state +Lines: 1 +Online +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Path: sys/class/fc_host/host1/speed Lines: 1 8 Gbit @@ -1376,6 +1426,72 @@ Lines: 1 0x60 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/class/fc_host/host2 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/dev_loss_tmo +Lines: 1 +300 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/fabric_name +Lines: 1 +0xc050760aab8f2cff +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/issue_lip +Lines: 0 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/maxframe_size +Lines: 1 +2048 bytes +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/node_name +Lines: 1 +0xc050760aab8f2cff +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/port_id +Lines: 1 +0x0b19e2 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/port_name +Lines: 1 +0xc050760aab8f2cff +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/port_state +Lines: 1 +Online +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/port_type +Lines: 1 +NPIV VPORT +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/speed +Lines: 1 +unknown +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/supported_classes +Lines: 1 +Class 3 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/tgtid_bind_type +Lines: 1 +wwpn (World Wide Port Name) +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host2/uevent +Lines: 0 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/class/hwmon Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1385,6 +1501,9 @@ SymlinkTo: ../../devices/platform/coretemp.0/hwmon/hwmon0 Path: sys/class/hwmon/hwmon1 SymlinkTo: ../../devices/platform/coretemp.1/hwmon/hwmon1 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/hwmon/hwmon10 +SymlinkTo: ../../devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Path: sys/class/hwmon/hwmon2 SymlinkTo: ../../devices/platform/applesmc.768/hwmon/hwmon2 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1479,9 +1598,6 @@ SymlinkTo: ../../devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8 Path: sys/class/hwmon/hwmon9 SymlinkTo: ../../devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/class/hwmon/hwmon10 -SymlinkTo: ../../devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/class/infiniband Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2402,16 +2518,6 @@ Lines: 1 Samsung SSD 970 PRO 512GB Mode: 444 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/class/nvme/nvme0/serial -Lines: 1 -S680HF8N190894I -Mode: 444 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/class/nvme/nvme0/state -Lines: 1 -live -Mode: 444 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/class/nvme/nvme0/nvme0n1 Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2420,11 +2526,6 @@ Lines: 1 optimized Mode: 444 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/class/nvme/nvme0/nvme0n1/size -Lines: 1 -3906250000 -Mode: 444 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Path: sys/class/nvme/nvme0/nvme0n1/nuse Lines: 1 488281250 @@ -2438,6 +2539,21 @@ Lines: 1 4096 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/nvme/nvme0/nvme0n1/size +Lines: 1 +3906250000 +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/nvme/nvme0/serial +Lines: 1 +S680HF8N190894I +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/nvme/nvme0/state +Lines: 1 +live +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/class/nvme-subsystem Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -8524,69 +8640,6 @@ Lines: 1 2 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc/18000000.wifi -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc/18000000.wifi/ieee80211 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8/device -SymlinkTo: ../.. -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8/name -Lines: 1 -mt7996_phy0_0 -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8/temp1_input -Lines: 1 -55000 -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9/device -SymlinkTo: ../.. -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9/name -Lines: 1 -mt7996_phy0_1 -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9/temp1_input -Lines: 1 -56000 -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10/device -SymlinkTo: ../.. -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10/name -Lines: 1 -mt7996_phy0_2 -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10/temp1_input -Lines: 1 -57000 -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/devices/platform/bogus.0 Mode: 775 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -9164,6 +9217,69 @@ Lines: 1 0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc/18000000.wifi +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc/18000000.wifi/ieee80211 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10/name +Lines: 1 +mt7996_phy0_2 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon10/temp1_input +Lines: 1 +57000 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8/name +Lines: 1 +mt7996_phy0_0 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon8/temp1_input +Lines: 1 +55000 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9/name +Lines: 1 +mt7996_phy0_1 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/platform/soc/18000000.wifi/ieee80211/phy0/hwmon/hwmon9/temp1_input +Lines: 1 +56000 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/devices/system Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -9556,133 +9672,133 @@ Lines: 1 2 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/system/edac/mc/mc0/csrow0 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ch0_ce_count -Lines: 1 -0 -Mode: 644 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/system/edac/mc/mc0/csrow1 +Directory: sys/devices/system/edac/mc/mc0/csrow0 Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ch0_ce_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ce_count Lines: 1 -0 +3 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Directory: sys/devices/system/edac/mc/mc0/csrow2 -Mode: 755 -# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow2/ch0_ce_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ch0_ce_count Lines: 1 0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ch1_ce_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ch0_dimm_label Lines: 1 -0 +mc0csrow0channel0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ch1_ce_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ch0_ue_count Lines: 1 -0 +2 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow2/ch1_ce_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ch1_ce_count Lines: 1 0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ce_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ch1_dimm_label Lines: 1 -3 +mc0csrow0channel1 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ch0_ue_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ch1_ue_count Lines: 1 2 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ch0_ue_count +Path: sys/devices/system/edac/mc/mc0/csrow0/ue_count Lines: 1 -2 +4 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ch1_ue_count +Directory: sys/devices/system/edac/mc/mc0/csrow1 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/system/edac/mc/mc0/csrow1/ce_count Lines: 1 -2 +0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ch1_ue_count +Path: sys/devices/system/edac/mc/mc0/csrow1/ch0_ce_count Lines: 1 -2 +0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ce_count +Path: sys/devices/system/edac/mc/mc0/csrow1/ch0_dimm_label Lines: 1 -0 +mc0csrow1channel0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ue_count +Path: sys/devices/system/edac/mc/mc0/csrow1/ch0_ue_count Lines: 1 -4 +2 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow2/ce_count +Path: sys/devices/system/edac/mc/mc0/csrow1/ch1_ce_count Lines: 1 0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow2/ue_count +Path: sys/devices/system/edac/mc/mc0/csrow1/ch1_dimm_label Lines: 1 -5 +mc0csrow1channel1 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ue_count +Path: sys/devices/system/edac/mc/mc0/csrow1/ch1_ue_count +Lines: 1 +2 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/system/edac/mc/mc0/csrow1/ue_count Lines: 1 4 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/ue_count +Directory: sys/devices/system/edac/mc/mc0/csrow2 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/devices/system/edac/mc/mc0/csrow2/ce_count Lines: 1 -5 +0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/ue_noinfo_count +Path: sys/devices/system/edac/mc/mc0/csrow2/ch0_ce_count Lines: 1 -6 +0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ch0_dimm_label +Path: sys/devices/system/edac/mc/mc0/csrow2/ch0_dimm_label Lines: 1 -mc0csrow0channel0 +mc0csrow2channel0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow0/ch1_dimm_label +Path: sys/devices/system/edac/mc/mc0/csrow2/ch1_ce_count Lines: 1 -mc0csrow0channel1 +0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ch0_dimm_label +Path: sys/devices/system/edac/mc/mc0/csrow2/ch1_dimm_label Lines: 1 -mc0csrow1channel0 +mc0csrow2channel1 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow1/ch1_dimm_label +Path: sys/devices/system/edac/mc/mc0/csrow2/ue_count Lines: 1 -mc0csrow1channel1 +5 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow2/ch0_dimm_label +Path: sys/devices/system/edac/mc/mc0/ue_count Lines: 1 -mc0csrow2channel0 +5 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path: sys/devices/system/edac/mc/mc0/csrow2/ch1_dimm_label +Path: sys/devices/system/edac/mc/mc0/ue_noinfo_count Lines: 1 -mc0csrow2channel1 +6 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/devices/system/node @@ -9895,6 +10011,34 @@ Lines: 1 cpu-thermal Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/diskstats +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/diskstats/block +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/diskstats/block/sda +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/diskstats/block/sda/queue +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/diskstats/block/sda/queue/rotational +Lines: 1 +1 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/diskstats/block/sdb +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/diskstats/block/sdb/queue +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/diskstats/block/sdb/queue/rotational +Lines: 1 +0 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/fs Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -11941,6 +12085,202 @@ xpc 3571712 3568056 0 debug 0 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/class +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/class/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/class/hwmon/hwmon6 +SymlinkTo: ../../devices/platform/asus-nb-wmi/hwmon/hwmon6 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/class/hwmon/hwmon7 +SymlinkTo: ../../devices/platform/asus-nb-wmi/hwmon/hwmon7 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/devices +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/devices/platform +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon6 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon6/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon6/name +Lines: 1 +asus +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon6/pwm1 +Lines: 1 +128 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon6/pwm1_enable +Lines: 1 +2 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon7 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon7/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon7/name +Lines: 1 +asus_wmi_sensors +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon7/pwm1 +Lines: 1 +200 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/duplicate_chip_names/devices/platform/asus-nb-wmi/hwmon/hwmon7/pwm1_enable +Lines: 1 +2 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/class +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/class/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/class/hwmon/hwmon3 +SymlinkTo: ../../devices/platform/asus-nb-wmi/hwmon/hwmon3 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/class/hwmon/hwmon4 +SymlinkTo: ../../devices/platform/asus-nb-wmi/hwmon/hwmon4 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/devices +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/devices/platform +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon3 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon3/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon3/name +Lines: 1 +asus +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon3/pwm1_enable +Lines: 1 +2 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon4 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon4/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon4/name +Lines: 1 +asus +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/same_name_file/devices/platform/asus-nb-wmi/hwmon/hwmon4/pwm1_enable +Lines: 1 +2 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/class +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/class/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/class/hwmon/hwmon0 +SymlinkTo: ../../devices/platform/coretemp.0/hwmon/hwmon0 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/class/hwmon/hwmon1 +SymlinkTo: ../../devices/platform/coretemp.1/hwmon/hwmon1 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices/platform +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices/platform/coretemp.0 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices/platform/coretemp.0/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices/platform/coretemp.0/hwmon/hwmon0 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/devices/platform/coretemp.0/hwmon/hwmon0/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/devices/platform/coretemp.0/hwmon/hwmon0/name +Lines: 1 +coretemp +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/devices/platform/coretemp.0/hwmon/hwmon0/temp1_input +Lines: 1 +42000 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices/platform/coretemp.1 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices/platform/coretemp.1/hwmon +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/hwmon/unique_chip_names/devices/platform/coretemp.1/hwmon/hwmon1 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/devices/platform/coretemp.1/hwmon/hwmon1/device +SymlinkTo: ../.. +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/devices/platform/coretemp.1/hwmon/hwmon1/name +Lines: 1 +coretemp +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/hwmon/unique_chip_names/devices/platform/coretemp.1/hwmon/hwmon1/temp1_input +Lines: 1 +43000 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/kernel Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -11955,6 +12295,11 @@ Lines: 1 323 Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/kernel/mm/ksm/general_profit +Lines: 1 +-81920 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Path: sys/kernel/mm/ksm/merge_across_nodes Lines: 1 1 diff --git a/collector/fixtures/textfile/duplicate_metrics/a.prom b/collector/fixtures/textfile/duplicate_metrics/a.prom new file mode 100644 index 0000000000..43deca5531 --- /dev/null +++ b/collector/fixtures/textfile/duplicate_metrics/a.prom @@ -0,0 +1 @@ +dummy_metric 1 diff --git a/collector/fixtures/textfile/duplicate_metrics/b.prom b/collector/fixtures/textfile/duplicate_metrics/b.prom new file mode 100644 index 0000000000..43deca5531 --- /dev/null +++ b/collector/fixtures/textfile/duplicate_metrics/b.prom @@ -0,0 +1 @@ +dummy_metric 1 diff --git a/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help.out b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help.out new file mode 100644 index 0000000000..38c23a044a --- /dev/null +++ b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help.out @@ -0,0 +1,12 @@ +# HELP foo First help text. +# TYPE foo gauge +foo{file="a"} 1 +# HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. +# TYPE node_textfile_mtime_seconds gauge +node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_inconsistent_then_no_help/a.prom"} 1 +node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_inconsistent_then_no_help/b.prom"} 1 +node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_inconsistent_then_no_help/c.prom"} 1 +node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_inconsistent_then_no_help/d.prom"} 1 +# HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise +# TYPE node_textfile_scrape_error gauge +node_textfile_scrape_error 1 diff --git a/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/a.prom b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/a.prom new file mode 100644 index 0000000000..4e727fd6d5 --- /dev/null +++ b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/a.prom @@ -0,0 +1,3 @@ +# HELP foo First help text. +# TYPE foo gauge +foo{file="a"} 1 diff --git a/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/b.prom b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/b.prom new file mode 100644 index 0000000000..b094d1087e --- /dev/null +++ b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/b.prom @@ -0,0 +1,3 @@ +# HELP foo Second help text. +# TYPE foo gauge +foo{file="b"} 2 diff --git a/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/c.prom b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/c.prom new file mode 100644 index 0000000000..7e6cf1efa5 --- /dev/null +++ b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/c.prom @@ -0,0 +1,2 @@ +# TYPE foo gauge +foo{file="c"} 3 diff --git a/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/d.prom b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/d.prom new file mode 100644 index 0000000000..3569ccf392 --- /dev/null +++ b/collector/fixtures/textfile/metrics_merge_inconsistent_then_no_help/d.prom @@ -0,0 +1,3 @@ +# HELP foo First help text. +# TYPE foo gauge +foo{file="d"} 4 diff --git a/collector/fixtures/textfile/utf8_names/test.prom b/collector/fixtures/textfile/utf8_names/test.prom new file mode 100644 index 0000000000..905eca59b9 --- /dev/null +++ b/collector/fixtures/textfile/utf8_names/test.prom @@ -0,0 +1,3 @@ +# HELP "my.dotted.metric" A metric with UTF-8 compatible names. +# TYPE "my.dotted.metric" gauge +{"my.dotted.metric", "error.message"="Not Found"} 1 diff --git a/collector/helper.go b/collector/helper.go index 21dddf887c..1bddb21610 100644 --- a/collector/helper.go +++ b/collector/helper.go @@ -32,6 +32,16 @@ func readUintFromFile(path string) (uint64, error) { return value, nil } +// readIntFromFile reads a signed integer from the given file. Use it for +// values the kernel prints as signed (e.g. "%ld") and that can be negative. +func readIntFromFile(path string) (int64, error) { + data, err := os.ReadFile(path) + if err != nil { + return 0, err + } + return strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64) +} + var metricNameRegex = regexp.MustCompile(`_*[^0-9A-Za-z_]+_*`) // SanitizeMetricName sanitize the given metric name by replacing invalid characters by underscores. diff --git a/collector/helper_linux.go b/collector/helper_linux.go new file mode 100644 index 0000000000..0f9b1d6f81 --- /dev/null +++ b/collector/helper_linux.go @@ -0,0 +1,28 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package collector + +import ( + "regexp" + "strings" +) + +var hwmonInvalidMetricChars = regexp.MustCompile("[^a-z0-9:_]") + +func cleanMetricName(name string) string { + lower := strings.ToLower(name) + replaced := hwmonInvalidMetricChars.ReplaceAllLiteralString(lower, "_") + cleaned := strings.Trim(replaced, "_") + return cleaned +} diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index 833782446a..b9e3e17d8d 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -37,11 +37,10 @@ var ( collectorHWmonSensorInclude = kingpin.Flag("collector.hwmon.sensor-include", "Regexp of hwmon sensor to include (mutually exclusive to sensor-exclude).").String() collectorHWmonSensorExclude = kingpin.Flag("collector.hwmon.sensor-exclude", "Regexp of hwmon sensor to exclude (mutually exclusive to sensor-include).").String() - hwmonInvalidMetricChars = regexp.MustCompile("[^a-z0-9:_]") - hwmonFilenameFormat = regexp.MustCompile(`^(?P[^0-9]+)(?P[0-9]*)?(_(?P.+))?$`) - hwmonLabelDesc = []string{"chip", "sensor"} - hwmonChipNameLabelDesc = []string{"chip", "chip_name"} - hwmonSensorTypes = []string{ + hwmonFilenameFormat = regexp.MustCompile(`^(?P[^0-9]+)(?P[0-9]*)?(_(?P.+))?$`) + hwmonLabelDesc = []string{"chip", "sensor"} + hwmonChipNameLabelDesc = []string{"chip", "chip_name"} + hwmonSensorTypes = []string{ "vrm", "beep_enable", "update_interval", "in", "cpu", "fan", "pwm", "temp", "curr", "power", "energy", "humidity", "intrusion", "freq", @@ -61,7 +60,6 @@ type hwMonCollector struct { // NewHwMonCollector returns a new Collector exposing /sys/class/hwmon stats // (similar to lm-sensors). func NewHwMonCollector(logger *slog.Logger) (Collector, error) { - return &hwMonCollector{ logger: logger, deviceFilter: newDeviceFilter(*collectorHWmonChipExclude, *collectorHWmonChipInclude), @@ -69,14 +67,7 @@ func NewHwMonCollector(logger *slog.Logger) (Collector, error) { }, nil } -func cleanMetricName(name string) string { - lower := strings.ToLower(name) - replaced := hwmonInvalidMetricChars.ReplaceAllLiteralString(lower, "_") - cleaned := strings.Trim(replaced, "_") - return cleaned -} - -func addValueFile(data map[string]map[string]string, sensor string, prop string, file string) { +func addValueFile(data map[string]map[string]string, sensor, prop, file string) { raw, err := sysReadFile(file) if err != nil { return diff --git a/collector/hwmon_linux_test.go b/collector/hwmon_linux_test.go index 3206b0e09d..24db47e32a 100644 --- a/collector/hwmon_linux_test.go +++ b/collector/hwmon_linux_test.go @@ -18,76 +18,12 @@ package collector import ( "io" "log/slog" - "os" - "path/filepath" "slices" "testing" "github.com/prometheus/client_golang/prometheus" ) -// fakeHwmon describes a single hwmon node to materialize under a temporary -// /sys layout. The collector's hwmonName function reads the parent of the -// `device` symlink to derive a chip label, which is what produces the -// collision we need to test. -type fakeHwmon struct { - hwmonDir string // e.g. "hwmon3" - device string // parent device dir name, e.g. "asus-nb-wmi". Empty disables the device symlink. - name string // contents of the optional `name` file - files map[string]string // sensor file basename -> content -} - -// buildFakeSysfs writes a minimal /sys tree containing the supplied hwmon -// nodes and returns the path that should be passed as *sysPath. Each -// non-empty `device` shares a common /sys/devices/platform/ -// directory so two hwmon entries can collide on chip name. -func buildFakeSysfs(t *testing.T, hwmons []fakeHwmon) string { - t.Helper() - - sysRoot := t.TempDir() - classHwmon := filepath.Join(sysRoot, "class", "hwmon") - if err := os.MkdirAll(classHwmon, 0o755); err != nil { - t.Fatalf("mkdir class/hwmon: %v", err) - } - - for _, h := range hwmons { - var hwmonReal string - if h.device != "" { - hwmonReal = filepath.Join(sysRoot, "devices", "platform", h.device, "hwmon", h.hwmonDir) - } else { - hwmonReal = filepath.Join(sysRoot, "devices", "virtual", "hwmon", h.hwmonDir) - } - if err := os.MkdirAll(hwmonReal, 0o755); err != nil { - t.Fatalf("mkdir %s: %v", hwmonReal, err) - } - - if h.device != "" { - deviceTarget := filepath.Join(sysRoot, "devices", "platform", h.device) - if err := os.Symlink(deviceTarget, filepath.Join(hwmonReal, "device")); err != nil { - t.Fatalf("symlink device: %v", err) - } - } - - if h.name != "" { - if err := os.WriteFile(filepath.Join(hwmonReal, "name"), []byte(h.name+"\n"), 0o644); err != nil { - t.Fatalf("write name: %v", err) - } - } - - for fname, content := range h.files { - if err := os.WriteFile(filepath.Join(hwmonReal, fname), []byte(content+"\n"), 0o644); err != nil { - t.Fatalf("write %s: %v", fname, err) - } - } - - if err := os.Symlink(hwmonReal, filepath.Join(classHwmon, h.hwmonDir)); err != nil { - t.Fatalf("symlink class/hwmon: %v", err) - } - } - - return sysRoot -} - // gatherChipLabels runs the collector through a registry and returns the // observed `chip` label values across all metrics. It also surfaces any // gather error — which is the failure mode #3637 reported. @@ -138,31 +74,9 @@ func newTestHwmonCollector() *hwMonCollector { // that triggered #3637 on ASUS WMI laptops — must produce distinct chip // labels and not error during gather. func TestHwmonDuplicateChipNamesAreDisambiguated(t *testing.T) { - hwmons := []fakeHwmon{ - { - hwmonDir: "hwmon6", - device: "asus-nb-wmi", - name: "asus", - files: map[string]string{ - "pwm1": "128", - "pwm1_enable": "2", - }, - }, - { - hwmonDir: "hwmon7", - device: "asus-nb-wmi", - name: "asus_wmi_sensors", - files: map[string]string{ - "pwm1": "200", - "pwm1_enable": "2", - }, - }, - } - - sysRoot := buildFakeSysfs(t, hwmons) prev := *sysPath t.Cleanup(func() { *sysPath = prev }) - *sysPath = sysRoot + *sysPath = "fixtures/sys/hwmon/duplicate_chip_names" chips, err := gatherChipLabels(t, newTestHwmonCollector()) if err != nil { @@ -185,25 +99,9 @@ func TestHwmonDuplicateChipNamesAreDisambiguated(t *testing.T) { // When chip names are already unique, the collector must leave them alone // — no surprise suffixes for unaffected users. func TestHwmonUniqueChipNamesAreUnchanged(t *testing.T) { - hwmons := []fakeHwmon{ - { - hwmonDir: "hwmon0", - device: "coretemp.0", - name: "coretemp", - files: map[string]string{"temp1_input": "42000"}, - }, - { - hwmonDir: "hwmon1", - device: "coretemp.1", - name: "coretemp", - files: map[string]string{"temp1_input": "43000"}, - }, - } - - sysRoot := buildFakeSysfs(t, hwmons) prev := *sysPath t.Cleanup(func() { *sysPath = prev }) - *sysPath = sysRoot + *sysPath = "fixtures/sys/hwmon/unique_chip_names" chips, err := gatherChipLabels(t, newTestHwmonCollector()) if err != nil { @@ -221,25 +119,9 @@ func TestHwmonUniqueChipNamesAreUnchanged(t *testing.T) { // disambiguator collapses too. We must still emit unique chip labels by // falling back to the hwmonX basename. func TestHwmonDuplicateChipNamesWithSameNameFile(t *testing.T) { - hwmons := []fakeHwmon{ - { - hwmonDir: "hwmon3", - device: "asus-nb-wmi", - name: "asus", - files: map[string]string{"pwm1_enable": "2"}, - }, - { - hwmonDir: "hwmon4", - device: "asus-nb-wmi", - name: "asus", - files: map[string]string{"pwm1_enable": "2"}, - }, - } - - sysRoot := buildFakeSysfs(t, hwmons) prev := *sysPath t.Cleanup(func() { *sysPath = prev }) - *sysPath = sysRoot + *sysPath = "fixtures/sys/hwmon/same_name_file" chips, err := gatherChipLabels(t, newTestHwmonCollector()) if err != nil { diff --git a/collector/infiniband_linux.go b/collector/infiniband_linux.go index fb83c152a6..6a869ef188 100644 --- a/collector/infiniband_linux.go +++ b/collector/infiniband_linux.go @@ -147,18 +147,18 @@ func NewInfiniBandCollector(logger *slog.Logger) (Collector, error) { return &i, nil } -func (c *infinibandCollector) pushMetric(ch chan<- prometheus.Metric, name string, value uint64, deviceName string, port string, valueType prometheus.ValueType) { +func (c *infinibandCollector) pushMetric(ch chan<- prometheus.Metric, name string, value uint64, deviceName, port string, valueType prometheus.ValueType) { ch <- prometheus.MustNewConstMetric(c.metricDescs[name], valueType, float64(value), deviceName, port) } -func (c *infinibandCollector) pushCounter(ch chan<- prometheus.Metric, name string, value *uint64, deviceName string, port string) { +func (c *infinibandCollector) pushCounter(ch chan<- prometheus.Metric, name string, value *uint64, deviceName, port string) { if value != nil { c.pushMetric(ch, name, *value, deviceName, port, prometheus.CounterValue) } } func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error { - devices, err := c.fs.InfiniBandClass() + deviceNames, err := c.fs.InfiniBandClassDevices() if err != nil { if errors.Is(err, os.ErrNotExist) { c.logger.Debug("infiniband statistics not found, skipping") @@ -167,11 +167,16 @@ func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error { return fmt.Errorf("error obtaining InfiniBand class info: %w", err) } - for _, device := range devices { - if c.deviceFilter.ignored(device.Name) { + for _, name := range deviceNames { + if c.deviceFilter.ignored(name) { continue } + device, err := c.fs.InfiniBandDevice(name) + if err != nil { + return fmt.Errorf("error obtaining InfiniBand device info: %w", err) + } + infoDesc := prometheus.NewDesc( prometheus.BuildFQName(namespace, c.subsystem, "info"), "Non-numeric data from /sys/class/infiniband/, value is always 1.", @@ -221,7 +226,7 @@ func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error { // port.HwCounters if port.HwCounters.Lifespan != nil { - c.pushMetric(ch, "lifespan_seconds", *(port.HwCounters.Lifespan)/1000, port.Name, portStr, prometheus.GaugeValue) + c.pushMetric(ch, "lifespan_seconds", *port.HwCounters.Lifespan/1000, port.Name, portStr, prometheus.GaugeValue) } c.pushCounter(ch, "duplicate_requests_packets_total", port.HwCounters.DuplicateRequest, port.Name, portStr) diff --git a/collector/interrupts_linux.go b/collector/interrupts_linux.go index d70b0e042f..2cbcc912ff 100644 --- a/collector/interrupts_linux.go +++ b/collector/interrupts_linux.go @@ -27,9 +27,7 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -var ( - interruptLabelNames = []string{"cpu", "type", "info", "devices"} -) +var interruptLabelNames = []string{"cpu", "type", "info", "devices"} func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) (err error) { interrupts, err := getInterrupts() diff --git a/collector/interrupts_linux_test.go b/collector/interrupts_linux_test.go index d920916524..b9b319301d 100644 --- a/collector/interrupts_linux_test.go +++ b/collector/interrupts_linux_test.go @@ -47,7 +47,6 @@ func TestInterrupts(t *testing.T) { if want, got := "i8042", interrupts["12"].devices; want != got { t.Errorf("want interrupts devices %s, got %s", want, got) } - } // https://github.com/prometheus/node_exporter/issues/2557 diff --git a/collector/interrupts_openbsd.go b/collector/interrupts_openbsd.go index b9ab0d906d..82c02e1f9b 100644 --- a/collector/interrupts_openbsd.go +++ b/collector/interrupts_openbsd.go @@ -94,9 +94,7 @@ sysctl_intr(struct intr *intr, int idx) */ import "C" -var ( - interruptLabelNames = []string{"cpu", "type", "devices"} -) +var interruptLabelNames = []string{"cpu", "type", "devices"} func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) error { interrupts, err := getInterrupts() diff --git a/collector/interrupts_openbsd_amd64.go b/collector/interrupts_openbsd_amd64.go index fae7905d60..e019362d54 100644 --- a/collector/interrupts_openbsd_amd64.go +++ b/collector/interrupts_openbsd_amd64.go @@ -104,7 +104,7 @@ type interrupt struct { } func getInterrupts() (map[string]interrupt, error) { - var interrupts = map[string]interrupt{} + interrupts := map[string]interrupt{} n := nintr() for i := _C_int(0); i < n; i++ { diff --git a/collector/kernel_hung_linux.go b/collector/kernel_hung_linux.go index d77c504b6c..2a7894387a 100644 --- a/collector/kernel_hung_linux.go +++ b/collector/kernel_hung_linux.go @@ -45,12 +45,10 @@ func NewKernelHungCollector(logger *slog.Logger) (Collector, error) { }, nil } -var ( - kernelHungTasks = prometheus.NewDesc( - prometheus.BuildFQName(namespace, "kernel_hung", "tasks_total"), - "Total number of tasks that have been detected as hung since the system booted.", - nil, nil, - ) +var kernelHungTasks = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "kernel_hung", "tasks_total"), + "Total number of tasks that have been detected as hung since the system booted.", + nil, nil, ) func (c *kernelHungCollector) Update(ch chan<- prometheus.Metric) error { diff --git a/collector/ksmd_linux.go b/collector/ksmd_linux.go index 2a68f43f94..2634f05da7 100644 --- a/collector/ksmd_linux.go +++ b/collector/ksmd_linux.go @@ -1,4 +1,4 @@ -// Copyright 2015 The Prometheus Authors +// Copyright The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -16,68 +16,144 @@ package collector import ( - "fmt" + "errors" "log/slog" + "os" "path/filepath" "github.com/prometheus/client_golang/prometheus" ) +const ksmdCollectorSubsystem = "ksmd" + var ( - ksmdFiles = []string{"full_scans", "merge_across_nodes", "pages_shared", "pages_sharing", - "pages_to_scan", "pages_unshared", "pages_volatile", "run", "sleep_millisecs"} + ksmdFiles = []string{ + "full_scans", + "general_profit", + "merge_across_nodes", + "pages_shared", + "pages_sharing", + "pages_to_scan", + "pages_unshared", + "pages_volatile", + "run", + "sleep_millisecs", + } + + // Help text from https://docs.kernel.org/admin-guide/mm/ksm.html + ksmdFullScansDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "full_scans_total"), + "How many times all mergeable areas have been scanned.", + nil, nil, + ) + ksmdGeneralProfitDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "general_profit_bytes"), + "How effective is KSM. ksm_saved_pages * sizeof(page) - (all_rmap_items) * sizeof(rmap_item)", + nil, nil, + ) + ksmdMergeAcrossNodesDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "merge_across_nodes"), + "Specifies if pages from different NUMA nodes can be merged.", + nil, nil, + ) + ksmdPagesSharedDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "pages_shared"), + "How many shared pages are being used.", + nil, nil, + ) + ksmdPagesSharingDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "pages_sharing"), + "How many more sites are sharing them i.e. how much saved.", + nil, nil, + ) + ksmdPagesToScanDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "pages_to_scan"), + "How many pages to scan before ksmd goes to sleep.", + nil, nil, + ) + ksmdPagesUnsharedDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "pages_unshared"), + "How many pages unique but repeatedly checked for merging.", + nil, nil, + ) + ksmdPagesVolatileDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "pages_volatile"), + "How many pages changing too fast to be placed in a tree.", + nil, nil, + ) + ksmdRunDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "run"), + "The status of ksmd. stopped = 0, running = 1", + nil, nil, + ) + ksmdSleepSecondsDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, ksmdCollectorSubsystem, "sleep_seconds"), + "How many seconds ksmd should sleep before next scan.", + nil, nil, + ) ) type ksmdCollector struct { - metricDescs map[string]*prometheus.Desc - logger *slog.Logger + logger *slog.Logger } func init() { - registerCollector("ksmd", defaultDisabled, NewKsmdCollector) -} - -func getCanonicalMetricName(filename string) string { - switch filename { - case "full_scans": - return filename + "_total" - case "sleep_millisecs": - return "sleep_seconds" - default: - return filename - } + registerCollector(ksmdCollectorSubsystem, defaultDisabled, NewKsmdCollector) } // NewKsmdCollector returns a new Collector exposing kernel/system statistics. func NewKsmdCollector(logger *slog.Logger) (Collector, error) { - subsystem := "ksmd" - descs := make(map[string]*prometheus.Desc) - - for _, n := range ksmdFiles { - descs[n] = prometheus.NewDesc( - prometheus.BuildFQName(namespace, subsystem, getCanonicalMetricName(n)), - fmt.Sprintf("ksmd '%s' file.", n), nil, nil) - } - return &ksmdCollector{descs, logger}, nil + return &ksmdCollector{logger: logger}, nil } // Update implements Collector and exposes kernel and system statistics. func (c *ksmdCollector) Update(ch chan<- prometheus.Metric) error { for _, n := range ksmdFiles { - val, err := readUintFromFile(sysFilePath(filepath.Join("kernel/mm/ksm", n))) + path := sysFilePath(filepath.Join("kernel/mm/ksm", n)) + + var v float64 + var err error + if n == "general_profit" { + // The kernel prints general_profit as a signed value, which is + // negative when KSM costs more than it saves. + var val int64 + val, err = readIntFromFile(path) + v = float64(val) + } else { + var val uint64 + val, err = readUintFromFile(path) + v = float64(val) + } if err != nil { + if errors.Is(err, os.ErrNotExist) { + c.logger.Debug("ksmd file not found, skipping", "file", n) + continue + } return err } - t := prometheus.GaugeValue - v := float64(val) switch n { case "full_scans": - t = prometheus.CounterValue + ch <- prometheus.MustNewConstMetric(ksmdFullScansDesc, prometheus.CounterValue, v) + case "general_profit": + ch <- prometheus.MustNewConstMetric(ksmdGeneralProfitDesc, prometheus.GaugeValue, v) + case "merge_across_nodes": + ch <- prometheus.MustNewConstMetric(ksmdMergeAcrossNodesDesc, prometheus.GaugeValue, v) + case "pages_shared": + ch <- prometheus.MustNewConstMetric(ksmdPagesSharedDesc, prometheus.GaugeValue, v) + case "pages_sharing": + ch <- prometheus.MustNewConstMetric(ksmdPagesSharingDesc, prometheus.GaugeValue, v) + case "pages_to_scan": + ch <- prometheus.MustNewConstMetric(ksmdPagesToScanDesc, prometheus.GaugeValue, v) + case "pages_unshared": + ch <- prometheus.MustNewConstMetric(ksmdPagesUnsharedDesc, prometheus.GaugeValue, v) + case "pages_volatile": + ch <- prometheus.MustNewConstMetric(ksmdPagesVolatileDesc, prometheus.GaugeValue, v) + case "run": + ch <- prometheus.MustNewConstMetric(ksmdRunDesc, prometheus.GaugeValue, v) case "sleep_millisecs": - v /= 1000 + ch <- prometheus.MustNewConstMetric(ksmdSleepSecondsDesc, prometheus.GaugeValue, v/1000) } - ch <- prometheus.MustNewConstMetric(c.metricDescs[n], t, v) } return nil diff --git a/collector/loadavg_solaris.go b/collector/loadavg_solaris.go index 31b1105ef1..8e3a1259dd 100644 --- a/collector/loadavg_solaris.go +++ b/collector/loadavg_solaris.go @@ -27,14 +27,12 @@ import "C" func kstatToFloat(ks *kstat.KStat, kstatKey string) float64 { kstatValue, err := ks.GetNamed(kstatKey) - if err != nil { panic(err) } kstatLoadavg, err := strconv.ParseFloat( fmt.Sprintf("%.2f", float64(kstatValue.UintVal)/C.FSCALE), 64) - if err != nil { panic(err) } @@ -51,7 +49,6 @@ func getLoad() ([]float64, error) { defer tok.Close() ks, err := tok.Lookup("unix", 0, "system_misc") - if err != nil { panic(err) } diff --git a/collector/logind_linux_test.go b/collector/logind_linux_test.go index b2592a74e0..9673a2c91b 100644 --- a/collector/logind_linux_test.go +++ b/collector/logind_linux_test.go @@ -82,7 +82,6 @@ func TestLogindCollectorKnownStringOrOther(t *testing.T) { if actual != expected { t.Errorf("knownStringOrOther failed: got %q, expected %q.", actual, expected) } - } func TestLogindCollectorCollectMetrics(t *testing.T) { diff --git a/collector/mdadm_linux.go b/collector/mdadm_linux.go index 433e25c56b..37a7f8d619 100644 --- a/collector/mdadm_linux.go +++ b/collector/mdadm_linux.go @@ -117,7 +117,6 @@ var ( func (c *mdadmCollector) Update(ch chan<- prometheus.Metric) error { procFS, err := procfs.NewFS(*procPath) - if err != nil { return fmt.Errorf("failed to open procfs: %w", err) } diff --git a/collector/mdadm_linux_test.go b/collector/mdadm_linux_test.go index 6aa216232e..db20c99b60 100644 --- a/collector/mdadm_linux_test.go +++ b/collector/mdadm_linux_test.go @@ -285,6 +285,10 @@ func TestMdadmStats(t *testing.T) { } close(sink) }() + // Drain the sink so the Update goroutine ends before the test does and + // cannot race with flag parsing in the next test. + for range sink { + } err = testutil.GatherAndCompare(reg, strings.NewReader(testcase)) if err != nil { diff --git a/collector/meminfo_numa_linux.go b/collector/meminfo_numa_linux.go index cd494928a3..0023b80fa1 100644 --- a/collector/meminfo_numa_linux.go +++ b/collector/meminfo_numa_linux.go @@ -79,9 +79,7 @@ func (c *meminfoNumaCollector) Update(ch chan<- prometheus.Metric) error { } func getMemInfoNuma() ([]meminfoMetric, error) { - var ( - metrics []meminfoMetric - ) + var metrics []meminfoMetric nodes, err := filepath.Glob(sysFilePath("devices/system/node/node[0-9]*")) if err != nil { diff --git a/collector/mountstats_linux.go b/collector/mountstats_linux.go index c71e6e95e1..9e2d871f69 100644 --- a/collector/mountstats_linux.go +++ b/collector/mountstats_linux.go @@ -24,10 +24,8 @@ import ( "github.com/prometheus/procfs" ) -var ( - // 64-bit float mantissa: https://en.wikipedia.org/wiki/Double-precision_floating-point_format - float64Mantissa uint64 = 9007199254740992 -) +// 64-bit float mantissa: https://en.wikipedia.org/wiki/Double-precision_floating-point_format +var float64Mantissa uint64 = 9007199254740992 type mountStatsCollector struct { // General statistics diff --git a/collector/netclass_rtnl_linux.go b/collector/netclass_rtnl_linux.go index c71957cc29..93724d6f90 100644 --- a/collector/netclass_rtnl_linux.go +++ b/collector/netclass_rtnl_linux.go @@ -105,7 +105,7 @@ func (c *netClassCollector) netClassRTNLUpdate(ch chan<- prometheus.Metric) erro ) infoValue := 1.0 - var ifalias = "" + ifalias := "" if msg.Attributes.Alias != nil { ifalias = *msg.Attributes.Alias } @@ -205,7 +205,6 @@ func (c *netClassCollector) getNetClassInfoRTNL() ([]rtnetlink.LinkMessage, erro lMsgs, err := conn.Link.List() return lMsgs, err - } func (c *netClassCollector) getLinkModes() ([]*ethtool.LinkMode, error) { diff --git a/collector/netdev_darwin.go b/collector/netdev_darwin.go index 7b70a0d09e..866b852547 100644 --- a/collector/netdev_darwin.go +++ b/collector/netdev_darwin.go @@ -84,7 +84,7 @@ func getIfaceData(index int) (*ifMsghdr2, error) { unix.CTL_NET, unix.AF_LINK, 0, // NETLINK_GENERIC: functions not specific to a type of iface - 2, //IFMIB_IFDATA: per-interface data table + 2, // IFMIB_IFDATA: per-interface data table int32(index), 1, // IFDATA_GENERAL: generic stats for all kinds of ifaces } diff --git a/collector/netdev_openbsd_amd64.go b/collector/netdev_openbsd_amd64.go index 62b706d047..41301728c1 100644 --- a/collector/netdev_openbsd_amd64.go +++ b/collector/netdev_openbsd_amd64.go @@ -17,7 +17,6 @@ package collector import ( "log/slog" - "unsafe" "golang.org/x/sys/unix" diff --git a/collector/netstat_descs_drift_test.go b/collector/netstat_descs_drift_test.go new file mode 100644 index 0000000000..d79d7310b9 --- /dev/null +++ b/collector/netstat_descs_drift_test.go @@ -0,0 +1,77 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package collector + +import ( + "os" + "reflect" + "regexp" + "sort" + "testing" + + "github.com/prometheus/procfs" +) + +// TestNetStatDescsInSync guards against drift between the committed descriptor +// table (netstat_descs_linux.go) and the procfs structs it is generated from. +// If a procfs upgrade adds or removes statistics fields, this test fails until +// the table is regenerated with `GOOS=linux go generate ./collector`. +func TestNetStatDescsInSync(t *testing.T) { + src, err := os.ReadFile("netstat_descs_linux.go") + if err != nil { + t.Fatalf("read netstat_descs_linux.go: %v", err) + } + + re := regexp.MustCompile(`"([A-Za-z0-9]+_[A-Za-z0-9]+)": prometheus\.NewDesc`) + committed := map[string]bool{} + for _, m := range re.FindAllSubmatch(src, -1) { + committed[string(m[1])] = true + } + + var n procfs.ProcNetstat + var s procfs.ProcSnmp + var s6 procfs.ProcSnmp6 + expected := map[string]bool{} + for _, v := range []any{ + n.TcpExt, n.IpExt, + s.Ip, s.Icmp, s.IcmpMsg, s.Tcp, s.Udp, s.UdpLite, + s6.Ip6, s6.Icmp6, s6.Udp6, s6.UdpLite6, + } { + tt := reflect.TypeOf(v) + for f := range tt.Fields() { + if f.Type != reflect.TypeFor[*float64]() { + continue + } + expected[tt.Name()+"_"+f.Name] = true + } + } + + var missing, extra []string + for k := range expected { + if !committed[k] { + missing = append(missing, k) + } + } + for k := range committed { + if !expected[k] { + extra = append(extra, k) + } + } + sort.Strings(missing) + sort.Strings(extra) + + if len(missing) != 0 || len(extra) != 0 { + t.Fatalf("netstat_descs_linux.go is out of sync with procfs (missing=%v extra=%v); run `GOOS=linux go generate ./collector`", missing, extra) + } +} diff --git a/collector/netstat_descs_gen.go b/collector/netstat_descs_gen.go new file mode 100644 index 0000000000..3027a82aa5 --- /dev/null +++ b/collector/netstat_descs_gen.go @@ -0,0 +1,96 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build ignore + +// Command netstat-descs regenerates collector/netstat_descs_linux.go from the +// procfs netstat/snmp/snmp6 statistics structs. +// +// Run from the repository root: +// +// go generate ./collector +// +// The output is a table of explicit, source-visible prometheus.Desc literals +// (one per *float64 field of each statistics struct), keyed by +// "_". Keeping the descriptors as literals lets the AST-based +// documentation tooling read them and avoids allocating descriptors per scrape. +package main + +import ( + "fmt" + "os" + "reflect" + "strings" + + "github.com/prometheus/procfs" +) + +type entry struct { + key string + help string +} + +func main() { + var n procfs.ProcNetstat + var s procfs.ProcSnmp + var s6 procfs.ProcSnmp6 + + structs := []any{ + n.TcpExt, n.IpExt, + s.Ip, s.Icmp, s.IcmpMsg, s.Tcp, s.Udp, s.UdpLite, + s6.Ip6, s6.Icmp6, s6.Udp6, s6.UdpLite6, + } + + var b strings.Builder + b.WriteString(`// Code generated by netstat-descs; DO NOT EDIT. + +//go:build !nonetstat + +package collector + +import ( + "github.com/prometheus/client_golang/prometheus" +) + +// netStatMetricDescs returns the explicit, source-visible metric descriptors +// for every field of the procfs netstat/snmp/snmp6 statistics structs, keyed by +// "_". Descriptors are allocated once; collection looks them up +// by name instead of calling prometheus.NewDesc on every scrape. +func netStatMetricDescs() map[string]*prometheus.Desc { + return map[string]*prometheus.Desc{ +`) + + count := 0 + for _, v := range structs { + t := reflect.TypeOf(v) + proto := t.Name() + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Type != reflect.TypeFor[*float64]() { + continue + } + key := proto + "_" + f.Name + help := "Statistic " + proto + f.Name + "." + fmt.Fprintf(&b, "\t\t%q: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, netStatsSubsystem, %q),\n\t\t\t%q,\n\t\t\tnil, nil),\n", key, key, help) + count++ + } + } + + b.WriteString("\t}\n}\n") + + if err := os.WriteFile("netstat_descs_linux.go", []byte(b.String()), 0o644); err != nil { + fmt.Fprintln(os.Stderr, "write netstat_descs_linux.go:", err) + os.Exit(1) + } + fmt.Fprintf(os.Stderr, "wrote netstat_descs_linux.go (%d descriptors)\n", count) +} diff --git a/collector/netstat_descs_linux.go b/collector/netstat_descs_linux.go new file mode 100644 index 0000000000..1abc6ebec1 --- /dev/null +++ b/collector/netstat_descs_linux.go @@ -0,0 +1,1262 @@ +// Code generated by netstat-descs; DO NOT EDIT. + +//go:build !nonetstat + +package collector + +import ( + "github.com/prometheus/client_golang/prometheus" +) + +// netStatMetricDescs returns the explicit, source-visible metric descriptors +// for every field of the procfs netstat/snmp/snmp6 statistics structs, keyed by +// "_". Descriptors are allocated once; collection looks them up +// by name instead of calling prometheus.NewDesc on every scrape. +func netStatMetricDescs() map[string]*prometheus.Desc { + return map[string]*prometheus.Desc{ + "TcpExt_SyncookiesSent": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_SyncookiesSent"), + "Statistic TcpExtSyncookiesSent.", + nil, nil), + "TcpExt_SyncookiesRecv": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_SyncookiesRecv"), + "Statistic TcpExtSyncookiesRecv.", + nil, nil), + "TcpExt_SyncookiesFailed": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_SyncookiesFailed"), + "Statistic TcpExtSyncookiesFailed.", + nil, nil), + "TcpExt_EmbryonicRsts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_EmbryonicRsts"), + "Statistic TcpExtEmbryonicRsts.", + nil, nil), + "TcpExt_PruneCalled": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_PruneCalled"), + "Statistic TcpExtPruneCalled.", + nil, nil), + "TcpExt_RcvPruned": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_RcvPruned"), + "Statistic TcpExtRcvPruned.", + nil, nil), + "TcpExt_OfoPruned": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_OfoPruned"), + "Statistic TcpExtOfoPruned.", + nil, nil), + "TcpExt_OutOfWindowIcmps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_OutOfWindowIcmps"), + "Statistic TcpExtOutOfWindowIcmps.", + nil, nil), + "TcpExt_LockDroppedIcmps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_LockDroppedIcmps"), + "Statistic TcpExtLockDroppedIcmps.", + nil, nil), + "TcpExt_ArpFilter": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_ArpFilter"), + "Statistic TcpExtArpFilter.", + nil, nil), + "TcpExt_TW": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TW"), + "Statistic TcpExtTW.", + nil, nil), + "TcpExt_TWRecycled": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TWRecycled"), + "Statistic TcpExtTWRecycled.", + nil, nil), + "TcpExt_TWKilled": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TWKilled"), + "Statistic TcpExtTWKilled.", + nil, nil), + "TcpExt_PAWSActive": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_PAWSActive"), + "Statistic TcpExtPAWSActive.", + nil, nil), + "TcpExt_PAWSEstab": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_PAWSEstab"), + "Statistic TcpExtPAWSEstab.", + nil, nil), + "TcpExt_DelayedACKs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_DelayedACKs"), + "Statistic TcpExtDelayedACKs.", + nil, nil), + "TcpExt_DelayedACKLocked": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_DelayedACKLocked"), + "Statistic TcpExtDelayedACKLocked.", + nil, nil), + "TcpExt_DelayedACKLost": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_DelayedACKLost"), + "Statistic TcpExtDelayedACKLost.", + nil, nil), + "TcpExt_ListenOverflows": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_ListenOverflows"), + "Statistic TcpExtListenOverflows.", + nil, nil), + "TcpExt_ListenDrops": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_ListenDrops"), + "Statistic TcpExtListenDrops.", + nil, nil), + "TcpExt_TCPHPHits": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPHPHits"), + "Statistic TcpExtTCPHPHits.", + nil, nil), + "TcpExt_TCPPureAcks": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPPureAcks"), + "Statistic TcpExtTCPPureAcks.", + nil, nil), + "TcpExt_TCPHPAcks": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPHPAcks"), + "Statistic TcpExtTCPHPAcks.", + nil, nil), + "TcpExt_TCPRenoRecovery": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRenoRecovery"), + "Statistic TcpExtTCPRenoRecovery.", + nil, nil), + "TcpExt_TCPSackRecovery": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSackRecovery"), + "Statistic TcpExtTCPSackRecovery.", + nil, nil), + "TcpExt_TCPSACKReneging": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSACKReneging"), + "Statistic TcpExtTCPSACKReneging.", + nil, nil), + "TcpExt_TCPSACKReorder": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSACKReorder"), + "Statistic TcpExtTCPSACKReorder.", + nil, nil), + "TcpExt_TCPRenoReorder": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRenoReorder"), + "Statistic TcpExtTCPRenoReorder.", + nil, nil), + "TcpExt_TCPTSReorder": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPTSReorder"), + "Statistic TcpExtTCPTSReorder.", + nil, nil), + "TcpExt_TCPFullUndo": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFullUndo"), + "Statistic TcpExtTCPFullUndo.", + nil, nil), + "TcpExt_TCPPartialUndo": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPPartialUndo"), + "Statistic TcpExtTCPPartialUndo.", + nil, nil), + "TcpExt_TCPDSACKUndo": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDSACKUndo"), + "Statistic TcpExtTCPDSACKUndo.", + nil, nil), + "TcpExt_TCPLossUndo": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPLossUndo"), + "Statistic TcpExtTCPLossUndo.", + nil, nil), + "TcpExt_TCPLostRetransmit": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPLostRetransmit"), + "Statistic TcpExtTCPLostRetransmit.", + nil, nil), + "TcpExt_TCPRenoFailures": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRenoFailures"), + "Statistic TcpExtTCPRenoFailures.", + nil, nil), + "TcpExt_TCPSackFailures": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSackFailures"), + "Statistic TcpExtTCPSackFailures.", + nil, nil), + "TcpExt_TCPLossFailures": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPLossFailures"), + "Statistic TcpExtTCPLossFailures.", + nil, nil), + "TcpExt_TCPFastRetrans": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastRetrans"), + "Statistic TcpExtTCPFastRetrans.", + nil, nil), + "TcpExt_TCPSlowStartRetrans": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSlowStartRetrans"), + "Statistic TcpExtTCPSlowStartRetrans.", + nil, nil), + "TcpExt_TCPTimeouts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPTimeouts"), + "Statistic TcpExtTCPTimeouts.", + nil, nil), + "TcpExt_TCPLossProbes": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPLossProbes"), + "Statistic TcpExtTCPLossProbes.", + nil, nil), + "TcpExt_TCPLossProbeRecovery": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPLossProbeRecovery"), + "Statistic TcpExtTCPLossProbeRecovery.", + nil, nil), + "TcpExt_TCPRenoRecoveryFail": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRenoRecoveryFail"), + "Statistic TcpExtTCPRenoRecoveryFail.", + nil, nil), + "TcpExt_TCPSackRecoveryFail": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSackRecoveryFail"), + "Statistic TcpExtTCPSackRecoveryFail.", + nil, nil), + "TcpExt_TCPRcvCollapsed": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRcvCollapsed"), + "Statistic TcpExtTCPRcvCollapsed.", + nil, nil), + "TcpExt_TCPDSACKOldSent": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDSACKOldSent"), + "Statistic TcpExtTCPDSACKOldSent.", + nil, nil), + "TcpExt_TCPDSACKOfoSent": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDSACKOfoSent"), + "Statistic TcpExtTCPDSACKOfoSent.", + nil, nil), + "TcpExt_TCPDSACKRecv": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDSACKRecv"), + "Statistic TcpExtTCPDSACKRecv.", + nil, nil), + "TcpExt_TCPDSACKOfoRecv": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDSACKOfoRecv"), + "Statistic TcpExtTCPDSACKOfoRecv.", + nil, nil), + "TcpExt_TCPAbortOnData": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPAbortOnData"), + "Statistic TcpExtTCPAbortOnData.", + nil, nil), + "TcpExt_TCPAbortOnClose": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPAbortOnClose"), + "Statistic TcpExtTCPAbortOnClose.", + nil, nil), + "TcpExt_TCPAbortOnMemory": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPAbortOnMemory"), + "Statistic TcpExtTCPAbortOnMemory.", + nil, nil), + "TcpExt_TCPAbortOnTimeout": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPAbortOnTimeout"), + "Statistic TcpExtTCPAbortOnTimeout.", + nil, nil), + "TcpExt_TCPAbortOnLinger": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPAbortOnLinger"), + "Statistic TcpExtTCPAbortOnLinger.", + nil, nil), + "TcpExt_TCPAbortFailed": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPAbortFailed"), + "Statistic TcpExtTCPAbortFailed.", + nil, nil), + "TcpExt_TCPMemoryPressures": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMemoryPressures"), + "Statistic TcpExtTCPMemoryPressures.", + nil, nil), + "TcpExt_TCPMemoryPressuresChrono": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMemoryPressuresChrono"), + "Statistic TcpExtTCPMemoryPressuresChrono.", + nil, nil), + "TcpExt_TCPSACKDiscard": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSACKDiscard"), + "Statistic TcpExtTCPSACKDiscard.", + nil, nil), + "TcpExt_TCPDSACKIgnoredOld": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDSACKIgnoredOld"), + "Statistic TcpExtTCPDSACKIgnoredOld.", + nil, nil), + "TcpExt_TCPDSACKIgnoredNoUndo": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDSACKIgnoredNoUndo"), + "Statistic TcpExtTCPDSACKIgnoredNoUndo.", + nil, nil), + "TcpExt_TCPSpuriousRTOs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSpuriousRTOs"), + "Statistic TcpExtTCPSpuriousRTOs.", + nil, nil), + "TcpExt_TCPMD5NotFound": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMD5NotFound"), + "Statistic TcpExtTCPMD5NotFound.", + nil, nil), + "TcpExt_TCPMD5Unexpected": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMD5Unexpected"), + "Statistic TcpExtTCPMD5Unexpected.", + nil, nil), + "TcpExt_TCPMD5Failure": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMD5Failure"), + "Statistic TcpExtTCPMD5Failure.", + nil, nil), + "TcpExt_TCPSackShifted": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSackShifted"), + "Statistic TcpExtTCPSackShifted.", + nil, nil), + "TcpExt_TCPSackMerged": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSackMerged"), + "Statistic TcpExtTCPSackMerged.", + nil, nil), + "TcpExt_TCPSackShiftFallback": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSackShiftFallback"), + "Statistic TcpExtTCPSackShiftFallback.", + nil, nil), + "TcpExt_TCPBacklogDrop": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPBacklogDrop"), + "Statistic TcpExtTCPBacklogDrop.", + nil, nil), + "TcpExt_PFMemallocDrop": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_PFMemallocDrop"), + "Statistic TcpExtPFMemallocDrop.", + nil, nil), + "TcpExt_TCPMinTTLDrop": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMinTTLDrop"), + "Statistic TcpExtTCPMinTTLDrop.", + nil, nil), + "TcpExt_TCPDeferAcceptDrop": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDeferAcceptDrop"), + "Statistic TcpExtTCPDeferAcceptDrop.", + nil, nil), + "TcpExt_IPReversePathFilter": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_IPReversePathFilter"), + "Statistic TcpExtIPReversePathFilter.", + nil, nil), + "TcpExt_TCPTimeWaitOverflow": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPTimeWaitOverflow"), + "Statistic TcpExtTCPTimeWaitOverflow.", + nil, nil), + "TcpExt_TCPReqQFullDoCookies": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPReqQFullDoCookies"), + "Statistic TcpExtTCPReqQFullDoCookies.", + nil, nil), + "TcpExt_TCPReqQFullDrop": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPReqQFullDrop"), + "Statistic TcpExtTCPReqQFullDrop.", + nil, nil), + "TcpExt_TCPRetransFail": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRetransFail"), + "Statistic TcpExtTCPRetransFail.", + nil, nil), + "TcpExt_TCPRcvCoalesce": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRcvCoalesce"), + "Statistic TcpExtTCPRcvCoalesce.", + nil, nil), + "TcpExt_TCPRcvQDrop": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPRcvQDrop"), + "Statistic TcpExtTCPRcvQDrop.", + nil, nil), + "TcpExt_TCPOFOQueue": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPOFOQueue"), + "Statistic TcpExtTCPOFOQueue.", + nil, nil), + "TcpExt_TCPOFODrop": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPOFODrop"), + "Statistic TcpExtTCPOFODrop.", + nil, nil), + "TcpExt_TCPOFOMerge": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPOFOMerge"), + "Statistic TcpExtTCPOFOMerge.", + nil, nil), + "TcpExt_TCPChallengeACK": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPChallengeACK"), + "Statistic TcpExtTCPChallengeACK.", + nil, nil), + "TcpExt_TCPSYNChallenge": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSYNChallenge"), + "Statistic TcpExtTCPSYNChallenge.", + nil, nil), + "TcpExt_TCPFastOpenActive": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastOpenActive"), + "Statistic TcpExtTCPFastOpenActive.", + nil, nil), + "TcpExt_TCPFastOpenActiveFail": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastOpenActiveFail"), + "Statistic TcpExtTCPFastOpenActiveFail.", + nil, nil), + "TcpExt_TCPFastOpenPassive": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastOpenPassive"), + "Statistic TcpExtTCPFastOpenPassive.", + nil, nil), + "TcpExt_TCPFastOpenPassiveFail": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastOpenPassiveFail"), + "Statistic TcpExtTCPFastOpenPassiveFail.", + nil, nil), + "TcpExt_TCPFastOpenListenOverflow": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastOpenListenOverflow"), + "Statistic TcpExtTCPFastOpenListenOverflow.", + nil, nil), + "TcpExt_TCPFastOpenCookieReqd": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastOpenCookieReqd"), + "Statistic TcpExtTCPFastOpenCookieReqd.", + nil, nil), + "TcpExt_TCPFastOpenBlackhole": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFastOpenBlackhole"), + "Statistic TcpExtTCPFastOpenBlackhole.", + nil, nil), + "TcpExt_TCPSpuriousRtxHostQueues": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSpuriousRtxHostQueues"), + "Statistic TcpExtTCPSpuriousRtxHostQueues.", + nil, nil), + "TcpExt_BusyPollRxPackets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_BusyPollRxPackets"), + "Statistic TcpExtBusyPollRxPackets.", + nil, nil), + "TcpExt_TCPAutoCorking": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPAutoCorking"), + "Statistic TcpExtTCPAutoCorking.", + nil, nil), + "TcpExt_TCPFromZeroWindowAdv": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFromZeroWindowAdv"), + "Statistic TcpExtTCPFromZeroWindowAdv.", + nil, nil), + "TcpExt_TCPToZeroWindowAdv": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPToZeroWindowAdv"), + "Statistic TcpExtTCPToZeroWindowAdv.", + nil, nil), + "TcpExt_TCPWantZeroWindowAdv": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPWantZeroWindowAdv"), + "Statistic TcpExtTCPWantZeroWindowAdv.", + nil, nil), + "TcpExt_TCPSynRetrans": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSynRetrans"), + "Statistic TcpExtTCPSynRetrans.", + nil, nil), + "TcpExt_TCPOrigDataSent": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPOrigDataSent"), + "Statistic TcpExtTCPOrigDataSent.", + nil, nil), + "TcpExt_TCPHystartTrainDetect": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPHystartTrainDetect"), + "Statistic TcpExtTCPHystartTrainDetect.", + nil, nil), + "TcpExt_TCPHystartTrainCwnd": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPHystartTrainCwnd"), + "Statistic TcpExtTCPHystartTrainCwnd.", + nil, nil), + "TcpExt_TCPHystartDelayDetect": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPHystartDelayDetect"), + "Statistic TcpExtTCPHystartDelayDetect.", + nil, nil), + "TcpExt_TCPHystartDelayCwnd": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPHystartDelayCwnd"), + "Statistic TcpExtTCPHystartDelayCwnd.", + nil, nil), + "TcpExt_TCPACKSkippedSynRecv": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPACKSkippedSynRecv"), + "Statistic TcpExtTCPACKSkippedSynRecv.", + nil, nil), + "TcpExt_TCPACKSkippedPAWS": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPACKSkippedPAWS"), + "Statistic TcpExtTCPACKSkippedPAWS.", + nil, nil), + "TcpExt_TCPACKSkippedSeq": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPACKSkippedSeq"), + "Statistic TcpExtTCPACKSkippedSeq.", + nil, nil), + "TcpExt_TCPACKSkippedFinWait2": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPACKSkippedFinWait2"), + "Statistic TcpExtTCPACKSkippedFinWait2.", + nil, nil), + "TcpExt_TCPACKSkippedTimeWait": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPACKSkippedTimeWait"), + "Statistic TcpExtTCPACKSkippedTimeWait.", + nil, nil), + "TcpExt_TCPACKSkippedChallenge": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPACKSkippedChallenge"), + "Statistic TcpExtTCPACKSkippedChallenge.", + nil, nil), + "TcpExt_TCPWinProbe": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPWinProbe"), + "Statistic TcpExtTCPWinProbe.", + nil, nil), + "TcpExt_TCPKeepAlive": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPKeepAlive"), + "Statistic TcpExtTCPKeepAlive.", + nil, nil), + "TcpExt_TCPMTUPFail": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMTUPFail"), + "Statistic TcpExtTCPMTUPFail.", + nil, nil), + "TcpExt_TCPMTUPSuccess": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPMTUPSuccess"), + "Statistic TcpExtTCPMTUPSuccess.", + nil, nil), + "TcpExt_TCPWqueueTooBig": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPWqueueTooBig"), + "Statistic TcpExtTCPWqueueTooBig.", + nil, nil), + "TcpExt_TCPLoss": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPLoss"), + "Statistic TcpExtTCPLoss.", + nil, nil), + "TcpExt_PAWSPassive": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_PAWSPassive"), + "Statistic TcpExtPAWSPassive.", + nil, nil), + "TcpExt_TCPForwardRetrans": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPForwardRetrans"), + "Statistic TcpExtTCPForwardRetrans.", + nil, nil), + "TcpExt_TCPSchedulerFailed": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPSchedulerFailed"), + "Statistic TcpExtTCPSchedulerFailed.", + nil, nil), + "TcpExt_TCPPrequeued": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPPrequeued"), + "Statistic TcpExtTCPPrequeued.", + nil, nil), + "TcpExt_TCPDirectCopyFromBacklog": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDirectCopyFromBacklog"), + "Statistic TcpExtTCPDirectCopyFromBacklog.", + nil, nil), + "TcpExt_TCPDirectCopyFromPrequeue": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPDirectCopyFromPrequeue"), + "Statistic TcpExtTCPDirectCopyFromPrequeue.", + nil, nil), + "TcpExt_TCPPrequeueDropped": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPPrequeueDropped"), + "Statistic TcpExtTCPPrequeueDropped.", + nil, nil), + "TcpExt_TCPFACKReorder": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPFACKReorder"), + "Statistic TcpExtTCPFACKReorder.", + nil, nil), + "TcpExt_TCPHPHitsToUser": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "TcpExt_TCPHPHitsToUser"), + "Statistic TcpExtTCPHPHitsToUser.", + nil, nil), + "IpExt_InNoRoutes": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InNoRoutes"), + "Statistic IpExtInNoRoutes.", + nil, nil), + "IpExt_InTruncatedPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InTruncatedPkts"), + "Statistic IpExtInTruncatedPkts.", + nil, nil), + "IpExt_InMcastPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InMcastPkts"), + "Statistic IpExtInMcastPkts.", + nil, nil), + "IpExt_OutMcastPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_OutMcastPkts"), + "Statistic IpExtOutMcastPkts.", + nil, nil), + "IpExt_InBcastPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InBcastPkts"), + "Statistic IpExtInBcastPkts.", + nil, nil), + "IpExt_OutBcastPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_OutBcastPkts"), + "Statistic IpExtOutBcastPkts.", + nil, nil), + "IpExt_InOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InOctets"), + "Statistic IpExtInOctets.", + nil, nil), + "IpExt_OutOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_OutOctets"), + "Statistic IpExtOutOctets.", + nil, nil), + "IpExt_InMcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InMcastOctets"), + "Statistic IpExtInMcastOctets.", + nil, nil), + "IpExt_OutMcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_OutMcastOctets"), + "Statistic IpExtOutMcastOctets.", + nil, nil), + "IpExt_InBcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InBcastOctets"), + "Statistic IpExtInBcastOctets.", + nil, nil), + "IpExt_OutBcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_OutBcastOctets"), + "Statistic IpExtOutBcastOctets.", + nil, nil), + "IpExt_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InCsumErrors"), + "Statistic IpExtInCsumErrors.", + nil, nil), + "IpExt_InNoECTPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InNoECTPkts"), + "Statistic IpExtInNoECTPkts.", + nil, nil), + "IpExt_InECT1Pkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InECT1Pkts"), + "Statistic IpExtInECT1Pkts.", + nil, nil), + "IpExt_InECT0Pkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InECT0Pkts"), + "Statistic IpExtInECT0Pkts.", + nil, nil), + "IpExt_InCEPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_InCEPkts"), + "Statistic IpExtInCEPkts.", + nil, nil), + "IpExt_ReasmOverlaps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IpExt_ReasmOverlaps"), + "Statistic IpExtReasmOverlaps.", + nil, nil), + "Ip_Forwarding": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_Forwarding"), + "Statistic IpForwarding.", + nil, nil), + "Ip_DefaultTTL": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_DefaultTTL"), + "Statistic IpDefaultTTL.", + nil, nil), + "Ip_InReceives": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_InReceives"), + "Statistic IpInReceives.", + nil, nil), + "Ip_InHdrErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_InHdrErrors"), + "Statistic IpInHdrErrors.", + nil, nil), + "Ip_InAddrErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_InAddrErrors"), + "Statistic IpInAddrErrors.", + nil, nil), + "Ip_ForwDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_ForwDatagrams"), + "Statistic IpForwDatagrams.", + nil, nil), + "Ip_InUnknownProtos": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_InUnknownProtos"), + "Statistic IpInUnknownProtos.", + nil, nil), + "Ip_InDiscards": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_InDiscards"), + "Statistic IpInDiscards.", + nil, nil), + "Ip_InDelivers": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_InDelivers"), + "Statistic IpInDelivers.", + nil, nil), + "Ip_OutRequests": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_OutRequests"), + "Statistic IpOutRequests.", + nil, nil), + "Ip_OutDiscards": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_OutDiscards"), + "Statistic IpOutDiscards.", + nil, nil), + "Ip_OutNoRoutes": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_OutNoRoutes"), + "Statistic IpOutNoRoutes.", + nil, nil), + "Ip_ReasmTimeout": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_ReasmTimeout"), + "Statistic IpReasmTimeout.", + nil, nil), + "Ip_ReasmReqds": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_ReasmReqds"), + "Statistic IpReasmReqds.", + nil, nil), + "Ip_ReasmOKs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_ReasmOKs"), + "Statistic IpReasmOKs.", + nil, nil), + "Ip_ReasmFails": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_ReasmFails"), + "Statistic IpReasmFails.", + nil, nil), + "Ip_FragOKs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_FragOKs"), + "Statistic IpFragOKs.", + nil, nil), + "Ip_FragFails": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_FragFails"), + "Statistic IpFragFails.", + nil, nil), + "Ip_FragCreates": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip_FragCreates"), + "Statistic IpFragCreates.", + nil, nil), + "Icmp_InMsgs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InMsgs"), + "Statistic IcmpInMsgs.", + nil, nil), + "Icmp_InErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InErrors"), + "Statistic IcmpInErrors.", + nil, nil), + "Icmp_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InCsumErrors"), + "Statistic IcmpInCsumErrors.", + nil, nil), + "Icmp_InDestUnreachs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InDestUnreachs"), + "Statistic IcmpInDestUnreachs.", + nil, nil), + "Icmp_InTimeExcds": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InTimeExcds"), + "Statistic IcmpInTimeExcds.", + nil, nil), + "Icmp_InParmProbs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InParmProbs"), + "Statistic IcmpInParmProbs.", + nil, nil), + "Icmp_InSrcQuenchs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InSrcQuenchs"), + "Statistic IcmpInSrcQuenchs.", + nil, nil), + "Icmp_InRedirects": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InRedirects"), + "Statistic IcmpInRedirects.", + nil, nil), + "Icmp_InEchos": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InEchos"), + "Statistic IcmpInEchos.", + nil, nil), + "Icmp_InEchoReps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InEchoReps"), + "Statistic IcmpInEchoReps.", + nil, nil), + "Icmp_InTimestamps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InTimestamps"), + "Statistic IcmpInTimestamps.", + nil, nil), + "Icmp_InTimestampReps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InTimestampReps"), + "Statistic IcmpInTimestampReps.", + nil, nil), + "Icmp_InAddrMasks": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InAddrMasks"), + "Statistic IcmpInAddrMasks.", + nil, nil), + "Icmp_InAddrMaskReps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_InAddrMaskReps"), + "Statistic IcmpInAddrMaskReps.", + nil, nil), + "Icmp_OutMsgs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutMsgs"), + "Statistic IcmpOutMsgs.", + nil, nil), + "Icmp_OutErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutErrors"), + "Statistic IcmpOutErrors.", + nil, nil), + "Icmp_OutDestUnreachs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutDestUnreachs"), + "Statistic IcmpOutDestUnreachs.", + nil, nil), + "Icmp_OutTimeExcds": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutTimeExcds"), + "Statistic IcmpOutTimeExcds.", + nil, nil), + "Icmp_OutParmProbs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutParmProbs"), + "Statistic IcmpOutParmProbs.", + nil, nil), + "Icmp_OutSrcQuenchs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutSrcQuenchs"), + "Statistic IcmpOutSrcQuenchs.", + nil, nil), + "Icmp_OutRedirects": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutRedirects"), + "Statistic IcmpOutRedirects.", + nil, nil), + "Icmp_OutEchos": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutEchos"), + "Statistic IcmpOutEchos.", + nil, nil), + "Icmp_OutEchoReps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutEchoReps"), + "Statistic IcmpOutEchoReps.", + nil, nil), + "Icmp_OutTimestamps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutTimestamps"), + "Statistic IcmpOutTimestamps.", + nil, nil), + "Icmp_OutTimestampReps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutTimestampReps"), + "Statistic IcmpOutTimestampReps.", + nil, nil), + "Icmp_OutAddrMasks": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutAddrMasks"), + "Statistic IcmpOutAddrMasks.", + nil, nil), + "Icmp_OutAddrMaskReps": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp_OutAddrMaskReps"), + "Statistic IcmpOutAddrMaskReps.", + nil, nil), + "IcmpMsg_InType3": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IcmpMsg_InType3"), + "Statistic IcmpMsgInType3.", + nil, nil), + "IcmpMsg_OutType3": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "IcmpMsg_OutType3"), + "Statistic IcmpMsgOutType3.", + nil, nil), + "Tcp_RtoAlgorithm": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_RtoAlgorithm"), + "Statistic TcpRtoAlgorithm.", + nil, nil), + "Tcp_RtoMin": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_RtoMin"), + "Statistic TcpRtoMin.", + nil, nil), + "Tcp_RtoMax": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_RtoMax"), + "Statistic TcpRtoMax.", + nil, nil), + "Tcp_MaxConn": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_MaxConn"), + "Statistic TcpMaxConn.", + nil, nil), + "Tcp_ActiveOpens": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_ActiveOpens"), + "Statistic TcpActiveOpens.", + nil, nil), + "Tcp_PassiveOpens": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_PassiveOpens"), + "Statistic TcpPassiveOpens.", + nil, nil), + "Tcp_AttemptFails": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_AttemptFails"), + "Statistic TcpAttemptFails.", + nil, nil), + "Tcp_EstabResets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_EstabResets"), + "Statistic TcpEstabResets.", + nil, nil), + "Tcp_CurrEstab": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_CurrEstab"), + "Statistic TcpCurrEstab.", + nil, nil), + "Tcp_InSegs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_InSegs"), + "Statistic TcpInSegs.", + nil, nil), + "Tcp_OutSegs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_OutSegs"), + "Statistic TcpOutSegs.", + nil, nil), + "Tcp_RetransSegs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_RetransSegs"), + "Statistic TcpRetransSegs.", + nil, nil), + "Tcp_InErrs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_InErrs"), + "Statistic TcpInErrs.", + nil, nil), + "Tcp_OutRsts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_OutRsts"), + "Statistic TcpOutRsts.", + nil, nil), + "Tcp_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Tcp_InCsumErrors"), + "Statistic TcpInCsumErrors.", + nil, nil), + "Udp_InDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_InDatagrams"), + "Statistic UdpInDatagrams.", + nil, nil), + "Udp_NoPorts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_NoPorts"), + "Statistic UdpNoPorts.", + nil, nil), + "Udp_InErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_InErrors"), + "Statistic UdpInErrors.", + nil, nil), + "Udp_OutDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_OutDatagrams"), + "Statistic UdpOutDatagrams.", + nil, nil), + "Udp_RcvbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_RcvbufErrors"), + "Statistic UdpRcvbufErrors.", + nil, nil), + "Udp_SndbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_SndbufErrors"), + "Statistic UdpSndbufErrors.", + nil, nil), + "Udp_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_InCsumErrors"), + "Statistic UdpInCsumErrors.", + nil, nil), + "Udp_IgnoredMulti": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp_IgnoredMulti"), + "Statistic UdpIgnoredMulti.", + nil, nil), + "UdpLite_InDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_InDatagrams"), + "Statistic UdpLiteInDatagrams.", + nil, nil), + "UdpLite_NoPorts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_NoPorts"), + "Statistic UdpLiteNoPorts.", + nil, nil), + "UdpLite_InErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_InErrors"), + "Statistic UdpLiteInErrors.", + nil, nil), + "UdpLite_OutDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_OutDatagrams"), + "Statistic UdpLiteOutDatagrams.", + nil, nil), + "UdpLite_RcvbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_RcvbufErrors"), + "Statistic UdpLiteRcvbufErrors.", + nil, nil), + "UdpLite_SndbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_SndbufErrors"), + "Statistic UdpLiteSndbufErrors.", + nil, nil), + "UdpLite_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_InCsumErrors"), + "Statistic UdpLiteInCsumErrors.", + nil, nil), + "UdpLite_IgnoredMulti": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite_IgnoredMulti"), + "Statistic UdpLiteIgnoredMulti.", + nil, nil), + "Ip6_InReceives": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InReceives"), + "Statistic Ip6InReceives.", + nil, nil), + "Ip6_InHdrErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InHdrErrors"), + "Statistic Ip6InHdrErrors.", + nil, nil), + "Ip6_InTooBigErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InTooBigErrors"), + "Statistic Ip6InTooBigErrors.", + nil, nil), + "Ip6_InNoRoutes": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InNoRoutes"), + "Statistic Ip6InNoRoutes.", + nil, nil), + "Ip6_InAddrErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InAddrErrors"), + "Statistic Ip6InAddrErrors.", + nil, nil), + "Ip6_InUnknownProtos": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InUnknownProtos"), + "Statistic Ip6InUnknownProtos.", + nil, nil), + "Ip6_InTruncatedPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InTruncatedPkts"), + "Statistic Ip6InTruncatedPkts.", + nil, nil), + "Ip6_InDiscards": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InDiscards"), + "Statistic Ip6InDiscards.", + nil, nil), + "Ip6_InDelivers": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InDelivers"), + "Statistic Ip6InDelivers.", + nil, nil), + "Ip6_OutForwDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutForwDatagrams"), + "Statistic Ip6OutForwDatagrams.", + nil, nil), + "Ip6_OutRequests": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutRequests"), + "Statistic Ip6OutRequests.", + nil, nil), + "Ip6_OutDiscards": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutDiscards"), + "Statistic Ip6OutDiscards.", + nil, nil), + "Ip6_OutNoRoutes": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutNoRoutes"), + "Statistic Ip6OutNoRoutes.", + nil, nil), + "Ip6_ReasmTimeout": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_ReasmTimeout"), + "Statistic Ip6ReasmTimeout.", + nil, nil), + "Ip6_ReasmReqds": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_ReasmReqds"), + "Statistic Ip6ReasmReqds.", + nil, nil), + "Ip6_ReasmOKs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_ReasmOKs"), + "Statistic Ip6ReasmOKs.", + nil, nil), + "Ip6_ReasmFails": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_ReasmFails"), + "Statistic Ip6ReasmFails.", + nil, nil), + "Ip6_FragOKs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_FragOKs"), + "Statistic Ip6FragOKs.", + nil, nil), + "Ip6_FragFails": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_FragFails"), + "Statistic Ip6FragFails.", + nil, nil), + "Ip6_FragCreates": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_FragCreates"), + "Statistic Ip6FragCreates.", + nil, nil), + "Ip6_InMcastPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InMcastPkts"), + "Statistic Ip6InMcastPkts.", + nil, nil), + "Ip6_OutMcastPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutMcastPkts"), + "Statistic Ip6OutMcastPkts.", + nil, nil), + "Ip6_InOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InOctets"), + "Statistic Ip6InOctets.", + nil, nil), + "Ip6_OutOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutOctets"), + "Statistic Ip6OutOctets.", + nil, nil), + "Ip6_InMcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InMcastOctets"), + "Statistic Ip6InMcastOctets.", + nil, nil), + "Ip6_OutMcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutMcastOctets"), + "Statistic Ip6OutMcastOctets.", + nil, nil), + "Ip6_InBcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InBcastOctets"), + "Statistic Ip6InBcastOctets.", + nil, nil), + "Ip6_OutBcastOctets": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_OutBcastOctets"), + "Statistic Ip6OutBcastOctets.", + nil, nil), + "Ip6_InNoECTPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InNoECTPkts"), + "Statistic Ip6InNoECTPkts.", + nil, nil), + "Ip6_InECT1Pkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InECT1Pkts"), + "Statistic Ip6InECT1Pkts.", + nil, nil), + "Ip6_InECT0Pkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InECT0Pkts"), + "Statistic Ip6InECT0Pkts.", + nil, nil), + "Ip6_InCEPkts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Ip6_InCEPkts"), + "Statistic Ip6InCEPkts.", + nil, nil), + "Icmp6_InMsgs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InMsgs"), + "Statistic Icmp6InMsgs.", + nil, nil), + "Icmp6_InErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InErrors"), + "Statistic Icmp6InErrors.", + nil, nil), + "Icmp6_OutMsgs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutMsgs"), + "Statistic Icmp6OutMsgs.", + nil, nil), + "Icmp6_OutErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutErrors"), + "Statistic Icmp6OutErrors.", + nil, nil), + "Icmp6_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InCsumErrors"), + "Statistic Icmp6InCsumErrors.", + nil, nil), + "Icmp6_InDestUnreachs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InDestUnreachs"), + "Statistic Icmp6InDestUnreachs.", + nil, nil), + "Icmp6_InPktTooBigs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InPktTooBigs"), + "Statistic Icmp6InPktTooBigs.", + nil, nil), + "Icmp6_InTimeExcds": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InTimeExcds"), + "Statistic Icmp6InTimeExcds.", + nil, nil), + "Icmp6_InParmProblems": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InParmProblems"), + "Statistic Icmp6InParmProblems.", + nil, nil), + "Icmp6_InEchos": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InEchos"), + "Statistic Icmp6InEchos.", + nil, nil), + "Icmp6_InEchoReplies": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InEchoReplies"), + "Statistic Icmp6InEchoReplies.", + nil, nil), + "Icmp6_InGroupMembQueries": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InGroupMembQueries"), + "Statistic Icmp6InGroupMembQueries.", + nil, nil), + "Icmp6_InGroupMembResponses": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InGroupMembResponses"), + "Statistic Icmp6InGroupMembResponses.", + nil, nil), + "Icmp6_InGroupMembReductions": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InGroupMembReductions"), + "Statistic Icmp6InGroupMembReductions.", + nil, nil), + "Icmp6_InRouterSolicits": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InRouterSolicits"), + "Statistic Icmp6InRouterSolicits.", + nil, nil), + "Icmp6_InRouterAdvertisements": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InRouterAdvertisements"), + "Statistic Icmp6InRouterAdvertisements.", + nil, nil), + "Icmp6_InNeighborSolicits": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InNeighborSolicits"), + "Statistic Icmp6InNeighborSolicits.", + nil, nil), + "Icmp6_InNeighborAdvertisements": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InNeighborAdvertisements"), + "Statistic Icmp6InNeighborAdvertisements.", + nil, nil), + "Icmp6_InRedirects": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InRedirects"), + "Statistic Icmp6InRedirects.", + nil, nil), + "Icmp6_InMLDv2Reports": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InMLDv2Reports"), + "Statistic Icmp6InMLDv2Reports.", + nil, nil), + "Icmp6_OutDestUnreachs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutDestUnreachs"), + "Statistic Icmp6OutDestUnreachs.", + nil, nil), + "Icmp6_OutPktTooBigs": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutPktTooBigs"), + "Statistic Icmp6OutPktTooBigs.", + nil, nil), + "Icmp6_OutTimeExcds": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutTimeExcds"), + "Statistic Icmp6OutTimeExcds.", + nil, nil), + "Icmp6_OutParmProblems": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutParmProblems"), + "Statistic Icmp6OutParmProblems.", + nil, nil), + "Icmp6_OutEchos": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutEchos"), + "Statistic Icmp6OutEchos.", + nil, nil), + "Icmp6_OutEchoReplies": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutEchoReplies"), + "Statistic Icmp6OutEchoReplies.", + nil, nil), + "Icmp6_OutGroupMembQueries": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutGroupMembQueries"), + "Statistic Icmp6OutGroupMembQueries.", + nil, nil), + "Icmp6_OutGroupMembResponses": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutGroupMembResponses"), + "Statistic Icmp6OutGroupMembResponses.", + nil, nil), + "Icmp6_OutGroupMembReductions": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutGroupMembReductions"), + "Statistic Icmp6OutGroupMembReductions.", + nil, nil), + "Icmp6_OutRouterSolicits": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutRouterSolicits"), + "Statistic Icmp6OutRouterSolicits.", + nil, nil), + "Icmp6_OutRouterAdvertisements": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutRouterAdvertisements"), + "Statistic Icmp6OutRouterAdvertisements.", + nil, nil), + "Icmp6_OutNeighborSolicits": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutNeighborSolicits"), + "Statistic Icmp6OutNeighborSolicits.", + nil, nil), + "Icmp6_OutNeighborAdvertisements": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutNeighborAdvertisements"), + "Statistic Icmp6OutNeighborAdvertisements.", + nil, nil), + "Icmp6_OutRedirects": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutRedirects"), + "Statistic Icmp6OutRedirects.", + nil, nil), + "Icmp6_OutMLDv2Reports": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutMLDv2Reports"), + "Statistic Icmp6OutMLDv2Reports.", + nil, nil), + "Icmp6_InType1": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InType1"), + "Statistic Icmp6InType1.", + nil, nil), + "Icmp6_InType134": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InType134"), + "Statistic Icmp6InType134.", + nil, nil), + "Icmp6_InType135": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InType135"), + "Statistic Icmp6InType135.", + nil, nil), + "Icmp6_InType136": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InType136"), + "Statistic Icmp6InType136.", + nil, nil), + "Icmp6_InType143": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_InType143"), + "Statistic Icmp6InType143.", + nil, nil), + "Icmp6_OutType133": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutType133"), + "Statistic Icmp6OutType133.", + nil, nil), + "Icmp6_OutType135": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutType135"), + "Statistic Icmp6OutType135.", + nil, nil), + "Icmp6_OutType136": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutType136"), + "Statistic Icmp6OutType136.", + nil, nil), + "Icmp6_OutType143": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Icmp6_OutType143"), + "Statistic Icmp6OutType143.", + nil, nil), + "Udp6_InDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_InDatagrams"), + "Statistic Udp6InDatagrams.", + nil, nil), + "Udp6_NoPorts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_NoPorts"), + "Statistic Udp6NoPorts.", + nil, nil), + "Udp6_InErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_InErrors"), + "Statistic Udp6InErrors.", + nil, nil), + "Udp6_OutDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_OutDatagrams"), + "Statistic Udp6OutDatagrams.", + nil, nil), + "Udp6_RcvbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_RcvbufErrors"), + "Statistic Udp6RcvbufErrors.", + nil, nil), + "Udp6_SndbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_SndbufErrors"), + "Statistic Udp6SndbufErrors.", + nil, nil), + "Udp6_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_InCsumErrors"), + "Statistic Udp6InCsumErrors.", + nil, nil), + "Udp6_IgnoredMulti": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "Udp6_IgnoredMulti"), + "Statistic Udp6IgnoredMulti.", + nil, nil), + "UdpLite6_InDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite6_InDatagrams"), + "Statistic UdpLite6InDatagrams.", + nil, nil), + "UdpLite6_NoPorts": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite6_NoPorts"), + "Statistic UdpLite6NoPorts.", + nil, nil), + "UdpLite6_InErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite6_InErrors"), + "Statistic UdpLite6InErrors.", + nil, nil), + "UdpLite6_OutDatagrams": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite6_OutDatagrams"), + "Statistic UdpLite6OutDatagrams.", + nil, nil), + "UdpLite6_RcvbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite6_RcvbufErrors"), + "Statistic UdpLite6RcvbufErrors.", + nil, nil), + "UdpLite6_SndbufErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite6_SndbufErrors"), + "Statistic UdpLite6SndbufErrors.", + nil, nil), + "UdpLite6_InCsumErrors": prometheus.NewDesc( + prometheus.BuildFQName(namespace, netStatsSubsystem, "UdpLite6_InCsumErrors"), + "Statistic UdpLite6InCsumErrors.", + nil, nil), + } +} diff --git a/collector/netstat_freebsd.go b/collector/netstat_freebsd.go index 39d6259844..a670501599 100644 --- a/collector/netstat_freebsd.go +++ b/collector/netstat_freebsd.go @@ -253,10 +253,8 @@ func getData(queryString string, expectedSize int) ([]byte, error) { } func getTCPStates() ([]uint64, error) { - // This sysctl returns an array of uint64 data, err := sysctlRaw("net.inet.tcp.states") - if err != nil { return nil, err } @@ -344,7 +342,6 @@ func (c *netStatCollector) Update(ch chan<- prometheus.Metric) error { } tcpConnsPerStates, err := getTCPStates() - if err != nil { return err } @@ -357,7 +354,6 @@ func (c *netStatCollector) Update(ch chan<- prometheus.Metric) error { // Used by tests to mock unix.SysctlRaw func getFreeBSDDataMock(sysctl string) []byte { - if sysctl == "net.inet.tcp.stats" { tcpStats := C.struct_tcpstat{ tcps_sndtotal: 1234, diff --git a/collector/netstat_freebsd_test.go b/collector/netstat_freebsd_test.go index a08f5ab6ec..cebdff3d8a 100644 --- a/collector/netstat_freebsd_test.go +++ b/collector/netstat_freebsd_test.go @@ -77,7 +77,6 @@ func TestGetTCPStatesMetrics(t *testing.T) { t.Errorf("unexpected %s value: want %f, got %f", tcpStates[i], want, got) } } - } func TestGetUDPMetrics(t *testing.T) { diff --git a/collector/netstat_linux.go b/collector/netstat_linux.go index 5065a19af3..5ffa8e5ec4 100644 --- a/collector/netstat_linux.go +++ b/collector/netstat_linux.go @@ -13,22 +13,20 @@ //go:build !nonetstat +// Regenerate the explicit descriptor table after a procfs upgrade: +//go:generate go run netstat_descs_gen.go + package collector import ( - "bufio" - "errors" "fmt" - "io" "log/slog" - "maps" - "os" + "reflect" "regexp" - "strconv" - "strings" "github.com/alecthomas/kingpin/v2" "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/procfs" ) const ( @@ -37,9 +35,15 @@ const ( var ( netStatFields = kingpin.Flag("collector.netstat.fields", "Regexp of fields to return for netstat collector.").Default("^(.*_(InErrors|InErrs)|Ip_Forwarding|Ip(6|Ext)_(InOctets|OutOctets)|Icmp6?_(InMsgs|OutMsgs)|TcpExt_(Listen.*|Syncookies.*|TCPSynRetrans|TCPTimeouts|TCPOFOQueue|TCPRcvQDrop)|Tcp_(ActiveOpens|InSegs|OutSegs|OutRsts|PassiveOpens|RetransSegs|CurrEstab)|Udp6?_(InDatagrams|OutDatagrams|NoPorts|RcvbufErrors|SndbufErrors))$").String() + + // netStatDescs holds the explicit metric descriptors, allocated once at + // package init (see netstat_descs_linux.go) so collection never calls + // prometheus.NewDesc per scrape. + netStatDescs = netStatMetricDescs() ) type netStatCollector struct { + proc procfs.Proc fieldPattern *regexp.Regexp logger *slog.Logger } @@ -52,124 +56,79 @@ func init() { // a new Collector exposing network stats. func NewNetStatCollector(logger *slog.Logger) (Collector, error) { pattern := regexp.MustCompile(*netStatFields) + fs, err := procfs.NewFS(*procPath) + if err != nil { + return nil, fmt.Errorf("failed to open procfs: %w", err) + } + + // Network statistics in /proc/net are network namespace local. Reading + // them via the current process' /proc/self/net keeps the same semantics + // while allowing the use of the procfs parsers. + proc, err := fs.Self() + if err != nil { + return nil, fmt.Errorf("failed to open /proc/self: %w", err) + } + return &netStatCollector{ + proc: proc, fieldPattern: pattern, logger: logger, }, nil } func (c *netStatCollector) Update(ch chan<- prometheus.Metric) error { - netStats, err := getNetStats(procFilePath("net/netstat")) + netStats, err := c.proc.Netstat() if err != nil { return fmt.Errorf("couldn't get netstats: %w", err) } - snmpStats, err := getNetStats(procFilePath("net/snmp")) + snmpStats, err := c.proc.Snmp() if err != nil { return fmt.Errorf("couldn't get SNMP stats: %w", err) } - snmp6Stats, err := getSNMP6Stats(procFilePath("net/snmp6")) + snmp6Stats, err := c.proc.Snmp6() if err != nil { return fmt.Errorf("couldn't get SNMP6 stats: %w", err) } - // Merge the results of snmpStats into netStats (collisions are possible, but - // we know that the keys are always unique for the given use case). - maps.Copy(netStats, snmpStats) - maps.Copy(netStats, snmp6Stats) - for protocol, protocolStats := range netStats { - for name, value := range protocolStats { - key := protocol + "_" + name - v, err := strconv.ParseFloat(value, 64) - if err != nil { - return fmt.Errorf("invalid value %s in netstats: %w", value, err) - } - if !c.fieldPattern.MatchString(key) { - continue - } - ch <- prometheus.MustNewConstMetric( - prometheus.NewDesc( - prometheus.BuildFQName(namespace, netStatsSubsystem, key), - fmt.Sprintf("Statistic %s.", protocol+name), - nil, nil, - ), - prometheus.UntypedValue, v, - ) - } - } - return nil -} -func getNetStats(fileName string) (map[string]map[string]string, error) { - file, err := os.Open(fileName) - if err != nil { - return nil, err - } - defer file.Close() + c.emitStruct(ch, netStats.TcpExt) + c.emitStruct(ch, netStats.IpExt) + c.emitStruct(ch, snmpStats.Ip) + c.emitStruct(ch, snmpStats.Icmp) + c.emitStruct(ch, snmpStats.IcmpMsg) + c.emitStruct(ch, snmpStats.Tcp) + c.emitStruct(ch, snmpStats.Udp) + c.emitStruct(ch, snmpStats.UdpLite) + c.emitStruct(ch, snmp6Stats.Ip6) + c.emitStruct(ch, snmp6Stats.Icmp6) + c.emitStruct(ch, snmp6Stats.Udp6) + c.emitStruct(ch, snmp6Stats.UdpLite6) - return parseNetStats(file, fileName) + return nil } -func parseNetStats(r io.Reader, fileName string) (map[string]map[string]string, error) { - var ( - netStats = map[string]map[string]string{} - scanner = bufio.NewScanner(r) - ) - - for scanner.Scan() { - nameParts := strings.Split(scanner.Text(), " ") - scanner.Scan() - valueParts := strings.Split(scanner.Text(), " ") - // Remove trailing :. - protocol := nameParts[0][:len(nameParts[0])-1] - netStats[protocol] = map[string]string{} - if len(nameParts) != len(valueParts) { - return nil, fmt.Errorf("mismatch field count mismatch in %s: %s", - fileName, protocol) - } - for i := 1; i < len(nameParts); i++ { - netStats[protocol][nameParts[i]] = valueParts[i] - } - } - - return netStats, scanner.Err() -} +// emitStruct emits one metric per non-nil field of a procfs netstat/snmp +// statistics struct, using the struct's type name as the protocol name and +// looking up the pre-built descriptor by "_". +func (c *netStatCollector) emitStruct(ch chan<- prometheus.Metric, stats any) { + v := reflect.ValueOf(stats) + protocol := v.Type().Name() -func getSNMP6Stats(fileName string) (map[string]map[string]string, error) { - file, err := os.Open(fileName) - if err != nil { - // On systems with IPv6 disabled, this file won't exist. - // Do nothing. - if errors.Is(err, os.ErrNotExist) { - return nil, nil + for i := 0; i < v.NumField(); i++ { + value, ok := reflect.TypeAssert[*float64](v.Field(i)) + if !ok || value == nil { + continue } - return nil, err - } - defer file.Close() - - return parseSNMP6Stats(file) -} - -func parseSNMP6Stats(r io.Reader) (map[string]map[string]string, error) { - var ( - netStats = map[string]map[string]string{} - scanner = bufio.NewScanner(r) - ) - - for scanner.Scan() { - stat := strings.Fields(scanner.Text()) - if len(stat) < 2 { + name := v.Type().Field(i).Name + key := protocol + "_" + name + desc, ok := netStatDescs[key] + if !ok { continue } - // Expect to have "6" in metric name, skip line otherwise - if sixIndex := strings.Index(stat[0], "6"); sixIndex != -1 { - protocol := stat[0][:sixIndex+1] - name := stat[0][sixIndex+1:] - if _, present := netStats[protocol]; !present { - netStats[protocol] = map[string]string{} - } - netStats[protocol][name] = stat[1] + if !c.fieldPattern.MatchString(key) { + continue } - } - return netStats, scanner.Err() + ch <- prometheus.MustNewConstMetric(desc, prometheus.UntypedValue, *value) + } } diff --git a/collector/netstat_linux_test.go b/collector/netstat_linux_test.go index a30f44a2c9..8ba3a9dd30 100644 --- a/collector/netstat_linux_test.go +++ b/collector/netstat_linux_test.go @@ -16,83 +16,174 @@ package collector import ( - "os" + "io" + "log/slog" + "strings" "testing" + + "github.com/alecthomas/kingpin/v2" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/testutil" ) -func TestNetStats(t *testing.T) { - testNetStats(t, "fixtures/proc/net/netstat") - testSNMPStats(t, "fixtures/proc/net/snmp") - testSNMP6Stats(t, "fixtures/proc/net/snmp6") +type testNetStatCollector struct { + c Collector } -func testNetStats(t *testing.T, fileName string) { - file, err := os.Open(fileName) - if err != nil { - t.Fatal(err) - } - defer file.Close() - - netStats, err := parseNetStats(file, fileName) - if err != nil { - t.Fatal(err) - } - - if want, got := "102471", netStats["TcpExt"]["DelayedACKs"]; want != got { - t.Errorf("want netstat TCP DelayedACKs %s, got %s", want, got) - } +func (c testNetStatCollector) Collect(ch chan<- prometheus.Metric) { + c.c.Update(ch) +} - if want, got := "2786264347", netStats["IpExt"]["OutOctets"]; want != got { - t.Errorf("want netstat IP OutOctets %s, got %s", want, got) - } +func (c testNetStatCollector) Describe(ch chan<- *prometheus.Desc) { + prometheus.DescribeByCollect(c, ch) } -func testSNMPStats(t *testing.T, fileName string) { - file, err := os.Open(fileName) - if err != nil { - t.Fatal(err) - } - defer file.Close() +func NewTestNetStatCollector(t *testing.T, logger *slog.Logger) prometheus.Collector { + t.Helper() - snmpStats, err := parseNetStats(file, fileName) + c, err := NewNetStatCollector(logger) if err != nil { t.Fatal(err) } - - if want, got := "9", snmpStats["Udp"]["RcvbufErrors"]; want != got { - t.Errorf("want netstat Udp RcvbufErrors %s, got %s", want, got) - } - - if want, got := "8", snmpStats["Udp"]["SndbufErrors"]; want != got { - t.Errorf("want netstat Udp SndbufErrors %s, got %s", want, got) - } + return testNetStatCollector{c: c} } -func testSNMP6Stats(t *testing.T, fileName string) { - file, err := os.Open(fileName) - if err != nil { - t.Fatal(err) - } - defer file.Close() - - snmp6Stats, err := parseSNMP6Stats(file) - if err != nil { +func TestNetStats(t *testing.T) { + if _, err := kingpin.CommandLine.Parse([]string{}); err != nil { t.Fatal(err) } - - if want, got := "460", snmp6Stats["Ip6"]["InOctets"]; want != got { - t.Errorf("want netstat IPv6 InOctets %s, got %s", want, got) - } - - if want, got := "8", snmp6Stats["Icmp6"]["OutMsgs"]; want != got { - t.Errorf("want netstat ICPM6 OutMsgs %s, got %s", want, got) - } - - if want, got := "9", snmp6Stats["Udp6"]["RcvbufErrors"]; want != got { - t.Errorf("want netstat Udp6 RcvbufErrors %s, got %s", want, got) - } - - if want, got := "8", snmp6Stats["Udp6"]["SndbufErrors"]; want != got { - t.Errorf("want netstat Udp6 SndbufErrors %s, got %s", want, got) + *procPath = "fixtures/proc" + + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + c := NewTestNetStatCollector(t, logger) + + expected := ` +# HELP node_netstat_Icmp6_InErrors Statistic Icmp6InErrors. +# TYPE node_netstat_Icmp6_InErrors untyped +node_netstat_Icmp6_InErrors 0 +# HELP node_netstat_Icmp6_InMsgs Statistic Icmp6InMsgs. +# TYPE node_netstat_Icmp6_InMsgs untyped +node_netstat_Icmp6_InMsgs 0 +# HELP node_netstat_Icmp6_OutMsgs Statistic Icmp6OutMsgs. +# TYPE node_netstat_Icmp6_OutMsgs untyped +node_netstat_Icmp6_OutMsgs 8 +# HELP node_netstat_Icmp_InErrors Statistic IcmpInErrors. +# TYPE node_netstat_Icmp_InErrors untyped +node_netstat_Icmp_InErrors 0 +# HELP node_netstat_Icmp_InMsgs Statistic IcmpInMsgs. +# TYPE node_netstat_Icmp_InMsgs untyped +node_netstat_Icmp_InMsgs 104 +# HELP node_netstat_Icmp_OutMsgs Statistic IcmpOutMsgs. +# TYPE node_netstat_Icmp_OutMsgs untyped +node_netstat_Icmp_OutMsgs 120 +# HELP node_netstat_Ip6_InOctets Statistic Ip6InOctets. +# TYPE node_netstat_Ip6_InOctets untyped +node_netstat_Ip6_InOctets 460 +# HELP node_netstat_Ip6_OutOctets Statistic Ip6OutOctets. +# TYPE node_netstat_Ip6_OutOctets untyped +node_netstat_Ip6_OutOctets 536 +# HELP node_netstat_IpExt_InOctets Statistic IpExtInOctets. +# TYPE node_netstat_IpExt_InOctets untyped +node_netstat_IpExt_InOctets 6.28639697e+09 +# HELP node_netstat_IpExt_OutOctets Statistic IpExtOutOctets. +# TYPE node_netstat_IpExt_OutOctets untyped +node_netstat_IpExt_OutOctets 2.786264347e+09 +# HELP node_netstat_Ip_Forwarding Statistic IpForwarding. +# TYPE node_netstat_Ip_Forwarding untyped +node_netstat_Ip_Forwarding 1 +# HELP node_netstat_TcpExt_ListenDrops Statistic TcpExtListenDrops. +# TYPE node_netstat_TcpExt_ListenDrops untyped +node_netstat_TcpExt_ListenDrops 0 +# HELP node_netstat_TcpExt_ListenOverflows Statistic TcpExtListenOverflows. +# TYPE node_netstat_TcpExt_ListenOverflows untyped +node_netstat_TcpExt_ListenOverflows 0 +# HELP node_netstat_TcpExt_SyncookiesFailed Statistic TcpExtSyncookiesFailed. +# TYPE node_netstat_TcpExt_SyncookiesFailed untyped +node_netstat_TcpExt_SyncookiesFailed 2 +# HELP node_netstat_TcpExt_SyncookiesRecv Statistic TcpExtSyncookiesRecv. +# TYPE node_netstat_TcpExt_SyncookiesRecv untyped +node_netstat_TcpExt_SyncookiesRecv 0 +# HELP node_netstat_TcpExt_SyncookiesSent Statistic TcpExtSyncookiesSent. +# TYPE node_netstat_TcpExt_SyncookiesSent untyped +node_netstat_TcpExt_SyncookiesSent 0 +# HELP node_netstat_TcpExt_TCPOFOQueue Statistic TcpExtTCPOFOQueue. +# TYPE node_netstat_TcpExt_TCPOFOQueue untyped +node_netstat_TcpExt_TCPOFOQueue 42 +# HELP node_netstat_TcpExt_TCPRcvQDrop Statistic TcpExtTCPRcvQDrop. +# TYPE node_netstat_TcpExt_TCPRcvQDrop untyped +node_netstat_TcpExt_TCPRcvQDrop 131 +# HELP node_netstat_TcpExt_TCPTimeouts Statistic TcpExtTCPTimeouts. +# TYPE node_netstat_TcpExt_TCPTimeouts untyped +node_netstat_TcpExt_TCPTimeouts 115 +# HELP node_netstat_Tcp_ActiveOpens Statistic TcpActiveOpens. +# TYPE node_netstat_Tcp_ActiveOpens untyped +node_netstat_Tcp_ActiveOpens 3556 +# HELP node_netstat_Tcp_CurrEstab Statistic TcpCurrEstab. +# TYPE node_netstat_Tcp_CurrEstab untyped +node_netstat_Tcp_CurrEstab 0 +# HELP node_netstat_Tcp_InErrs Statistic TcpInErrs. +# TYPE node_netstat_Tcp_InErrs untyped +node_netstat_Tcp_InErrs 5 +# HELP node_netstat_Tcp_InSegs Statistic TcpInSegs. +# TYPE node_netstat_Tcp_InSegs untyped +node_netstat_Tcp_InSegs 5.7252008e+07 +# HELP node_netstat_Tcp_OutRsts Statistic TcpOutRsts. +# TYPE node_netstat_Tcp_OutRsts untyped +node_netstat_Tcp_OutRsts 1003 +# HELP node_netstat_Tcp_OutSegs Statistic TcpOutSegs. +# TYPE node_netstat_Tcp_OutSegs untyped +node_netstat_Tcp_OutSegs 5.4915039e+07 +# HELP node_netstat_Tcp_PassiveOpens Statistic TcpPassiveOpens. +# TYPE node_netstat_Tcp_PassiveOpens untyped +node_netstat_Tcp_PassiveOpens 230 +# HELP node_netstat_Tcp_RetransSegs Statistic TcpRetransSegs. +# TYPE node_netstat_Tcp_RetransSegs untyped +node_netstat_Tcp_RetransSegs 227 +# HELP node_netstat_Udp6_InDatagrams Statistic Udp6InDatagrams. +# TYPE node_netstat_Udp6_InDatagrams untyped +node_netstat_Udp6_InDatagrams 0 +# HELP node_netstat_Udp6_InErrors Statistic Udp6InErrors. +# TYPE node_netstat_Udp6_InErrors untyped +node_netstat_Udp6_InErrors 0 +# HELP node_netstat_Udp6_NoPorts Statistic Udp6NoPorts. +# TYPE node_netstat_Udp6_NoPorts untyped +node_netstat_Udp6_NoPorts 0 +# HELP node_netstat_Udp6_OutDatagrams Statistic Udp6OutDatagrams. +# TYPE node_netstat_Udp6_OutDatagrams untyped +node_netstat_Udp6_OutDatagrams 0 +# HELP node_netstat_Udp6_RcvbufErrors Statistic Udp6RcvbufErrors. +# TYPE node_netstat_Udp6_RcvbufErrors untyped +node_netstat_Udp6_RcvbufErrors 9 +# HELP node_netstat_Udp6_SndbufErrors Statistic Udp6SndbufErrors. +# TYPE node_netstat_Udp6_SndbufErrors untyped +node_netstat_Udp6_SndbufErrors 8 +# HELP node_netstat_UdpLite6_InErrors Statistic UdpLite6InErrors. +# TYPE node_netstat_UdpLite6_InErrors untyped +node_netstat_UdpLite6_InErrors 0 +# HELP node_netstat_UdpLite_InErrors Statistic UdpLiteInErrors. +# TYPE node_netstat_UdpLite_InErrors untyped +node_netstat_UdpLite_InErrors 0 +# HELP node_netstat_Udp_InDatagrams Statistic UdpInDatagrams. +# TYPE node_netstat_Udp_InDatagrams untyped +node_netstat_Udp_InDatagrams 88542 +# HELP node_netstat_Udp_InErrors Statistic UdpInErrors. +# TYPE node_netstat_Udp_InErrors untyped +node_netstat_Udp_InErrors 0 +# HELP node_netstat_Udp_NoPorts Statistic UdpNoPorts. +# TYPE node_netstat_Udp_NoPorts untyped +node_netstat_Udp_NoPorts 120 +# HELP node_netstat_Udp_OutDatagrams Statistic UdpOutDatagrams. +# TYPE node_netstat_Udp_OutDatagrams untyped +node_netstat_Udp_OutDatagrams 53028 +# HELP node_netstat_Udp_RcvbufErrors Statistic UdpRcvbufErrors. +# TYPE node_netstat_Udp_RcvbufErrors untyped +node_netstat_Udp_RcvbufErrors 9 +# HELP node_netstat_Udp_SndbufErrors Statistic UdpSndbufErrors. +# TYPE node_netstat_Udp_SndbufErrors untyped +node_netstat_Udp_SndbufErrors 8 +` + + if err := testutil.CollectAndCompare(c, strings.NewReader(expected)); err != nil { + t.Errorf("unexpected collecting result:\n%s", err) } } diff --git a/collector/nvme_linux.go b/collector/nvme_linux.go index dff757c7bd..d1bb8436ad 100644 --- a/collector/nvme_linux.go +++ b/collector/nvme_linux.go @@ -21,10 +21,16 @@ import ( "log/slog" "os" + "github.com/alecthomas/kingpin/v2" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/procfs/sysfs" ) +var ( + nvmeNamespaceUsage = kingpin.Flag("collector.nvme.namespace-usage", "Expose namespace used bytes (reads nuse, which makes the kernel query the controller).").Default("true").Bool() + nvmeNamespaceCapacity = kingpin.Flag("collector.nvme.namespace-capacity", "Export namespace size (nsze) with the incorrect metric name nvme_namespace_capacity_bytes").Default("true").Bool() +) + type nvmeCollector struct { fs sysfs.FS logger *slog.Logger @@ -49,7 +55,7 @@ var ( nvmeNamespaceCapacityBytes = prometheus.NewDesc( prometheus.BuildFQName(namespace, "nvme", "namespace_capacity_bytes"), - "Capacity of the NVMe namespace in bytes. Computed as namespace_size * namespace_logical_block_size", + "Size of the NVMe namespace in bytes. DEPRECATED: please use nvme_namespace_size_bytes instead.", []string{"device", "nsid"}, nil, ) @@ -78,6 +84,9 @@ func NewNVMeCollector(logger *slog.Logger) (Collector, error) { if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) } + if *nvmeNamespaceCapacity { + logger.Warn("The metric nvme_namespace_capacity_bytes is deprecated, and is planned to be removed in the next major version release. Please use nvme_namespace_size_bytes instead.") + } return &nvmeCollector{ fs: fs, logger: logger, @@ -120,14 +129,16 @@ func (c *nvmeCollector) Update(ch chan<- prometheus.Metric) error { namespace.ANAState, ) - // Namespace capacity in bytes - ch <- prometheus.MustNewConstMetric( - nvmeNamespaceCapacityBytes, - prometheus.GaugeValue, - float64(namespace.CapacityBytes), - device.Name, - namespace.ID, - ) + if *nvmeNamespaceCapacity { + // Namespace size in bytes + ch <- prometheus.MustNewConstMetric( + nvmeNamespaceCapacityBytes, + prometheus.GaugeValue, + float64(namespace.SizeBytes), + device.Name, + namespace.ID, + ) + } // Namespace size in bytes ch <- prometheus.MustNewConstMetric( @@ -139,13 +150,26 @@ func (c *nvmeCollector) Update(ch chan<- prometheus.Metric) error { ) // Namespace used space in bytes - ch <- prometheus.MustNewConstMetric( - nvmeNamespaceUsedBytes, - prometheus.GaugeValue, - float64(namespace.UsedBytes), - device.Name, - namespace.ID, - ) + if *nvmeNamespaceUsage { + usedBlocks, err := namespace.UsedBlocks() + if err != nil { + // The kernel queries the controller on read, so this can + // fail, e.g. with EIO if the controller is not live. + // Keep collecting the other namespaces. + c.logger.Warn("Could not read NVMe namespace usage", "device", device.Name, "namespace", namespace.Name, "err", err) + } else if usedBlocks == nil { + c.logger.Debug("NVMe namespace nuse file not present, skipping", "device", device.Name, "namespace", namespace.Name) + } else { + usedBytes := *usedBlocks * namespace.LogicalBlockSize + ch <- prometheus.MustNewConstMetric( + nvmeNamespaceUsedBytes, + prometheus.GaugeValue, + float64(usedBytes), + device.Name, + namespace.ID, + ) + } + } // Namespace logical block size in bytes ch <- prometheus.MustNewConstMetric( diff --git a/collector/os_release.go b/collector/os_release.go index 34c1557748..8be8b3bb0d 100644 --- a/collector/os_release.go +++ b/collector/os_release.go @@ -37,9 +37,7 @@ const ( systemVersionPlist = "/System/Library/CoreServices/SystemVersion.plist" ) -var ( - versionRegex = regexp.MustCompile(`^[0-9]+\.?[0-9]*`) -) +var versionRegex = regexp.MustCompile(`^[0-9]+\.?[0-9]*`) type osRelease struct { Name string @@ -84,8 +82,20 @@ var ( prometheus.BuildFQName(namespace, "os", "info"), "A metric with a constant '1' value labeled by build_id, id, id_like, image_id, image_version, "+ "name, pretty_name, variant, variant_id, version, version_codename, version_id.", - []string{"build_id", "id", "id_like", "image_id", "image_version", "name", "pretty_name", - "variant", "variant_id", "version", "version_codename", "version_id"}, nil, + []string{ + "build_id", + "id", + "id_like", + "image_id", + "image_version", + "name", + "pretty_name", + "variant", + "variant_id", + "version", + "version_codename", + "version_id", + }, nil, ) osVersionDesc = prometheus.NewDesc( prometheus.BuildFQName(namespace, "os", "version"), @@ -162,7 +172,6 @@ func (c *osReleaseCollector) UpdateStruct(path string) error { if c.os.SupportEnd != "" { c.supportEnd, err = time.Parse(time.DateOnly, c.os.SupportEnd) - if err != nil { return err } diff --git a/collector/pcidevice_linux.go b/collector/pcidevice_linux.go index 0d1baab2f5..a396e241f7 100644 --- a/collector/pcidevice_linux.go +++ b/collector/pcidevice_linux.go @@ -174,8 +174,18 @@ func NewPcideviceCollector(logger *slog.Logger) (Collector, error) { // Build label names based on whether name resolution is enabled labelNames := append(pcideviceLabelNames, - []string{"parent_segment", "parent_bus", "parent_device", "parent_function", - "class_id", "vendor_id", "device_id", "subsystem_vendor_id", "subsystem_device_id", "revision"}...) + []string{ + "parent_segment", + "parent_bus", + "parent_device", + "parent_function", + "class_id", + "vendor_id", + "device_id", + "subsystem_vendor_id", + "subsystem_device_id", + "revision", + }...) if c.pciNames { c.loadPCIIds() diff --git a/collector/powersupplyclass.go b/collector/powersupplyclass.go index 33142617f3..4a524a4793 100644 --- a/collector/powersupplyclass.go +++ b/collector/powersupplyclass.go @@ -23,9 +23,7 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -var ( - powerSupplyClassIgnoredPowerSupplies = kingpin.Flag("collector.powersupply.ignored-supplies", "Regexp of power supplies to ignore for powersupplyclass collector.").Default("^$").String() -) +var powerSupplyClassIgnoredPowerSupplies = kingpin.Flag("collector.powersupply.ignored-supplies", "Regexp of power supplies to ignore for powersupplyclass collector.").Default("^$").String() type powerSupplyClassCollector struct { subsystem string diff --git a/collector/powersupplyclass_darwin.go b/collector/powersupplyclass_darwin.go index be3d778ce5..7a075193c9 100644 --- a/collector/powersupplyclass_darwin.go +++ b/collector/powersupplyclass_darwin.go @@ -291,7 +291,7 @@ func getPowerSourceList() ([]*C.struct_macos_powersupply, error) { return nil, err } - dict, err := C.IOPSGetPowerSourceDescription(infos, (C.CFTypeRef)(ps)) + dict, err := C.IOPSGetPowerSourceDescription(infos, C.CFTypeRef(ps)) if err != nil { return nil, err } @@ -373,7 +373,7 @@ func convertValue(value *C.int) *float64 { } ret := new(float64) - *ret = (float64)(*value) + *ret = float64(*value) return ret } diff --git a/collector/powersupplyclass_linux.go b/collector/powersupplyclass_linux.go index b4fbf3510a..e98d332ed2 100644 --- a/collector/powersupplyclass_linux.go +++ b/collector/powersupplyclass_linux.go @@ -143,7 +143,7 @@ func (c *powerSupplyClassCollector) Update(ch chan<- prometheus.Metric) error { return nil } -func pushPowerSupplyMetric(ch chan<- prometheus.Metric, subsystem string, name string, value float64, powerSupplyName string, valueType prometheus.ValueType) { +func pushPowerSupplyMetric(ch chan<- prometheus.Metric, subsystem, name string, value float64, powerSupplyName string, valueType prometheus.ValueType) { fieldDesc := prometheus.NewDesc( prometheus.BuildFQName(namespace, subsystem, name), fmt.Sprintf("%s value of /sys/class/power_supply/.", name), @@ -160,7 +160,6 @@ func getPowerSupplyClassInfo(ignore *regexp.Regexp) (sysfs.PowerSupplyClass, err return nil, err } powerSupplyClass, err := fs.PowerSupplyClass() - if err != nil { return powerSupplyClass, fmt.Errorf("error obtaining power_supply class info: %w", err) } diff --git a/collector/pressure_linux.go b/collector/pressure_linux.go index 659c4b3768..568fc61c11 100644 --- a/collector/pressure_linux.go +++ b/collector/pressure_linux.go @@ -33,9 +33,7 @@ const ( psiResourceIRQ = "irq" ) -var ( - psiResources = []string{psiResourceCPU, psiResourceIO, psiResourceMemory, psiResourceIRQ} -) +var psiResources = []string{psiResourceCPU, psiResourceIO, psiResourceMemory, psiResourceIRQ} type pressureStatsCollector struct { cpu *prometheus.Desc diff --git a/collector/processes_linux.go b/collector/processes_linux.go index eff5cf06b5..bb99c525db 100644 --- a/collector/processes_linux.go +++ b/collector/processes_linux.go @@ -82,6 +82,7 @@ func NewProcessStatCollector(logger *slog.Logger) (Collector, error) { logger: logger, }, nil } + func (c *processCollector) Update(ch chan<- prometheus.Metric) error { pids, states, threads, threadStates, err := c.getAllocatedThreads() if err != nil { diff --git a/collector/processes_linux_test.go b/collector/processes_linux_test.go index 4b20ef8d63..b1c0c8fbd0 100644 --- a/collector/processes_linux_test.go +++ b/collector/processes_linux_test.go @@ -42,7 +42,6 @@ func TestReadProcessStatus(t *testing.T) { t.Fatalf("Current threads: %d Shouldn't be less than wanted %d", threads, want) } if states == nil { - t.Fatalf("Process states cannot be nil %v:", states) } maxPid, err := readUintFromFile(procFilePath("sys/kernel/pid_max")) diff --git a/collector/rapl_linux.go b/collector/rapl_linux.go index 92c402d539..0cd49c6493 100644 --- a/collector/rapl_linux.go +++ b/collector/rapl_linux.go @@ -40,14 +40,11 @@ func init() { registerCollector(raplCollectorSubsystem, defaultEnabled, NewRaplCollector) } -var ( - raplZoneLabel = kingpin.Flag("collector.rapl.enable-zone-label", "Enables service unit metric unit_start_time_seconds").Bool() -) +var raplZoneLabel = kingpin.Flag("collector.rapl.enable-zone-label", "Enables service unit metric unit_start_time_seconds").Bool() // NewRaplCollector returns a new Collector exposing RAPL metrics. func NewRaplCollector(logger *slog.Logger) (Collector, error) { fs, err := sysfs.NewFS(*sysPath) - if err != nil { return nil, err } diff --git a/collector/resctrl_linux.go b/collector/resctrl_linux.go new file mode 100644 index 0000000000..9995950210 --- /dev/null +++ b/collector/resctrl_linux.go @@ -0,0 +1,110 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !noresctrl + +package collector + +import ( + "errors" + "log/slog" + "os" + + "github.com/alecthomas/kingpin/v2" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/procfs/resctrlfs" +) + +const resctrlSubsystem = "resctrl" + +// The resctrl filesystem exposes the cache and memory bandwidth monitoring of +// the CPU (Intel RDT, AMD PQoS, Arm MPAM), documented in +// https://docs.kernel.org/filesystems/resctrl.html and +// https://docs.kernel.org/arch/arm64/mpam.html. +// +// It is not mounted by default, hence this collector is disabled by default. +// Mount it with: +// +// mount -t resctrl resctrl /sys/fs/resctrl +var resctrlPath = kingpin.Flag("collector.resctrl.path", "resctrl filesystem mountpoint.").Default(resctrlfs.DefaultMountPoint).String() + +type resctrlCollector struct{} + +func init() { + registerCollector("resctrl", defaultDisabled, NewResctrlCollector) +} + +var ( + resctrlMemoryBandwidth = prometheus.NewDesc( + prometheus.BuildFQName(namespace, resctrlSubsystem, "memory_bandwidth_bytes_total"), + "Bytes moved between the last level cache and memory. scope=total includes remote sockets, scope=local is memory attached to this domain.", + []string{"domain", "scope"}, nil, + ) + resctrlLLCOccupancy = prometheus.NewDesc( + prometheus.BuildFQName(namespace, resctrlSubsystem, "llc_occupancy_bytes"), + "Last level cache bytes occupied in this domain.", + []string{"domain"}, nil, + ) +) + +// NewResctrlCollector returns a new Collector exposing resctrl monitoring counters. +func NewResctrlCollector(_ *slog.Logger) (Collector, error) { + return &resctrlCollector{}, nil +} + +func (c *resctrlCollector) Update(ch chan<- prometheus.Metric) error { + // The filesystem is opened on every scrape because it can be mounted and + // unmounted while node_exporter runs. + fs, err := resctrlfs.NewFS(*resctrlPath) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return ErrNoData + } + return err + } + + domains, err := fs.MonData() + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return ErrNoData + } + return err + } + + found := false + for _, domain := range domains { + // The metrics describe the last level cache, so only L3 fits them. + if domain.Resource != "L3" { + continue + } + found = true + + // The bandwidth counters wrap. No correction is applied: Prometheus + // reads a wrap as a counter reset, which is the closest available + // approximation. + if v := domain.MBMTotalBytes; v != nil { + ch <- prometheus.MustNewConstMetric(resctrlMemoryBandwidth, prometheus.CounterValue, float64(*v), domain.ID, "total") + } + if v := domain.MBMLocalBytes; v != nil { + ch <- prometheus.MustNewConstMetric(resctrlMemoryBandwidth, prometheus.CounterValue, float64(*v), domain.ID, "local") + } + if v := domain.LLCOccupancy; v != nil { + ch <- prometheus.MustNewConstMetric(resctrlLLCOccupancy, prometheus.GaugeValue, float64(*v), domain.ID) + } + } + + if !found { + return ErrNoData + } + return nil +} diff --git a/collector/resctrl_linux_test.go b/collector/resctrl_linux_test.go new file mode 100644 index 0000000000..fd5598a92d --- /dev/null +++ b/collector/resctrl_linux_test.go @@ -0,0 +1,91 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !noresctrl + +package collector + +import ( + "io" + "log/slog" + "strings" + "testing" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/testutil" +) + +type testResctrlCollector struct { + rc Collector +} + +func (c testResctrlCollector) Collect(ch chan<- prometheus.Metric) { + c.rc.Update(ch) +} + +func (c testResctrlCollector) Describe(ch chan<- *prometheus.Desc) { + prometheus.DescribeByCollect(c, ch) +} + +func newTestResctrlCollector(logger *slog.Logger) (prometheus.Collector, error) { + rc, err := NewResctrlCollector(logger) + if err != nil { + return testResctrlCollector{}, err + } + return testResctrlCollector{rc}, nil +} + +func TestResctrlMetrics(t *testing.T) { + *resctrlPath = "fixtures/resctrl" + + // Domain 1 reports "Unavailable" for mbm_local_bytes, so that sample is + // absent. + testcase := `# HELP node_resctrl_llc_occupancy_bytes Last level cache bytes occupied in this domain. +# TYPE node_resctrl_llc_occupancy_bytes gauge +node_resctrl_llc_occupancy_bytes{domain="0"} 4.4040192e+07 +node_resctrl_llc_occupancy_bytes{domain="1"} 8.388608e+06 +# HELP node_resctrl_memory_bandwidth_bytes_total Bytes moved between the last level cache and memory. scope=total includes remote sockets, scope=local is memory attached to this domain. +# TYPE node_resctrl_memory_bandwidth_bytes_total counter +node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="local"} 2.10196273664e+11 +node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="total"} 3.15294410752e+11 +node_resctrl_memory_bandwidth_bytes_total{domain="1",scope="total"} 1.05098136832e+11 +` + + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + c, err := newTestResctrlCollector(logger) + if err != nil { + t.Fatal(err) + } + + if err := testutil.CollectAndCompare(c, strings.NewReader(testcase)); err != nil { + t.Fatal(err) + } +} + +func TestResctrlNotMounted(t *testing.T) { + *resctrlPath = t.TempDir() + + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + c, err := NewResctrlCollector(logger) + if err != nil { + t.Fatal(err) + } + + ch := make(chan prometheus.Metric, 16) + err = c.Update(ch) + close(ch) + + if err != ErrNoData { + t.Fatalf("expected ErrNoData, got %v", err) + } +} diff --git a/collector/slabinfo_linux.go b/collector/slabinfo_linux.go index 48bbf2abfe..bcb06509cd 100644 --- a/collector/slabinfo_linux.go +++ b/collector/slabinfo_linux.go @@ -47,7 +47,8 @@ func NewSlabinfoCollector(logger *slog.Logger) (Collector, error) { return nil, fmt.Errorf("failed to open procfs: %w", err) } - return &slabinfoCollector{logger: logger, + return &slabinfoCollector{ + logger: logger, fs: fs, subsystem: "slabinfo", labels: []string{"slab"}, diff --git a/collector/softirqs_linux.go b/collector/softirqs_linux.go index 0c64751049..294b539766 100644 --- a/collector/softirqs_linux.go +++ b/collector/softirqs_linux.go @@ -22,9 +22,7 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -var ( - softirqLabelNames = []string{"cpu", "type"} -) +var softirqLabelNames = []string{"cpu", "type"} func (c *softirqsCollector) Update(ch chan<- prometheus.Metric) (err error) { softirqs, err := c.fs.Softirqs() diff --git a/collector/swap_linux.go b/collector/swap_linux.go index 9a275e1614..18894de392 100644 --- a/collector/swap_linux.go +++ b/collector/swap_linux.go @@ -68,8 +68,10 @@ func (c *swapCollector) getSwapInfo() ([]SwapsEntry, error) { metrics := make([]SwapsEntry, 0, len(swaps)) for _, swap := range swaps { - metrics = append(metrics, SwapsEntry{Device: swap.Filename, Type: swap.Type, - Priority: swap.Priority, Size: swap.Size, Used: swap.Used}) + metrics = append(metrics, SwapsEntry{ + Device: swap.Filename, Type: swap.Type, + Priority: swap.Priority, Size: swap.Size, Used: swap.Used, + }) } return metrics, nil diff --git a/collector/sysctl_bsd.go b/collector/sysctl_bsd.go index e3c8dc5cf4..23a818a8ef 100644 --- a/collector/sysctl_bsd.go +++ b/collector/sysctl_bsd.go @@ -111,5 +111,4 @@ func (b bsdSysctl) getCLong() (float64, error) { C.sizeof_long, C.sizeof_int, ) - } diff --git a/collector/systemd_linux_test.go b/collector/systemd_linux_test.go index 98668ed6be..cc273d8580 100644 --- a/collector/systemd_linux_test.go +++ b/collector/systemd_linux_test.go @@ -101,6 +101,7 @@ func TestSystemdIgnoreFilter(t *testing.T) { } } } + func TestSystemdIgnoreFilterDefaultKeepsAll(t *testing.T) { logger := slog.New(slog.NewTextHandler(io.Discard, nil)) c, err := NewSystemdCollector(logger) @@ -132,7 +133,7 @@ func TestSystemdSummary(t *testing.T) { } } -func testSummaryHelper(t *testing.T, state string, actual float64, expected float64) { +func testSummaryHelper(t *testing.T, state string, actual, expected float64) { if actual != expected { t.Errorf("Summary mode didn't count %s jobs correctly. Actual: %f, expected: %f", state, actual, expected) } diff --git a/collector/tainted_linux.go b/collector/tainted_linux.go new file mode 100644 index 0000000000..3ab3f25c6e --- /dev/null +++ b/collector/tainted_linux.go @@ -0,0 +1,79 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !notainted + +package collector + +import ( + "fmt" + "log/slog" + "strconv" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/procfs" +) + +type taintedCollector struct { + fs procfs.FS + logger *slog.Logger + desc *prometheus.Desc +} + +func init() { + registerCollector("tainted", defaultDisabled, NewTaintedCollector) +} + +// NewTaintedCollector returns a Collector exposing kernel taint flags from +// /proc/sys/kernel/tainted as a labelled gauge. +// See https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html +func NewTaintedCollector(logger *slog.Logger) (Collector, error) { + fs, err := procfs.NewFS(*procPath) + if err != nil { + return nil, fmt.Errorf("failed to open procfs: %w", err) + } + return &taintedCollector{ + fs: fs, + logger: logger, + desc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, "kernel", "tainted"), + "Taint flags set on the running Linux kernel, as reported by /proc/sys/kernel/tainted. "+ + "Value is 1 if the flag is set, 0 otherwise. "+ + "See https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html for flag meanings.", + []string{"bit", "flag"}, + nil, + ), + }, nil +} + +func (c *taintedCollector) Update(ch chan<- prometheus.Metric) error { + tainted, err := c.fs.KernelTainted() + if err != nil { + return fmt.Errorf("couldn't read kernel tainted state: %w", err) + } + + for _, b := range tainted.Bits { + var val float64 + if b.Set { + val = 1.0 + } + ch <- prometheus.MustNewConstMetric( + c.desc, + prometheus.GaugeValue, + val, + strconv.Itoa(b.Index), + b.Flag, + ) + } + return nil +} diff --git a/collector/tainted_linux_test.go b/collector/tainted_linux_test.go new file mode 100644 index 0000000000..0ce7e3b621 --- /dev/null +++ b/collector/tainted_linux_test.go @@ -0,0 +1,103 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !notainted + +package collector + +import ( + "io" + "log/slog" + "testing" + + "github.com/prometheus/client_golang/prometheus" +) + +func TestTaintedCollector(t *testing.T) { + *procPath = "fixtures/proc" + + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + c, err := NewTaintedCollector(logger) + if err != nil { + t.Fatalf("failed to create tainted collector: %v", err) + } + + reg := prometheus.NewPedanticRegistry() + reg.MustRegister(&taintedCollectorWrapper{c.(*taintedCollector)}) + + mfs, err := reg.Gather() + if err != nil { + t.Fatalf("gather failed: %v", err) + } + if len(mfs) != 1 { + t.Fatalf("expected 1 metric family, got %d", len(mfs)) + } + + mf := mfs[0] + if got := mf.GetName(); got != "node_kernel_tainted" { + t.Errorf("metric name: want node_kernel_tainted, got %s", got) + } + + // Expect one series per known taint bit (20 defined by the kernel). + const wantBits = 20 + if got := len(mf.GetMetric()); got != wantBits { + t.Errorf("metric count: want %d, got %d", wantBits, got) + } + + // Build bit → value map for assertion. + // Fixture is 12288 = bit 12 (O) + bit 13 (E). + // Build flag → value map for assertion (labels: bit, flag). + flagVals := make(map[string]float64) + for _, m := range mf.GetMetric() { + // Each metric has exactly 2 labels: bit and flag. + for _, lp := range m.GetLabel() { + if lp.GetName() == "flag" { + flagVals[lp.GetValue()] = m.GetGauge().GetValue() + } + } + } + + // Fixture is 12288 = bit 12 (O) + bit 13 (E). + for _, tc := range []struct { + flag string + want float64 + }{ + {"O", 1}, // Externally-built (out-of-tree) module — set + {"E", 1}, // Unsigned module — set + {"L", 0}, // Soft lockup — must be clear + {"P", 0}, + {"T", 0}, + } { + got, ok := flagVals[tc.flag] + if !ok { + t.Errorf("flag %q not found in metrics", tc.flag) + continue + } + if got != tc.want { + t.Errorf("flag %q: want %.0f, got %.0f", tc.flag, tc.want, got) + } + } +} + +// taintedCollectorWrapper adapts taintedCollector to prometheus.Collector. +type taintedCollectorWrapper struct { + c *taintedCollector +} + +func (w *taintedCollectorWrapper) Describe(ch chan<- *prometheus.Desc) { + ch <- w.c.desc +} + +func (w *taintedCollectorWrapper) Collect(ch chan<- prometheus.Metric) { + _ = w.c.Update(ch) +} diff --git a/collector/tapestats_linux.go b/collector/tapestats_linux.go index e195ce1c51..4ed617f7c8 100644 --- a/collector/tapestats_linux.go +++ b/collector/tapestats_linux.go @@ -26,9 +26,7 @@ import ( "github.com/prometheus/procfs/sysfs" ) -var ( - ignoredTapeDevices = kingpin.Flag("collector.tapestats.ignored-devices", "Regexp of devices to ignore for tapestats.").Default("^$").String() -) +var ignoredTapeDevices = kingpin.Flag("collector.tapestats.ignored-devices", "Regexp of devices to ignore for tapestats.").Default("^$").String() type tapestatsCollector struct { ignoredDevicesPattern *regexp.Regexp @@ -53,7 +51,7 @@ func init() { // NewTapestatsCollector returns a new Collector exposing tape device stats. // Docs from https://www.kernel.org/doc/html/latest/scsi/st.html#sysfs-and-statistics-for-tape-devices func NewTapestatsCollector(logger *slog.Logger) (Collector, error) { - var tapeLabelNames = []string{"device"} + tapeLabelNames := []string{"device"} fs, err := sysfs.NewFS(*sysPath) if err != nil { diff --git a/collector/tcpstat_linux_test.go b/collector/tcpstat_linux_test.go index 8a56af9ccd..f4259a78d9 100644 --- a/collector/tcpstat_linux_test.go +++ b/collector/tcpstat_linux_test.go @@ -84,5 +84,4 @@ func Test_parseTCPStats(t *testing.T) { if want, got := 22, int(tcpStats[tcpRxQueuedBytes]); want != got { t.Errorf("want tcpstat number of bytes in rx queue %d, got %d", want, got) } - } diff --git a/collector/textfile.go b/collector/textfile.go index 5b39609d73..8e4055f297 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -219,12 +219,14 @@ func (c *textFileCollector) Update(ch chan<- prometheus.Metric) error { // Check for metrics with inconsistent help texts and take the first help text occurrence. if helpTexts, seen := metricsNamesToHelpTexts[*mf.Name]; seen { if mf.Help != nil && helpTexts[0] != *mf.Help || helpTexts[1] != "" { - metricsNamesToHelpTexts[*mf.Name] = [2]string{helpTexts[0], *mf.Help} + if mf.Help != nil { + metricsNamesToHelpTexts[*mf.Name] = [2]string{helpTexts[0], *mf.Help} + } errored = true c.logger.Error("inconsistent metric help text", "metric", *mf.Name, "original_help_text", helpTexts[0], - "new_help_text", *mf.Help, + "new_help_text", mf.GetHelp(), // Only the first file path will be recorded in case of two or more inconsistent help texts. "file", metricsNamesToFiles[*mf.Name][0]) continue @@ -293,7 +295,7 @@ func (c *textFileCollector) processFile(dir, name string) (*time.Time, map[strin } defer f.Close() - parser := expfmt.NewTextParser(model.LegacyValidation) + parser := expfmt.NewTextParser(model.UTF8Validation) families, err := parser.TextToMetricFamilies(f) if err != nil { return nil, nil, fmt.Errorf("failed to parse textfile data from %q: %w", path, err) diff --git a/collector/textfile_test.go b/collector/textfile_test.go index 2fb31faca1..ebfbfec566 100644 --- a/collector/textfile_test.go +++ b/collector/textfile_test.go @@ -121,6 +121,10 @@ func TestTextfileCollector(t *testing.T) { paths: []string{"fixtures/textfile/metrics_merge_different_help"}, out: "fixtures/textfile/metrics_merge_different_help.out", }, + { + paths: []string{"fixtures/textfile/metrics_merge_inconsistent_then_no_help"}, + out: "fixtures/textfile/metrics_merge_inconsistent_then_no_help.out", + }, } for i, test := range tests { @@ -156,3 +160,28 @@ func TestTextfileCollector(t *testing.T) { } } } + +func TestTextfileCollectorSupportsUTF8Names(t *testing.T) { + c := &textFileCollector{ + paths: []string{"fixtures/textfile/utf8_names"}, + logger: slog.New(slog.NewTextHandler(io.Discard, nil)), + } + registry := prometheus.NewRegistry() + registry.MustRegister(collectorAdapter{c}) + + families, err := registry.Gather() + if err != nil { + t.Fatalf("failed to gather textfile with UTF-8 names: %v", err) + } + + for _, family := range families { + if family.GetName() != "my.dotted.metric" { + continue + } + if got := family.Metric[0].Label[0].GetName(); got != "error.message" { + t.Fatalf("expected dotted label name, got %q", got) + } + return + } + t.Fatalf("expected dotted metric name, got %v", families) +} diff --git a/collector/thermal_darwin.go b/collector/thermal_darwin.go index c55b9b2845..8b6ba72839 100644 --- a/collector/thermal_darwin.go +++ b/collector/thermal_darwin.go @@ -62,6 +62,11 @@ type thermCollector struct { const thermal = "thermal" +// errNoCPUPowerStatus is returned when the system does not report any CPU power +// status. Apple Silicon does not implement IOPMCopyCPUPowerStatus, so this is an +// expected condition on those systems rather than a failure. +var errNoCPUPowerStatus = errors.New("no CPU power status has been recorded") + func init() { registerCollector(thermal, defaultEnabled, NewThermCollector) } @@ -110,18 +115,25 @@ func NewThermCollector(logger *slog.Logger) (Collector, error) { func (c *thermCollector) Update(ch chan<- prometheus.Metric) error { cpuPowerStatus, err := fetchCPUPowerStatus() - if err != nil { + switch { + case err == nil: + if value, ok := cpuPowerStatus[string(C.kIOPMCPUPowerLimitSchedulerTimeKey)]; ok { + ch <- c.cpuSchedulerLimit.mustNewConstMetric(float64(value) / 100.0) + } + if value, ok := cpuPowerStatus[string(C.kIOPMCPUPowerLimitProcessorCountKey)]; ok { + ch <- c.cpuAvailableCPU.mustNewConstMetric(float64(value)) + } + if value, ok := cpuPowerStatus[string(C.kIOPMCPUPowerLimitProcessorSpeedKey)]; ok { + ch <- c.cpuSpeedLimit.mustNewConstMetric(float64(value) / 100.0) + } + case errors.Is(err, errNoCPUPowerStatus): + // Apple Silicon does not report CPU power status. The temperature + // sensors collected below are still available, so this must not abort + // the collector. + c.logger.Debug("No CPU power status reported by the system, skipping CPU power metrics") + default: return err } - if value, ok := cpuPowerStatus[(string(C.kIOPMCPUPowerLimitSchedulerTimeKey))]; ok { - ch <- c.cpuSchedulerLimit.mustNewConstMetric(float64(value) / 100.0) - } - if value, ok := cpuPowerStatus[(string(C.kIOPMCPUPowerLimitProcessorCountKey))]; ok { - ch <- c.cpuAvailableCPU.mustNewConstMetric(float64(value)) - } - if value, ok := cpuPowerStatus[(string(C.kIOPMCPUPowerLimitProcessorSpeedKey))]; ok { - ch <- c.cpuSpeedLimit.mustNewConstMetric(float64(value) / 100.0) - } return c.updateTemperatures(ch) } @@ -135,7 +147,7 @@ func fetchCPUPowerStatus() (map[string]int, error) { }() if C.kIOReturnNotFound == cfDictRef.ret { - return nil, errors.New("no CPU power status has been recorded") + return nil, errNoCPUPowerStatus } if C.kIOReturnSuccess != cfDictRef.ret { diff --git a/collector/thermal_darwin_arm64.go b/collector/thermal_darwin_arm64.go index 24558a1c9d..bfbc52a338 100644 --- a/collector/thermal_darwin_arm64.go +++ b/collector/thermal_darwin_arm64.go @@ -39,10 +39,12 @@ CFArrayRef IOHIDEventSystemClientCopyServices(IOHIDEventSystemClientRef client); IOHIDEventRef IOHIDServiceClientCopyEvent(IOHIDServiceClientRef service, int64_t type, int32_t options, int64_t timestamp); double IOHIDEventGetFloatValue(IOHIDEventRef event, int32_t field); CFTypeRef IOHIDServiceClientCopyProperty(IOHIDServiceClientRef service, CFStringRef key); +uint64_t IOHIDServiceClientGetRegistryID(IOHIDServiceClientRef service); */ import "C" import ( + "strconv" "unsafe" "github.com/prometheus/client_golang/prometheus" @@ -50,6 +52,18 @@ import ( const absoluteZeroCelsius = -273.15 +// A thermal sensor is labelled with its IOHID "Product" property, which is not +// unique. Apple Silicon reports several services under one product name: some +// are distinct sensors that only share the name and can be told apart by their +// location, while others share the location too and differ only by the registry +// ID of the service. +type thermalSensor struct { + name string + location string + registryID string + temp float64 +} + func (c *thermCollector) updateTemperatures(ch chan<- prometheus.Metric) error { client := C.IOHIDEventSystemClientCreate(C.kCFAllocatorDefault) if client == nil { @@ -101,10 +115,18 @@ func (c *thermCollector) updateTemperatures(ch chan<- prometheus.Metric) error { cfProdKey := C.CFStringCreateWithCString(C.kCFAllocatorDefault, prodKey, C.kCFStringEncodingUTF8) defer C.CFRelease(C.CFTypeRef(cfProdKey)) + locKey := C.CString("LocationID") + defer C.free(unsafe.Pointer(locKey)) + cfLocKey := C.CFStringCreateWithCString(C.kCFAllocatorDefault, locKey, C.kCFStringEncodingUTF8) + defer C.CFRelease(C.CFTypeRef(cfLocKey)) + + // Read every sensor first, so that colliding product names can be detected + // before any metric is emitted. + sensors := make([]thermalSensor, 0, int(count)) for i := 0; i < int(count); i++ { - service := C.CFArrayGetValueAtIndex(services, C.CFIndex(i)) + service := C.IOHIDServiceClientRef(C.CFArrayGetValueAtIndex(services, C.CFIndex(i))) - event := C.IOHIDServiceClientCopyEvent((C.IOHIDServiceClientRef)(service), C.kIOHIDEventTypeTemperature, 0, 0) + event := C.IOHIDServiceClientCopyEvent(service, C.kIOHIDEventTypeTemperature, 0, 0) if event == nil { continue } @@ -118,18 +140,80 @@ func (c *thermCollector) updateTemperatures(ch chan<- prometheus.Metric) error { continue } - nameRef := C.IOHIDServiceClientCopyProperty((C.IOHIDServiceClientRef)(service), cfProdKey) + nameRef := C.IOHIDServiceClientCopyProperty(service, cfProdKey) name := "Unknown" if nameRef != 0 { - name = cfStringToString((C.CFStringRef)(nameRef)) + name = cfStringToString(C.CFStringRef(nameRef)) C.CFRelease(C.CFTypeRef(nameRef)) } - ch <- c.temperature.mustNewConstMetric(float64(temp), name) + sensors = append(sensors, thermalSensor{ + name: name, + location: serviceNumberProperty(service, cfLocKey), + registryID: strconv.FormatUint(uint64(C.IOHIDServiceClientGetRegistryID(service)), 10), + temp: float64(temp), + }) } + + for i, label := range resolveSensorNames(sensors) { + ch <- c.temperature.mustNewConstMetric(sensors[i].temp, label) + } + return nil } +// resolveSensorNames returns the sensor label to report for each sensor, in the +// order the sensors were given. +// +// Emitting the same label set twice makes the registry reject the samples and +// fail the whole scrape. A product name shared by several services is therefore +// qualified with the service location, falling back to the registry ID, which is +// unique per service, when the location does not tell them apart either. +func resolveSensorNames(sensors []thermalSensor) []string { + nameCount := make(map[string]int, len(sensors)) + nameLocationCount := make(map[string]int, len(sensors)) + for _, s := range sensors { + nameCount[s.name]++ + nameLocationCount[s.name+"\x00"+s.location]++ + } + + labels := make([]string, 0, len(sensors)) + for _, s := range sensors { + label := s.name + if nameCount[s.name] > 1 { + suffix := s.location + if suffix == "" || nameLocationCount[s.name+"\x00"+s.location] > 1 { + suffix = s.registryID + } + label = s.name + "_" + suffix + } + labels = append(labels, label) + } + + return labels +} + +// serviceNumberProperty reads a numeric IOHID service property, returning an +// empty string when it is absent or not a number. +func serviceNumberProperty(service C.IOHIDServiceClientRef, key C.CFStringRef) string { + ref := C.IOHIDServiceClientCopyProperty(service, key) + if ref == 0 { + return "" + } + defer C.CFRelease(ref) + + if C.CFGetTypeID(ref) != C.CFNumberGetTypeID() { + return "" + } + + var value C.longlong + if C.CFNumberGetValue(C.CFNumberRef(ref), C.kCFNumberLongLongType, unsafe.Pointer(&value)) == 0 { + return "" + } + + return strconv.FormatInt(int64(value), 10) +} + func cfStringToString(s C.CFStringRef) string { p := C.CFStringGetCStringPtr(s, C.kCFStringEncodingUTF8) if p != nil { diff --git a/collector/thermal_darwin_arm64_test.go b/collector/thermal_darwin_arm64_test.go new file mode 100644 index 0000000000..ba3e867a8b --- /dev/null +++ b/collector/thermal_darwin_arm64_test.go @@ -0,0 +1,121 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !notherm && darwin && arm64 && cgo + +package collector + +import "testing" + +func TestResolveSensorNames(t *testing.T) { + for _, tc := range []struct { + name string + sensors []thermalSensor + want []string + }{ + { + name: "unique names are left alone", + sensors: []thermalSensor{{name: "NAND CH0 temp", location: "1", registryID: "10"}}, + want: []string{"NAND CH0 temp"}, + }, + { + // Several "gas gauge battery" services are distinct sensors that + // only share a product name. + name: "a shared name is qualified with the location", + sensors: []thermalSensor{ + {name: "gas gauge battery", location: "1413951555", registryID: "10"}, + {name: "gas gauge battery", location: "1413951574", registryID: "11"}, + }, + want: []string{"gas gauge battery_1413951555", "gas gauge battery_1413951574"}, + }, + { + // The PMU sensors report the same product name and the same + // location, so only the registry ID separates them. + name: "a shared location falls back to the registry ID", + sensors: []thermalSensor{ + {name: "PMU tdie2", location: "1414541922", registryID: "10"}, + {name: "PMU tdie2", location: "1414541922", registryID: "11"}, + {name: "PMU tdie2", location: "1414541922", registryID: "12"}, + }, + want: []string{"PMU tdie2_10", "PMU tdie2_11", "PMU tdie2_12"}, + }, + { + name: "a missing location falls back to the registry ID", + sensors: []thermalSensor{ + {name: "sensor", location: "", registryID: "10"}, + {name: "sensor", location: "", registryID: "11"}, + }, + want: []string{"sensor_10", "sensor_11"}, + }, + { + // Only the services that cannot be told apart by location fall back + // to the registry ID. + name: "location and registry ID are mixed within one name", + sensors: []thermalSensor{ + {name: "sensor", location: "1", registryID: "10"}, + {name: "sensor", location: "2", registryID: "11"}, + {name: "sensor", location: "2", registryID: "12"}, + }, + want: []string{"sensor_1", "sensor_11", "sensor_12"}, + }, + { + name: "no sensors", + sensors: nil, + want: []string{}, + }, + } { + t.Run(tc.name, func(t *testing.T) { + got := resolveSensorNames(tc.sensors) + if len(got) != len(tc.want) { + t.Fatalf("got %d labels, want %d: %q", len(got), len(tc.want), got) + } + for i := range tc.want { + if got[i] != tc.want[i] { + t.Errorf("label %d: got %q, want %q", i, got[i], tc.want[i]) + } + } + + seen := make(map[string]struct{}, len(got)) + for _, l := range got { + if _, dup := seen[l]; dup { + t.Errorf("duplicate label %q", l) + } + seen[l] = struct{}{} + } + }) + } +} + +// Every reading must be reported. Sensors sharing a product name are +// disambiguated rather than dropped. +func TestResolveSensorNamesKeepsEveryReading(t *testing.T) { + sensors := []thermalSensor{ + {name: "a", location: "1", registryID: "10"}, + {name: "a", location: "1", registryID: "11"}, + {name: "a", location: "2", registryID: "12"}, + {name: "b", location: "1", registryID: "13"}, + } + + got := resolveSensorNames(sensors) + if len(got) != len(sensors) { + t.Fatalf("got %d labels for %d sensors", len(got), len(sensors)) + } + + seen := make(map[string]struct{}, len(got)) + for _, l := range got { + if _, dup := seen[l]; dup { + t.Errorf("duplicate label %q", l) + } + seen[l] = struct{}{} + } +} diff --git a/collector/thermal_darwin_test.go b/collector/thermal_darwin_test.go new file mode 100644 index 0000000000..59bb5b2043 --- /dev/null +++ b/collector/thermal_darwin_test.go @@ -0,0 +1,89 @@ +// Copyright The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !notherm && darwin && cgo + +package collector + +import ( + "errors" + "io" + "log/slog" + "strings" + "testing" + + "github.com/prometheus/client_golang/prometheus" + dto "github.com/prometheus/client_model/go" +) + +// Apple Silicon does not implement IOPMCopyCPUPowerStatus, so fetchCPUPowerStatus +// reports errNoCPUPowerStatus there. That is an expected condition and must not +// abort the collector, otherwise the temperature sensors, which are read after +// the CPU power status, are never collected. +func TestThermalUpdateWithoutCPUPowerStatus(t *testing.T) { + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + + c, err := NewThermCollector(logger) + if err != nil { + t.Fatalf("failed to create collector: %v", err) + } + + ch := make(chan prometheus.Metric, 1024) + err = c.Update(ch) + close(ch) + + if errors.Is(err, errNoCPUPowerStatus) { + t.Fatal("Update returned errNoCPUPowerStatus; a system without CPU power status must still collect temperatures") + } + if err != nil { + t.Fatalf("Update failed: %v", err) + } +} + +// Several IOHID services report the same product name, so the collector must +// qualify the colliding ones. Duplicate label sets are rejected by the registry +// and fail the whole scrape. +func TestThermalTemperaturesAreUnique(t *testing.T) { + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + + c, err := NewThermCollector(logger) + if err != nil { + t.Fatalf("failed to create collector: %v", err) + } + + ch := make(chan prometheus.Metric, 4096) + if err := c.Update(ch); err != nil { + t.Fatalf("Update failed: %v", err) + } + close(ch) + + seen := make(map[string]struct{}) + for m := range ch { + var pb dto.Metric + if err := m.Write(&pb); err != nil { + t.Fatalf("cannot read metric: %v", err) + } + + var key strings.Builder + key.WriteString(m.Desc().String()) + for _, l := range pb.GetLabel() { + key.WriteString("," + l.GetName() + "=" + l.GetValue()) + } + + id := key.String() + if _, duplicate := seen[id]; duplicate { + t.Errorf("duplicate metric collected: %s", id) + } + seen[id] = struct{}{} + } +} diff --git a/collector/thermal_zone_linux.go b/collector/thermal_zone_linux.go index c7c58c29b3..ea6c53252a 100644 --- a/collector/thermal_zone_linux.go +++ b/collector/thermal_zone_linux.go @@ -26,8 +26,10 @@ import ( "github.com/prometheus/procfs/sysfs" ) -const coolingDevice = "cooling_device" -const thermalZone = "thermal_zone" +const ( + coolingDevice = "cooling_device" + thermalZone = "thermal_zone" +) type thermalZoneCollector struct { fs sysfs.FS diff --git a/collector/timex.go b/collector/timex.go index 6494726ef7..ddb8e66c9c 100644 --- a/collector/timex.go +++ b/collector/timex.go @@ -163,7 +163,7 @@ func NewTimexCollector(logger *slog.Logger) (Collector, error) { func (c *timexCollector) Update(ch chan<- prometheus.Metric) error { var syncStatus float64 var divisor float64 - var timex = new(unix.Timex) + timex := new(unix.Timex) status, err := unix.Adjtimex(timex) if err != nil { diff --git a/collector/udp_queues_linux.go b/collector/udp_queues_linux.go index 0ebd930098..e29a0f3189 100644 --- a/collector/udp_queues_linux.go +++ b/collector/udp_queues_linux.go @@ -55,7 +55,6 @@ func NewUDPqueuesCollector(logger *slog.Logger) (Collector, error) { } func (c *udpQueuesCollector) Update(ch chan<- prometheus.Metric) error { - s4, errIPv4 := c.fs.NetUDPSummary() if errIPv4 == nil { ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s4.TxQueueLength), "tx", "v4") diff --git a/collector/uname_bsd.go b/collector/uname_bsd.go index 07f7aca063..dc14b26068 100644 --- a/collector/uname_bsd.go +++ b/collector/uname_bsd.go @@ -43,7 +43,7 @@ func getUname() (uname, error) { // parseHostNameAndDomainName for FreeBSD,OpenBSD,Darwin. // Attempts to emulate what happens in the Linux uname calls since these OS doesn't have a Domainname. -func parseHostNameAndDomainName(utsname unix.Utsname) (hostname string, domainname string) { +func parseHostNameAndDomainName(utsname unix.Utsname) (hostname, domainname string) { nodename := unix.ByteSliceToString(utsname.Nodename[:]) split := strings.SplitN(nodename, ".", 2) diff --git a/collector/vmstat_linux.go b/collector/vmstat_linux.go index 987aebe9eb..3303135a23 100644 --- a/collector/vmstat_linux.go +++ b/collector/vmstat_linux.go @@ -32,9 +32,7 @@ const ( vmStatSubsystem = "vmstat" ) -var ( - vmStatFields = kingpin.Flag("collector.vmstat.fields", "Regexp of fields to return for vmstat collector.").Default("^(oom_kill|pgpg|pswp|pg.*fault).*").String() -) +var vmStatFields = kingpin.Flag("collector.vmstat.fields", "Regexp of fields to return for vmstat collector.").Default("^(oom_kill|pgpg|pswp|pg.*fault).*").String() type vmStatCollector struct { fieldPattern *regexp.Regexp diff --git a/collector/wifi_linux.go b/collector/wifi_linux.go index 8f482c76ce..a79fc76baa 100644 --- a/collector/wifi_linux.go +++ b/collector/wifi_linux.go @@ -32,9 +32,7 @@ type wifiCollector struct { logger *slog.Logger } -var ( - collectorWifi = kingpin.Flag("collector.wifi.fixtures", "test fixtures to use for wifi collector metrics").Default("").String() -) +var collectorWifi = kingpin.Flag("collector.wifi.fixtures", "test fixtures to use for wifi collector metrics").Default("").String() func init() { registerCollector("wifi", defaultDisabled, NewWifiCollector) diff --git a/collector/xfs_linux.go b/collector/xfs_linux.go index b5157849bc..b156a15dea 100644 --- a/collector/xfs_linux.go +++ b/collector/xfs_linux.go @@ -66,9 +66,7 @@ func (c *xfsCollector) updateXFSStats(ch chan<- prometheus.Metric, s *xfs.Stats) subsystem = "xfs" ) - var ( - labels = []string{"device"} - ) + labels := []string{"device"} // Metric names and descriptions are sourced from: // http://xfs.org/index.php/Runtime_Stats. diff --git a/collector/zfs_linux.go b/collector/zfs_linux.go index 9e968f73fe..dca4d6051c 100644 --- a/collector/zfs_linux.go +++ b/collector/zfs_linux.go @@ -171,7 +171,7 @@ func (c *zfsCollector) updatePoolStats(ch chan<- prometheus.Metric) error { return errZFSNotAvailable } - err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { + err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName, datasetName string, s zfsSysctl, v uint64) { ch <- c.constPoolObjsetMetric(poolName, datasetName, s, v) }) file.Close() @@ -198,7 +198,7 @@ func (c *zfsCollector) updatePoolStats(ch chan<- prometheus.Metric) error { return errZFSNotAvailable } - err = c.parsePoolStateFile(file, zpoolPath, func(poolName string, stateName string, isActive uint64) { + err = c.parsePoolStateFile(file, zpoolPath, func(poolName, stateName string, isActive uint64) { ch <- c.constPoolStateMetric(poolName, stateName, isActive) }) @@ -262,7 +262,7 @@ func (c *zfsCollector) parsePoolProcfsFile(reader io.Reader, zpoolPath string, h line := strings.Fields(scanner.Text()) if !parseLine && len(line) >= 12 && line[0] == "nread" { - //Start parsing from here. + // Start parsing from here. parseLine = true fields = make([]string, len(line)) copy(fields, line) @@ -398,7 +398,7 @@ func (c *zfsCollector) constPoolMetric(poolName string, sysctl zfsSysctl, value ) } -func (c *zfsCollector) constPoolObjsetMetric(poolName string, datasetName string, sysctl zfsSysctl, value uint64) prometheus.Metric { +func (c *zfsCollector) constPoolObjsetMetric(poolName, datasetName string, sysctl zfsSysctl, value uint64) prometheus.Metric { metricName := sysctl.metricName() return prometheus.MustNewConstMetric( @@ -415,7 +415,7 @@ func (c *zfsCollector) constPoolObjsetMetric(poolName string, datasetName string ) } -func (c *zfsCollector) constPoolStateMetric(poolName string, stateName string, isActive uint64) prometheus.Metric { +func (c *zfsCollector) constPoolStateMetric(poolName, stateName string, isActive uint64) prometheus.Metric { return prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, "zfs_zpool", "state"), diff --git a/collector/zfs_linux_test.go b/collector/zfs_linux_test.go index 29b9ede2d3..150f4a0ab0 100644 --- a/collector/zfs_linux_test.go +++ b/collector/zfs_linux_test.go @@ -35,7 +35,6 @@ func TestArcstatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(arcstatsFile, "arcstats", func(s zfsSysctl, v any) { - if s == zfsSysctl("kstat.zfs.misc.arcstats.hits") { if v.(uint64) != 8772612 { t.Fatalf("Incorrect value parsed from procfs data") @@ -72,7 +71,6 @@ func TestZfetchstatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(zfetchstatsFile, "zfetchstats", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.zfetchstats.hits") { return } @@ -82,9 +80,7 @@ func TestZfetchstatsParsing(t *testing.T) { if v.(uint64) != 7067992 { t.Fatalf("Incorrect value parsed from procfs data") } - }) - if err != nil { t.Fatal(err) } @@ -108,7 +104,6 @@ func TestZilParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(zilFile, "zil", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.zil.zil_commit_count") { return } @@ -118,9 +113,7 @@ func TestZilParsing(t *testing.T) { if v.(uint64) != 10 { t.Fatalf("Incorrect value parsed from procfs data") } - }) - if err != nil { t.Fatal(err) } @@ -144,7 +137,6 @@ func TestVdevCacheStatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(vdevCacheStatsFile, "vdev_cache_stats", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.vdev_cache_stats.delegations") { return } @@ -154,9 +146,7 @@ func TestVdevCacheStatsParsing(t *testing.T) { if v.(uint64) != 40 { t.Fatalf("Incorrect value parsed from procfs data") } - }) - if err != nil { t.Fatal(err) } @@ -180,7 +170,6 @@ func TestXuioStatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(xuioStatsFile, "xuio_stats", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.xuio_stats.onloan_read_buf") { return } @@ -190,9 +179,7 @@ func TestXuioStatsParsing(t *testing.T) { if v.(uint64) != 32 { t.Fatalf("Incorrect value parsed from procfs data") } - }) - if err != nil { t.Fatal(err) } @@ -216,7 +203,6 @@ func TestFmParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(fmFile, "fm", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.fm.erpt-dropped") { return } @@ -226,9 +212,7 @@ func TestFmParsing(t *testing.T) { if v.(uint64) != 18 { t.Fatalf("Incorrect value parsed from procfs data") } - }) - if err != nil { t.Fatal(err) } @@ -252,7 +236,6 @@ func TestDmuTxParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(dmuTxFile, "dmu_tx", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.dmu_tx.dmu_tx_assigned") { return } @@ -262,9 +245,7 @@ func TestDmuTxParsing(t *testing.T) { if v.(uint64) != 3532844 { t.Fatalf("Incorrect value parsed from procfs data") } - }) - if err != nil { t.Fatal(err) } @@ -302,7 +283,6 @@ func TestZpoolParsing(t *testing.T) { if v != 1884160 && v != 2826240 { t.Fatalf("Incorrect value parsed from procfs data %v", v) } - }) file.Close() if err != nil { @@ -347,7 +327,7 @@ func TestZpoolObjsetParsingWithSpace(t *testing.T) { } handlerCalled = false - err = c.parsePoolObjsetFile(file, test.path, func(_ string, datasetName string, _ zfsSysctl, _ uint64) { + err = c.parsePoolObjsetFile(file, test.path, func(_, datasetName string, _ zfsSysctl, _ uint64) { handlerCalled = true if test.expectedDataset != datasetName { t.Fatalf("Incorrectly parsed dataset name: expected: '%s', got: '%s'", test.expectedDataset, datasetName) @@ -381,7 +361,7 @@ func TestZpoolObjsetParsing(t *testing.T) { t.Fatal(err) } - err = c.parsePoolObjsetFile(file, zpoolPath, func(_ string, _ string, s zfsSysctl, v uint64) { + err = c.parsePoolObjsetFile(file, zpoolPath, func(_, _ string, s zfsSysctl, v uint64) { if s != zfsSysctl("kstat.zfs.misc.objset.writes") { return } @@ -391,7 +371,6 @@ func TestZpoolObjsetParsing(t *testing.T) { if v != 0 && v != 4 && v != 10 { t.Fatalf("Incorrect value parsed from procfs data %v", v) } - }) file.Close() if err != nil { @@ -417,7 +396,6 @@ func TestAbdstatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(abdstatsFile, "abdstats", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.abdstats.linear_data_size") { return } @@ -427,9 +405,7 @@ func TestAbdstatsParsing(t *testing.T) { if v.(uint64) != 223232 { t.Fatalf("Incorrect value parsed from procfs abdstats data") } - }) - if err != nil { t.Fatal(err) } @@ -453,7 +429,6 @@ func TestDbufstatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(dbufstatsFile, "dbufstats", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.dbufstats.hash_hits") { return } @@ -463,9 +438,7 @@ func TestDbufstatsParsing(t *testing.T) { if v.(uint64) != 108807 { t.Fatalf("Incorrect value parsed from procfs dbufstats data") } - }) - if err != nil { t.Fatal(err) } @@ -489,7 +462,6 @@ func TestDnodestatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(dnodestatsFile, "dnodestats", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.dnodestats.dnode_hold_alloc_hits") { return } @@ -499,9 +471,7 @@ func TestDnodestatsParsing(t *testing.T) { if v.(uint64) != 37617 { t.Fatalf("Incorrect value parsed from procfs dnodestats data") } - }) - if err != nil { t.Fatal(err) } @@ -525,7 +495,6 @@ func TestVdevMirrorstatsParsing(t *testing.T) { handlerCalled := false err = c.parseProcfsFile(vdevMirrorStatsFile, "vdev_mirror_stats", func(s zfsSysctl, v any) { - if s != zfsSysctl("kstat.zfs.misc.vdev_mirror_stats.preferred_not_found") { return } @@ -535,9 +504,7 @@ func TestVdevMirrorstatsParsing(t *testing.T) { if v.(uint64) != 94 { t.Fatalf("Incorrect value parsed from procfs vdev_mirror_stats data") } - }) - if err != nil { t.Fatal(err) } @@ -565,7 +532,7 @@ func TestPoolStateParsing(t *testing.T) { t.Fatal(err) } - err = c.parsePoolStateFile(file, zpoolPath, func(poolName string, stateName string, isActive uint64) { + err = c.parsePoolStateFile(file, zpoolPath, func(poolName, stateName string, isActive uint64) { handlerCalled = true if poolName == "pool1" { @@ -592,7 +559,6 @@ func TestPoolStateParsing(t *testing.T) { t.Fatalf("Incorrect parsed value for suspended state") } } - }) file.Close() if err != nil { @@ -602,5 +568,4 @@ func TestPoolStateParsing(t *testing.T) { if !handlerCalled { t.Fatal("Zpool parsing handler was not called for some expected sysctls") } - } diff --git a/collector/zoneinfo_linux.go b/collector/zoneinfo_linux.go index 0b40fd3c59..78091b1959 100644 --- a/collector/zoneinfo_linux.go +++ b/collector/zoneinfo_linux.go @@ -92,6 +92,7 @@ func (c *zoneinfoCollector) Update(ch chan<- prometheus.Metric) error { } return nil } + func createGaugeMetricDescriptions() map[string]*prometheus.Desc { return map[string]*prometheus.Desc{ "NrFreePages": prometheus.NewDesc( @@ -199,8 +200,8 @@ func createGaugeMetricDescriptions() map[string]*prometheus.Desc { "Number of shmem pages (included tmpfs/GEM pages)", []string{"node", "zone"}, nil), } - } + func createCounterMetricDescriptions() map[string]*prometheus.Desc { return map[string]*prometheus.Desc{ "NrDirtied": prometheus.NewDesc( diff --git a/debian/changelog b/debian/changelog index 23865ce2c3..a6b12c1edc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +cl-node-exporter (1.2.2-1) stable; urgency=medium + + [ Roman Krompets ] + * CLOS-9230: Sync node_exporter with upstream (v1.13.1) + + -- Roman Krompets Mon, 23 Nov 2026 10:00:00 +0000 + cl-node-exporter (1.2.1-1) stable; urgency=medium [ Roman Krompets ] diff --git a/debian/rules b/debian/rules index 0a0ea703d4..a58208c573 100644 --- a/debian/rules +++ b/debian/rules @@ -29,7 +29,7 @@ _clshare_plus := /usr/share/cloudlinux/cl_plus dh $@ override_dh_auto_build: - curl https://dl.google.com/go/go1.24.0.linux-amd64.tar.gz --output /tmp/go.tar.gz + curl https://dl.google.com/go/go1.27.4.linux-amd64.tar.gz --output /tmp/go.tar.gz tar xzf /tmp/go.tar.gz -C /tmp/ make build make tools @@ -51,11 +51,17 @@ override_dh_auto_install: mkdir -p $(buildroot)/opt/node_exporter_tests/tools install -D -m 755 tools/tools $(buildroot)/opt/node_exporter_tests/tools/tools - # remove broken symlinks + # remove broken symlinks (QA rejects them); block device slaves/ entries are + # read by name only (diskstats backing devices), so they become empty files + find $(buildroot)/opt/node_exporter_tests/collector/fixtures -xtype l -path '*/slaves/*' -exec rm {} \; -exec touch {} \; find $(buildroot)/opt/node_exporter_tests/collector/fixtures -xtype l -delete echo "$(version)-$(release)" > $(buildroot)/usr/share/cloudlinux/cl_version + # dh_movefiles moves files and symlinks only: create the empty fixture + # directories (e.g. sys/block/dm-5/slaves/sd*) in the tests package + cd $(buildroot) && find ./opt/node_exporter_tests/collector -type d -empty -exec install -d $(CURDIR)/debian/$(name)-tests/{} \; + # Packaging dh_movefiles -p$(name) \ .$(_clshare_plus)/node_exporter diff --git a/docs/design/cloudlinux-packaging.md b/docs/design/cloudlinux-packaging.md index bec3b7189e..acc63b5803 100644 --- a/docs/design/cloudlinux-packaging.md +++ b/docs/design/cloudlinux-packaging.md @@ -30,8 +30,8 @@ package (`cl_plus`). | Path | Purpose | |------|---------| | `/opt/node_exporter_tests/node_exporter` | Second copy of the built binary, used by the e2e harness. | -| `/opt/node_exporter_tests/end-to-end-test.sh` | E2E harness script. | -| `/opt/node_exporter_tests/collector/` | Fixture data (procfs/sysfs/udev snapshots). Broken symlinks under `fixtures/` are stripped during `%install` because dh on Ubuntu rejects them. | +| `/opt/node_exporter_tests/end-to-end-test.sh` | E2E harness script. Needs `curl` and `diff` (diffutils) on the test host, in both modes; the subpackage declares no dependencies (`AutoReq: 0`). | +| `/opt/node_exporter_tests/collector/` | Fixture data (procfs/sysfs/udev snapshots). Both recipes strip broken symlinks under `fixtures/` during install, so the package ships none (see Invariants). The five broken `sys/block/dm-*/slaves/*` links are replaced by empty regular files of the same name instead: the diskstats collector only lists the entry names there (procfs `SysBlockDeviceUnderlyingDevices`, `Readdirnames`) for `node_disk_device_mapper_backing_device_info` (upstream v1.13.0+), and without them the e2e output misses five series in both modes. | | `/opt/node_exporter_tests/tools/tools` | Build-tag matcher helper used by the e2e script. | This subpackage exists so the QA pipeline can run the upstream e2e suite on @@ -43,11 +43,24 @@ the exact binary that ships, including the CloudLinux unix-socket mode (see Both packages download and use a pinned upstream Go toolchain at build time rather than relying on the distro's `golang` package: -- **Pinned version: `go1.24.0`.** Hard-coded in both `node_exporter.spec` - (`%build` section) and `debian/rules` (`override_dh_auto_build`). -- **Source:** `https://dl.google.com/go/go1.24.0.linux-.tar.gz`. +- **Pinned version: `go1.27.4`.** Hard-coded in both `node_exporter.spec` + (`%build` section) and `debian/rules` (`override_dh_auto_build`). It must + be at least the `go` directive in `go.mod` (`1.26.0` at upstream v1.13.1): + with an older toolchain the go command's default `GOTOOLCHAIN=auto` + silently downloads the required toolchain from `proxy.golang.org` (the + 1.2.1 package pinned `go1.24.0` but its binary reports `go1.25.0`). The + pin follows the Go line upstream builds releases with (`.promu.yml`, + `setup-go` in `.github/workflows/ci.yml`), at its latest patch release. +- **Source:** `https://dl.google.com/go/go1.27.4.linux-.tar.gz` + (`amd64`; the spec's non-x86_64 branch fetches `386`). The archive is not + checksum-verified by the recipes; the published SHA-256 values are listed + at `https://go.dev/dl/?mode=json`. - **Location:** extracted to `%{_tmppath}/go` (RPM) or `/tmp/go` (deb). -- The pinned toolchain is prepended to `PATH` for the duration of the build. +- The pinned toolchain is appended to `PATH` in the spec (a `go` already on + the builder's `PATH` would win) and prepended in `debian/rules`. +- Go modules are not vendored: `make build` / `make test` download them + from the Go module proxy, and `make build` downloads `promu` from GitHub, + so build workers need internet access. RPM spec also runs 32-bit cross-testing (`make test-32bit`) on x86_64/amd64 builds. The deb rules do not. @@ -63,9 +76,12 @@ builds. The deb rules do not. ### Debian-only conventions (`debian/rules`) -- After install, `find $buildroot/opt/node_exporter_tests/collector/fixtures - -xtype l -delete` removes broken symlinks produced by the procfs fixture - ttar archive. Without this, `dh_*` fails the build on Ubuntu. +- `dh_movefiles` moves only files and symlinks, so empty fixture + directories (e.g. `sys/block/dm-5/slaves/sd*`, listed by the dmmultipath + collector) are created in the tests package directly with + `find -type d -empty -exec install -d`. Without them the deb tests + package's e2e misses the `node_dmmultipath_*` path series. QA does not + run the e2e on Ubuntu, so only a manual run catches this. - `override_dh_auto_clean` only removes `debian/tmp` — it does not invoke `make clean`, so the vendored Go toolchain in `/tmp/go` may persist between builds on a long-lived worker. @@ -89,6 +105,12 @@ builds. The deb rules do not. - **Tests subpackage is optional.** The binary package must function without `cl-node-exporter-tests` installed; the test subpackage is a QA-only artifact. +- **No dangling symlinks in either package.** QA's + `rpm_tests/common/0_integrity_check.bats` ("symlinks are correct and + exists") fails a package with a symlink to a missing target, on every + target including Ubuntu. Fixture links that dangle after extraction are + deleted, or, where a collector needs the entry name, replaced by an empty + file in both recipes. - **Both architectures are amd64-only today.** Both `node_exporter.spec` (via the `%ifarch` x86_64/amd64/ia32e branches being the only curl'd Go archives) and `debian/control` (`Architecture: amd64`) restrict the @@ -98,7 +120,9 @@ builds. The deb rules do not. | Aspect | Test | Type | Covers | |--------|------|------|--------| -| Binary builds and e2e passes on RPM build workers | `%build` section of `node_exporter.spec` runs `make build`, `make test`, `make test-32bit` | RPM build-time | Compilation + unit tests + 32-bit cross-compile + e2e socket/TCP tests (`make test-e2e`) on RPM workers. Failure aborts the build. | +| Binary builds and unit tests pass on RPM build workers | `%build` section of `node_exporter.spec` runs `make build`, `make tools`, `make test`, `make test-32bit` | RPM build-time | Compilation + unit tests (with `-race` on x86_64) + 32-bit cross-compile tests on RPM workers. Failure aborts the build. `make test-e2e` is not run here; the root-package tests that need a built binary skip (it is not at `$GOPATH/bin`). | +| E2E over TCP and unix socket on the shipped binary | `rpm_tests/p_cl-node-exporter` in the QA repo runs `/opt/node_exporter_tests/end-to-end-test.sh` and `-s` | QA (installed package) | Both runs must exit 0 with no output. Ubuntu is skipped there (covered by `cl-end-server-tools` tests). | +| Packages ship no dangling symlinks | `rpm_tests/common/0_integrity_check.bats` in the QA repo ("symlinks are correct and exists") | QA (installed package) | Every symlink in `cl-node-exporter` and `cl-node-exporter-tests` must resolve; runs on all targets including Ubuntu. | | Binary builds on Ubuntu build workers | `override_dh_auto_build` in `debian/rules` runs `make build`, `make tools`, `make test` | deb build-time | Compilation + unit tests on Ubuntu. (No `test-e2e` is wired in deb.) | | Fixture ttar archive is extractable | `make test-e2e` depends on `collector/fixtures/sys/.unpacked` and `collector/fixtures/udev/.unpacked` | Build | If the ttar archives are corrupt or missing, the build fails at extraction time. | @@ -112,10 +136,10 @@ builds. The deb rules do not. - **Version-file format is not asserted.** If a future change to the spec accidentally drops the newline, quotes the string, or appends the architecture, Sentry tagging will silently degrade. -- **Tests subpackage is not smoke-tested after install.** No CI job - installs `cl-node-exporter-tests` on a fresh VM and runs - `/opt/node_exporter_tests/end-to-end-test.sh` against the shipped - binary. +- **Tests subpackage runs on RPM systems only.** QA's + `rpm_tests/p_cl-node-exporter` installs `cl-node-exporter-tests` and runs + the e2e harness against the shipped binary on CloudLinux, but skips + Ubuntu. - **No coverage for non-amd64 targets.** Non-x86_64 arches are not built and therefore not exercised at all for the RPM or deb paths, even though upstream supports them. diff --git a/docs/design/unix-socket-listener.md b/docs/design/unix-socket-listener.md index c93dadd620..1821873436 100644 --- a/docs/design/unix-socket-listener.md +++ b/docs/design/unix-socket-listener.md @@ -10,7 +10,8 @@ HTTP authentication/TLS. Access control is delegated to filesystem permissions on the socket file. This feature is CloudLinux-specific — it does not exist in upstream -`prometheus/node_exporter`. +`prometheus/node_exporter`, and exporter-toolkit (checked up to v0.21.0) has +no unix socket listener either. ## Flags @@ -19,33 +20,60 @@ This feature is CloudLinux-specific — it does not exist in upstream | `--web.socket-path` | `""` (empty — disabled) | Filesystem path of the unix socket to listen on. When non-empty, disables the upstream TCP/TLS listener entirely. | | `--web.socket-permissions` | `0640` | `chmod` bits applied to the socket file after it is created. Accepts an integer (octal literal recognised by Go's `Int32` parser). | -Flags are parsed by `kingpin` and defined in `node_exporter.go`. Both flags -ship in the fork's main package and are always visible in `--help`, regardless -of OS. Upstream flags (`--web.listen-address`, `--web.config.file`, -`--web.systemd-socket`) are still present but are mutually exclusive with -`--web.socket-path` at runtime (see Invariants below). +Flags are parsed by `kingpin` and defined in `main()` in `node_exporter.go`. +Both flags ship in the fork's main package and are always visible in +`--help`, regardless of OS. The upstream web flags are registered by +exporter-toolkit's `bootstrap.New`: `--web.listen-address`, +`--web.config.file` and `--web.systemd-socket` are still present but are +ignored when `--web.socket-path` is set (see Invariants below); +`--web.telemetry-path`, `--web.disable-exporter-metrics` and +`--web.max-requests` apply to both transports. ## Mechanism -When `--web.socket-path` is non-empty, the exporter: - -1. Calls `os.Remove` on the socket path before binding. Any pre-existing file +Upstream (since v1.13.0) starts the exporter through exporter-toolkit's +`bootstrap.Runner`: `runner.Run()` parses the flags, calls the runner's +`MetricsHandlerFactory`, builds the HTTP mux (metrics path, landing page, +routes the factory registered, e.g. `/debug/pprof/`) and then opens the +listeners with `web.ListenAndServe` (TCP, vsock or systemd sockets). The +toolkit offers no hook to replace the listener, so the fork hooks in at the +factory: after `bootstrap.New`, `main()` wraps `runner.MetricsHandlerFactory` +with `unixSocketFactory` (`node_exporter.go`). Bootstrap calls the factory +after parsing flags and before opening any listener. + +When `--web.socket-path` is empty (default), the wrapper returns the upstream +handler unchanged and bootstrap serves TCP (+ optional TLS) exactly as +upstream does. When it is non-empty, the wrapper builds the upstream handler +and calls `serveUnixSocket`, which never returns to bootstrap on success: + +1. Registers on `http.DefaultServeMux` what bootstrap serves over TCP: the + metrics path wrapped in `Bootstrap.MaxRequestsHandler` + (`--web.max-requests`), the landing page built from `runner.LandingConfig` + unless the metrics path is `/`, and `net/http/pprof`, which registers + itself on `DefaultServeMux`. +2. Logs the `Starting node_exporter` and `Build context` lines that + `runner.Run()` logs before listening. +3. Calls `os.Remove` on the socket path before binding. Any pre-existing file (stale socket from a previous run, regular file, symlink) is removed unconditionally. -2. Binds a `net.Listen("unix", path)` listener. -3. `chmod`s the newly created socket to `--web.socket-permissions`. If the - chmod fails, the socket file is removed and the process exits non-zero. -4. Serves HTTP over the unix listener in a goroutine. -5. Installs a `SIGINT` / `SIGTERM` handler. On signal the server is closed and - the socket file is `os.Remove`d before exit (exit code 0). -6. Registers a `defer os.Remove` on the socket path as a secondary cleanup in - case the signal handler path is bypassed. - -When `--web.socket-path` is empty (default), the exporter falls through to the -upstream `web.ListenAndServe(...)` path using `toolkitFlags` (TCP + optional -TLS). The unix-socket branch and the TCP branch are mutually exclusive in the -same process. - +4. Binds a `net.Listen("unix", path)` listener. +5. `chmod`s the newly created socket to `--web.socket-permissions`. If the + chmod fails, the error is returned: the listener is closed, which also + removes the socket file, and `main()` exits 1 with the error on stderr. +6. Serves plain HTTP over the unix listener in a goroutine, with the same + `ReadHeaderTimeout` (one minute) as bootstrap's TCP server. + `--web.config.file` (TLS, basic auth) is not applied to the socket. +7. Installs a `SIGINT` / `SIGTERM` handler. On signal the server is closed, + the socket file is `os.Remove`d and the process exits 0. If serving fails + instead, the error is returned, the deferred listener close removes the + socket file and `main()` exits 1. + +Bind errors are returned the same way (exit 1, error on stderr). Because the +wrapper does not return to bootstrap in socket mode, `web.ListenAndServe` is +never called and no TCP listener exists in that process. + +`SIGHUP` is not handled in either mode: Go's default action terminates the +process and leaves the socket file behind (unchanged from earlier releases). ## Invariants - **Exclusive listener.** When `--web.socket-path` is non-empty, no TCP @@ -57,7 +85,7 @@ same process. - **Socket is always removed on clean shutdown.** On `SIGINT`/`SIGTERM`, or on any error path after successful bind, the socket file must not be left behind. The e2e test `end-to-end-test.sh -s` asserts this explicitly and - fails the build if the socket file is still present after shutdown. + fails if the socket file is still present after shutdown. - **Permissions are applied before first accept.** The chmod step happens synchronously before the `Serve` goroutine is started, so no client can connect to an over-permissive socket. @@ -84,23 +112,23 @@ its parent directory, and setting the scraping group. | Metrics over unix socket match metrics over TCP | `end-to-end-test.sh -s` (invoked by `make test-e2e`) | E2E | Full `/metrics` exposition via `curl --unix-socket` must diff-equal the fixture produced via TCP. | | Socket file is removed on clean shutdown | `end-to-end-test.sh` finish trap (socket mode) | E2E | After SIGTERM, `ls` on the socket path must fail; test exits non-zero otherwise. | | Both transports still work after refactors | `Makefile` `test-e2e` target | E2E | Runs the e2e suite twice — once with TCP (`--web.listen-address`) and once with `--web.socket-path`. | +| Default permissions are applied | `end-to-end-test.sh -s` | E2E | Without `--web.socket-permissions` (as `cl_plus` runs it) the socket file's `ls -ld` mode string starts with `srw-r-----`. | +| No TCP listener in socket mode | `end-to-end-test.sh -s` | E2E | The exporter also gets `--web.listen-address=127.0.0.1:`; `curl` to that address must fail with exit code 7 (connection refused) while the socket serves metrics. This shows bootstrap never opens its listeners; it does not look for TCP listeners on other addresses. The check uses only `ls` and `curl`, which the script already needs, so it runs unchanged on Linux and on the BSD, Solaris and macOS jobs of the upstream workflows. | +| Non-default permissions, ignored TCP flags, SIGTERM exit | `TestUnixSocket` in `node_exporter_test.go` | Go (runs the binary) | `--web.socket-permissions 0600` gives a `0600` socket; the `--web.listen-address` passed alongside is not served; SIGTERM exits 0 and removes the socket. Like the other binary tests there, it is skipped unless the binary is at `$GOPATH/bin/node_exporter`, so it does not run in package builds. | ### Known gaps -- **Permission mode semantics are not tested.** No automated test verifies - that `--web.socket-permissions` actually produces the requested mode on - disk, nor that a non-default value (e.g., `0600`, `0660`) is honoured. -- **Concurrent-start / stale-socket scenarios are not tested.** The e2e - suite does not cover the case where a previous process crashed leaving a - socket file behind, nor the case where two exporters race on the same - path. +- **Concurrent-start / stale-socket scenarios are barely tested.** The e2e + suite pre-creates the socket path as a regular file, so removal of a + stale file at startup is exercised, but a stale socket left by a crashed + process and two exporters racing on the same path are not. - **Chmod-failure path is not tested.** Exit behaviour when `chmod` fails (e.g., socket path on a filesystem that rejects mode changes) is not exercised. - **Signal-handling coverage is shallow.** Only the graceful `SIGINT`/`SIGTERM` path is exercised; `SIGKILL` or panic paths (which leak the socket file by design) are not asserted anywhere. -- **No assertion that TCP flags are ignored in socket mode.** A user - passing both `--web.listen-address` and `--web.socket-path` gets - socket-only behaviour silently; this is not documented in `--help` or - checked at flag-parse time. +- **Ignoring TCP flags in socket mode is silent.** A user passing both + `--web.listen-address` and `--web.socket-path` gets socket-only behaviour + (asserted by `TestUnixSocket` and `end-to-end-test.sh -s`); this is not + documented in `--help` or reported at flag-parse time. diff --git a/end-to-end-test.sh b/end-to-end-test.sh index 552d49ab70..179bac5ffb 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -74,6 +74,7 @@ enabled_collectors=$(cat << COLLECTORS processes qdisc rapl + resctrl schedstat slabinfo sockstat @@ -180,6 +181,7 @@ collector_flags=$(cat << FLAGS --collector.netdev.device-include=lo --collector.qdisc.device-include=(wlan0|eth0) --collector.qdisc.fixtures=collector/fixtures/qdisc/ + --collector.resctrl.path=collector/fixtures/resctrl --collector.stat.softirq --collector.sysctl.include-info=kernel.seccomp.actions_avail --collector.sysctl.include=fs.file-nr @@ -271,7 +273,8 @@ EOF if [ ${socket} -ne 0 ]; then touch "${unix_socket}" - connection_params="--web.socket-path=${unix_socket}" + # The TCP address is passed as well: unix socket mode must not listen on it. + connection_params="--web.socket-path=${unix_socket} --web.listen-address=127.0.0.1:${port}" else connection_params="--web.listen-address=127.0.0.1:${port}" fi @@ -293,7 +296,7 @@ generated_metrics="${tmpdir}/e2e-output.txt" for os in freebsd openbsd netbsd solaris dragonfly darwin; do if [ "${GOHOSTOS}" = "${os}" ]; then generated_metrics="${tmpdir}/e2e-output-${GOHOSTOS}.txt" - fixture_metrics="${fixture_metrics::-4}-${GOHOSTOS}.txt" + fixture_metrics="${fixture_metrics%.txt}-${GOHOSTOS}.txt" fi done @@ -370,6 +373,25 @@ sleep 1 fi ) | grep --text -E -v "${skip_re}" > "${generated_metrics}" +if [ ${socket} -ne 0 ]; then + # The default --web.socket-permissions (0640, what cl_plus runs with) is + # applied to the socket file. + socket_mode=$(ls -ld "${unix_socket}") + socket_mode=${socket_mode:0:10} + if [ "${socket_mode}" != "srw-r-----" ]; then + echo "Unix socket has mode ${socket_mode}, want srw-r-----" + exit 1 + fi + # No TCP listener is opened in unix socket mode: connecting to the + # --web.listen-address passed above must be refused (curl exit code 7). + tcp_rc=0 + curl -s -o /dev/null "http://127.0.0.1:${port}/" || tcp_rc=$? + if [ ${tcp_rc} -ne 7 ]; then + echo "Node exporter accepted a TCP connection on 127.0.0.1:${port} in unix socket mode (curl exit code ${tcp_rc}, want 7)" + exit 1 + fi +fi + # The following ignore-list is only applicable to the VMs used to run E2E tests on platforms for which containerized environments are not available. # However, owing to this, there are some non-deterministic metrics that end up generating samples, unlike their containerized counterparts, for e.g., node_network_receive_bytes_total. non_deterministic_metrics=$(cat << METRICS @@ -409,6 +431,7 @@ non_deterministic_metrics=$(cat << METRICS node_memory_swapped_in_bytes_total node_memory_swapped_out_bytes_total node_memory_swap_size_bytes + node_memory_total_bytes node_memory_wired_bytes node_netstat_tcp_receive_packets_total node_netstat_tcp_transmit_packets_total @@ -433,6 +456,7 @@ non_deterministic_metrics=$(cat << METRICS node_network_receive_bytes_total node_network_receive_multicast_total node_network_transmit_multicast_total + node_thermal_temperature_celsius node_zfs_abdstats_linear_count_total node_zfs_abdstats_linear_data_bytes node_zfs_abdstats_scatter_chunk_waste_bytes @@ -442,6 +466,7 @@ non_deterministic_metrics=$(cat << METRICS node_zfs_arcstats_anon_bytes node_zfs_arcstats_c_bytes node_zfs_arcstats_c_max_bytes + node_zfs_arcstats_c_min_bytes node_zfs_arcstats_data_bytes node_zfs_arcstats_demand_data_hits_total node_zfs_arcstats_demand_data_misses_total diff --git a/go.mod b/go.mod index bd7983b8c0..e7b276e5f5 100644 --- a/go.mod +++ b/go.mod @@ -1,33 +1,33 @@ module github.com/prometheus/node_exporter -go 1.25.0 +go 1.26.0 require ( github.com/alecthomas/kingpin/v2 v2.4.0 - github.com/beevik/ntp v1.5.0 + github.com/beevik/ntp v1.6.0 github.com/coreos/go-systemd/v22 v22.7.0 github.com/dennwc/btrfs v0.0.0-20260222081608-edfb8b9e4f55 github.com/ema/qdisc v1.0.0 - github.com/godbus/dbus/v5 v5.2.2 + github.com/godbus/dbus/v5 v5.2.4 github.com/hashicorp/go-envparse v0.1.0 github.com/hodgesds/perf-utils v0.7.0 github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 - github.com/jsimonetti/rtnetlink/v2 v2.2.0 + github.com/jsimonetti/rtnetlink/v2 v2.3.0 github.com/lufia/iostat v1.2.1 github.com/mattn/go-xmlrpc v0.0.3 - github.com/mdlayher/ethtool v0.6.1 + github.com/mdlayher/ethtool v0.7.0 github.com/mdlayher/netlink v1.11.2 - github.com/mdlayher/wifi v0.8.0 + github.com/mdlayher/wifi v0.10.0 github.com/opencontainers/selinux v1.15.1 - github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 + github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 github.com/prometheus-community/go-runit v0.1.0 - github.com/prometheus/client_golang v1.23.2 - github.com/prometheus/client_model v0.6.2 - github.com/prometheus/common v0.70.0 - github.com/prometheus/exporter-toolkit v0.17.1 - github.com/prometheus/procfs v0.21.1 + github.com/prometheus/client_golang v1.25.0 + github.com/prometheus/client_model v0.6.3 + github.com/prometheus/common v0.74.0 + github.com/prometheus/exporter-toolkit v0.20.0 + github.com/prometheus/procfs v0.23.0 github.com/safchain/ethtool v0.7.0 - golang.org/x/sys v0.47.0 + golang.org/x/sys v0.50.0 howett.net/plist v1.0.1 ) @@ -48,16 +48,17 @@ require ( github.com/mdlayher/vsock v1.3.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect + github.com/pandatix/go-abnf v0.5.5 // indirect github.com/siebenmann/go-kstat v0.0.0-20210513183136-173c9b0a9973 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - go.yaml.in/yaml/v2 v2.4.4 // indirect - golang.org/x/crypto v0.54.0 // indirect - golang.org/x/net v0.57.0 // indirect - golang.org/x/oauth2 v0.36.0 // indirect - golang.org/x/sync v0.22.0 // indirect - golang.org/x/text v0.40.0 // indirect + go.yaml.in/yaml/v2 v2.4.5 // indirect + golang.org/x/crypto v0.58.0 // indirect + golang.org/x/net v0.62.0 // indirect + golang.org/x/oauth2 v0.38.0 // indirect + golang.org/x/sync v0.24.0 // indirect + golang.org/x/text v0.43.0 // indirect golang.org/x/time v0.15.0 // indirect - google.golang.org/protobuf v1.36.11 // indirect + google.golang.org/protobuf v1.36.12 // indirect ) diff --git a/go.sum b/go.sum index 0ab3abcb66..57b40f790f 100644 --- a/go.sum +++ b/go.sum @@ -4,20 +4,19 @@ github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjH github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0= github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs= -github.com/beevik/ntp v1.5.0 h1:y+uj/JjNwlY2JahivxYvtmv4ehfi3h74fAuABB9ZSM4= -github.com/beevik/ntp v1.5.0/go.mod h1:mJEhBrwT76w9D+IfOEGvuzyuudiW9E52U2BaTrMOYow= +github.com/beevik/ntp v1.6.0 h1:bW359Vvw6bicGhKsVi+ZDLMsMYzb2ohUpLaF/Juv0k8= +github.com/beevik/ntp v1.6.0/go.mod h1:VTAbDFySkuc8cQiAYHhXslAHjJdenICebskhYqBWC4k= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cilium/ebpf v0.20.0 h1:atwWj9d3NffHyPZzVlx3hmw1on5CLe9eljR8VuHTwhM= -github.com/cilium/ebpf v0.20.0/go.mod h1:pzLjFymM+uZPLk/IXZUL63xdx5VXEo+enTzxkZXdycw= +github.com/cilium/ebpf v0.22.0 h1:v2ktp0roffpMOj2MMf3idtCQZOsAoC4BJbAJN+ke2bY= +github.com/cilium/ebpf v0.22.0/go.mod h1:CDzZbe2hC5JjlDC+CY3KFCzlYwN4gbxppYM+Z10bQt4= github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA= github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w= github.com/cyphar/filepath-securejoin v0.6.1 h1:5CeZ1jPXEiYt3+Z6zqprSAgSWiggmpVyciv8syjIpVE= github.com/cyphar/filepath-securejoin v0.6.1/go.mod h1:A8hd4EnAeyujCJRrICiOWqjS1AX0a9kM5XL+NwKoYSc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dennwc/btrfs v0.0.0-20260222081608-edfb8b9e4f55 h1:VAnGuI8RNnP8vHqCn8X1O63TexAv+QjMqffBdkLbYKU= github.com/dennwc/btrfs v0.0.0-20260222081608-edfb8b9e4f55/go.mod h1:Kn6RQo4OP1ZEoLB3uldDJabFcf72VgDRInxEqLEo8OE= @@ -25,8 +24,8 @@ github.com/dennwc/ioctl v1.0.1-0.20181021180353-017804252068 h1:K71w/n/Y74EQsKo9 github.com/dennwc/ioctl v1.0.1-0.20181021180353-017804252068/go.mod h1:ellh2YB5ldny99SBU/VX7Nq0xiZbHphf1DrtHxxjMk0= github.com/ema/qdisc v1.0.0 h1:EHLG08FVRbWLg8uRICa3xzC9Zm0m7HyMHfXobWFnXYg= github.com/ema/qdisc v1.0.0/go.mod h1:FhIc0fLYi7f+lK5maMsesDqwYojIOh3VfRs8EVd5YJQ= -github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ= -github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= +github.com/godbus/dbus/v5 v5.2.4 h1:F2gUCy++NMIxGmo9J+z5le/+ZC8W1OgeR51P4i9ZB/U= +github.com/godbus/dbus/v5 v5.2.4/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -42,18 +41,18 @@ github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973/go.mod h1:PoK3ejP github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/jsimonetti/rtnetlink/v2 v2.2.0 h1:/KfZ310gOAFrXXol5VwnFEt+ucldD/0dsSRZwpHCP9w= -github.com/jsimonetti/rtnetlink/v2 v2.2.0/go.mod h1:lbjDHxC+5RJ08lzPeA90Ls2pEoId3F08MoEMlhfHxeI= -github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= -github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/jsimonetti/rtnetlink/v2 v2.3.0 h1:RcO6g+rsiPuHB5oGXi4V1Gnq1FW3wY/OeJFxq/mDoEA= +github.com/jsimonetti/rtnetlink/v2 v2.3.0/go.mod h1:vhjO1m9rZR3EhuoaiTJy+pTfcFn2911lLXs2++/syos= +github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ= +github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lufia/iostat v1.2.1 h1:tnCdZBIglgxD47RyD55kfWQcJMGzO+1QBziSQfesf2k= github.com/lufia/iostat v1.2.1/go.mod h1:rEPNA0xXgjHQjuI5Cy05sLlS2oRcSlWHRLrvh/AQ+Pg= github.com/mattn/go-xmlrpc v0.0.3 h1:Y6WEMLEsqs3RviBrAa1/7qmbGB7DVD3brZIbqMbQdGY= github.com/mattn/go-xmlrpc v0.0.3/go.mod h1:mqc2dz7tP5x5BKlCahN/n+hs7OSZKJkS9JsHNBRlrxA= -github.com/mdlayher/ethtool v0.6.1 h1:fSfcX6EN3yBqcB+vsCnq8hpbIT4vEa7T+BKb0NjT894= -github.com/mdlayher/ethtool v0.6.1/go.mod h1:ezmdXM273WHGEt1OvaeqvKAkcjw28/dbYYeQuC2aIxQ= +github.com/mdlayher/ethtool v0.7.0 h1:cZ/so6IXQe8AV1ML2St/iz77ou8tkoMj3qXcmERLhrE= +github.com/mdlayher/ethtool v0.7.0/go.mod h1:zy+PslWS2FC+l3j1Tc8xtP+/m6XyuQe/va5Dw8+VS14= github.com/mdlayher/genetlink v1.4.0 h1:f/Xs7Y2T+GyX9b3dbiUhnLE9InGs5F9RxJ2JwBMl71o= github.com/mdlayher/genetlink v1.4.0/go.mod h1:d1hrKr8fwZU2JkcAtQUAzeTrI7nbgQSl+5k1cC0biSA= github.com/mdlayher/netlink v1.11.2 h1:HKh2jqe+omdSWcQ88nrT7INE61B0NXfiSPFdgL4YbNI= @@ -62,30 +61,31 @@ github.com/mdlayher/socket v0.6.1 h1:M7uj2NtuujUY4mYr1C57NmfNiRHbkKpnBxO856lsc3A github.com/mdlayher/socket v0.6.1/go.mod h1:+/SGtqc9V+5dAuRgQsU0fGBI+oRDiW7O2Obx10OIWfg= github.com/mdlayher/vsock v1.3.0 h1:bqQfZ1OznI03y6YiXp2sze05RVdzLn/zsfjnjd4+ivI= github.com/mdlayher/vsock v1.3.0/go.mod h1:WsuksavOvwCnV5UqGHUkvAvCy+Dqy81y4goKQTzxxNY= -github.com/mdlayher/wifi v0.8.0 h1:qi73hVANXCYJEsT6t147dMILsx9V6UBNipZw0mPYdu0= -github.com/mdlayher/wifi v0.8.0/go.mod h1:QHQ211ZKtZKSKssCznixGUOqBcoyBQAuQWSAOnanY4A= +github.com/mdlayher/wifi v0.10.0 h1:pAczBxBsER85yh561+d1RPw2B3ykazOpd5IGf0gJCgM= +github.com/mdlayher/wifi v0.10.0/go.mod h1:rZVskXHC+Jw0KQHeguAS4EGCmbfX7fo/O+4b0Bxx4bI= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/opencontainers/selinux v1.15.1 h1:ERxeh5caJvCzNAKdI8WQbJmB1LDTn4BuaAg8wihLBpA= github.com/opencontainers/selinux v1.15.1/go.mod h1:LenyElirjUHszfxrjuFqC85HIeXZKumHcKMQtnaDlQQ= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pandatix/go-abnf v0.5.5 h1:EXex5KkRQx4Dm6GnpAcQnIMBs9KiK0uf8p/wq+4t9PM= +github.com/pandatix/go-abnf v0.5.5/go.mod h1:AE0KD3/VNoCjGzc1gqetRKshbI4SYErXQ/8kPenR5mc= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= -github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 h1:XA01Vk/wv9YikCi1V51yRzIHPMT5of9+cMpZoZvDn/M= +github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus-community/go-runit v0.1.0 h1:uTWEj/Fn2RoLdfg/etSqwzgYNOYPrARx1BHUN052tGA= github.com/prometheus-community/go-runit v0.1.0/go.mod h1:AvJ9Jo3gAFu2lbM4+qfjdpq30FfiLDJZKbQ015u08IQ= -github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= -github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= -github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= -github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.70.0 h1:bcpru3tWPVnxGnETLgOV5jbp/JRXgYEyv65CuBLAMMI= -github.com/prometheus/common v0.70.0/go.mod h1:S/SFasQmgGiYH6C81LKCtYa8QACgthGg5zxL2udV7SY= -github.com/prometheus/exporter-toolkit v0.17.1 h1:psKN4wM7shBL/BxZkDHgm6YZJ3fAVG36+r86An/+7q0= -github.com/prometheus/exporter-toolkit v0.17.1/go.mod h1:dabwPJvxsC5+tsp2iolQrqBWZh+QlISKlYRpj9Hh5xk= -github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI= -github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY= +github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0= +github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk= +github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo= +github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM= +github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI= +github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA= +github.com/prometheus/exporter-toolkit v0.20.0 h1:hz3g2aPcq3mXlQSt1MGjj2rwVk1wtRalF+/FjYxFRkI= +github.com/prometheus/exporter-toolkit v0.20.0/go.mod h1:gIIY0Mw0ci1wgYscdeMqVh6FUPYJca549eOkE39nU64= +github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4= +github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk= github.com/safchain/ethtool v0.7.0 h1:rlJzfDetsVvT61uz8x1YIcFn12akMfuPulHtZjtb7Is= github.com/safchain/ethtool v0.7.0/go.mod h1:MenQKEjXdfkjD3mp2QdCk8B/hwvkrlOTm/FD4gTpFxQ= github.com/siebenmann/go-kstat v0.0.0-20210513183136-173c9b0a9973 h1:GfSdC6wKfTGcgCS7BtzF5694Amne1pGCSTY252WhlEY= @@ -99,8 +99,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= @@ -109,30 +109,31 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= -go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= -golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= -golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= -golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= -golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= -golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= -golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= -golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= -golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI= +go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= +golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54= +golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w= +golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY= +golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= +golang.org/x/oauth2 v0.38.0 h1:uW7XQbcu1eoiQS7uMJvLOjPMl04bTbmY1VeRPxvbspI= +golang.org/x/oauth2 v0.38.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58= +golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA= +golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= -golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= -golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= +golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= +golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= -google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= -google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM= howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= diff --git a/node_exporter.go b/node_exporter.go index 9ace4d5936..ac54e73346 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -26,9 +26,7 @@ import ( "slices" "sort" "syscall" - - "github.com/prometheus/common/promslog" - "github.com/prometheus/common/promslog/flag" + "time" "github.com/alecthomas/kingpin/v2" "github.com/prometheus/client_golang/prometheus" @@ -36,8 +34,8 @@ import ( versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/version" + "github.com/prometheus/exporter-toolkit/bootstrap" "github.com/prometheus/exporter-toolkit/web" - "github.com/prometheus/exporter-toolkit/web/kingpinflag" "github.com/prometheus/node_exporter/collector" ) @@ -104,7 +102,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // In exclude mode, filtered collectors = enabled - excludeed. f := []string{} for _, c := range h.enabledCollectors { - if (slices.Index(excludes, c)) == -1 { + if slices.Index(excludes, c) == -1 { f = append(f, c) } } @@ -192,18 +190,6 @@ func main() { "web.socket-permissions", "Permissions of unix socket file.", ).Default("0640").Int32() - metricsPath = kingpin.Flag( - "web.telemetry-path", - "Path under which to expose metrics.", - ).Default("/metrics").String() - disableExporterMetrics = kingpin.Flag( - "web.disable-exporter-metrics", - "Exclude metrics about the exporter itself (promhttp_*, process_*, go_*).", - ).Bool() - maxRequests = kingpin.Flag( - "web.max-requests", - "Maximum number of parallel scrape requests. Use 0 to disable.", - ).Default("40").Int() disableDefaultCollectors = kingpin.Flag( "collector.disable-defaults", "Set all collectors to disabled by default.", @@ -211,83 +197,98 @@ func main() { maxProcs = kingpin.Flag( "runtime.gomaxprocs", "The target number of CPUs Go will run on (GOMAXPROCS)", ).Envar("GOMAXPROCS").Default("1").Int() - toolkitFlags = kingpinflag.AddFlags(kingpin.CommandLine, ":9100") ) - promslogConfig := &promslog.Config{} - flag.AddFlags(kingpin.CommandLine, promslogConfig) - kingpin.Version(version.Print("node_exporter")) kingpin.CommandLine.UsageWriter(os.Stdout) - kingpin.HelpFlag.Short('h') - kingpin.Parse() - logger := promslog.New(promslogConfig) + runner := bootstrap.New(bootstrap.Config{ + App: kingpin.CommandLine, + Name: "node_exporter", + Description: "Prometheus Node Exporter", + DefaultAddress: ":9100", + MetricsHandlerFactory: func(b *bootstrap.Bootstrap) (http.Handler, error) { + if *disableDefaultCollectors { + collector.DisableDefaultCollectors() + } + if user, err := user.Current(); err == nil && user.Uid == "0" { + b.Logger.Warn("Node Exporter is running as root user. This exporter is designed to run as unprivileged user, root is not required.") + } + runtime.GOMAXPROCS(*maxProcs) + b.Logger.Debug("Go MAXPROCS", "procs", runtime.GOMAXPROCS(0)) + b.Handle("/debug/pprof/", http.DefaultServeMux) + return newHandler(!b.DisableExporterMetrics, b.MaxRequests, b.Logger), nil + }, + }) - if *disableDefaultCollectors { - collector.DisableDefaultCollectors() - } - logger.Info("Starting node_exporter", "version", version.Info()) - logger.Info("Build context", "build_context", version.BuildContext()) - if user, err := user.Current(); err == nil && user.Uid == "0" { - logger.Warn("Node Exporter is running as root user. This exporter is designed to run as unprivileged user, root is not required.") + // CloudLinux: serve on a unix socket instead of TCP when --web.socket-path + // is set, see docs/design/unix-socket-listener.md. + runner.MetricsHandlerFactory = unixSocketFactory(runner, socketPath, socketPermissions) + + if err := runner.Run(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) } - runtime.GOMAXPROCS(*maxProcs) - logger.Debug("Go MAXPROCS", "procs", runtime.GOMAXPROCS(0)) +} - http.Handle(*metricsPath, newHandler(!*disableExporterMetrics, *maxRequests, logger)) - if *metricsPath != "/" { - landingConfig := web.LandingConfig{ - Name: "Node Exporter", - Description: "Prometheus Node Exporter", - Version: version.Info(), - Links: []web.LandingLinks{ - { - Address: *metricsPath, - Text: "Metrics", - }, - }, +// unixSocketFactory wraps the runner's metrics handler factory to serve the +// exporter on the unix socket given by --web.socket-path (CloudLinux fork). +// exporter-toolkit has no unix socket listener; bootstrap calls the factory +// after parsing flags and before opening its TCP listeners, so in socket mode +// the wrapper serves there and never returns to bootstrap: no TCP listener is +// opened. SIGINT/SIGTERM remove the socket file and exit 0. +func unixSocketFactory(runner *bootstrap.Runner, path *string, permissions *int32) bootstrap.MetricsHandlerFactory { + factory := runner.MetricsHandlerFactory + return func(b *bootstrap.Bootstrap) (http.Handler, error) { + handler, err := factory(b) + if err != nil || *path == "" { + return handler, err } + return nil, serveUnixSocket(runner, b, handler, *path, os.FileMode(*permissions)) + } +} + +func serveUnixSocket(runner *bootstrap.Runner, b *bootstrap.Bootstrap, handler http.Handler, path string, mode os.FileMode) error { + // Serve what bootstrap serves over TCP: the metrics path, the landing + // page and net/http/pprof, which registers itself on DefaultServeMux. + http.Handle(b.MetricsPath, b.MaxRequestsHandler(handler)) + if b.MetricsPath != "/" { + landingConfig := runner.LandingConfig + landingConfig.Links = append(landingConfig.Links, web.LandingLinks{ + Address: b.MetricsPath, + Text: "Metrics", + }) landingPage, err := web.NewLandingPage(landingConfig) if err != nil { - logger.Error(err.Error()) - os.Exit(1) + return err } http.Handle("/", landingPage) } + b.Logger.Info("Starting node_exporter", "version", version.Info()) + b.Logger.Info("Build context", "build_context", version.BuildContext()) - server := &http.Server{} - if *socketPath != "" { - os.Remove(*socketPath) - unixListener, err := net.Listen("unix", *socketPath) - if err != nil { - logger.Error("Error listening on socket", "err", err) - os.Exit(1) - } - if err := os.Chmod(*socketPath, os.FileMode(*socketPermissions)); err != nil { - logger.Error("Error changing socket permissions", "err", err) - os.Remove(*socketPath) - os.Exit(1) - } - defer os.Remove(*socketPath) - - go func() { - if err := server.Serve(unixListener); err != nil && err != http.ErrServerClosed { - logger.Error("Error serving", "err", err) - os.Exit(1) - } - }() + os.Remove(path) + listener, err := net.Listen("unix", path) + if err != nil { + return fmt.Errorf("error listening on socket: %w", err) + } + // Closing the listener also removes the socket file. + defer listener.Close() + if err := os.Chmod(path, mode); err != nil { + return fmt.Errorf("error changing socket permissions: %w", err) + } - done := make(chan os.Signal, 1) - signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) - logger.Info("Listening on", "path", *socketPath) - <-done - logger.Info("Connection closed on", "path", *socketPath) + server := &http.Server{ReadHeaderTimeout: time.Minute} + done := make(chan os.Signal, 1) + signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) + errc := make(chan error, 1) + go func() { errc <- server.Serve(listener) }() + b.Logger.Info("Listening on", "path", path) + select { + case <-done: + b.Logger.Info("Connection closed on", "path", path) server.Close() - os.Remove(*socketPath) + os.Remove(path) os.Exit(0) - } else { - if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil { - logger.Error(err.Error()) - os.Exit(1) - } + case err = <-errc: } + return err } diff --git a/node_exporter.spec b/node_exporter.spec index 14f5f94e7b..ae91fc7ab8 100644 --- a/node_exporter.spec +++ b/node_exporter.spec @@ -4,7 +4,7 @@ Autoreq: 0 %define pkg_version_file %{cl_dir}%{name} Name: cl-node-exporter -Version: 1.2.1 +Version: 1.2.2 Release: 1%{dist}.cloudlinux Summary: CL Node Exporter tool License: Apache License, Version 2.0 @@ -38,9 +38,9 @@ This package provides end-to-end tests for Node Exporter tool %build # download new version of Go compiler %ifarch x86_64 amd64 ia32e -curl https://dl.google.com/go/go1.24.0.linux-amd64.tar.gz --output %{_tmppath}/go.tar.gz +curl https://dl.google.com/go/go1.27.4.linux-amd64.tar.gz --output %{_tmppath}/go.tar.gz %else -curl https://dl.google.com/go/go1.24.0.linux-386.tar.gz --output %{_tmppath}/go.tar.gz +curl https://dl.google.com/go/go1.27.4.linux-386.tar.gz --output %{_tmppath}/go.tar.gz %endif tar xzf %{_tmppath}/go.tar.gz -C %{_tmppath} export PATH=$PATH:%{_tmppath}/go/bin @@ -72,7 +72,9 @@ install -D -m 755 node_exporter $RPM_BUILD_ROOT/opt/node_exporter_tests/node_exp mkdir -p $RPM_BUILD_ROOT/opt/node_exporter_tests/tools install -D -m 755 tools/tools $RPM_BUILD_ROOT/opt/node_exporter_tests/tools/tools -# remove broken symlinks +# remove broken symlinks (QA rejects them); block device slaves/ entries are +# read by name only (diskstats backing devices), so they become empty files +find $RPM_BUILD_ROOT/opt/node_exporter_tests/collector/fixtures -xtype l -path '*/slaves/*' -exec rm {} \; -exec touch {} \; find $RPM_BUILD_ROOT/opt/node_exporter_tests/collector/fixtures -xtype l -delete # write package version to file @@ -94,6 +96,9 @@ exit 0 %changelog +* Mon Nov 23 2026 Roman Krompets 1.2.2-1 +- CLOS-9230: Sync repository with upstream (v1.13.1) + * Fri Apr 24 2026 Roman Krompets 1.2.1-1 - CLPRO-3024: Sync repository with upstream (v1.11.1) diff --git a/node_exporter_test.go b/node_exporter_test.go index 0d6b41e4d5..eaa6337ca0 100644 --- a/node_exporter_test.go +++ b/node_exporter_test.go @@ -14,21 +14,22 @@ package main import ( + "context" "fmt" "io" + "net" "net/http" "os" "os/exec" "path/filepath" + "syscall" "testing" "time" "github.com/prometheus/procfs" ) -var ( - binary = filepath.Join(os.Getenv("GOPATH"), "bin/node_exporter") -) +var binary = filepath.Join(os.Getenv("GOPATH"), "bin/node_exporter") const ( address = "localhost:19100" @@ -84,27 +85,74 @@ func TestHandlingOfDuplicatedMetrics(t *testing.T) { t.Skipf("node_exporter binary not available, try to run `make build` first: %s", err) } - dir, err := os.MkdirTemp("", "node-exporter") + exporter := exec.Command(binary, "--web.listen-address", address, "--collector.textfile.directory", "collector/fixtures/textfile/duplicate_metrics") + test := func(_ int) error { + return queryExporter(address) + } + + if err := runCommandAndTests(exporter, address, test); err != nil { + t.Error(err) + } +} + +// TestUnixSocket covers the CloudLinux unix socket transport, see +// docs/design/unix-socket-listener.md. +func TestUnixSocket(t *testing.T) { + if _, err := os.Stat(binary); err != nil { + t.Skipf("node_exporter binary not available, try to run `make build` first: %s", err) + } + + socket := filepath.Join(t.TempDir(), "node_exporter.socket") + exporter := exec.Command(binary, + "--web.socket-path", socket, + "--web.socket-permissions", "0600", + "--web.listen-address", address) + if err := exporter.Start(); err != nil { + t.Fatalf("failed to start command: %s", err) + } + defer exporter.Process.Kill() + + client := &http.Client{Transport: &http.Transport{ + DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { + return (&net.Dialer{}).DialContext(ctx, "unix", socket) + }, + }} + var err error + for range 10 { + time.Sleep(500 * time.Millisecond) + var resp *http.Response + if resp, err = client.Get("http://localhost/metrics"); err == nil { + resp.Body.Close() + if resp.StatusCode != http.StatusOK { + err = fmt.Errorf("want /metrics status code %d, have %d", http.StatusOK, resp.StatusCode) + } + break + } + } if err != nil { - t.Fatal(err) + t.Fatalf("metrics are not served on the unix socket: %s", err) } - defer os.RemoveAll(dir) - content := []byte("dummy_metric 1\n") - if err := os.WriteFile(filepath.Join(dir, "a.prom"), content, 0600); err != nil { + fi, err := os.Stat(socket) + if err != nil { t.Fatal(err) } - if err := os.WriteFile(filepath.Join(dir, "b.prom"), content, 0600); err != nil { - t.Fatal(err) + if fi.Mode()&os.ModeSocket == 0 || fi.Mode().Perm() != 0o600 { + t.Errorf("want a socket with permissions 0600, have %s", fi.Mode()) } - exporter := exec.Command(binary, "--web.listen-address", address, "--collector.textfile.directory", dir) - test := func(_ int) error { - return queryExporter(address) + if err := queryExporter(address); err == nil { + t.Errorf("want no TCP listener on %s in unix socket mode", address) } - if err := runCommandAndTests(exporter, address, test); err != nil { - t.Error(err) + if err := exporter.Process.Signal(syscall.SIGTERM); err != nil { + t.Fatal(err) + } + if err := exporter.Wait(); err != nil { + t.Errorf("want clean exit on SIGTERM, have %s", err) + } + if _, err := os.Stat(socket); !os.IsNotExist(err) { + t.Errorf("want the socket file removed on SIGTERM, have %v", err) } }