Use int64 throughout the ZFS collector.
This avoids issues with integer overflows on 32-bit architectures. The Prometheus data format is float64, so regardless of the architecture we should handle large numbers. Fixes #629.
This commit is contained in:
parent
8661bbbb42
commit
e1f129c729
3 changed files with 24 additions and 24 deletions
|
|
@ -32,7 +32,7 @@ func TestArcstatsParsing(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(arcstatsFile, "arcstats", func(s zfsSysctl, v int) {
|
||||
err = c.parseProcfsFile(arcstatsFile, "arcstats", func(s zfsSysctl, v int64) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.arcstats.hits") {
|
||||
return
|
||||
|
|
@ -40,7 +40,7 @@ func TestArcstatsParsing(t *testing.T) {
|
|||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(8772612) {
|
||||
if v != int64(8772612) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ func TestZfetchstatsParsing(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(zfetchstatsFile, "zfetchstats", func(s zfsSysctl, v int) {
|
||||
err = c.parseProcfsFile(zfetchstatsFile, "zfetchstats", func(s zfsSysctl, v int64) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.zfetchstats.hits") {
|
||||
return
|
||||
|
|
@ -76,7 +76,7 @@ func TestZfetchstatsParsing(t *testing.T) {
|
|||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(7067992) {
|
||||
if v != int64(7067992) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ func TestZilParsing(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(zilFile, "zil", func(s zfsSysctl, v int) {
|
||||
err = c.parseProcfsFile(zilFile, "zil", func(s zfsSysctl, v int64) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.zil.zil_commit_count") {
|
||||
return
|
||||
|
|
@ -112,7 +112,7 @@ func TestZilParsing(t *testing.T) {
|
|||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(10) {
|
||||
if v != int64(10) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ func TestVdevCacheStatsParsing(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(vdevCacheStatsFile, "vdev_cache_stats", func(s zfsSysctl, v int) {
|
||||
err = c.parseProcfsFile(vdevCacheStatsFile, "vdev_cache_stats", func(s zfsSysctl, v int64) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.vdev_cache_stats.delegations") {
|
||||
return
|
||||
|
|
@ -148,7 +148,7 @@ func TestVdevCacheStatsParsing(t *testing.T) {
|
|||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(40) {
|
||||
if v != int64(40) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ func TestXuioStatsParsing(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(xuioStatsFile, "xuio_stats", func(s zfsSysctl, v int) {
|
||||
err = c.parseProcfsFile(xuioStatsFile, "xuio_stats", func(s zfsSysctl, v int64) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.xuio_stats.onloan_read_buf") {
|
||||
return
|
||||
|
|
@ -184,7 +184,7 @@ func TestXuioStatsParsing(t *testing.T) {
|
|||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(32) {
|
||||
if v != int64(32) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ func TestFmParsing(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(fmFile, "fm", func(s zfsSysctl, v int) {
|
||||
err = c.parseProcfsFile(fmFile, "fm", func(s zfsSysctl, v int64) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.fm.erpt-dropped") {
|
||||
return
|
||||
|
|
@ -220,7 +220,7 @@ func TestFmParsing(t *testing.T) {
|
|||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(18) {
|
||||
if v != int64(18) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ func TestDmuTxParsing(t *testing.T) {
|
|||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(dmuTxFile, "dmu_tx", func(s zfsSysctl, v int) {
|
||||
err = c.parseProcfsFile(dmuTxFile, "dmu_tx", func(s zfsSysctl, v int64) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.dmu_tx.dmu_tx_assigned") {
|
||||
return
|
||||
|
|
@ -256,7 +256,7 @@ func TestDmuTxParsing(t *testing.T) {
|
|||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(3532844) {
|
||||
if v != int64(3532844) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
|
|
@ -289,14 +289,14 @@ func TestZpoolParsing(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = c.parsePoolProcfsFile(file, zpoolPath, func(poolName string, s zfsSysctl, v int) {
|
||||
err = c.parsePoolProcfsFile(file, zpoolPath, func(poolName string, s zfsSysctl, v int64) {
|
||||
if s != zfsSysctl("kstat.zfs.misc.io.nread") {
|
||||
return
|
||||
}
|
||||
|
||||
handlerCalled = true
|
||||
|
||||
if v != int(1884160) && v != int(2826240) {
|
||||
if v != int64(1884160) && v != int64(2826240) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data %v", v)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue