Skip to content

Commit

Permalink
Add ZFS freebsd per dataset stats (prometheus#2753)
Browse files Browse the repository at this point in the history
* Rename parsePoolObjsetFile to parseLinuxPoolObjsetFile to better reflect
it's scope
* Create a new parseFreeBSDPoolObjsetStats function, to generate a list
of per pool metrics to be queried via sysctl


---------

Signed-off-by: Conall O'Brien <conall@conall.net>
  • Loading branch information
conallob authored and oblitorum committed Apr 9, 2024
1 parent d1eee71 commit 4547806
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 3 deletions.
6 changes: 6 additions & 0 deletions collector/exec_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,37 @@ func NewExecCollector(logger log.Logger) (Collector, error) {
name: "exec_context_switches_total",
description: "Context switches since system boot. Resets at architecture unsigned integer.",
mib: "vm.stats.sys.v_swtch",
labels: nil,
},
{
name: "exec_traps_total",
description: "Traps since system boot. Resets at architecture unsigned integer.",
mib: "vm.stats.sys.v_trap",
labels: nil,
},
{
name: "exec_system_calls_total",
description: "System calls since system boot. Resets at architecture unsigned integer.",
mib: "vm.stats.sys.v_syscall",
},
labels: nil,
{
name: "exec_device_interrupts_total",
description: "Device interrupts since system boot. Resets at architecture unsigned integer.",
mib: "vm.stats.sys.v_intr",
labels: nil,
},
{
name: "exec_software_interrupts_total",
description: "Software interrupts since system boot. Resets at architecture unsigned integer.",
mib: "vm.stats.sys.v_soft",
labels: nil,
},
{
name: "exec_forks_total",
description: "Number of fork() calls since system boot. Resets at architecture unsigned integer.",
mib: "vm.stats.vm.v_forks",
labels: nil,
},
},
logger: logger,
Expand Down
12 changes: 12 additions & 0 deletions collector/memory_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,61 +69,71 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) {
description: "Recently used by userland",
mib: "vm.stats.vm.v_active_count",
conversion: fromPage,
labels: nil,
},
{
name: "inactive_bytes",
description: "Not recently used by userland",
mib: "vm.stats.vm.v_inactive_count",
conversion: fromPage,
labels: nil,
},
{
name: "wired_bytes",
description: "Locked in memory by kernel, mlock, etc",
mib: "vm.stats.vm.v_wire_count",
conversion: fromPage,
labels: nil,
},
{
name: "user_wired_bytes",
description: "Locked in memory by user, mlock, etc",
mib: "vm.stats.vm.v_user_wire_count",
conversion: fromPage,
dataType: bsdSysctlTypeCLong,
labels: nil,
},
{
name: "cache_bytes",
description: "Almost free, backed by swap or files, available for re-allocation",
mib: "vm.stats.vm.v_cache_count",
conversion: fromPage,
labels: nil,
},
{
name: "buffer_bytes",
description: "Disk IO Cache entries for non ZFS filesystems, only usable by kernel",
mib: "vfs.bufspace",
dataType: bsdSysctlTypeCLong,
labels: nil,
},
{
name: "free_bytes",
description: "Unallocated, available for allocation",
mib: "vm.stats.vm.v_free_count",
conversion: fromPage,
labels: nil,
},
{
name: "laundry_bytes",
description: "Dirty not recently used by userland",
mib: "vm.stats.vm.v_laundry_count",
conversion: fromPage,
labels: nil,
},
{
name: "size_bytes",
description: "Total physical memory size",
mib: "vm.stats.vm.v_page_count",
conversion: fromPage,
labels: nil,
},
{
name: "swap_size_bytes",
description: "Total swap memory size",
mib: mibSwapTotal,
dataType: bsdSysctlTypeUint64,
labels: nil,
},
// Descriptions via: top(1)
{
Expand All @@ -132,13 +142,15 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) {
mib: "vm.stats.vm.v_swappgsin",
valueType: prometheus.CounterValue,
conversion: fromPage,
labels: nil,
},
{
name: "swap_out_bytes_total",
description: "Bytes paged out to swap devices",
mib: "vm.stats.vm.v_swappgsout",
valueType: prometheus.CounterValue,
conversion: fromPage,
labels: nil,
},
},
}, nil
Expand Down
6 changes: 6 additions & 0 deletions collector/netisr_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,41 +45,47 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) {
mib: "net.isr.numthreads",
dataType: bsdSysctlTypeUint32,
valueType: prometheus.GaugeValue,
labels: nil,
},
{
name: "maxprot",
description: "netisr maximum protocols",
mib: "net.isr.maxprot",
dataType: bsdSysctlTypeUint32,
valueType: prometheus.GaugeValue,
labels: nil,
},
{
name: "defaultqlimit",
description: "netisr default queue limit",
mib: "net.isr.defaultqlimit",
dataType: bsdSysctlTypeUint32,
valueType: prometheus.GaugeValue,
labels: nil,
},
{
name: "maxqlimit",
description: "netisr maximum queue limit",
mib: "net.isr.maxqlimit",
dataType: bsdSysctlTypeUint32,
valueType: prometheus.GaugeValue,
labels: nil,
},
{
name: "bindthreads",
description: "netisr threads bound to CPUs",
mib: "net.isr.bindthreads",
dataType: bsdSysctlTypeUint32,
valueType: prometheus.GaugeValue,
labels: nil,
},
{
name: "maxthreads",
description: "netisr maximum thread count",
mib: "net.isr.maxthreads",
dataType: bsdSysctlTypeUint32,
valueType: prometheus.GaugeValue,
labels: nil,
},
},
logger: logger,
Expand Down
3 changes: 3 additions & 0 deletions collector/sysctl_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type bsdSysctl struct {

// Post-retrieval conversion hooks
conversion func(float64) float64

// Prometheus labels
labels prometheus.Labels
}

func (b bsdSysctl) Value() (float64, error) {
Expand Down
Loading

0 comments on commit 4547806

Please sign in to comment.