Skip to content

Commit 1379167

Browse files
authored
Task/add warning for external stg (#61)
* chedck if pool has external disks * check if storage has any external pool * fix test * expose external functions * Reduce usage of -isInternalStorage function * create PoolInfo data in flashsystem * add Mdisks list into Pool data * return from Collect in case of error * add compression data for poolInfo * refactor vars and functions names Signed-off-by: 662962756 <bvered@il.ibm.com> Signed-off-by: Tal Yichye <tal.yichye@ibm.com>
1 parent 16ecc12 commit 1379167

4 files changed

Lines changed: 238 additions & 202 deletions

File tree

pkg/collectors/flash_system.go

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/IBM/ibm-storage-odf-block-driver/pkg/rest"
2222
"github.com/prometheus/client_golang/prometheus"
2323
log "k8s.io/klog"
24+
"strconv"
2425
)
2526

2627
type PerfCollector struct {
@@ -104,17 +105,72 @@ func (f *PerfCollector) Collect(ch chan<- prometheus.Metric) {
104105
f.systems = updatedSystems
105106

106107
for systemName, fsRestClient := range f.systems {
108+
var poolsInfoList []PoolInfo
109+
pools, mDisksList, err := getSystemPoolsAndMDisks(fsRestClient)
110+
if err != nil {
111+
log.Errorf("get pools or mdisks failed: %v", err)
112+
return
113+
}
114+
for _, pool := range pools {
115+
poolInfo := PoolInfo{}
116+
poolInfo.PoolName = pool[MdiskNameKey].(string)
117+
poolInfo.PoolMDisksList, err = getPoolMDisks(fsRestClient, poolInfo.PoolName, mDisksList)
118+
if err != nil {
119+
log.Errorf("get mdisks for pool failed: %v", err)
120+
return
121+
}
122+
poolInfo.IsInternalStorage = IsPoolFromInternalStorage(poolInfo)
123+
poolInfo.IsCompressionEnabled = IsCompressionEnabled(poolInfo)
124+
poolInfo.IsArrayMode = IsPoolArrayMode(poolInfo)
125+
poolInfo.PoolId, _ = strconv.Atoi(pool[MdiskIdKey].(string))
126+
poolInfo.PoolMDiskGrpInfo = pool
127+
poolsInfoList = append(poolsInfoList, poolInfo)
128+
}
129+
107130
log.Info("Collect metrics for ", systemName)
108-
f.collectSystemMetrics(ch, fsRestClient)
131+
f.collectSystemMetrics(ch, fsRestClient, poolsInfoList)
109132

110133
valid, _ := fsRestClient.CheckVersion()
111134
if valid && len(fsRestClient.DriverManager.GetPoolNames()) > 0 {
112135
// Skip unsupported version when generate pool metrics
113-
f.collectPoolMetrics(ch, fsRestClient)
136+
f.collectPoolMetrics(ch, fsRestClient, poolsInfoList)
114137
}
115138

116139
}
117140
// ch <- f.scrapeDuration
118141
// ch <- f.totalScrapes
119142
// ch <- f.failedScrapes
120143
}
144+
145+
func getSystemPoolsAndMDisks(fsRestClient *rest.FSRestClient) (rest.PoolList, rest.MDisksList, error) {
146+
var pools rest.PoolList
147+
var mDisksList rest.MDisksList
148+
pools, err := fsRestClient.Lsmdiskgrp()
149+
if err != nil {
150+
log.Errorf("get pool list error: %v", err)
151+
return pools, mDisksList, err
152+
}
153+
154+
mDisksList, err = fsRestClient.LsAllMDisk()
155+
if err != nil {
156+
log.Errorf("get disk list error: %v", err)
157+
return pools, mDisksList, err
158+
}
159+
return pools, mDisksList, nil
160+
}
161+
162+
func getPoolMDisks(fsRestClient *rest.FSRestClient, poolName string, mDisksList rest.MDisksList) ([]rest.SingleMDiskInfo, error) {
163+
var mDisksInPool []rest.SingleMDiskInfo
164+
for _, mDisk := range mDisksList {
165+
if poolName == mDisk[MdiskGroupNameKey].(string) {
166+
mDiskId, _ := strconv.Atoi(mDisk[MdiskIdKey].(string))
167+
mDiskInfo, err := fsRestClient.LsSingleMDisk(mDiskId)
168+
if err != nil {
169+
log.Errorf("get single mdisk info error: %v", err)
170+
return mDisksInPool, err
171+
}
172+
mDisksInPool = append(mDisksInPool, mDiskInfo)
173+
}
174+
}
175+
return mDisksInPool, nil
176+
}

pkg/collectors/flash_system_test.go

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ func poster(req *http.Request, c *rest.FSRestClient) ([]byte, int, error) {
252252
body =
253253
`[
254254
{
255-
"id": "9",
256-
"name": "mdisk9",
255+
"id": "0",
256+
"name": "mdisk0",
257257
"status": "online",
258258
"mode": "managed",
259259
"mdisk_grp_id": "3",
@@ -266,26 +266,26 @@ func poster(req *http.Request, c *rest.FSRestClient) ([]byte, int, error) {
266266
"controller_name": "controller0"
267267
},
268268
{
269-
"id": "10",
269+
"id": "1",
270270
"name": "mdisk1",
271271
"status": "online",
272272
"mode": "managed",
273273
"mdisk_grp_id": "3",
274-
"mdisk_grp_name": "Pool0",
274+
"mdisk_grp_name": "Pool1",
275275
"capacity": "1090009511627776",
276276
"physical_capacity": "1099511627776",
277277
"physical_free_capacity": "777389080576",
278278
"allocated_capacity": "322122547200",
279279
"effective_used_capacity": "1099511627776",
280-
"controller_name": "controller0"
280+
"controller_name": ""
281281
},
282282
{
283-
"id": "11",
284-
"name": "mdisk1",
283+
"id": "2",
284+
"name": "mdisk2",
285285
"status": "online",
286286
"mode": "managed",
287287
"mdisk_grp_id": "9",
288-
"mdisk_grp_name": "Pool9",
288+
"mdisk_grp_name": "Pool2",
289289
"capacity": "1090009511627776",
290290
"physical_capacity": "1099511627776",
291291
"physical_free_capacity": "777389080576",
@@ -294,8 +294,8 @@ func poster(req *http.Request, c *rest.FSRestClient) ([]byte, int, error) {
294294
"controller_name": ""
295295
},
296296
{
297-
"id": "12",
298-
"name": "mdisk1",
297+
"id": "3",
298+
"name": "mdisk3",
299299
"status": "online",
300300
"mode": "managed",
301301
"mdisk_grp_id": "2",
@@ -308,10 +308,10 @@ func poster(req *http.Request, c *rest.FSRestClient) ([]byte, int, error) {
308308
"controller_name": ""
309309
}
310310
]`
311-
case "/lsmdisk/9":
311+
case "/lsmdisk/0":
312312
body = `{
313-
"id": "9",
314-
"name": "mdisk9",
313+
"id": "0",
314+
"name": "mdisk0",
315315
"status": "online",
316316
"mode": "managed",
317317
"mdisk_grp_id": "3",
@@ -320,42 +320,45 @@ func poster(req *http.Request, c *rest.FSRestClient) ([]byte, int, error) {
320320
"physical_capacity": "1099511627776",
321321
"physical_free_capacity": "777389080576",
322322
"allocated_capacity": "322122547200",
323-
"effective_used_capacity": "1099511627776"
323+
"effective_used_capacity": "1099511627776",
324+
"controller_name": "controller0"
324325
}`
325-
case "/lsmdisk/10":
326+
case "/lsmdisk/1":
326327
body = `{
327-
"id": "10",
328+
"id": "1",
328329
"name": "mdisk1",
329330
"status": "online",
330331
"mode": "managed",
331332
"mdisk_grp_id": "3",
332-
"mdisk_grp_name": "Pool0",
333+
"mdisk_grp_name": "Pool1",
333334
"capacity": "1090009511627776",
334335
"physical_capacity": "1099511627776",
335336
"physical_free_capacity": "777389080576",
336337
"allocated_capacity": "322122547200",
337-
"effective_used_capacity": "1099511627776"
338+
"effective_used_capacity": "1099511627776",
339+
"controller_name": ""
338340
}`
339-
case "/lsmdisk/11":
341+
case "/lsmdisk/2":
340342
body =
341343
`{
342-
"id": "11",
343-
"name": "mdisk1",
344+
"id": "2",
345+
"name": "mdisk2",
344346
"status": "online",
345347
"mode": "managed",
346348
"mdisk_grp_id": "9",
347-
"mdisk_grp_name": "Pool9",
349+
"mdisk_grp_name": "Pool2",
348350
"capacity": "1090009511627776",
349351
"physical_capacity": "1099511627776",
350352
"physical_free_capacity": "777389080576",
351353
"allocated_capacity": "322122547200",
352-
"effective_used_capacity": "1099511627776"
354+
"effective_used_capacity": "1099511627776",
355+
"controller_name": ""
353356
}`
354-
case "/lsmdisk/12":
357+
case "/lsmdisk/3":
355358
body =
356359
`{
357-
"id": "12",
358-
"name": "mdisk1",
360+
"id": "3",
361+
"name": "mdisk3",
359362
"status": "online",
360363
"mode": "managed",
361364
"mdisk_grp_id": "2",
@@ -364,7 +367,8 @@ func poster(req *http.Request, c *rest.FSRestClient) ([]byte, int, error) {
364367
"physical_capacity": "1099511627776",
365368
"physical_free_capacity": "777389080576",
366369
"allocated_capacity": "322122547200",
367-
"effective_used_capacity": ""
370+
"effective_used_capacity": "",
371+
"controller_name": ""
368372
}`
369373
}
370374
return []byte(body), 200, nil
@@ -540,11 +544,11 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
540544
`[
541545
{
542546
"id": "9",
543-
"name": "mdisk9",
547+
"name": "mdisk5",
544548
"status": "online",
545549
"mode": "managed",
546550
"mdisk_grp_id": "3",
547-
"mdisk_grp_name": "Pool0",
551+
"mdisk_grp_name": "Pool5",
548552
"capacity": "1099511627776",
549553
"physical_capacity": "1099511627776",
550554
"physical_free_capacity": "777389080576",
@@ -554,11 +558,11 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
554558
},
555559
{
556560
"id": "10",
557-
"name": "mdisk1",
561+
"name": "mdisk6",
558562
"status": "online",
559563
"mode": "managed",
560564
"mdisk_grp_id": "3",
561-
"mdisk_grp_name": "Pool0",
565+
"mdisk_grp_name": "Pool6",
562566
"capacity": "1090009511627776",
563567
"physical_capacity": "1099511627776",
564568
"physical_free_capacity": "777389080576",
@@ -568,31 +572,31 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
568572
},
569573
{
570574
"id": "11",
571-
"name": "mdisk1",
575+
"name": "mdisk7",
572576
"status": "online",
573577
"mode": "managed",
574578
"mdisk_grp_id": "9",
575-
"mdisk_grp_name": "Pool9",
579+
"mdisk_grp_name": "Pool7",
576580
"capacity": "1090009511627776",
577581
"physical_capacity": "1099511627776",
578582
"physical_free_capacity": "777389080576",
579583
"allocated_capacity": "322122547200",
580584
"effective_used_capacity": "1099511627776",
581-
"controller_name": "controller0"
585+
"controller_name": ""
582586
},
583587
{
584588
"id": "12",
585-
"name": "mdisk1",
589+
"name": "mdisk8",
586590
"status": "online",
587591
"mode": "managed",
588592
"mdisk_grp_id": "2",
589-
"mdisk_grp_name": "Pool2",
593+
"mdisk_grp_name": "Pool8",
590594
"capacity": "1090009511627776",
591595
"physical_capacity": "1099511627776",
592596
"physical_free_capacity": "777389080576",
593597
"allocated_capacity": "322122547200",
594598
"effective_used_capacity": "",
595-
"controller_name": "controller0"
599+
"controller_name": ""
596600
}
597601
]`
598602
case "/lsmdisk/9":
@@ -602,12 +606,13 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
602606
"status": "online",
603607
"mode": "managed",
604608
"mdisk_grp_id": "3",
605-
"mdisk_grp_name": "Pool0",
609+
"mdisk_grp_name": "Pool5",
606610
"capacity": "1099511627776",
607611
"physical_capacity": "1099511627776",
608612
"physical_free_capacity": "777389080576",
609613
"allocated_capacity": "322122547200",
610-
"effective_used_capacity": "1099511627776"
614+
"effective_used_capacity": "1099511627776",
615+
"controller_name": ""
611616
}`
612617
case "/lsmdisk/10":
613618
body = `{
@@ -616,12 +621,13 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
616621
"status": "online",
617622
"mode": "managed",
618623
"mdisk_grp_id": "3",
619-
"mdisk_grp_name": "Pool0",
624+
"mdisk_grp_name": "Pool6",
620625
"capacity": "1090009511627776",
621626
"physical_capacity": "1099511627776",
622627
"physical_free_capacity": "777389080576",
623628
"allocated_capacity": "322122547200",
624-
"effective_used_capacity": "1099511627776"
629+
"effective_used_capacity": "1099511627776",
630+
"controller_name": ""
625631
}`
626632
case "/lsmdisk/11":
627633
body =
@@ -636,7 +642,8 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
636642
"physical_capacity": "1099511627776",
637643
"physical_free_capacity": "777389080576",
638644
"allocated_capacity": "322122547200",
639-
"effective_used_capacity": "1099511627776"
645+
"effective_used_capacity": "1099511627776",
646+
"controller_name": ""
640647
}`
641648
case "/lsmdisk/12":
642649
body =
@@ -651,7 +658,8 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
651658
"physical_capacity": "1099511627776",
652659
"physical_free_capacity": "777389080576",
653660
"allocated_capacity": "322122547200",
654-
"effective_used_capacity": ""
661+
"effective_used_capacity": "",
662+
"controller_name": ""
655663
}`
656664
}
657665
return []byte(body), 200, nil
@@ -784,16 +792,16 @@ func TestMetrics(t *testing.T) {
784792
785793
# HELP flashsystem_pool_metadata Pool metadata
786794
# TYPE flashsystem_pool_metadata gauge
787-
flashsystem_pool_metadata{pool_id="0",pool_name="Pool0",storageclass="fs-sc-1,fs-sc-default",subsystem_name="FS-system-name"} 0
788-
flashsystem_pool_metadata{pool_id="1",pool_name="Pool1",storageclass="fs-sc-2,fs-sc-3",subsystem_name="FS-system-name"} 0
789-
flashsystem_pool_metadata{pool_id="2",pool_name="Pool2",storageclass="fs-sc-4",subsystem_name="FS-system-name"} 0
790-
flashsystem_pool_metadata{pool_id="5",pool_name="Pool5",storageclass="fs-second-sc-1",subsystem_name="FS-system-name-second"} 0
791-
flashsystem_pool_metadata{pool_id="6",pool_name="Pool6",storageclass="fs-second-sc-2",subsystem_name="FS-system-name-second"} 0
795+
flashsystem_pool_metadata{is_internal_storage="0",pool_id="0",pool_name="Pool0",storageclass="fs-sc-1,fs-sc-default",subsystem_name="FS-system-name"} 0
796+
flashsystem_pool_metadata{is_internal_storage="1",pool_id="1",pool_name="Pool1",storageclass="fs-sc-2,fs-sc-3",subsystem_name="FS-system-name"} 0
797+
flashsystem_pool_metadata{is_internal_storage="1",pool_id="2",pool_name="Pool2",storageclass="fs-sc-4",subsystem_name="FS-system-name"} 0
798+
flashsystem_pool_metadata{is_internal_storage="1",pool_id="5",pool_name="Pool5",storageclass="fs-second-sc-1",subsystem_name="FS-system-name-second"} 0
799+
flashsystem_pool_metadata{is_internal_storage="1",pool_id="6",pool_name="Pool6",storageclass="fs-second-sc-2",subsystem_name="FS-system-name-second"} 0
792800
793801
# HELP flashsystem_subsystem_metadata System information
794802
# TYPE flashsystem_subsystem_metadata gauge
795-
flashsystem_subsystem_metadata{model="SAN Volume Controller",subsystem_name="FS-system-name",vendor="IBM",version="8.4.0.2"} 0
796-
flashsystem_subsystem_metadata{model="FlashSystem 9200",subsystem_name="FS-system-name-second",vendor="IBM",version="8.5.2.0"} 0
803+
flashsystem_subsystem_metadata{is_internal_storage="0",model="SAN Volume Controller",subsystem_name="FS-system-name",vendor="IBM",version="8.4.0.2"} 0
804+
flashsystem_subsystem_metadata{is_internal_storage="1",model="FlashSystem 9200",subsystem_name="FS-system-name-second",vendor="IBM",version="8.5.2.0"} 0
797805
798806
# HELP flashsystem_subsystem_health System health
799807
# TYPE flashsystem_subsystem_health gauge
@@ -802,8 +810,8 @@ func TestMetrics(t *testing.T) {
802810
803811
# HELP flashsystem_subsystem_response System response
804812
# TYPE flashsystem_subsystem_response gauge
805-
flashsystem_subsystem_response{model="",subsystem_name="FS-system-name",vendor="",version=""} 1
806-
flashsystem_subsystem_response{model="",subsystem_name="FS-system-name-second",vendor="",version=""} 1
813+
flashsystem_subsystem_response{is_internal_storage="0",model="",subsystem_name="FS-system-name",vendor="",version="",} 1
814+
flashsystem_subsystem_response{is_internal_storage="0", model="",subsystem_name="FS-system-name-second",vendor="",version=""} 1
807815
808816
# HELP flashsystem_subsystem_latency_seconds overall performance - average latency seconds
809817
# TYPE flashsystem_subsystem_latency_seconds gauge

0 commit comments

Comments
 (0)