Skip to content

Commit b5a5d60

Browse files
Add AIX filesystem collector
1 parent cb78488 commit b5a5d60

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

collector/filesystem_aix.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright 2024 The Prometheus Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
//go:build !nofilesystem
15+
// +build !nofilesystem
16+
17+
package collector
18+
19+
import (
20+
"github.com/power-devops/perfstat"
21+
)
22+
23+
const (
24+
defMountPointsExcluded = "^/(dev|aha)($|/)"
25+
defFSTypesExcluded = "^procfs$"
26+
)
27+
28+
// Expose filesystem fullness.
29+
func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {
30+
fsStat, err := perfstat.FileSystemStat()
31+
if err != nil {
32+
return nil, err
33+
}
34+
for _, stat := range fsStat {
35+
if c.excludedMountPointsPattern.MatchString(stat.MountPoint) {
36+
c.logger.Debug("Ignoring mount point", "mountpoint", stat.MountPoint)
37+
continue
38+
}
39+
fstype := stat.TypeString()
40+
if c.excludedFSTypesPattern.MatchString(fstype) {
41+
c.logger.Debug("Ignoring fs type", "type", fstype)
42+
continue
43+
}
44+
45+
ro := 0.0
46+
if stat.Flags&perfstat.VFS_READONLY != 0 {
47+
ro = 1.0
48+
}
49+
50+
stats = append(stats, filesystemStats{
51+
labels: filesystemLabels{
52+
device: stat.Device,
53+
mountPoint: stat.MountPoint,
54+
fsType: fstype,
55+
},
56+
size: float64(stat.TotalBlocks / 512.0),
57+
free: float64(stat.FreeBlocks / 512.0),
58+
avail: float64(stat.FreeBlocks / 512.0), // AIX doesn't distinguish between free and available blocks.
59+
files: float64(stat.TotalInodes),
60+
filesFree: float64(stat.FreeInodes),
61+
ro: ro,
62+
})
63+
}
64+
return stats, nil
65+
}

collector/filesystem_common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nofilesystem && (linux || freebsd || netbsd || openbsd || darwin || dragonfly)
14+
//go:build !nofilesystem && (linux || freebsd || netbsd || openbsd || darwin || dragonfly || aix)
1515
// +build !nofilesystem
16-
// +build linux freebsd netbsd openbsd darwin dragonfly
16+
// +build linux freebsd netbsd openbsd darwin dragonfly aix
1717

1818
package collector
1919

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/coreos/go-systemd/v22 v22.5.0
99
github.com/dennwc/btrfs v0.0.0-20240418142341-0167142bde7a
1010
github.com/ema/qdisc v1.0.0
11+
github.com/go-kit/log v0.2.1
1112
github.com/godbus/dbus/v5 v5.1.0
1213
github.com/hashicorp/go-envparse v0.1.0
1314
github.com/hodgesds/perf-utils v0.7.0
@@ -38,6 +39,7 @@ require (
3839
github.com/beorn7/perks v1.0.1 // indirect
3940
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4041
github.com/dennwc/ioctl v1.0.0 // indirect
42+
github.com/go-logfmt/logfmt v0.5.1 // indirect
4143
github.com/google/go-cmp v0.6.0 // indirect
4244
github.com/jpillora/backoff v1.0.0 // indirect
4345
github.com/klauspost/compress v1.17.9 // indirect

go.sum

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ github.com/dennwc/ioctl v1.0.0 h1:DsWAAjIxRqNcLn9x6mwfuf2pet3iB7aK90K4tF16rLg=
2121
github.com/dennwc/ioctl v1.0.0/go.mod h1:ellh2YB5ldny99SBU/VX7Nq0xiZbHphf1DrtHxxjMk0=
2222
github.com/ema/qdisc v1.0.0 h1:EHLG08FVRbWLg8uRICa3xzC9Zm0m7HyMHfXobWFnXYg=
2323
github.com/ema/qdisc v1.0.0/go.mod h1:FhIc0fLYi7f+lK5maMsesDqwYojIOh3VfRs8EVd5YJQ=
24+
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
25+
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
26+
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
27+
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
2428
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
2529
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
2630
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@@ -71,6 +75,8 @@ github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaL
7175
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
7276
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7377
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
78+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
79+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
7480
github.com/prometheus-community/go-runit v0.1.0 h1:uTWEj/Fn2RoLdfg/etSqwzgYNOYPrARx1BHUN052tGA=
7581
github.com/prometheus-community/go-runit v0.1.0/go.mod h1:AvJ9Jo3gAFu2lbM4+qfjdpq30FfiLDJZKbQ015u08IQ=
7682
github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4=
@@ -110,6 +116,7 @@ golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
110116
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
111117
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
112118
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
119+
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
113120
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
114121
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
115122
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=

0 commit comments

Comments
 (0)