Skip to content

Commit f34aaa6

Browse files
authored
Add ZFS freebsd per dataset stats (prometheus#2753)
* 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 <[email protected]>
1 parent 5ae22fa commit f34aaa6

File tree

7 files changed

+100
-3
lines changed

7 files changed

+100
-3
lines changed

collector/exec_bsd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,37 @@ func NewExecCollector(logger log.Logger) (Collector, error) {
4949
name: "exec_context_switches_total",
5050
description: "Context switches since system boot. Resets at architecture unsigned integer.",
5151
mib: "vm.stats.sys.v_swtch",
52+
labels: nil,
5253
},
5354
{
5455
name: "exec_traps_total",
5556
description: "Traps since system boot. Resets at architecture unsigned integer.",
5657
mib: "vm.stats.sys.v_trap",
58+
labels: nil,
5759
},
5860
{
5961
name: "exec_system_calls_total",
6062
description: "System calls since system boot. Resets at architecture unsigned integer.",
6163
mib: "vm.stats.sys.v_syscall",
6264
},
65+
labels: nil,
6366
{
6467
name: "exec_device_interrupts_total",
6568
description: "Device interrupts since system boot. Resets at architecture unsigned integer.",
6669
mib: "vm.stats.sys.v_intr",
70+
labels: nil,
6771
},
6872
{
6973
name: "exec_software_interrupts_total",
7074
description: "Software interrupts since system boot. Resets at architecture unsigned integer.",
7175
mib: "vm.stats.sys.v_soft",
76+
labels: nil,
7277
},
7378
{
7479
name: "exec_forks_total",
7580
description: "Number of fork() calls since system boot. Resets at architecture unsigned integer.",
7681
mib: "vm.stats.vm.v_forks",
82+
labels: nil,
7783
},
7884
},
7985
logger: logger,

collector/memory_bsd.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,61 +69,71 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) {
6969
description: "Recently used by userland",
7070
mib: "vm.stats.vm.v_active_count",
7171
conversion: fromPage,
72+
labels: nil,
7273
},
7374
{
7475
name: "inactive_bytes",
7576
description: "Not recently used by userland",
7677
mib: "vm.stats.vm.v_inactive_count",
7778
conversion: fromPage,
79+
labels: nil,
7880
},
7981
{
8082
name: "wired_bytes",
8183
description: "Locked in memory by kernel, mlock, etc",
8284
mib: "vm.stats.vm.v_wire_count",
8385
conversion: fromPage,
86+
labels: nil,
8487
},
8588
{
8689
name: "user_wired_bytes",
8790
description: "Locked in memory by user, mlock, etc",
8891
mib: "vm.stats.vm.v_user_wire_count",
8992
conversion: fromPage,
9093
dataType: bsdSysctlTypeCLong,
94+
labels: nil,
9195
},
9296
{
9397
name: "cache_bytes",
9498
description: "Almost free, backed by swap or files, available for re-allocation",
9599
mib: "vm.stats.vm.v_cache_count",
96100
conversion: fromPage,
101+
labels: nil,
97102
},
98103
{
99104
name: "buffer_bytes",
100105
description: "Disk IO Cache entries for non ZFS filesystems, only usable by kernel",
101106
mib: "vfs.bufspace",
102107
dataType: bsdSysctlTypeCLong,
108+
labels: nil,
103109
},
104110
{
105111
name: "free_bytes",
106112
description: "Unallocated, available for allocation",
107113
mib: "vm.stats.vm.v_free_count",
108114
conversion: fromPage,
115+
labels: nil,
109116
},
110117
{
111118
name: "laundry_bytes",
112119
description: "Dirty not recently used by userland",
113120
mib: "vm.stats.vm.v_laundry_count",
114121
conversion: fromPage,
122+
labels: nil,
115123
},
116124
{
117125
name: "size_bytes",
118126
description: "Total physical memory size",
119127
mib: "vm.stats.vm.v_page_count",
120128
conversion: fromPage,
129+
labels: nil,
121130
},
122131
{
123132
name: "swap_size_bytes",
124133
description: "Total swap memory size",
125134
mib: mibSwapTotal,
126135
dataType: bsdSysctlTypeUint64,
136+
labels: nil,
127137
},
128138
// Descriptions via: top(1)
129139
{
@@ -132,13 +142,15 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) {
132142
mib: "vm.stats.vm.v_swappgsin",
133143
valueType: prometheus.CounterValue,
134144
conversion: fromPage,
145+
labels: nil,
135146
},
136147
{
137148
name: "swap_out_bytes_total",
138149
description: "Bytes paged out to swap devices",
139150
mib: "vm.stats.vm.v_swappgsout",
140151
valueType: prometheus.CounterValue,
141152
conversion: fromPage,
153+
labels: nil,
142154
},
143155
},
144156
}, nil

collector/netisr_freebsd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,47 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) {
4545
mib: "net.isr.numthreads",
4646
dataType: bsdSysctlTypeUint32,
4747
valueType: prometheus.GaugeValue,
48+
labels: nil,
4849
},
4950
{
5051
name: "maxprot",
5152
description: "netisr maximum protocols",
5253
mib: "net.isr.maxprot",
5354
dataType: bsdSysctlTypeUint32,
5455
valueType: prometheus.GaugeValue,
56+
labels: nil,
5557
},
5658
{
5759
name: "defaultqlimit",
5860
description: "netisr default queue limit",
5961
mib: "net.isr.defaultqlimit",
6062
dataType: bsdSysctlTypeUint32,
6163
valueType: prometheus.GaugeValue,
64+
labels: nil,
6265
},
6366
{
6467
name: "maxqlimit",
6568
description: "netisr maximum queue limit",
6669
mib: "net.isr.maxqlimit",
6770
dataType: bsdSysctlTypeUint32,
6871
valueType: prometheus.GaugeValue,
72+
labels: nil,
6973
},
7074
{
7175
name: "bindthreads",
7276
description: "netisr threads bound to CPUs",
7377
mib: "net.isr.bindthreads",
7478
dataType: bsdSysctlTypeUint32,
7579
valueType: prometheus.GaugeValue,
80+
labels: nil,
7681
},
7782
{
7883
name: "maxthreads",
7984
description: "netisr maximum thread count",
8085
mib: "net.isr.maxthreads",
8186
dataType: bsdSysctlTypeUint32,
8287
valueType: prometheus.GaugeValue,
88+
labels: nil,
8389
},
8490
},
8591
logger: logger,

collector/sysctl_bsd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ type bsdSysctl struct {
5959

6060
// Post-retrieval conversion hooks
6161
conversion func(float64) float64
62+
63+
// Prometheus labels
64+
labels prometheus.Labels
6265
}
6366

6467
func (b bsdSysctl) Value() (float64, error) {

0 commit comments

Comments
 (0)