Check BSD's mib which accounts for swap size (#1149)
* Change Dfly's CPU counting frequency, see: https://github.com/prometheus/node_exporter/issues/1129 Signed-off-by: iori-yja <fivio.11235813@gmail.com> * Convert Dfly's CPU unit into second Signed-off-by: iori-yja <fivio.11235813@gmail.com> * Check BSD's mib which accounts for swap size; see #1127 Signed-off-by: iori-yja <fivo.11235813@gmail.com> * fix swap check code Signed-off-by: iori-yja <fivo.11235813@gmail.com>
This commit is contained in:
parent
3cf5b006fb
commit
17fee8081f
2 changed files with 12 additions and 16 deletions
|
|
@ -45,6 +45,13 @@ func NewMemoryCollector() (Collector, error) {
|
|||
}
|
||||
size := float64(tmp32)
|
||||
|
||||
mibSwapTotal := "vm.swap_total"
|
||||
/* swap_total is FreeBSD specific. Fall back to Dfly specific mib if not present. */
|
||||
_, err = unix.SysctlUint32(mibSwapTotal)
|
||||
if err != nil {
|
||||
mibSwapTotal = "vm.swap_size"
|
||||
}
|
||||
|
||||
fromPage := func(v float64) float64 {
|
||||
return v * size
|
||||
}
|
||||
|
|
@ -98,7 +105,7 @@ func NewMemoryCollector() (Collector, error) {
|
|||
{
|
||||
name: "swap_size_bytes",
|
||||
description: "Total swap memory size",
|
||||
mib: "vm.swap_total",
|
||||
mib: mibSwapTotal,
|
||||
dataType: bsdSysctlTypeUint64,
|
||||
},
|
||||
// Descriptions via: top(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue