pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/sysutils/node_exporter



Module Name:    pkgsrc
Committed By:   tnn
Date:           Sun Aug  4 00:08:21 UTC 2024

Modified Files:
        pkgsrc/sysutils/node_exporter: Makefile distinfo
Added Files:
        pkgsrc/sysutils/node_exporter/patches:
            patch-collector_filesystem__common.go
            patch-collector_filesystem__netbsd.go

Log Message:
node_exporter: add filesystem collector for NetBSD. Submitted to upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 pkgsrc/sysutils/node_exporter/Makefile
cvs rdiff -u -r1.12 -r1.13 pkgsrc/sysutils/node_exporter/distinfo
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__common.go \
    pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__netbsd.go

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/sysutils/node_exporter/Makefile
diff -u pkgsrc/sysutils/node_exporter/Makefile:1.68 pkgsrc/sysutils/node_exporter/Makefile:1.69
--- pkgsrc/sysutils/node_exporter/Makefile:1.68 Sun Jul 28 01:14:24 2024
+++ pkgsrc/sysutils/node_exporter/Makefile      Sun Aug  4 00:08:21 2024
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.68 2024/07/28 01:14:24 tnn Exp $
+# $NetBSD: Makefile,v 1.69 2024/08/04 00:08:21 tnn Exp $
 
 DISTNAME=      node_exporter-1.8.2
-PKGREVISION=   1
+PKGREVISION=   2
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=prometheus/}
 CATEGORIES=    sysutils
 GITHUB_TAG=    v${PKGVERSION_NOREV}

Index: pkgsrc/sysutils/node_exporter/distinfo
diff -u pkgsrc/sysutils/node_exporter/distinfo:1.12 pkgsrc/sysutils/node_exporter/distinfo:1.13
--- pkgsrc/sysutils/node_exporter/distinfo:1.12 Sun Jul 28 01:14:24 2024
+++ pkgsrc/sysutils/node_exporter/distinfo      Sun Aug  4 00:08:21 2024
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.12 2024/07/28 01:14:24 tnn Exp $
+$NetBSD: distinfo,v 1.13 2024/08/04 00:08:21 tnn Exp $
 
 BLAKE2s (github.com_alecthomas_kingpin_v2_@v_v2.4.0.mod) = 20c554bf73adc1d4faea9cf1eba7f569d362037f364d643d7176e790eed60759
 SHA512 (github.com_alecthomas_kingpin_v2_@v_v2.4.0.mod) = 27b647208aec705c995e523035f278c6b81102ba59f5a95e6e7adf1e8cba2e166d73f0d1115946acfcb736918b5b0db66d2f2aeba084a3581a7a29d342f511b2
@@ -387,5 +387,7 @@ Size (howett.net_plist_@v_v1.0.1.zip) = 
 BLAKE2s (node_exporter-1.8.2.tar.gz) = 2370bedb44e5469e3f9971b1c7e493adf4995107d748a8853e7549750e53548f
 SHA512 (node_exporter-1.8.2.tar.gz) = 68112a85a9ffde88d75893c30ab992ae3c591d44fbefa10e45cf94d228c8f8c44bb3585707521e355817c4b4276cf77eeaf4ed9d0261de02620135ad12f5e711
 Size (node_exporter-1.8.2.tar.gz) = 335292 bytes
+SHA1 (patch-collector_filesystem__common.go) = 5340a9b36478efa1563c7359469840a7bb652343
+SHA1 (patch-collector_filesystem__netbsd.go) = 446190ceca0c37bada8ed444ce497c2e9b8e05ae
 SHA1 (patch-collector_netdev__common.go) = 83b6615334490e8ccfd8c311b36ee2ec98c0ad15
 SHA1 (patch-collector_netdev__netbsd.go) = 59d5409ea5ab267c48c9a5d299e66c7c283f8680

Added files:

