Skip to content

Commit a7049aa

Browse files
Add AIX filesystem collector
Signed-off-by: Johannes Ziemke <[email protected]>
1 parent 3083446 commit a7049aa

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-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.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaL
7171
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
7272
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7373
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
74+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
75+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
7476
github.com/prometheus-community/go-runit v0.1.0 h1:uTWEj/Fn2RoLdfg/etSqwzgYNOYPrARx1BHUN052tGA=
7577
github.com/prometheus-community/go-runit v0.1.0/go.mod h1:AvJ9Jo3gAFu2lbM4+qfjdpq30FfiLDJZKbQ015u08IQ=
7678
github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4=
@@ -110,6 +112,7 @@ golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
110112
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
111113
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
112114
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
115+
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
113116
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
114117
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
115118
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=

0 commit comments

Comments
 (0)