Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added suspended as a node_zfs_zpool_state #2449

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions collector/fixtures/e2e-64k-page-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4155,16 +4155,25 @@ node_zfs_zpool_rupdate{zpool="poolz1"} 1.10734831944501e+14
# HELP node_zfs_zpool_state kstat.zfs.misc.state
# TYPE node_zfs_zpool_state gauge
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="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="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="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="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="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="pool2"} 0
node_zfs_zpool_state{state="unavail",zpool="poolz1"} 0
# HELP node_zfs_zpool_wcnt kstat.zfs.misc.io.wcnt
# TYPE node_zfs_zpool_wcnt untyped
Expand Down
9 changes: 9 additions & 0 deletions collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4177,16 +4177,25 @@ node_zfs_zpool_rupdate{zpool="poolz1"} 1.10734831944501e+14
# HELP node_zfs_zpool_state kstat.zfs.misc.state
# TYPE node_zfs_zpool_state gauge
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="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="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="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="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="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="pool2"} 0
node_zfs_zpool_state{state="unavail",zpool="poolz1"} 0
# HELP node_zfs_zpool_wcnt kstat.zfs.misc.io.wcnt
# TYPE node_zfs_zpool_wcnt untyped
Expand Down
1 change: 1 addition & 0 deletions collector/fixtures/proc/spl/kstat/zfs/pool2/state
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUSPENDED
2 changes: 1 addition & 1 deletion collector/zfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
// 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) {
file, err := os.Open(procFilePath(path))
Expand Down
9 changes: 9 additions & 0 deletions collector/zfs_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,15 @@ func TestPoolStateParsing(t *testing.T) {
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()
if err != nil {
Expand Down