Index: pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__common.go
diff -u /dev/null pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__common.go:1.1
--- /dev/null   Sun Aug  4 00:08:21 2024
+++ pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__common.go Sun Aug  4 00:08:21 2024
@@ -0,0 +1,18 @@
+$NetBSD: patch-collector_filesystem__common.go,v 1.1 2024/08/04 00:08:21 tnn Exp $
+
+https://github.com/prometheus/node_exporter/pull/3082
+
+--- collector/filesystem_common.go.orig        2024-07-14 11:52:11.000000000 +0000
++++ collector/filesystem_common.go
+@@ -11,9 +11,9 @@
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ 
+-//go:build !nofilesystem && (linux || freebsd || openbsd || darwin || dragonfly)
++//go:build !nofilesystem && (linux || freebsd || netbsd || openbsd || darwin || dragonfly)
+ // +build !nofilesystem
+-// +build linux freebsd openbsd darwin dragonfly
++// +build linux freebsd netbsd openbsd darwin dragonfly
+ 
+ package collector
+ 
Index: pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__netbsd.go
diff -u /dev/null pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__netbsd.go:1.1
--- /dev/null   Sun Aug  4 00:08:21 2024
+++ pkgsrc/sysutils/node_exporter/patches/patch-collector_filesystem__netbsd.go Sun Aug  4 00:08:21 2024
@@ -0,0 +1,139 @@
+$NetBSD: patch-collector_filesystem__netbsd.go,v 1.1 2024/08/04 00:08:21 tnn Exp $
+
+https://github.com/prometheus/node_exporter/pull/3082
+
+--- collector/filesystem_netbsd.go.orig        2024-08-03 23:20:13.370086227 +0000
++++ collector/filesystem_netbsd.go
+@@ -0,0 +1,132 @@
++// Copyright 2024 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 !nofilesystem
++// +build !nofilesystem
++
++package collector
++
++import (
++      "fmt"
++      "github.com/go-kit/log/level"
++      "golang.org/x/sys/unix"
++      "syscall"
++      "unsafe"
++)
++
++const (
++      defMountPointsExcluded = "^/(dev)($|/)"
++      defFSTypesExcluded     = "^(kernfs|procfs|ptyfs|fdesc)$"
++      _VFS_NAMELEN           = 32
++      _VFS_MNAMELEN          = 1024
++)
++
++/*
++ * Go uses the NetBSD 9 ABI and thus syscall.SYS_GETVFSSTAT is compat_90_getvfsstat.
++ * We have to declare struct statvfs90 because it is not included in the unix package.
++ * See NetBSD/src/sys/compat/sys/statvfs.h.
++ */
++type statvfs90 struct {
++      F_flag   uint
++      F_bsize  uint
++      F_frsize uint
++      F_iosize uint
++
++      F_blocks uint64
++      F_bfree  uint64
++      F_bavail uint64
++      F_bresvd uint64
++
++      F_files  uint64
++      F_ffree  uint64
++      F_favail uint64
++      F_fresvd uint64
++
++      F_syncreads  uint64
++      F_syncwrites uint64
++
++      F_asyncreads  uint64
++      F_asyncwrites uint64
++
++      F_fsidx   [2]uint32
++      F_fsid    uint32
++      F_namemax uint
++      F_owner   uint32
++      F_spare   [4]uint32
++
++      F_fstypename  [_VFS_NAMELEN]byte
++      F_mntonname   [_VFS_MNAMELEN]byte
++      F_mntfromname [_VFS_MNAMELEN]byte
++
++      cgo_pad [4]byte
++}
++
++func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {
++      var mnt []statvfs90
++      if syscall.SYS_GETVFSSTAT != 356 /* compat_90_getvfsstat */ {
++              /*
++               * Catch if golang ever updates to newer ABI and bail.
++               */
++              return nil, fmt.Errorf("getvfsstat: ABI mismatch")
++      }
++      for {
++              r1, _, errno := syscall.Syscall(syscall.SYS_GETVFSSTAT, uintptr(0), 0, unix.ST_NOWAIT)
++              if errno != 0 {
++                      return nil, fmt.Errorf("getvfsstat: %s", string(errno))
++              }
++              mnt = make([]statvfs90, r1, r1)
++              r2, _, errno := syscall.Syscall(syscall.SYS_GETVFSSTAT, uintptr(unsafe.Pointer(&mnt[0])), unsafe.Sizeof(mnt[0])*r1, unix.ST_NOWAIT)
++              if errno != 0 {
++                      return nil, fmt.Errorf("getvfsstat: %s", string(errno))
++              }
++              if r1 == r2 {
++                      break
++              }
++      }
++
++      stats = []filesystemStats{}
++      for _, v := range mnt {
++              mountpoint := unix.ByteSliceToString(v.F_mntonname[:])
++              if c.excludedMountPointsPattern.MatchString(mountpoint) {
++                      level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint)
++                      continue
++              }
++
++              device := unix.ByteSliceToString(v.F_mntfromname[:])
++              fstype := unix.ByteSliceToString(v.F_fstypename[:])
++              if c.excludedFSTypesPattern.MatchString(fstype) {
++                      level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype)
++                      continue
++              }
++
++              var ro float64
++              if (v.F_flag & unix.MNT_RDONLY) != 0 {
++                      ro = 1
++              }
++
++              stats = append(stats, filesystemStats{
++                      labels: filesystemLabels{
++                              device:     device,
++                              mountPoint: mountpoint,
++                              fsType:     fstype,
++                      },
++                      size:      float64(v.F_blocks) * float64(v.F_bsize),
++                      free:      float64(v.F_bfree) * float64(v.F_bsize),
++                      avail:     float64(v.F_bavail) * float64(v.F_bsize),
++                      files:     float64(v.F_files),
++                      filesFree: float64(v.F_ffree),
++                      ro:        ro,
++              })
++      }
++      return stats, nil
++}



Home | Main Index | Thread Index | Old Index