feat: added suspended as a node_zfs_zpool_state (#2449)

Signed-off-by: Pablo Caderno <kaderno@gmail.com>
This commit is contained in:
Pablo Caderno 2023-04-27 02:12:54 +10:00 committed by GitHub
parent b87c6a8826
commit d31af1d1e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 1 deletions

View file

@ -4165,16 +4165,25 @@ node_zfs_zpool_rupdate{zpool="poolz1"} 1.10734831944501e+14
# HELP node_zfs_zpool_state kstat.zfs.misc.state # HELP node_zfs_zpool_state kstat.zfs.misc.state
# TYPE node_zfs_zpool_state gauge # TYPE node_zfs_zpool_state gauge
node_zfs_zpool_state{state="degraded",zpool="pool1"} 0 node_zfs_zpool_state{state="degraded",zpool="pool1"} 0
node_zfs_zpool_state{state="degraded",zpool="pool2"} 0
node_zfs_zpool_state{state="degraded",zpool="poolz1"} 1 node_zfs_zpool_state{state="degraded",zpool="poolz1"} 1
node_zfs_zpool_state{state="faulted",zpool="pool1"} 0 node_zfs_zpool_state{state="faulted",zpool="pool1"} 0
node_zfs_zpool_state{state="faulted",zpool="pool2"} 0
node_zfs_zpool_state{state="faulted",zpool="poolz1"} 0 node_zfs_zpool_state{state="faulted",zpool="poolz1"} 0
node_zfs_zpool_state{state="offline",zpool="pool1"} 0 node_zfs_zpool_state{state="offline",zpool="pool1"} 0
node_zfs_zpool_state{state="offline",zpool="pool2"} 0
node_zfs_zpool_state{state="offline",zpool="poolz1"} 0 node_zfs_zpool_state{state="offline",zpool="poolz1"} 0
node_zfs_zpool_state{state="online",zpool="pool1"} 1 node_zfs_zpool_state{state="online",zpool="pool1"} 1
node_zfs_zpool_state{state="online",zpool="pool2"} 0
node_zfs_zpool_state{state="online",zpool="poolz1"} 0 node_zfs_zpool_state{state="online",zpool="poolz1"} 0
node_zfs_zpool_state{state="removed",zpool="pool1"} 0 node_zfs_zpool_state{state="removed",zpool="pool1"} 0
node_zfs_zpool_state{state="removed",zpool="pool2"} 0
node_zfs_zpool_state{state="removed",zpool="poolz1"} 0 node_zfs_zpool_state{state="removed",zpool="poolz1"} 0
node_zfs_zpool_state{state="suspended",zpool="pool1"} 0
node_zfs_zpool_state{state="suspended",zpool="pool2"} 1
node_zfs_zpool_state{state="suspended",zpool="poolz1"} 0
node_zfs_zpool_state{state="unavail",zpool="pool1"} 0 node_zfs_zpool_state{state="unavail",zpool="pool1"} 0
node_zfs_zpool_state{state="unavail",zpool="pool2"} 0
node_zfs_zpool_state{state="unavail",zpool="poolz1"} 0 node_zfs_zpool_state{state="unavail",zpool="poolz1"} 0
# HELP node_zfs_zpool_wcnt kstat.zfs.misc.io.wcnt # HELP node_zfs_zpool_wcnt kstat.zfs.misc.io.wcnt
# TYPE node_zfs_zpool_wcnt untyped # TYPE node_zfs_zpool_wcnt untyped

View file

@ -4187,16 +4187,25 @@ node_zfs_zpool_rupdate{zpool="poolz1"} 1.10734831944501e+14
# HELP node_zfs_zpool_state kstat.zfs.misc.state # HELP node_zfs_zpool_state kstat.zfs.misc.state
# TYPE node_zfs_zpool_state gauge # TYPE node_zfs_zpool_state gauge
node_zfs_zpool_state{state="degraded",zpool="pool1"} 0 node_zfs_zpool_state{state="degraded",zpool="pool1"} 0
node_zfs_zpool_state{state="degraded",zpool="pool2"} 0
node_zfs_zpool_state{state="degraded",zpool="poolz1"} 1 node_zfs_zpool_state{state="degraded",zpool="poolz1"} 1
node_zfs_zpool_state{state="faulted",zpool="pool1"} 0 node_zfs_zpool_state{state="faulted",zpool="pool1"} 0
node_zfs_zpool_state{state="faulted",zpool="pool2"} 0
node_zfs_zpool_state{state="faulted",zpool="poolz1"} 0 node_zfs_zpool_state{state="faulted",zpool="poolz1"} 0
node_zfs_zpool_state{state="offline",zpool="pool1"} 0 node_zfs_zpool_state{state="offline",zpool="pool1"} 0
node_zfs_zpool_state{state="offline",zpool="pool2"} 0
node_zfs_zpool_state{state="offline",zpool="poolz1"} 0 node_zfs_zpool_state{state="offline",zpool="poolz1"} 0
node_zfs_zpool_state{state="online",zpool="pool1"} 1 node_zfs_zpool_state{state="online",zpool="pool1"} 1
node_zfs_zpool_state{state="online",zpool="pool2"} 0
node_zfs_zpool_state{state="online",zpool="poolz1"} 0 node_zfs_zpool_state{state="online",zpool="poolz1"} 0
node_zfs_zpool_state{state="removed",zpool="pool1"} 0 node_zfs_zpool_state{state="removed",zpool="pool1"} 0
node_zfs_zpool_state{state="removed",zpool="pool2"} 0
node_zfs_zpool_state{state="removed",zpool="poolz1"} 0 node_zfs_zpool_state{state="removed",zpool="poolz1"} 0
node_zfs_zpool_state{state="suspended",zpool="pool1"} 0
node_zfs_zpool_state{state="suspended",zpool="pool2"} 1
node_zfs_zpool_state{state="suspended",zpool="poolz1"} 0
node_zfs_zpool_state{state="unavail",zpool="pool1"} 0 node_zfs_zpool_state{state="unavail",zpool="pool1"} 0
node_zfs_zpool_state{state="unavail",zpool="pool2"} 0
node_zfs_zpool_state{state="unavail",zpool="poolz1"} 0 node_zfs_zpool_state{state="unavail",zpool="poolz1"} 0
# HELP node_zfs_zpool_wcnt kstat.zfs.misc.io.wcnt # HELP node_zfs_zpool_wcnt kstat.zfs.misc.io.wcnt
# TYPE node_zfs_zpool_wcnt untyped # TYPE node_zfs_zpool_wcnt untyped

View file

@ -0,0 +1 @@
SUSPENDED

View file

@ -42,7 +42,7 @@ const (
// kstatDataString = "7" // kstatDataString = "7"
) )
var zfsPoolStatesName = []string{"online", "degraded", "faulted", "offline", "removed", "unavail"} var zfsPoolStatesName = []string{"online", "degraded", "faulted", "offline", "removed", "unavail", "suspended"}
func (c *zfsCollector) openProcFile(path string) (*os.File, error) { func (c *zfsCollector) openProcFile(path string) (*os.File, error) {
file, err := os.Open(procFilePath(path)) file, err := os.Open(procFilePath(path))

View file

@ -535,6 +535,15 @@ func TestPoolStateParsing(t *testing.T) {
t.Fatalf("Incorrect parsed value for degraded state") t.Fatalf("Incorrect parsed value for degraded state")
} }
} }
if poolName == "pool2" {
if isActive != uint64(1) && stateName == "suspended" {
t.Fatalf("Incorrect parsed value for suspended state")
}
if isActive != uint64(0) && stateName != "suspended" {
t.Fatalf("Incorrect parsed value for suspended state")
}
}
}) })
file.Close() file.Close()
if err != nil { if err != nil {