Skip to content

Commit 30454d9

Browse files
frittenthekeoblitorum
authored andcommitted
Add check state for mdadm arrays via node_md_state metric (prometheus#1810)
* Expose metric for state=check for node_md_state * Added new e2e output fixture including md201 which is in checking state and a the new state=check labeled metric for all other md Signed-off-by: Christian Rohmann <[email protected]>
1 parent a07edaa commit 30454d9

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

collector/fixtures/e2e-output.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ node_md_blocks{device="md12"} 3.886394368e+09
14791479
node_md_blocks{device="md120"} 2.095104e+06
14801480
node_md_blocks{device="md126"} 1.855870976e+09
14811481
node_md_blocks{device="md127"} 3.12319552e+08
1482+
node_md_blocks{device="md201"} 1.993728e+06
14821483
node_md_blocks{device="md219"} 7932
14831484
node_md_blocks{device="md3"} 5.853468288e+09
14841485
node_md_blocks{device="md4"} 4.883648e+06
@@ -1497,6 +1498,7 @@ node_md_blocks_synced{device="md12"} 3.886394368e+09
14971498
node_md_blocks_synced{device="md120"} 2.095104e+06
14981499
node_md_blocks_synced{device="md126"} 1.855870976e+09
14991500
node_md_blocks_synced{device="md127"} 3.12319552e+08
1501+
node_md_blocks_synced{device="md201"} 114176
15001502
node_md_blocks_synced{device="md219"} 7932
15011503
node_md_blocks_synced{device="md3"} 5.853468288e+09
15021504
node_md_blocks_synced{device="md4"} 4.883648e+06
@@ -1533,6 +1535,9 @@ node_md_disks{device="md126",state="spare"} 0
15331535
node_md_disks{device="md127",state="active"} 2
15341536
node_md_disks{device="md127",state="failed"} 0
15351537
node_md_disks{device="md127",state="spare"} 0
1538+
node_md_disks{device="md201",state="active"} 2
1539+
node_md_disks{device="md201",state="failed"} 0
1540+
node_md_disks{device="md201",state="spare"} 0
15361541
node_md_disks{device="md219",state="active"} 0
15371542
node_md_disks{device="md219",state="failed"} 0
15381543
node_md_disks{device="md219",state="spare"} 3
@@ -1565,6 +1570,7 @@ node_md_disks_required{device="md12"} 2
15651570
node_md_disks_required{device="md120"} 2
15661571
node_md_disks_required{device="md126"} 2
15671572
node_md_disks_required{device="md127"} 2
1573+
node_md_disks_required{device="md201"} 2
15681574
node_md_disks_required{device="md219"} 0
15691575
node_md_disks_required{device="md3"} 8
15701576
node_md_disks_required{device="md4"} 0
@@ -1575,66 +1581,87 @@ node_md_disks_required{device="md9"} 4
15751581
# HELP node_md_state Indicates the state of md-device.
15761582
# TYPE node_md_state gauge
15771583
node_md_state{device="md0",state="active"} 1
1584+
node_md_state{device="md0",state="check"} 0
15781585
node_md_state{device="md0",state="inactive"} 0
15791586
node_md_state{device="md0",state="recovering"} 0
15801587
node_md_state{device="md0",state="resync"} 0
15811588
node_md_state{device="md00",state="active"} 1
1589+
node_md_state{device="md00",state="check"} 0
15821590
node_md_state{device="md00",state="inactive"} 0
15831591
node_md_state{device="md00",state="recovering"} 0
15841592
node_md_state{device="md00",state="resync"} 0
15851593
node_md_state{device="md10",state="active"} 1
1594+
node_md_state{device="md10",state="check"} 0
15861595
node_md_state{device="md10",state="inactive"} 0
15871596
node_md_state{device="md10",state="recovering"} 0
15881597
node_md_state{device="md10",state="resync"} 0
15891598
node_md_state{device="md101",state="active"} 1
1599+
node_md_state{device="md101",state="check"} 0
15901600
node_md_state{device="md101",state="inactive"} 0
15911601
node_md_state{device="md101",state="recovering"} 0
15921602
node_md_state{device="md101",state="resync"} 0
15931603
node_md_state{device="md11",state="active"} 0
1604+
node_md_state{device="md11",state="check"} 0
15941605
node_md_state{device="md11",state="inactive"} 0
15951606
node_md_state{device="md11",state="recovering"} 0
15961607
node_md_state{device="md11",state="resync"} 1
15971608
node_md_state{device="md12",state="active"} 1
1609+
node_md_state{device="md12",state="check"} 0
15981610
node_md_state{device="md12",state="inactive"} 0
15991611
node_md_state{device="md12",state="recovering"} 0
16001612
node_md_state{device="md12",state="resync"} 0
16011613
node_md_state{device="md120",state="active"} 1
1614+
node_md_state{device="md120",state="check"} 0
16021615
node_md_state{device="md120",state="inactive"} 0
16031616
node_md_state{device="md120",state="recovering"} 0
16041617
node_md_state{device="md120",state="resync"} 0
16051618
node_md_state{device="md126",state="active"} 1
1619+
node_md_state{device="md126",state="check"} 0
16061620
node_md_state{device="md126",state="inactive"} 0
16071621
node_md_state{device="md126",state="recovering"} 0
16081622
node_md_state{device="md126",state="resync"} 0
16091623
node_md_state{device="md127",state="active"} 1
1624+
node_md_state{device="md127",state="check"} 0
16101625
node_md_state{device="md127",state="inactive"} 0
16111626
node_md_state{device="md127",state="recovering"} 0
16121627
node_md_state{device="md127",state="resync"} 0
1628+
node_md_state{device="md201",state="active"} 0
1629+
node_md_state{device="md201",state="check"} 1
1630+
node_md_state{device="md201",state="inactive"} 0
1631+
node_md_state{device="md201",state="recovering"} 0
1632+
node_md_state{device="md201",state="resync"} 0
16131633
node_md_state{device="md219",state="active"} 0
1634+
node_md_state{device="md219",state="check"} 0
16141635
node_md_state{device="md219",state="inactive"} 1
16151636
node_md_state{device="md219",state="recovering"} 0
16161637
node_md_state{device="md219",state="resync"} 0
16171638
node_md_state{device="md3",state="active"} 1
1639+
node_md_state{device="md3",state="check"} 0
16181640
node_md_state{device="md3",state="inactive"} 0
16191641
node_md_state{device="md3",state="recovering"} 0
16201642
node_md_state{device="md3",state="resync"} 0
16211643
node_md_state{device="md4",state="active"} 0
1644+
node_md_state{device="md4",state="check"} 0
16221645
node_md_state{device="md4",state="inactive"} 1
16231646
node_md_state{device="md4",state="recovering"} 0
16241647
node_md_state{device="md4",state="resync"} 0
16251648
node_md_state{device="md6",state="active"} 0
1649+
node_md_state{device="md6",state="check"} 0
16261650
node_md_state{device="md6",state="inactive"} 0
16271651
node_md_state{device="md6",state="recovering"} 1
16281652
node_md_state{device="md6",state="resync"} 0
16291653
node_md_state{device="md7",state="active"} 1
1654+
node_md_state{device="md7",state="check"} 0
16301655
node_md_state{device="md7",state="inactive"} 0
16311656
node_md_state{device="md7",state="recovering"} 0
16321657
node_md_state{device="md7",state="resync"} 0
16331658
node_md_state{device="md8",state="active"} 0
1659+
node_md_state{device="md8",state="check"} 0
16341660
node_md_state{device="md8",state="inactive"} 0
16351661
node_md_state{device="md8",state="recovering"} 0
16361662
node_md_state{device="md8",state="resync"} 1
16371663
node_md_state{device="md9",state="active"} 0
1664+
node_md_state{device="md9",state="check"} 0
16381665
node_md_state{device="md9",state="inactive"} 0
16391666
node_md_state{device="md9",state="recovering"} 0
16401667
node_md_state{device="md9",state="resync"} 1

collector/fixtures/proc/mdstat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ md8 : active raid1 sdb1[1] sda1[0] sdc[2](S) sde[3](S)
2020
195310144 blocks [2/2] [UU]
2121
[=>...................] resync = 8.5% (16775552/195310144) finish=17.0min speed=259783K/sec
2222

23+
md201 : active raid1 sda3[0] sdb3[1]
24+
1993728 blocks super 1.2 [2/2] [UU]
25+
[=>...................] check = 5.7% (114176/1993728) finish=0.2min speed=114176K/sec
26+
2327
md7 : active raid6 sdb1[0] sde1[3] sdd1[2] sdc1[1](F)
2428
7813735424 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/3] [U_UU]
2529
bitmap: 0/30 pages [0KB], 65536KB chunk

collector/mdadm_linux.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ var (
6464
[]string{"device"},
6565
prometheus.Labels{"state": "resync"},
6666
)
67+
checkDesc = prometheus.NewDesc(
68+
prometheus.BuildFQName(namespace, "md", "state"),
69+
"Indicates the state of md-device.",
70+
[]string{"device"},
71+
prometheus.Labels{"state": "check"},
72+
)
6773

6874
disksDesc = prometheus.NewDesc(
6975
prometheus.BuildFQName(namespace, "md", "disks"),
@@ -174,6 +180,13 @@ func (c *mdadmCollector) Update(ch chan<- prometheus.Metric) error {
174180
mdStat.Name,
175181
)
176182

183+
ch <- prometheus.MustNewConstMetric(
184+
checkDesc,
185+
prometheus.GaugeValue,
186+
stateVals["checking"],
187+
mdStat.Name,
188+
)
189+
177190
ch <- prometheus.MustNewConstMetric(
178191
blocksTotalDesc,
179192
prometheus.GaugeValue,

0 commit comments

Comments
 (0)