Skip to content

Commit 16ecc12

Browse files
authored
Calc physical and logical pool capacities by fixing reclaimable capacity calculations (#60)
* Calc physical and logical pool capacities by fixing reclaimable capacity calculations * Calc physical storage capacity by fixing reclaimable calculation per pool * Error: S1002: should omit comparison to bool constant, can be simplified * fix tests * check if pool mdisks are compressed * check if pool mdisks are compressed * add a test section to calc reclamation for non-compressed drives * revert files * remove reclaimable-0 in case of external storage * rename variables * fix test * fix calculation * remove child-pool calc Signed-off-by: 662962756 <bvered@il.ibm.com>
1 parent 744d551 commit 16ecc12

4 files changed

Lines changed: 548 additions & 64 deletions

File tree

pkg/collectors/flash_system_test.go

Lines changed: 258 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,124 @@ func poster(req *http.Request, c *rest.FSRestClient) ([]byte, int, error) {
248248
]`
249249
case "/lscurrentuser":
250250
body = `[{"name": "superuser", "role": "SecurityAdmin"}]`
251+
case "/lsmdisk":
252+
body =
253+
`[
254+
{
255+
"id": "9",
256+
"name": "mdisk9",
257+
"status": "online",
258+
"mode": "managed",
259+
"mdisk_grp_id": "3",
260+
"mdisk_grp_name": "Pool0",
261+
"capacity": "1099511627776",
262+
"physical_capacity": "1099511627776",
263+
"physical_free_capacity": "777389080576",
264+
"allocated_capacity": "322122547200",
265+
"effective_used_capacity": "1099511627776",
266+
"controller_name": "controller0"
267+
},
268+
{
269+
"id": "10",
270+
"name": "mdisk1",
271+
"status": "online",
272+
"mode": "managed",
273+
"mdisk_grp_id": "3",
274+
"mdisk_grp_name": "Pool0",
275+
"capacity": "1090009511627776",
276+
"physical_capacity": "1099511627776",
277+
"physical_free_capacity": "777389080576",
278+
"allocated_capacity": "322122547200",
279+
"effective_used_capacity": "1099511627776",
280+
"controller_name": "controller0"
281+
},
282+
{
283+
"id": "11",
284+
"name": "mdisk1",
285+
"status": "online",
286+
"mode": "managed",
287+
"mdisk_grp_id": "9",
288+
"mdisk_grp_name": "Pool9",
289+
"capacity": "1090009511627776",
290+
"physical_capacity": "1099511627776",
291+
"physical_free_capacity": "777389080576",
292+
"allocated_capacity": "322122547200",
293+
"effective_used_capacity": "1099511627776",
294+
"controller_name": ""
295+
},
296+
{
297+
"id": "12",
298+
"name": "mdisk1",
299+
"status": "online",
300+
"mode": "managed",
301+
"mdisk_grp_id": "2",
302+
"mdisk_grp_name": "Pool2",
303+
"capacity": "1090009511627776",
304+
"physical_capacity": "1099511627776",
305+
"physical_free_capacity": "777389080576",
306+
"allocated_capacity": "322122547200",
307+
"effective_used_capacity": "",
308+
"controller_name": ""
309+
}
310+
]`
311+
case "/lsmdisk/9":
312+
body = `{
313+
"id": "9",
314+
"name": "mdisk9",
315+
"status": "online",
316+
"mode": "managed",
317+
"mdisk_grp_id": "3",
318+
"mdisk_grp_name": "Pool0",
319+
"capacity": "1099511627776",
320+
"physical_capacity": "1099511627776",
321+
"physical_free_capacity": "777389080576",
322+
"allocated_capacity": "322122547200",
323+
"effective_used_capacity": "1099511627776"
324+
}`
325+
case "/lsmdisk/10":
326+
body = `{
327+
"id": "10",
328+
"name": "mdisk1",
329+
"status": "online",
330+
"mode": "managed",
331+
"mdisk_grp_id": "3",
332+
"mdisk_grp_name": "Pool0",
333+
"capacity": "1090009511627776",
334+
"physical_capacity": "1099511627776",
335+
"physical_free_capacity": "777389080576",
336+
"allocated_capacity": "322122547200",
337+
"effective_used_capacity": "1099511627776"
338+
}`
339+
case "/lsmdisk/11":
340+
body =
341+
`{
342+
"id": "11",
343+
"name": "mdisk1",
344+
"status": "online",
345+
"mode": "managed",
346+
"mdisk_grp_id": "9",
347+
"mdisk_grp_name": "Pool9",
348+
"capacity": "1090009511627776",
349+
"physical_capacity": "1099511627776",
350+
"physical_free_capacity": "777389080576",
351+
"allocated_capacity": "322122547200",
352+
"effective_used_capacity": "1099511627776"
353+
}`
354+
case "/lsmdisk/12":
355+
body =
356+
`{
357+
"id": "12",
358+
"name": "mdisk1",
359+
"status": "online",
360+
"mode": "managed",
361+
"mdisk_grp_id": "2",
362+
"mdisk_grp_name": "Pool2",
363+
"capacity": "1090009511627776",
364+
"physical_capacity": "1099511627776",
365+
"physical_free_capacity": "777389080576",
366+
"allocated_capacity": "322122547200",
367+
"effective_used_capacity": ""
368+
}`
251369
}
252370
return []byte(body), 200, nil
253371
}
@@ -417,6 +535,124 @@ func posterSecondSystem(req *http.Request, c *rest.FSRestClient) ([]byte, int, e
417535
]`
418536
case "/lscurrentuser":
419537
body = `[{"name": "superuser", "role": "Administrator"}]`
538+
case "/lsmdisk":
539+
body =
540+
`[
541+
{
542+
"id": "9",
543+
"name": "mdisk9",
544+
"status": "online",
545+
"mode": "managed",
546+
"mdisk_grp_id": "3",
547+
"mdisk_grp_name": "Pool0",
548+
"capacity": "1099511627776",
549+
"physical_capacity": "1099511627776",
550+
"physical_free_capacity": "777389080576",
551+
"allocated_capacity": "322122547200",
552+
"effective_used_capacity": "1099511627776",
553+
"controller_name": ""
554+
},
555+
{
556+
"id": "10",
557+
"name": "mdisk1",
558+
"status": "online",
559+
"mode": "managed",
560+
"mdisk_grp_id": "3",
561+
"mdisk_grp_name": "Pool0",
562+
"capacity": "1090009511627776",
563+
"physical_capacity": "1099511627776",
564+
"physical_free_capacity": "777389080576",
565+
"allocated_capacity": "322122547200",
566+
"effective_used_capacity": "1099511627776",
567+
"controller_name": ""
568+
},
569+
{
570+
"id": "11",
571+
"name": "mdisk1",
572+
"status": "online",
573+
"mode": "managed",
574+
"mdisk_grp_id": "9",
575+
"mdisk_grp_name": "Pool9",
576+
"capacity": "1090009511627776",
577+
"physical_capacity": "1099511627776",
578+
"physical_free_capacity": "777389080576",
579+
"allocated_capacity": "322122547200",
580+
"effective_used_capacity": "1099511627776",
581+
"controller_name": "controller0"
582+
},
583+
{
584+
"id": "12",
585+
"name": "mdisk1",
586+
"status": "online",
587+
"mode": "managed",
588+
"mdisk_grp_id": "2",
589+
"mdisk_grp_name": "Pool2",
590+
"capacity": "1090009511627776",
591+
"physical_capacity": "1099511627776",
592+
"physical_free_capacity": "777389080576",
593+
"allocated_capacity": "322122547200",
594+
"effective_used_capacity": "",
595+
"controller_name": "controller0"
596+
}
597+
]`
598+
case "/lsmdisk/9":
599+
body = `{
600+
"id": "9",
601+
"name": "mdisk9",
602+
"status": "online",
603+
"mode": "managed",
604+
"mdisk_grp_id": "3",
605+
"mdisk_grp_name": "Pool0",
606+
"capacity": "1099511627776",
607+
"physical_capacity": "1099511627776",
608+
"physical_free_capacity": "777389080576",
609+
"allocated_capacity": "322122547200",
610+
"effective_used_capacity": "1099511627776"
611+
}`
612+
case "/lsmdisk/10":
613+
body = `{
614+
"id": "10",
615+
"name": "mdisk1",
616+
"status": "online",
617+
"mode": "managed",
618+
"mdisk_grp_id": "3",
619+
"mdisk_grp_name": "Pool0",
620+
"capacity": "1090009511627776",
621+
"physical_capacity": "1099511627776",
622+
"physical_free_capacity": "777389080576",
623+
"allocated_capacity": "322122547200",
624+
"effective_used_capacity": "1099511627776"
625+
}`
626+
case "/lsmdisk/11":
627+
body =
628+
`{
629+
"id": "11",
630+
"name": "mdisk1",
631+
"status": "online",
632+
"mode": "managed",
633+
"mdisk_grp_id": "9",
634+
"mdisk_grp_name": "Pool9",
635+
"capacity": "1090009511627776",
636+
"physical_capacity": "1099511627776",
637+
"physical_free_capacity": "777389080576",
638+
"allocated_capacity": "322122547200",
639+
"effective_used_capacity": "1099511627776"
640+
}`
641+
case "/lsmdisk/12":
642+
body =
643+
`{
644+
"id": "12",
645+
"name": "mdisk1",
646+
"status": "online",
647+
"mode": "managed",
648+
"mdisk_grp_id": "2",
649+
"mdisk_grp_name": "Pool2",
650+
"capacity": "1090009511627776",
651+
"physical_capacity": "1099511627776",
652+
"physical_free_capacity": "777389080576",
653+
"allocated_capacity": "322122547200",
654+
"effective_used_capacity": ""
655+
}`
420656
}
421657
return []byte(body), 200, nil
422658
}
@@ -490,7 +726,15 @@ func TestMetrics(t *testing.T) {
490726
flashsystem_pool_logical_capacity_used_bytes{pool_name="Pool5",subsystem_name="FS-system-name-second"} 3.07863255737e+11
491727
flashsystem_pool_logical_capacity_used_bytes{pool_name="Pool6",subsystem_name="FS-system-name-second"} 6.02369163264e+11
492728
493-
# HELP flashsystem_pool_capacity_usable_bytes Pool usable capacity (Byte)
729+
# HELP flashsystem_pool_logical_capacity_bytes Pool total logical capacity (byte)
730+
# TYPE flashsystem_pool_logical_capacity_bytes gauge
731+
flashsystem_pool_logical_capacity_bytes{pool_name="Pool0",subsystem_name="FS-system-name"} 7882338729984
732+
flashsystem_pool_logical_capacity_bytes{pool_name="Pool1",subsystem_name="FS-system-name"} 644245094400
733+
flashsystem_pool_logical_capacity_bytes{pool_name="Pool2",subsystem_name="FS-system-name"} 644245094400
734+
flashsystem_pool_logical_capacity_bytes{pool_name="Pool5",subsystem_name="FS-system-name-second"} 4244114883215
735+
flashsystem_pool_logical_capacity_bytes{pool_name="Pool6",subsystem_name="FS-system-name-second"} 644245094400
736+
737+
# HELP flashsystem_pool_capacity_usable_bytes Pool usable capacity (byte)
494738
# TYPE flashsystem_pool_capacity_usable_bytes gauge
495739
flashsystem_pool_capacity_usable_bytes{pool_name="Pool0",subsystem_name="FS-system-name"} 1.0798621523968e+13
496740
flashsystem_pool_capacity_usable_bytes{pool_name="Pool1",subsystem_name="FS-system-name"} 1.0798621523968e+13
@@ -506,6 +750,14 @@ func TestMetrics(t *testing.T) {
506750
flashsystem_pool_capacity_used_bytes{pool_name="Pool5",subsystem_name="FS-system-name-second"} 5.4975581349e+10
507751
flashsystem_pool_capacity_used_bytes{pool_name="Pool6",subsystem_name="FS-system-name-second"} -1
508752
753+
# HELP flashsystem_pool_capacity_bytes Pool total capacity (bytes)
754+
# TYPE flashsystem_pool_capacity_bytes gauge
755+
flashsystem_pool_capacity_bytes{pool_name="Pool0",subsystem_name="FS-system-name"} 1.0799695265792e+13
756+
flashsystem_pool_capacity_bytes{pool_name="Pool1",subsystem_name="FS-system-name"} 1.0799695265792e+13
757+
flashsystem_pool_capacity_bytes{pool_name="Pool2",subsystem_name="FS-system-name"} 1.0799695265792e+13
758+
flashsystem_pool_capacity_bytes{pool_name="Pool5",subsystem_name="FS-system-name-second"} 1.649267441664e+12
759+
flashsystem_pool_capacity_bytes{pool_name="Pool6",subsystem_name="FS-system-name-second"} -1
760+
509761
# HELP flashsystem_capacity_warning_threshold Pool capacity warning threshold
510762
# TYPE flashsystem_capacity_warning_threshold gauge
511763
flashsystem_capacity_warning_threshold{pool_name="Pool0",subsystem_name="FS-system-name"} 80
@@ -590,8 +842,8 @@ func TestMetrics(t *testing.T) {
590842
591843
# HELP flashsystem_subsystem_physical_free_capacity_bytes System physical free capacity (byte)
592844
# TYPE flashsystem_subsystem_physical_free_capacity_bytes gauge
593-
flashsystem_subsystem_physical_free_capacity_bytes{subsystem_name="FS-system-name"} 3.7416452783924e+13
594-
flashsystem_subsystem_physical_free_capacity_bytes{subsystem_name="FS-system-name-second"} 2.8416452791924e+13
845+
flashsystem_subsystem_physical_free_capacity_bytes{subsystem_name="FS-system-name"} 3.741645275136e+13
846+
flashsystem_subsystem_physical_free_capacity_bytes{subsystem_name="FS-system-name-second"} 2.84164527514e+13
595847
596848
# HELP flashsystem_subsystem_physical_total_capacity_bytes System physical total capacity (byte)
597849
# TYPE flashsystem_subsystem_physical_total_capacity_bytes gauge
@@ -600,15 +852,15 @@ func TestMetrics(t *testing.T) {
600852
601853
# HELP flashsystem_subsystem_physical_used_capacity_bytes System physical used capacity (byte)
602854
# TYPE flashsystem_subsystem_physical_used_capacity_bytes gauge
603-
flashsystem_subsystem_physical_used_capacity_bytes{subsystem_name="FS-system-name"} 3.3311315427532e+13
604-
flashsystem_subsystem_physical_used_capacity_bytes{subsystem_name="FS-system-name-second"} 4.8011315419532e+13
855+
flashsystem_subsystem_physical_used_capacity_bytes{subsystem_name="FS-system-name"} 3.3311315460096e+13
856+
flashsystem_subsystem_physical_used_capacity_bytes{subsystem_name="FS-system-name-second"} 4.8011315460056e+13
605857
`
606858

607859
err := testutil.CollectAndCompare(testCollector, strings.NewReader(expected),
608860
SystemReadIOPS, SystemWriteIOPS, SystemReadBytes, SystemWriteBytes, SystemLatency, SystemReadLatency,
609861
SystemWriteLatency, SystemMetadata, SystemHealth, SystemResponse, SystemPhysicalTotalCapacity,
610862
SystemPhysicalUsedCapacity, SystemPhysicalFreeCapacity,
611-
PoolMetadata, PoolHealth, PoolWarningThreshold, PoolCapacityUsable, PoolCapacityUsed, PoolEfficiencySavings,
863+
PoolMetadata, PoolHealth, PoolWarningThreshold, PoolLogicalCapacity, PoolCapacityUsable, PoolPhysicalCapacity, PoolCapacityUsed, PoolEfficiencySavings,
612864
PoolLogicalCapacityUsable, PoolLogicalCapacityUsed)
613865

614866
if err != nil {

0 commit comments

Comments
 (0)