Skip to content

Commit cca725b

Browse files
committed
collectors/mdadm_linux: support reshape status + expose remaining mdstats
Signed-off-by: Philipp Born <[email protected]>
1 parent e6a9cfb commit cca725b

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-0
lines changed

collector/fixtures/e2e-output.txt

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,7 @@ node_md_blocks{device="md201"} 1.993728e+06
15781578
node_md_blocks{device="md219"} 7932
15791579
node_md_blocks{device="md3"} 5.853468288e+09
15801580
node_md_blocks{device="md4"} 4.883648e+06
1581+
node_md_blocks{device="md42"} 1.95338144e+09
15811582
node_md_blocks{device="md6"} 1.95310144e+08
15821583
node_md_blocks{device="md7"} 7.813735424e+09
15831584
node_md_blocks{device="md8"} 1.95310144e+08
@@ -1597,10 +1598,71 @@ node_md_blocks_synced{device="md201"} 114176
15971598
node_md_blocks_synced{device="md219"} 7932
15981599
node_md_blocks_synced{device="md3"} 5.853468288e+09
15991600
node_md_blocks_synced{device="md4"} 4.883648e+06
1601+
node_md_blocks_synced{device="md42"} 1.95338144e+09
16001602
node_md_blocks_synced{device="md6"} 1.6775552e+07
16011603
node_md_blocks_synced{device="md7"} 7.813735424e+09
16021604
node_md_blocks_synced{device="md8"} 1.6775552e+07
16031605
node_md_blocks_synced{device="md9"} 0
1606+
# HELP node_md_blocks_synced_pct Percentage of blocks synced on device.
1607+
# TYPE node_md_blocks_synced_pct gauge
1608+
node_md_blocks_synced_pct{device="md0"} 0
1609+
node_md_blocks_synced_pct{device="md00"} 0
1610+
node_md_blocks_synced_pct{device="md10"} 0
1611+
node_md_blocks_synced_pct{device="md101"} 0
1612+
node_md_blocks_synced_pct{device="md11"} 0
1613+
node_md_blocks_synced_pct{device="md12"} 0
1614+
node_md_blocks_synced_pct{device="md120"} 0
1615+
node_md_blocks_synced_pct{device="md126"} 0
1616+
node_md_blocks_synced_pct{device="md127"} 0
1617+
node_md_blocks_synced_pct{device="md201"} 5.7
1618+
node_md_blocks_synced_pct{device="md219"} 0
1619+
node_md_blocks_synced_pct{device="md3"} 0
1620+
node_md_blocks_synced_pct{device="md4"} 0
1621+
node_md_blocks_synced_pct{device="md42"} 0
1622+
node_md_blocks_synced_pct{device="md6"} 8.5
1623+
node_md_blocks_synced_pct{device="md7"} 0
1624+
node_md_blocks_synced_pct{device="md8"} 8.5
1625+
node_md_blocks_synced_pct{device="md9"} 0
1626+
# HELP node_md_blocks_synced_speed Estimated finishing time for current sync.
1627+
# TYPE node_md_blocks_synced_speed gauge
1628+
node_md_blocks_synced_speed{device="md0"} 0
1629+
node_md_blocks_synced_speed{device="md00"} 0
1630+
node_md_blocks_synced_speed{device="md10"} 0
1631+
node_md_blocks_synced_speed{device="md101"} 0
1632+
node_md_blocks_synced_speed{device="md11"} 0
1633+
node_md_blocks_synced_speed{device="md12"} 0
1634+
node_md_blocks_synced_speed{device="md120"} 0
1635+
node_md_blocks_synced_speed{device="md126"} 0
1636+
node_md_blocks_synced_speed{device="md127"} 0
1637+
node_md_blocks_synced_speed{device="md201"} 0.2
1638+
node_md_blocks_synced_speed{device="md219"} 0
1639+
node_md_blocks_synced_speed{device="md3"} 0
1640+
node_md_blocks_synced_speed{device="md4"} 0
1641+
node_md_blocks_synced_speed{device="md42"} 0
1642+
node_md_blocks_synced_speed{device="md6"} 17
1643+
node_md_blocks_synced_speed{device="md7"} 0
1644+
node_md_blocks_synced_speed{device="md8"} 17
1645+
node_md_blocks_synced_speed{device="md9"} 0
1646+
# HELP node_md_blocks_tobesynced Number of blocks on the device that need to be synced.
1647+
# TYPE node_md_blocks_tobesynced gauge
1648+
node_md_blocks_tobesynced{device="md0"} 248896
1649+
node_md_blocks_tobesynced{device="md00"} 4.186624e+06
1650+
node_md_blocks_tobesynced{device="md10"} 3.14159265e+08
1651+
node_md_blocks_tobesynced{device="md101"} 322560
1652+
node_md_blocks_tobesynced{device="md11"} 4.190208e+06
1653+
node_md_blocks_tobesynced{device="md12"} 3.886394368e+09
1654+
node_md_blocks_tobesynced{device="md120"} 2.095104e+06
1655+
node_md_blocks_tobesynced{device="md126"} 1.855870976e+09
1656+
node_md_blocks_tobesynced{device="md127"} 3.12319552e+08
1657+
node_md_blocks_tobesynced{device="md201"} 1.993728e+06
1658+
node_md_blocks_tobesynced{device="md219"} 7932
1659+
node_md_blocks_tobesynced{device="md3"} 5.853468288e+09
1660+
node_md_blocks_tobesynced{device="md4"} 4.883648e+06
1661+
node_md_blocks_tobesynced{device="md42"} 1.95338144e+09
1662+
node_md_blocks_tobesynced{device="md6"} 1.95310144e+08
1663+
node_md_blocks_tobesynced{device="md7"} 7.813735424e+09
1664+
node_md_blocks_tobesynced{device="md8"} 1.95310144e+08
1665+
node_md_blocks_tobesynced{device="md9"} 523968
16041666
# HELP node_md_disks Number of active/failed/spare disks of device.
16051667
# TYPE node_md_disks gauge
16061668
node_md_disks{device="md0",state="active"} 2
@@ -1642,6 +1704,9 @@ node_md_disks{device="md3",state="spare"} 2
16421704
node_md_disks{device="md4",state="active"} 0
16431705
node_md_disks{device="md4",state="failed"} 1
16441706
node_md_disks{device="md4",state="spare"} 1
1707+
node_md_disks{device="md42",state="active"} 2
1708+
node_md_disks{device="md42",state="failed"} 0
1709+
node_md_disks{device="md42",state="spare"} 1
16451710
node_md_disks{device="md6",state="active"} 1
16461711
node_md_disks{device="md6",state="failed"} 1
16471712
node_md_disks{device="md6",state="spare"} 1
@@ -1669,6 +1734,7 @@ node_md_disks_required{device="md201"} 2
16691734
node_md_disks_required{device="md219"} 0
16701735
node_md_disks_required{device="md3"} 8
16711736
node_md_disks_required{device="md4"} 0
1737+
node_md_disks_required{device="md42"} 3
16721738
node_md_disks_required{device="md6"} 2
16731739
node_md_disks_required{device="md7"} 4
16741740
node_md_disks_required{device="md8"} 2
@@ -1679,86 +1745,109 @@ node_md_state{device="md0",state="active"} 1
16791745
node_md_state{device="md0",state="check"} 0
16801746
node_md_state{device="md0",state="inactive"} 0
16811747
node_md_state{device="md0",state="recovering"} 0
1748+
node_md_state{device="md0",state="reshaping"} 0
16821749
node_md_state{device="md0",state="resync"} 0
16831750
node_md_state{device="md00",state="active"} 1
16841751
node_md_state{device="md00",state="check"} 0
16851752
node_md_state{device="md00",state="inactive"} 0
16861753
node_md_state{device="md00",state="recovering"} 0
1754+
node_md_state{device="md00",state="reshaping"} 0
16871755
node_md_state{device="md00",state="resync"} 0
16881756
node_md_state{device="md10",state="active"} 1
16891757
node_md_state{device="md10",state="check"} 0
16901758
node_md_state{device="md10",state="inactive"} 0
16911759
node_md_state{device="md10",state="recovering"} 0
1760+
node_md_state{device="md10",state="reshaping"} 0
16921761
node_md_state{device="md10",state="resync"} 0
16931762
node_md_state{device="md101",state="active"} 1
16941763
node_md_state{device="md101",state="check"} 0
16951764
node_md_state{device="md101",state="inactive"} 0
16961765
node_md_state{device="md101",state="recovering"} 0
1766+
node_md_state{device="md101",state="reshaping"} 0
16971767
node_md_state{device="md101",state="resync"} 0
16981768
node_md_state{device="md11",state="active"} 0
16991769
node_md_state{device="md11",state="check"} 0
17001770
node_md_state{device="md11",state="inactive"} 0
17011771
node_md_state{device="md11",state="recovering"} 0
1772+
node_md_state{device="md11",state="reshaping"} 0
17021773
node_md_state{device="md11",state="resync"} 1
17031774
node_md_state{device="md12",state="active"} 1
17041775
node_md_state{device="md12",state="check"} 0
17051776
node_md_state{device="md12",state="inactive"} 0
17061777
node_md_state{device="md12",state="recovering"} 0
1778+
node_md_state{device="md12",state="reshaping"} 0
17071779
node_md_state{device="md12",state="resync"} 0
17081780
node_md_state{device="md120",state="active"} 1
17091781
node_md_state{device="md120",state="check"} 0
17101782
node_md_state{device="md120",state="inactive"} 0
17111783
node_md_state{device="md120",state="recovering"} 0
1784+
node_md_state{device="md120",state="reshaping"} 0
17121785
node_md_state{device="md120",state="resync"} 0
17131786
node_md_state{device="md126",state="active"} 1
17141787
node_md_state{device="md126",state="check"} 0
17151788
node_md_state{device="md126",state="inactive"} 0
17161789
node_md_state{device="md126",state="recovering"} 0
1790+
node_md_state{device="md126",state="reshaping"} 0
17171791
node_md_state{device="md126",state="resync"} 0
17181792
node_md_state{device="md127",state="active"} 1
17191793
node_md_state{device="md127",state="check"} 0
17201794
node_md_state{device="md127",state="inactive"} 0
17211795
node_md_state{device="md127",state="recovering"} 0
1796+
node_md_state{device="md127",state="reshaping"} 0
17221797
node_md_state{device="md127",state="resync"} 0
17231798
node_md_state{device="md201",state="active"} 0
17241799
node_md_state{device="md201",state="check"} 1
17251800
node_md_state{device="md201",state="inactive"} 0
17261801
node_md_state{device="md201",state="recovering"} 0
1802+
node_md_state{device="md201",state="reshaping"} 0
17271803
node_md_state{device="md201",state="resync"} 0
17281804
node_md_state{device="md219",state="active"} 0
17291805
node_md_state{device="md219",state="check"} 0
17301806
node_md_state{device="md219",state="inactive"} 1
17311807
node_md_state{device="md219",state="recovering"} 0
1808+
node_md_state{device="md219",state="reshaping"} 0
17321809
node_md_state{device="md219",state="resync"} 0
17331810
node_md_state{device="md3",state="active"} 1
17341811
node_md_state{device="md3",state="check"} 0
17351812
node_md_state{device="md3",state="inactive"} 0
17361813
node_md_state{device="md3",state="recovering"} 0
1814+
node_md_state{device="md3",state="reshaping"} 0
17371815
node_md_state{device="md3",state="resync"} 0
17381816
node_md_state{device="md4",state="active"} 0
17391817
node_md_state{device="md4",state="check"} 0
17401818
node_md_state{device="md4",state="inactive"} 1
17411819
node_md_state{device="md4",state="recovering"} 0
1820+
node_md_state{device="md4",state="reshaping"} 0
17421821
node_md_state{device="md4",state="resync"} 0
1822+
node_md_state{device="md42",state="active"} 1
1823+
node_md_state{device="md42",state="check"} 0
1824+
node_md_state{device="md42",state="inactive"} 0
1825+
node_md_state{device="md42",state="recovering"} 0
1826+
node_md_state{device="md42",state="reshaping"} 0
1827+
node_md_state{device="md42",state="resync"} 0
17431828
node_md_state{device="md6",state="active"} 0
17441829
node_md_state{device="md6",state="check"} 0
17451830
node_md_state{device="md6",state="inactive"} 0
17461831
node_md_state{device="md6",state="recovering"} 1
1832+
node_md_state{device="md6",state="reshaping"} 0
17471833
node_md_state{device="md6",state="resync"} 0
17481834
node_md_state{device="md7",state="active"} 1
17491835
node_md_state{device="md7",state="check"} 0
17501836
node_md_state{device="md7",state="inactive"} 0
17511837
node_md_state{device="md7",state="recovering"} 0
1838+
node_md_state{device="md7",state="reshaping"} 0
17521839
node_md_state{device="md7",state="resync"} 0
17531840
node_md_state{device="md8",state="active"} 0
17541841
node_md_state{device="md8",state="check"} 0
17551842
node_md_state{device="md8",state="inactive"} 0
17561843
node_md_state{device="md8",state="recovering"} 0
1844+
node_md_state{device="md8",state="reshaping"} 0
17571845
node_md_state{device="md8",state="resync"} 1
17581846
node_md_state{device="md9",state="active"} 0
17591847
node_md_state{device="md9",state="check"} 0
17601848
node_md_state{device="md9",state="inactive"} 0
17611849
node_md_state{device="md9",state="recovering"} 0
1850+
node_md_state{device="md9",state="reshaping"} 0
17621851
node_md_state{device="md9",state="resync"} 1
17631852
# HELP node_memory_Active_anon_bytes Memory information field Active_anon_bytes.
17641853
# TYPE node_memory_Active_anon_bytes gauge

