Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: prometheus/procfs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.12.0
Choose a base ref
...
head repository: prometheus/procfs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.15.1
Choose a head ref

Commits on Oct 3, 2023

  1. Update common Prometheus files (#578)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Oct 3, 2023
    Copy the full SHA
    894a5e8 View commit details

Commits on Oct 11, 2023

  1. fix(meminfo): account for optional unit field so values are accurate

    Addresses: #565
    
    Previously, this function was ignoring the optional unit field, leading
    to incorrect results on systems that do report the field. This uses the
    humanize lib used elsewhere within the Prometheus ecosystem to normalize
    the value to bytes, including when a unit is provided.
    
    To try and maintain existing behavior, the fixed/unit-scaled values are
    stored as new struct fields.
    
    Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
    tjhop authored and discordianfish committed Oct 11, 2023
    Copy the full SHA
    18260ef View commit details
  2. ref(meminfo): simplify variable assignment

    Addresses PR feedback
    #569 (comment)
    
    Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
    tjhop authored and discordianfish committed Oct 11, 2023
    Copy the full SHA
    f75eb9f View commit details
  3. fix(meminfo): remove bytes versions of fields that aren't bytes

    Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
    tjhop authored and discordianfish committed Oct 11, 2023
    Copy the full SHA
    2cfca8d View commit details

Commits on Nov 12, 2023

  1. Bump github.com/google/go-cmp from 0.5.9 to 0.6.0

    Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.9 to 0.6.0.
    - [Release notes](https://github.com/google/go-cmp/releases)
    - [Commits](google/go-cmp@v0.5.9...v0.6.0)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/google/go-cmp
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and discordianfish committed Nov 12, 2023
    Copy the full SHA
    f78f919 View commit details
  2. Bump golang.org/x/sys from 0.12.0 to 0.13.0

    Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.12.0 to 0.13.0.
    - [Commits](golang/sys@v0.12.0...v0.13.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sys
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and discordianfish committed Nov 12, 2023
    Copy the full SHA
    43bf323 View commit details
  3. Update common Prometheus files

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored and discordianfish committed Nov 12, 2023
    Copy the full SHA
    e9c69c6 View commit details
  4. Bump golang.org/x/sync from 0.3.0 to 0.5.0

    Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.3.0 to 0.5.0.
    - [Commits](golang/sync@v0.3.0...v0.5.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sync
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and discordianfish committed Nov 12, 2023
    Copy the full SHA
    6990574 View commit details

Commits on Nov 22, 2023

  1. Update crypto.go, fix incorrect spelling (#591)

    Signed-off-by: linuxgcc <linuxgcc@users.noreply.github.com>
    linuxgcc authored Nov 22, 2023
    Copy the full SHA
    f11f6e4 View commit details

Commits on Nov 28, 2023

  1. Add udp drops (#538)

    * Add drops field in /proc/net/udp{,6} files for parsing
    
    Signed-off-by: Aleksandr Lebedev <lebedevam88@gmail.com>
    Signed-off-by: Александр Лебедев <allebedev@samokat.ru>
    
    * Add count of UDP dropped packets
    
    Signed-off-by: Aleksandr Lebedev <lebedevam88@gmail.com>
    Signed-off-by: Александр Лебедев <allebedev@samokat.ru>
    
    * Change the type of variable isUDP to local
    
    Signed-off-by: Александр Лебедев <allebedev@samokat.ru>
    
    * Update net_ip_socket.go
    
    Co-authored-by: Ben Kochie <superq@gmail.com>
    Signed-off-by: Aleksandr Lebedev <49903054+alebsys@users.noreply.github.com>
    
    * Update net_ip_socket.go
    
    Co-authored-by: Ben Kochie <superq@gmail.com>
    Signed-off-by: Aleksandr Lebedev <49903054+alebsys@users.noreply.github.com>
    
    ---------
    
    Signed-off-by: Aleksandr Lebedev <lebedevam88@gmail.com>
    Signed-off-by: Александр Лебедев <allebedev@samokat.ru>
    Signed-off-by: Aleksandr Lebedev <49903054+alebsys@users.noreply.github.com>
    Co-authored-by: Ben Kochie <superq@gmail.com>
    alebsys and SuperQ authored Nov 28, 2023
    Copy the full SHA
    9fdfbe8 View commit details
  2. Update common Prometheus files (#590)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Nov 28, 2023
    Copy the full SHA
    feff289 View commit details

Commits on Dec 10, 2023

  1. Update common Prometheus files (#595)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Dec 10, 2023
    Copy the full SHA
    732ca0f View commit details

Commits on Dec 14, 2023

  1. meminfo: add Percpu field (#588)

    Signed-off-by: wangqing <wangqing@uniontech.com>
    Co-authored-by: wangqing <wangqing@uniontech.com>
    wangqingfree and wangqing authored Dec 14, 2023
    Copy the full SHA
    8f660d1 View commit details
  2. Bump golang.org/x/sys from 0.13.0 to 0.15.0 (#593)

    Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.13.0 to 0.15.0.
    - [Commits](golang/sys@v0.13.0...v0.15.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sys
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 14, 2023
    Copy the full SHA
    534069e View commit details
  3. Update common Prometheus files (#596)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Dec 14, 2023
    Copy the full SHA
    a45c08c View commit details

Commits on Dec 18, 2023

  1. Update common Prometheus files (#598)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Dec 18, 2023
    Copy the full SHA
    8a3ea46 View commit details

Commits on Jan 29, 2024

  1. Update common Prometheus files

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored and discordianfish committed Jan 29, 2024
    Copy the full SHA
    495e483 View commit details

Commits on Feb 2, 2024

  1. Bump golang.org/x/sync from 0.5.0 to 0.6.0 (#602)

    Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.5.0 to 0.6.0.
    - [Commits](golang/sync@v0.5.0...v0.6.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sync
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 2, 2024
    Copy the full SHA
    f06ab8f View commit details
  2. Bump golang.org/x/sys from 0.15.0 to 0.16.0 (#603)

    Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.15.0 to 0.16.0.
    - [Commits](golang/sys@v0.15.0...v0.16.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sys
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 2, 2024
    Copy the full SHA
    dd493f4 View commit details

Commits on Feb 15, 2024

  1. infiniband: support Intel irdma devices (#605)

    This skips parsing /sys/class/infiniband/<device>/ports/<port-num>/counters
    for irdma devices, which do not expose it, and would previously cause
    parseInfiniBandPort() to return an error. Instead, irdma devices expose
    /sys/class/infiniband/<device>/ports/<port-num>/hw_counters.
    
    Fixes: #589
    
    Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
    dswarbrick authored Feb 15, 2024
    Copy the full SHA
    868112d View commit details
  2. Update common Prometheus files (#604)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Feb 15, 2024
    Copy the full SHA
    d735b08 View commit details
  3. golint: redundant type from array, slice, or map composite literal (#601

    )
    
    Signed-off-by: wangqing <wangqing@uniontech.com>
    Co-authored-by: wangqing <wangqing@uniontech.com>
    wangqingfree and wangqing authored Feb 15, 2024
    Copy the full SHA
    51a293e View commit details
  4. feat: Add /sys/fs/btrfs/<FSID>/commit_stats statistics (#580)

    * Add commit_stats statistics
    
    ---------
    
    Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
    Co-authored-by: Ben Kochie <superq@gmail.com>
    dongjiang1989 and SuperQ authored Feb 15, 2024
    Copy the full SHA
    f5f033b View commit details
  5. Add support for gtime and cgtime stats. (#597)

    Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
    Co-authored-by: Thomas Barrett <tbarrett@crusoeenergy.com>
    thomasbarrett and Thomas Barrett authored Feb 15, 2024
    Copy the full SHA
    d254b01 View commit details
  6. Add /sys/class/watchdog statistics (#594)

    Signed-off-by: Gavin Lam <gavin.oss@tutamail.com>
    gavinkflam authored Feb 15, 2024
    Copy the full SHA
    0f527e6 View commit details
  7. Add support for for /proc/net/tls_stat kTLS stats (#579)

    Signed-off-by: Felix Aronsson <felixaronsson@gmail.com>
    defect authored Feb 15, 2024
    Copy the full SHA
    6d8714c View commit details
  8. Bump golang.org/x/sys from 0.16.0 to 0.17.0 (#606)

    Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.16.0 to 0.17.0.
    - [Commits](golang/sys@v0.16.0...v0.17.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sys
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 15, 2024
    Copy the full SHA
    4b77c68 View commit details

Commits on Feb 26, 2024

  1. Update common Prometheus files (#608)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Feb 26, 2024
    Copy the full SHA
    da53333 View commit details

Commits on Mar 5, 2024

  1. chore: class_fibrechannel: support optional attributes (#607)

    Signed-off-by: machine424 <ayoubmrini424@gmail.com>
    machine424 authored Mar 5, 2024
    Copy the full SHA
    7b6eccc View commit details
  2. Update common Prometheus files (#609)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Mar 5, 2024
    Copy the full SHA
    6ae6f98 View commit details

Commits on Mar 7, 2024

  1. Update common Prometheus files (#610)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Mar 7, 2024
    Copy the full SHA
    b5cb3d2 View commit details
  2. Bump golang.org/x/sys from 0.17.0 to 0.18.0 (#611)

    Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.17.0 to 0.18.0.
    - [Commits](golang/sys@v0.17.0...v0.18.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sys
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 7, 2024
    Copy the full SHA
    72170b5 View commit details

Commits on Mar 14, 2024

  1. Update common Prometheus files (#613)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Mar 14, 2024
    Copy the full SHA
    aa18116 View commit details

Commits on Mar 21, 2024

  1. Update common Prometheus files (#615)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored Mar 21, 2024
    Copy the full SHA
    f7c2619 View commit details

Commits on Mar 22, 2024

  1. Update common Prometheus files

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored and discordianfish committed Mar 22, 2024
    Copy the full SHA
    6bba74b View commit details

Commits on Mar 23, 2024

  1. Update common Prometheus files

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored and discordianfish committed Mar 23, 2024
    Copy the full SHA
    c5ada8d View commit details

Commits on Apr 5, 2024

  1. Revert add avgRTT to nfs mountstats #487 (#625)

    This is an artificiality computed value from existing values. The goal
    of this library is to provide simple raw access to values, rather than
    pre-compute data.
    
    Reverts: #487
    
    Signed-off-by: SuperQ <superq@gmail.com>
    SuperQ authored Apr 5, 2024
    Copy the full SHA
    5819c81 View commit details

Commits on Apr 8, 2024

  1. style: returns procfs build-in error like other parsing methods (#630)

    Signed-off-by: weidongkl <weidong@uniontech.com>
    weidongkl authored Apr 8, 2024
    Copy the full SHA
    3387ec6 View commit details

Commits on Apr 9, 2024

  1. update MAINTAINERS.md (#629)

    Fixes #628
    
    Signed-off-by: Paul Gier <paul.gier@datastax.com>
    pgier authored Apr 9, 2024
    Copy the full SHA
    eac8540 View commit details

Commits on Apr 10, 2024

  1. *: s/(%v|%s)/%w and use go1.20 (#617)

    * *: `s/(%v|%s)/%w` for all `fmt.Errorf` errors
    
    The `%w` verb was introduced in `go1.20` which allows for error
    wrapping. However, even though the minimum supported version was
    specified as `go1.19` there are already sparse occurences of the `%w`
    verb throughout the codebase. Hence it's safe to move the minimum
    supported version to `go1.20` since its constructs have been in use
    within the repository for a while now.
    
    Refer: https://go.dev/doc/go1.20#errors
    Fixes: #519
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    
    * chore: Specify minimum Golang version as `1.20`
    
    PTAL at the previous commit (d559fd9) for more details.
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    
    * fixup! chore: Specify minimum Golang version as `1.20`
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    
    ---------
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    rexagod authored Apr 10, 2024
    Copy the full SHA
    69fc8f6 View commit details
  2. Update Go versions

    * Update minimum Go to 1.21.
    * Update testing to include Go 1.22.
    * Update Go modules.
    Signed-off-by: SuperQ <superq@gmail.com>
    SuperQ committed Apr 10, 2024
    Copy the full SHA
    faa3526 View commit details

Commits on Apr 14, 2024

  1. chore: Use kernel-compliant types for {U,G}IDs (#620)

    As defined in the `torvalds/linux` git tree, `uidgid_types.h`:
    https://github.com/torvalds/linux/blob/8e938e39866920ddc266898e6ae1fffc5c8f51aa/include/linux/uidgid_types.h#L8
    
    Fixes: #372
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    rexagod authored Apr 14, 2024
    Copy the full SHA
    0fdebd3 View commit details

Commits on Apr 15, 2024

  1. Merge pull request #632 from prometheus/superq/1.22

    Update Go versions
    simonpasquier authored Apr 15, 2024
    Copy the full SHA
    ee70db2 View commit details
  2. fix: same TCP connection appears twice (#631)

    ```
    TCP, TCP6, UDP, and UDP6 are dynamically changing,
    and when we read these files, we should read them all at once.
    there will be data consistency issues if using line by lin reading
    
    fix: #576
    ```
    
    Signed-off-by: weidongkl <weidong@uniontech.com>
    weidongkl authored Apr 15, 2024
    Copy the full SHA
    987bedc View commit details

Commits on Apr 17, 2024

  1. Revert "fix: same TCP connection appears twice (#631)" (#633)

    This reverts commit 987bedc.
    SuperQ authored Apr 17, 2024
    Copy the full SHA
    6bec248 View commit details

Commits on May 2, 2024

  1. Update common Prometheus files (#635)

    Signed-off-by: prombot <prometheus-team@googlegroups.com>
    prombot authored May 2, 2024
    Copy the full SHA
    5cca38b View commit details

Commits on May 12, 2024

  1. enhancement: Use pointer fields for FibreChannel* (#623)

    * enhancement: Use pointer fields for `FibreChannel*`
    
    Allow fields to be `nil`-checked.
    
    Fixes: #612
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    
    * fixup! enhancement: Use pointer fields for `FibreChannel*`
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    
    ---------
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    rexagod authored May 12, 2024
    Copy the full SHA
    68fb3df View commit details
  2. bugfix: Allow multiple xprt fields for NFS stats (#619)

    Allow parsing multiple `xprt` fields present in the same NFS transport
    stats data.
    
    Fixes: #450
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    rexagod authored May 12, 2024
    Copy the full SHA
    2085b8f View commit details
  3. bugfix: s/TrimRight/TrimSuffix for certain cases (#618)

    Use `TrimSuffix` instead of `TrimRight` in cases where an exact suffix
    string needs to be removed, not all occurrences of all characters in a
    specified cutset.
    
    Fixes: #507
    
    Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
    rexagod authored May 12, 2024
    Copy the full SHA
    1adce6b View commit details

Commits on May 13, 2024

  1. Parse recovery line to be synced blocks (#637)

    Capture the blocks to be synced from the recvery line as it can differ
    from the total blocks.
    * Reformat test struct to make it easier to read.
    
    Fixes: #636
    
    Signed-off-by: SuperQ <superq@gmail.com>
    SuperQ authored May 13, 2024
    Copy the full SHA
    5a801c6 View commit details
Showing with 1,832 additions and 485 deletions.
  1. +3 −3 .circleci/config.yml
  2. +13 −6 .github/workflows/golangci-lint.yml
  3. +7 −0 .golangci.yml
  4. +2 −1 MAINTAINERS.md
  5. +17 −9 Makefile.common
  6. +3 −3 arp.go
  7. +10 −0 btrfs/btrfs.go
  8. +58 −0 btrfs/get.go
  9. +40 −14 btrfs/get_test.go
  10. +3 −3 buddyinfo.go
  11. +2 −2 cpuinfo.go
  12. +3 −3 crypto.go
  13. +2 −2 fscache.go
  14. +4 −4 go.mod
  15. +6 −6 go.sum
  16. +3 −3 ipvs.go
  17. +1 −1 loadavg.go
  18. +35 −25 mdstat.go
  19. +255 −17 mdstat_test.go
  20. +166 −54 meminfo.go
  21. +41 −0 meminfo_test.go
  22. +1 −1 mountinfo.go
  23. +3 −8 mountstats.go
  24. +116 −107 mountstats_test.go
  25. +2 −2 net_conntrackstat.go
  26. +33 −13 net_ip_socket.go
  27. +9 −1 net_ip_socket_test.go
  28. +2 −2 net_sockstat.go
  29. +1 −1 net_softnet.go
  30. +5 −5 net_tcp_test.go
  31. +119 −0 net_tls_stat.go
  32. +48 −0 net_tls_stat_test.go
  33. +13 −2 net_udp_test.go
  34. +7 −7 net_unix.go
  35. +11 −11 net_wireless.go
  36. +4 −4 proc.go
  37. +1 −1 proc_limits.go
  38. +2 −2 proc_ns.go
  39. +1 −1 proc_psi.go
  40. +1 −1 proc_smaps.go
  41. +7 −0 proc_stat.go
  42. +23 −6 proc_status.go
  43. +4 −4 proc_status_test.go
  44. +1 −1 proc_sys.go
  45. +11 −11 softirqs.go
  46. +11 −11 stat.go
  47. +3 −3 swaps.go
  48. +60 −55 sysfs/class_fibrechannel.go
  49. +101 −27 sysfs/class_fibrechannel_test.go
  50. +14 −6 sysfs/class_infiniband.go
  51. +1 −1 sysfs/class_power_supply.go
  52. +2 −1 sysfs/class_thermal.go
  53. +123 −0 sysfs/class_watchdog.go
  54. +76 −0 sysfs/class_watchdog_test.go
  55. +91 −13 sysfs/system_cpu.go
  56. +39 −15 sysfs/system_cpu_test.go
  57. +209 −3 testdata/fixtures.ttar
  58. +1 −1 thread.go
  59. +2 −2 zoneinfo.go
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ version: 2.1
jobs:
lint:
docker:
- image: cimg/go:1.21
- image: cimg/go:1.22
steps:
- checkout
- run: make check_license
@@ -46,16 +46,16 @@ workflows:
matrix:
parameters:
go_version:
- "1.19"
- "1.20"
- "1.21"
- "1.22"
- test:
name: test-windows
os: windows
run_test: false
matrix:
parameters:
go_version:
- "1.19"
- "1.20"
- "1.21"
- "1.22"
19 changes: 13 additions & 6 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -12,21 +12,28 @@ on:
- ".golangci.yml"
pull_request:

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: install Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.20.x
go-version: 1.22.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'
- name: Lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
with:
version: v1.54.2
args: --verbose
version: v1.59.0
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
---
linters:
enable:
- errcheck
- godot
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- testifylint
- unused

linter-settings:
godot:
3 changes: 2 additions & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Johannes 'fish' Ziemke <github@freigeist.org> @discordianfish
* Paul Gier <pgier@redhat.com> @pgier
* Paul Gier <paulgier@gmail.com> @pgier
* Ben Kochie <superq@gmail.com> @SuperQ
26 changes: 17 additions & 9 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -49,23 +49,23 @@ endif
GOTEST := $(GO) test
GOTEST_DIR :=
ifneq ($(CIRCLE_JOB),)
ifneq ($(shell command -v gotestsum > /dev/null),)
ifneq ($(shell command -v gotestsum 2> /dev/null),)
GOTEST_DIR := test-results
GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
endif
endif

PROMU_VERSION ?= 0.15.0
PROMU_VERSION ?= 0.17.0
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz

SKIP_GOLANGCI_LINT :=
GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v1.54.2
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
GOLANGCI_LINT_VERSION ?= v1.59.0
# 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.
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386 arm64))
# If we're in CI and there is an Actions file, that means the linter
# is being run in Actions, so we don't need to run it here.
ifneq (,$(SKIP_GOLANGCI_LINT))
@@ -169,16 +169,20 @@ common-vet:
common-lint: $(GOLANGCI_LINT)
ifdef GOLANGCI_LINT
@echo ">> running golangci-lint"
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
# Otherwise staticcheck might fail randomly for some reason not yet explained.
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
endif

.PHONY: common-lint-fix
common-lint-fix: $(GOLANGCI_LINT)
ifdef GOLANGCI_LINT
@echo ">> running golangci-lint fix"
$(GOLANGCI_LINT) run --fix $(GOLANGCI_LINT_OPTS) $(pkgs)
endif

.PHONY: common-yamllint
common-yamllint:
@echo ">> running yamllint on all YAML files in the repository"
ifeq (, $(shell command -v yamllint > /dev/null))
ifeq (, $(shell command -v yamllint 2> /dev/null))
@echo "yamllint not installed so skipping"
else
yamllint .
@@ -204,6 +208,10 @@ common-tarball: promu
@echo ">> building release tarball"
$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)

.PHONY: common-docker-repo-name
common-docker-repo-name:
@echo "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)"

.PHONY: common-docker $(BUILD_DOCKER_ARCHS)
common-docker: $(BUILD_DOCKER_ARCHS)
$(BUILD_DOCKER_ARCHS): common-docker-%:
6 changes: 3 additions & 3 deletions arp.go
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ type ARPEntry struct {
func (fs FS) GatherARPEntries() ([]ARPEntry, error) {
data, err := os.ReadFile(fs.proc.Path("net/arp"))
if err != nil {
return nil, fmt.Errorf("%s: error reading arp %s: %w", ErrFileRead, fs.proc.Path("net/arp"), err)
return nil, fmt.Errorf("%w: error reading arp %s: %w", ErrFileRead, fs.proc.Path("net/arp"), err)
}

return parseARPEntries(data)
@@ -78,11 +78,11 @@ func parseARPEntries(data []byte) ([]ARPEntry, error) {
} else if width == expectedDataWidth {
entry, err := parseARPEntry(columns)
if err != nil {
return []ARPEntry{}, fmt.Errorf("%s: Failed to parse ARP entry: %v: %w", ErrFileParse, entry, err)
return []ARPEntry{}, fmt.Errorf("%w: Failed to parse ARP entry: %v: %w", ErrFileParse, entry, err)
}
entries = append(entries, entry)
} else {
return []ARPEntry{}, fmt.Errorf("%s: %d columns found, but expected %d: %w", ErrFileParse, width, expectedDataWidth, err)
return []ARPEntry{}, fmt.Errorf("%w: %d columns found, but expected %d: %w", ErrFileParse, width, expectedDataWidth, err)
}

}
10 changes: 10 additions & 0 deletions btrfs/btrfs.go
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ type Stats struct {
NodeSize uint64
QuotaOverride uint64
SectorSize uint64
CommitStats CommitStats
}

// Allocation contains allocation statistics for data, metadata and system data.
@@ -65,3 +66,12 @@ type LayoutUsage struct {
type Device struct {
Size uint64
}

// Number of commits and various time related statistics.
// See Linux fs/btrfs/sysfs.c with 6.x version.
type CommitStats struct {
Commits uint64
LastCommitMs uint64
MaxCommitMs uint64
TotalCommitMs uint64
}
58 changes: 58 additions & 0 deletions btrfs/get.go
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@
package btrfs

import (
"bufio"
"fmt"
"os"
"path"
"path/filepath"
@@ -245,6 +247,62 @@ func (r *reader) readFilesystemStats() (s *Stats) {
Metadata: r.readAllocationStats("allocation/metadata"),
System: r.readAllocationStats("allocation/system"),
},

// Read commit stats data
CommitStats: r.readCommitStats("commit_stats"),
}
return
}

// readCommitStats returns the commit_stats information for commit stats metrics.
func (r *reader) readCommitStats(p string) CommitStats {
stats := CommitStats{}

f, err := os.Open(path.Join(r.path, p))
if err != nil {
// if commit_stats not found. maybe btrfs version < 6.0
if !os.IsNotExist(err) {
r.err = err
}
return stats
}
defer f.Close()

scanner := bufio.NewScanner(f)

for scanner.Scan() {
line := scanner.Text()
parts := strings.Fields(scanner.Text())
// require <key> <value>
if len(parts) != 2 {
r.err = fmt.Errorf("invalid commit_stats line %q", line)
return stats
}

value, err := strconv.ParseUint(parts[1], 10, 64)
if err != nil {
r.err = fmt.Errorf("error parsing commit_stats line: %w", err)
return stats
}

switch metricName := parts[0]; metricName {
case "commits":
stats.Commits = value
case "last_commit_ms":
stats.LastCommitMs = value
case "max_commit_ms":
stats.MaxCommitMs = value
case "total_commit_ms":
stats.TotalCommitMs = value
default:
continue
}
}

if err := scanner.Err(); err != nil {
r.err = fmt.Errorf("error scanning commit_stats file: %w", err)
return stats
}

return stats
}
54 changes: 40 additions & 14 deletions btrfs/get_test.go
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ type testVector struct {
uuid, label string
devices, features int
data, meta, system alloc
commitstats commit
}

type alloc struct {
@@ -27,6 +28,13 @@ type alloc struct {
ratio float64
}

type commit struct {
commits uint64
lastCommitMs uint64
maxCommitMs uint64
totalCommitMs uint64
}

func TestFSBtrfsStats(t *testing.T) {
btrfs, err := NewFS("testdata/fixtures/sys")
if err != nil {
@@ -39,22 +47,24 @@ func TestFSBtrfsStats(t *testing.T) {

tests := []testVector{
{
uuid: "0abb23a9-579b-43e6-ad30-227ef47fcb9d",
label: "fixture",
devices: 2,
features: 4,
data: alloc{"raid0", 2147483648, 1},
meta: alloc{"raid1", 1073741824, 2},
system: alloc{"raid1", 8388608, 2},
uuid: "0abb23a9-579b-43e6-ad30-227ef47fcb9d",
label: "fixture",
devices: 2,
features: 4,
data: alloc{"raid0", 2147483648, 1},
meta: alloc{"raid1", 1073741824, 2},
system: alloc{"raid1", 8388608, 2},
commitstats: commit{258051, 1000, 51462, 47836090},
},
{
uuid: "7f07c59f-6136-449c-ab87-e1cf2328731b",
label: "",
devices: 4,
features: 5,
data: alloc{"raid5", 644087808, 4. / 3.},
meta: alloc{"raid6", 429391872, 4. / 2.},
system: alloc{"raid6", 16777216, 4. / 2.},
uuid: "7f07c59f-6136-449c-ab87-e1cf2328731b",
label: "",
devices: 4,
features: 5,
data: alloc{"raid5", 644087808, 4. / 3.},
meta: alloc{"raid6", 429391872, 4. / 2.},
system: alloc{"raid6", 16777216, 4. / 2.},
commitstats: commit{0, 0, 0, 0},
},
}

@@ -98,5 +108,21 @@ func TestFSBtrfsStats(t *testing.T) {
if want, got := tt.system.ratio, stats[i].Allocation.System.Layouts[tt.system.layout].Ratio; want != got {
t.Errorf("fs %q unexpected system ratio:\nwant: %f\nhave: %f", tt.uuid, want, got)
}

if want, got := tt.commitstats.commits, stats[i].CommitStats.Commits; want != got {
t.Errorf("fs %q unexpected commit stats commits:\nwant: %d\nhave: %d", tt.uuid, want, got)
}

if want, got := tt.commitstats.lastCommitMs, stats[i].CommitStats.LastCommitMs; want != got {
t.Errorf("fs %q unexpected commit stats last_commit_ms:\nwant: %d\nhave: %d", tt.uuid, want, got)
}

if want, got := tt.commitstats.maxCommitMs, stats[i].CommitStats.MaxCommitMs; want != got {
t.Errorf("fs %q unexpected commit stats max_commit_ms:\nwant: %d\nhave: %d", tt.uuid, want, got)
}

if want, got := tt.commitstats.totalCommitMs, stats[i].CommitStats.TotalCommitMs; want != got {
t.Errorf("fs %q unexpected commit stats total_commit_ms:\nwant: %d\nhave: %d", tt.uuid, want, got)
}
}
}
6 changes: 3 additions & 3 deletions buddyinfo.go
Original file line number Diff line number Diff line change
@@ -58,8 +58,8 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
return nil, fmt.Errorf("%w: Invalid number of fields, found: %v", ErrFileParse, parts)
}

node := strings.TrimRight(parts[1], ",")
zone := strings.TrimRight(parts[3], ",")
node := strings.TrimSuffix(parts[1], ",")
zone := strings.TrimSuffix(parts[3], ",")
arraySize := len(parts[4:])

if bucketCount == -1 {
@@ -74,7 +74,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
for i := 0; i < arraySize; i++ {
sizes[i], err = strconv.ParseFloat(parts[i+4], 64)
if err != nil {
return nil, fmt.Errorf("%s: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err)
return nil, fmt.Errorf("%w: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err)
}
}

4 changes: 2 additions & 2 deletions cpuinfo.go
Original file line number Diff line number Diff line change
@@ -194,7 +194,7 @@ func parseCPUInfoARM(info []byte) ([]CPUInfo, error) {
firstLine := firstNonEmptyLine(scanner)
match, err := regexp.MatchString("^[Pp]rocessor", firstLine)
if !match || !strings.Contains(firstLine, ":") {
return nil, fmt.Errorf("%s: Cannot parse line: %q: %w", ErrFileParse, firstLine, err)
return nil, fmt.Errorf("%w: Cannot parse line: %q: %w", ErrFileParse, firstLine, err)

}
field := strings.SplitN(firstLine, ": ", 2)
@@ -386,7 +386,7 @@ func parseCPUInfoLoong(info []byte) ([]CPUInfo, error) {
// find the first "processor" line
firstLine := firstNonEmptyLine(scanner)
if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
return nil, errors.New("invalid cpuinfo file: " + firstLine)
return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
}
field := strings.SplitN(firstLine, ": ", 2)
cpuinfo := []CPUInfo{}
Loading