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

zfs: Allow space in dataset name #3186

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions collector/fixtures/e2e-64k-page-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4315,108 +4315,139 @@ node_zfs_zil_zil_itx_needcopy_count 0
# TYPE node_zfs_zpool_dataset_nread untyped
node_zfs_zpool_dataset_nread{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nread{dataset="pool1/dataset1",zpool="pool1"} 28
node_zfs_zpool_dataset_nread{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nread{dataset="pool3/dataset with space",zpool="pool3"} 28
node_zfs_zpool_dataset_nread{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nread{dataset="poolz1/dataset1",zpool="poolz1"} 28
# HELP node_zfs_zpool_dataset_nunlinked kstat.zfs.misc.objset.nunlinked
# TYPE node_zfs_zpool_dataset_nunlinked untyped
node_zfs_zpool_dataset_nunlinked{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nunlinked{dataset="pool1/dataset1",zpool="pool1"} 3
node_zfs_zpool_dataset_nunlinked{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nunlinked{dataset="pool3/dataset with space",zpool="pool3"} 3
node_zfs_zpool_dataset_nunlinked{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nunlinked{dataset="poolz1/dataset1",zpool="poolz1"} 14
# HELP node_zfs_zpool_dataset_nunlinks kstat.zfs.misc.objset.nunlinks
# TYPE node_zfs_zpool_dataset_nunlinks untyped
node_zfs_zpool_dataset_nunlinks{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nunlinks{dataset="pool1/dataset1",zpool="pool1"} 3
node_zfs_zpool_dataset_nunlinks{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nunlinks{dataset="pool3/dataset with space",zpool="pool3"} 3
node_zfs_zpool_dataset_nunlinks{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nunlinks{dataset="poolz1/dataset1",zpool="poolz1"} 14
# HELP node_zfs_zpool_dataset_nwritten kstat.zfs.misc.objset.nwritten
# TYPE node_zfs_zpool_dataset_nwritten untyped
node_zfs_zpool_dataset_nwritten{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nwritten{dataset="pool1/dataset1",zpool="pool1"} 12302
node_zfs_zpool_dataset_nwritten{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nwritten{dataset="pool3/dataset with space",zpool="pool3"} 12302
node_zfs_zpool_dataset_nwritten{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nwritten{dataset="poolz1/dataset1",zpool="poolz1"} 32806
# HELP node_zfs_zpool_dataset_reads kstat.zfs.misc.objset.reads
# TYPE node_zfs_zpool_dataset_reads untyped
node_zfs_zpool_dataset_reads{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_reads{dataset="pool1/dataset1",zpool="pool1"} 2
node_zfs_zpool_dataset_reads{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_reads{dataset="pool3/dataset with space",zpool="pool3"} 2
node_zfs_zpool_dataset_reads{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_reads{dataset="poolz1/dataset1",zpool="poolz1"} 2
# HELP node_zfs_zpool_dataset_writes kstat.zfs.misc.objset.writes
# TYPE node_zfs_zpool_dataset_writes untyped
node_zfs_zpool_dataset_writes{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_writes{dataset="pool1/dataset1",zpool="pool1"} 4
node_zfs_zpool_dataset_writes{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_writes{dataset="pool3/dataset with space",zpool="pool3"} 4
node_zfs_zpool_dataset_writes{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_writes{dataset="poolz1/dataset1",zpool="poolz1"} 10
# HELP node_zfs_zpool_nread kstat.zfs.misc.io.nread
# TYPE node_zfs_zpool_nread untyped
node_zfs_zpool_nread{zpool="pool1"} 1.88416e+06
node_zfs_zpool_nread{zpool="pool3"} 1.88416e+06
node_zfs_zpool_nread{zpool="poolz1"} 2.82624e+06
# HELP node_zfs_zpool_nwritten kstat.zfs.misc.io.nwritten
# TYPE node_zfs_zpool_nwritten untyped
node_zfs_zpool_nwritten{zpool="pool1"} 3.206144e+06
node_zfs_zpool_nwritten{zpool="pool3"} 3.206144e+06
node_zfs_zpool_nwritten{zpool="poolz1"} 2.680501248e+09
# HELP node_zfs_zpool_rcnt kstat.zfs.misc.io.rcnt
# TYPE node_zfs_zpool_rcnt untyped
node_zfs_zpool_rcnt{zpool="pool1"} 0
node_zfs_zpool_rcnt{zpool="pool3"} 0
node_zfs_zpool_rcnt{zpool="poolz1"} 0
# HELP node_zfs_zpool_reads kstat.zfs.misc.io.reads
# TYPE node_zfs_zpool_reads untyped
node_zfs_zpool_reads{zpool="pool1"} 22
node_zfs_zpool_reads{zpool="pool3"} 22
node_zfs_zpool_reads{zpool="poolz1"} 33
# HELP node_zfs_zpool_rlentime kstat.zfs.misc.io.rlentime
# TYPE node_zfs_zpool_rlentime untyped
node_zfs_zpool_rlentime{zpool="pool1"} 1.04112268e+08
node_zfs_zpool_rlentime{zpool="pool3"} 1.04112268e+08
node_zfs_zpool_rlentime{zpool="poolz1"} 6.472105124093e+12
# HELP node_zfs_zpool_rtime kstat.zfs.misc.io.rtime
# TYPE node_zfs_zpool_rtime untyped
node_zfs_zpool_rtime{zpool="pool1"} 2.4168078e+07
node_zfs_zpool_rtime{zpool="pool3"} 2.4168078e+07
node_zfs_zpool_rtime{zpool="poolz1"} 9.82909164e+09
# HELP node_zfs_zpool_rupdate kstat.zfs.misc.io.rupdate
# TYPE node_zfs_zpool_rupdate untyped
node_zfs_zpool_rupdate{zpool="pool1"} 7.921048984922e+13
node_zfs_zpool_rupdate{zpool="pool3"} 7.921048984922e+13
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="pool3"} 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="pool3"} 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="pool3"} 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="pool3"} 1
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="pool3"} 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="pool3"} 0
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="pool3"} 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
node_zfs_zpool_wcnt{zpool="pool1"} 0
node_zfs_zpool_wcnt{zpool="pool3"} 0
node_zfs_zpool_wcnt{zpool="poolz1"} 0
# HELP node_zfs_zpool_wlentime kstat.zfs.misc.io.wlentime
# TYPE node_zfs_zpool_wlentime untyped
node_zfs_zpool_wlentime{zpool="pool1"} 1.04112268e+08
node_zfs_zpool_wlentime{zpool="pool3"} 1.04112268e+08
node_zfs_zpool_wlentime{zpool="poolz1"} 6.472105124093e+12
# HELP node_zfs_zpool_writes kstat.zfs.misc.io.writes
# TYPE node_zfs_zpool_writes untyped
node_zfs_zpool_writes{zpool="pool1"} 132
node_zfs_zpool_writes{zpool="pool3"} 132
node_zfs_zpool_writes{zpool="poolz1"} 25294
# HELP node_zfs_zpool_wtime kstat.zfs.misc.io.wtime
# TYPE node_zfs_zpool_wtime untyped
node_zfs_zpool_wtime{zpool="pool1"} 7.155162e+06
node_zfs_zpool_wtime{zpool="pool3"} 7.155162e+06
node_zfs_zpool_wtime{zpool="poolz1"} 9.673715628e+09
# HELP node_zfs_zpool_wupdate kstat.zfs.misc.io.wupdate
# TYPE node_zfs_zpool_wupdate untyped
node_zfs_zpool_wupdate{zpool="pool1"} 7.9210489694949e+13
node_zfs_zpool_wupdate{zpool="pool3"} 7.9210489694949e+13
node_zfs_zpool_wupdate{zpool="poolz1"} 1.10734831833266e+14
# HELP node_zoneinfo_high_pages Zone watermark pages_high
# TYPE node_zoneinfo_high_pages gauge
Expand Down
31 changes: 31 additions & 0 deletions collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4337,108 +4337,139 @@ node_zfs_zil_zil_itx_needcopy_count 0
# TYPE node_zfs_zpool_dataset_nread untyped
node_zfs_zpool_dataset_nread{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nread{dataset="pool1/dataset1",zpool="pool1"} 28
node_zfs_zpool_dataset_nread{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nread{dataset="pool3/dataset with space",zpool="pool3"} 28
node_zfs_zpool_dataset_nread{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nread{dataset="poolz1/dataset1",zpool="poolz1"} 28
# HELP node_zfs_zpool_dataset_nunlinked kstat.zfs.misc.objset.nunlinked
# TYPE node_zfs_zpool_dataset_nunlinked untyped
node_zfs_zpool_dataset_nunlinked{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nunlinked{dataset="pool1/dataset1",zpool="pool1"} 3
node_zfs_zpool_dataset_nunlinked{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nunlinked{dataset="pool3/dataset with space",zpool="pool3"} 3
node_zfs_zpool_dataset_nunlinked{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nunlinked{dataset="poolz1/dataset1",zpool="poolz1"} 14
# HELP node_zfs_zpool_dataset_nunlinks kstat.zfs.misc.objset.nunlinks
# TYPE node_zfs_zpool_dataset_nunlinks untyped
node_zfs_zpool_dataset_nunlinks{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nunlinks{dataset="pool1/dataset1",zpool="pool1"} 3
node_zfs_zpool_dataset_nunlinks{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nunlinks{dataset="pool3/dataset with space",zpool="pool3"} 3
node_zfs_zpool_dataset_nunlinks{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nunlinks{dataset="poolz1/dataset1",zpool="poolz1"} 14
# HELP node_zfs_zpool_dataset_nwritten kstat.zfs.misc.objset.nwritten
# TYPE node_zfs_zpool_dataset_nwritten untyped
node_zfs_zpool_dataset_nwritten{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_nwritten{dataset="pool1/dataset1",zpool="pool1"} 12302
node_zfs_zpool_dataset_nwritten{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_nwritten{dataset="pool3/dataset with space",zpool="pool3"} 12302
node_zfs_zpool_dataset_nwritten{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_nwritten{dataset="poolz1/dataset1",zpool="poolz1"} 32806
# HELP node_zfs_zpool_dataset_reads kstat.zfs.misc.objset.reads
# TYPE node_zfs_zpool_dataset_reads untyped
node_zfs_zpool_dataset_reads{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_reads{dataset="pool1/dataset1",zpool="pool1"} 2
node_zfs_zpool_dataset_reads{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_reads{dataset="pool3/dataset with space",zpool="pool3"} 2
node_zfs_zpool_dataset_reads{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_reads{dataset="poolz1/dataset1",zpool="poolz1"} 2
# HELP node_zfs_zpool_dataset_writes kstat.zfs.misc.objset.writes
# TYPE node_zfs_zpool_dataset_writes untyped
node_zfs_zpool_dataset_writes{dataset="pool1",zpool="pool1"} 0
node_zfs_zpool_dataset_writes{dataset="pool1/dataset1",zpool="pool1"} 4
node_zfs_zpool_dataset_writes{dataset="pool3",zpool="pool3"} 0
node_zfs_zpool_dataset_writes{dataset="pool3/dataset with space",zpool="pool3"} 4
node_zfs_zpool_dataset_writes{dataset="poolz1",zpool="poolz1"} 0
node_zfs_zpool_dataset_writes{dataset="poolz1/dataset1",zpool="poolz1"} 10
# HELP node_zfs_zpool_nread kstat.zfs.misc.io.nread
# TYPE node_zfs_zpool_nread untyped
node_zfs_zpool_nread{zpool="pool1"} 1.88416e+06
node_zfs_zpool_nread{zpool="pool3"} 1.88416e+06
node_zfs_zpool_nread{zpool="poolz1"} 2.82624e+06
# HELP node_zfs_zpool_nwritten kstat.zfs.misc.io.nwritten
# TYPE node_zfs_zpool_nwritten untyped
node_zfs_zpool_nwritten{zpool="pool1"} 3.206144e+06
node_zfs_zpool_nwritten{zpool="pool3"} 3.206144e+06
node_zfs_zpool_nwritten{zpool="poolz1"} 2.680501248e+09
# HELP node_zfs_zpool_rcnt kstat.zfs.misc.io.rcnt
# TYPE node_zfs_zpool_rcnt untyped
node_zfs_zpool_rcnt{zpool="pool1"} 0
node_zfs_zpool_rcnt{zpool="pool3"} 0
node_zfs_zpool_rcnt{zpool="poolz1"} 0
# HELP node_zfs_zpool_reads kstat.zfs.misc.io.reads
# TYPE node_zfs_zpool_reads untyped
node_zfs_zpool_reads{zpool="pool1"} 22
node_zfs_zpool_reads{zpool="pool3"} 22
node_zfs_zpool_reads{zpool="poolz1"} 33
# HELP node_zfs_zpool_rlentime kstat.zfs.misc.io.rlentime
# TYPE node_zfs_zpool_rlentime untyped
node_zfs_zpool_rlentime{zpool="pool1"} 1.04112268e+08
node_zfs_zpool_rlentime{zpool="pool3"} 1.04112268e+08
node_zfs_zpool_rlentime{zpool="poolz1"} 6.472105124093e+12
# HELP node_zfs_zpool_rtime kstat.zfs.misc.io.rtime
# TYPE node_zfs_zpool_rtime untyped
node_zfs_zpool_rtime{zpool="pool1"} 2.4168078e+07
node_zfs_zpool_rtime{zpool="pool3"} 2.4168078e+07
node_zfs_zpool_rtime{zpool="poolz1"} 9.82909164e+09
# HELP node_zfs_zpool_rupdate kstat.zfs.misc.io.rupdate
# TYPE node_zfs_zpool_rupdate untyped
node_zfs_zpool_rupdate{zpool="pool1"} 7.921048984922e+13
node_zfs_zpool_rupdate{zpool="pool3"} 7.921048984922e+13
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="pool3"} 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="pool3"} 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="pool3"} 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="pool3"} 1
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="pool3"} 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="pool3"} 0
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="pool3"} 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
node_zfs_zpool_wcnt{zpool="pool1"} 0
node_zfs_zpool_wcnt{zpool="pool3"} 0
node_zfs_zpool_wcnt{zpool="poolz1"} 0
# HELP node_zfs_zpool_wlentime kstat.zfs.misc.io.wlentime
# TYPE node_zfs_zpool_wlentime untyped
node_zfs_zpool_wlentime{zpool="pool1"} 1.04112268e+08
node_zfs_zpool_wlentime{zpool="pool3"} 1.04112268e+08
node_zfs_zpool_wlentime{zpool="poolz1"} 6.472105124093e+12
# HELP node_zfs_zpool_writes kstat.zfs.misc.io.writes
# TYPE node_zfs_zpool_writes untyped
node_zfs_zpool_writes{zpool="pool1"} 132
node_zfs_zpool_writes{zpool="pool3"} 132
node_zfs_zpool_writes{zpool="poolz1"} 25294
# HELP node_zfs_zpool_wtime kstat.zfs.misc.io.wtime
# TYPE node_zfs_zpool_wtime untyped
node_zfs_zpool_wtime{zpool="pool1"} 7.155162e+06
node_zfs_zpool_wtime{zpool="pool3"} 7.155162e+06
node_zfs_zpool_wtime{zpool="poolz1"} 9.673715628e+09
# HELP node_zfs_zpool_wupdate kstat.zfs.misc.io.wupdate
# TYPE node_zfs_zpool_wupdate untyped
node_zfs_zpool_wupdate{zpool="pool1"} 7.9210489694949e+13
node_zfs_zpool_wupdate{zpool="pool3"} 7.9210489694949e+13
node_zfs_zpool_wupdate{zpool="poolz1"} 1.10734831833266e+14
# HELP node_zoneinfo_high_pages Zone watermark pages_high
# TYPE node_zoneinfo_high_pages gauge
Expand Down
3 changes: 3 additions & 0 deletions collector/fixtures/proc/spl/kstat/zfs/pool3/io
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
12 3 0x00 1 80 79205351707403 395818011156865
nread nwritten reads writes wtime wlentime wupdate rtime rlentime rupdate wcnt rcnt
1884160 3206144 22 132 7155162 104112268 79210489694949 24168078 104112268 79210489849220 0 0
9 changes: 9 additions & 0 deletions collector/fixtures/proc/spl/kstat/zfs/pool3/objset-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
23 1 0x01 7 2160 221578688875 6665999035587
name type data
dataset_name 7 pool3
writes 4 0
nwritten 4 0
reads 4 0
nread 4 0
nunlinks 4 0
nunlinked 4 0
9 changes: 9 additions & 0 deletions collector/fixtures/proc/spl/kstat/zfs/pool3/objset-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
24 1 0x01 7 2160 221611904716 7145015038451
name type data
dataset_name 7 pool3/dataset with space
writes 4 4
nwritten 4 12302
reads 4 2
nread 4 28
nunlinks 4 3
nunlinked 4 3
1 change: 1 addition & 0 deletions collector/fixtures/proc/spl/kstat/zfs/pool3/state
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ONLINE
5 changes: 3 additions & 2 deletions collector/zfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ func (c *zfsCollector) parsePoolObjsetFile(reader io.Reader, zpoolPath string, h
parseLine := false
var zpoolName, datasetName string
for scanner.Scan() {
parts := strings.Fields(scanner.Text())
line := scanner.Text()
parts := strings.Fields(line)

if !parseLine && len(parts) == 3 && parts[0] == "name" && parts[1] == "type" && parts[2] == "data" {
parseLine = true
Expand All @@ -315,7 +316,7 @@ func (c *zfsCollector) parsePoolObjsetFile(reader io.Reader, zpoolPath string, h
zpoolPathElements := strings.Split(zpoolPath, "/")
pathLen := len(zpoolPathElements)
zpoolName = zpoolPathElements[pathLen-2]
datasetName = parts[2]
datasetName = line[strings.Index(line, parts[2]):]
continue
}

Expand Down
49 changes: 49 additions & 0 deletions collector/zfs_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,55 @@ func TestZpoolParsing(t *testing.T) {
}
}

func TestZpoolObjsetParsingWithSpace(t *testing.T) {
tests := []struct {
path string
expectedDataset string
}{
{
path: "fixtures/proc/spl/kstat/zfs/pool1/objset-1",
expectedDataset: "pool1",
},
{
path: "fixtures/proc/spl/kstat/zfs/pool1/objset-2",
expectedDataset: "pool1/dataset1",
},
{
path: "fixtures/proc/spl/kstat/zfs/pool3/objset-1",
expectedDataset: "pool3",
},
{
path: "fixtures/proc/spl/kstat/zfs/pool3/objset-2",
expectedDataset: "pool3/dataset with space",
},
}

c := zfsCollector{}

var handlerCalled bool
for _, test := range tests {
file, err := os.Open(test.path)
if err != nil {
t.Fatal(err)
}

handlerCalled = false
err = c.parsePoolObjsetFile(file, test.path, func(poolName string, datasetName string, s zfsSysctl, v uint64) {
handlerCalled = true
if test.expectedDataset != datasetName {
t.Fatalf("Incorrectly parsed dataset name: expected: '%s', got: '%s'", test.expectedDataset, datasetName)
}
})
file.Close()
if err != nil {
t.Fatal(err)
}
if !handlerCalled {
t.Fatalf("Zpool parsing handler was not called for '%s'", test.path)
}
}
}

func TestZpoolObjsetParsing(t *testing.T) {
zpoolPaths, err := filepath.Glob("fixtures/proc/spl/kstat/zfs/*/objset-*")
if err != nil {
Expand Down
Loading