collector/fixtures/proc/mdstat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,9 @@ md120 : active linear sda1[1] sdb1[0]
5757
md101 : active (read-only) raid0 sdb[2] sdd[1] sdc[0]
5858
322560 blocks super 1.2 512k chunks
5959

60+
md42 : active raid5 sda1[3](S) sdd1[0] sde1[1]
61+
1953381440 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/2] [UU_]
62+
[===========>.........] reshape = 56.1% (1096879076/1953381440) finish=1868.1min speed=7640K/sec
63+
bitmap: 4/15 pages [16KB], 65536KB chunk
64+
6065
unused devices: <none>

collector/mdadm_linux.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ var (
5858
[]string{"device"},
5959
prometheus.Labels{"state": "recovering"},
6060
)
61+
reshapingDesc = prometheus.NewDesc(
62+
prometheus.BuildFQName(namespace, "md", "state"),
63+
"Indicates the state of md-device.",
64+
[]string{"device"},
65+
prometheus.Labels{"state": "reshaping"},
66+
)
6167
resyncDesc = prometheus.NewDesc(
6268
prometheus.BuildFQName(namespace, "md", "state"),
6369
"Indicates the state of md-device.",
@@ -98,6 +104,31 @@ var (
98104
[]string{"device"},
99105
nil,
100106
)
107+
108+
blocksToBeSyncedDesc = prometheus.NewDesc(
109+
prometheus.BuildFQName(namespace, "md", "blocks_tobesynced"),
110+
"Number of blocks on the device that need to be synced.",
111+
[]string{"device"},
112+
nil,
113+
)
114+
blocksSyncedPctDesc = prometheus.NewDesc(
115+
prometheus.BuildFQName(namespace, "md", "blocks_synced_pct"),
116+
"Percentage of blocks synced on device.",
117+
[]string{"device"},
118+
nil,
119+
)
120+
blocksSyncedFinishTimeDesc = prometheus.NewDesc(
121+
prometheus.BuildFQName(namespace, "md", "blocks_synced_speed"),
122+
"Estimated finishing time for current sync.",
123+
[]string{"device"},
124+
nil,
125+
)
126+
blocksSyncedSpeedDesc = prometheus.NewDesc(
127+
prometheus.BuildFQName(namespace, "md", "blocks_synced_speed"),
128+
"Progress percentage of current sync.",
129+
[]string{"device"},
130+
nil,
131+
)
101132
)
102133

103134
func (c *mdadmCollector) Update(ch chan<- prometheus.Metric) error {
@@ -166,6 +197,13 @@ func (c *mdadmCollector) Update(ch chan<- prometheus.Metric) error {
166197
mdStat.Name,
167198
)
168199

200+
ch <- prometheus.MustNewConstMetric(
201+
reshapingDesc,
202+
prometheus.GaugeValue,
203+
stateVals["reshaping"],
204+
mdStat.Name,
205+
)
206+
169207
ch <- prometheus.MustNewConstMetric(
170208
recoveringDesc,
171209
prometheus.GaugeValue,
@@ -199,6 +237,30 @@ func (c *mdadmCollector) Update(ch chan<- prometheus.Metric) error {
199237
float64(mdStat.BlocksSynced),
200238
mdStat.Name,
201239
)
240+
ch <- prometheus.MustNewConstMetric(
241+
blocksToBeSyncedDesc,
242+
prometheus.GaugeValue,
243+
float64(mdStat.BlocksToBeSynced),
244+
mdStat.Name,
245+
)
246+
ch <- prometheus.MustNewConstMetric(
247+
blocksSyncedPctDesc,
248+
prometheus.GaugeValue,
249+
float64(mdStat.BlocksSyncedPct),
250+
mdStat.Name,
251+
)
252+
ch <- prometheus.MustNewConstMetric(
253+
blocksSyncedFinishTimeDesc,
254+
prometheus.GaugeValue,
255+
float64(mdStat.BlocksSyncedFinishTime),
256+
mdStat.Name,
257+
)
258+
ch <- prometheus.MustNewConstMetric(
259+
blocksSyncedSpeedDesc,
260+
prometheus.GaugeValue,
261+
float64(mdStat.BlocksSyncedSpeed),
262+
mdStat.Name,
263+
)
202264
}
203265

204266
return nil

0 commit comments

Comments
 (0)