From abf8c564b74212ca4f275612b9560ee342646e83 Mon Sep 17 00:00:00 2001 From: SourceDoctor Date: Tue, 26 Dec 2023 22:10:14 +0100 Subject: [PATCH] fix smart application parsing (#15672) * fix smart application parsing * style fix * test * test * test * . --- includes/polling/applications/smart.inc.php | 40 ++++++++++----------- tests/data/linux_smart-legacy.json | 4 +-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/includes/polling/applications/smart.inc.php b/includes/polling/applications/smart.inc.php index 21657e6228..00f2319507 100644 --- a/includes/polling/applications/smart.inc.php +++ b/includes/polling/applications/smart.inc.php @@ -13,13 +13,13 @@ try { $legacy = $e->getOutput(); $lines = explode("\n", $legacy); - $data = ['disks'=>[], 'legacy'=>1]; + $data = ['disks' => [], 'legacy' => 1]; $int = 0; while (isset($lines[$int])) { [$disk, $id5, $id10, $id173, $id177, $id183, $id184, $id187, $id188, $id190, $id194, $id196, $id197, $id198, $id199, $id231, $id233, $completed, $interrupted, $read_failure, - $unknown_failure, $extended, $short, $conveyance, $selective] = explode(',', $lines[$int]); + $unknown_failure, $extended, $short, $conveyance, $selective, $id9] = explode(',', $lines[$int]); $int++; // could really be any of these, but make sure we have something defined, @@ -110,24 +110,24 @@ $new_disks_with_failed_health = []; $data['disks_with_failed_tests'] = []; $data['disks_with_failed_health'] = []; $data['has'] = [ - 'id5'=>0, - 'id9'=>0, - 'id10'=>0, - 'id173'=>0, - 'id177'=>0, - 'id183'=>0, - 'id184'=>0, - 'id187'=>0, - 'id188'=>0, - 'id190'=>0, - 'id194'=>0, - 'id196'=>0, - 'id197'=>0, - 'id198'=>0, - 'id199'=>0, - 'id231'=>0, - 'id232'=>0, - 'id233'=>0, + 'id5' => 0, + 'id9' => 0, + 'id10' => 0, + 'id173' => 0, + 'id177' => 0, + 'id183' => 0, + 'id184' => 0, + 'id187' => 0, + 'id188' => 0, + 'id190' => 0, + 'id194' => 0, + 'id196' => 0, + 'id197' => 0, + 'id198' => 0, + 'id199' => 0, + 'id231' => 0, + 'id232' => 0, + 'id233' => 0, ]; $metrics = [ diff --git a/tests/data/linux_smart-legacy.json b/tests/data/linux_smart-legacy.json index 7e15041da6..8b1c2b9920 100644 --- a/tests/data/linux_smart-legacy.json +++ b/tests/data/linux_smart-legacy.json @@ -23,7 +23,7 @@ "app_state_prev": "UNKNOWN", "app_status": "", "app_instance": "", - "data": "{\"disks\":{\"Z304VCFY\":{\"10\":\"0\",\"173\":\"null\",\"177\":\"null\",\"183\":\"0\",\"184\":\"0\",\"187\":\"0\",\"188\":\"0\",\"190\":\"35\",\"194\":\"35\",\"196\":\"null\",\"197\":\"0\",\"198\":\"0\",\"199\":\"0\",\"231\":\"null\",\"233\":\"null\",\"5\":\"0\",\"9\":null,\"completed\":\"5\",\"interrupted\":\"1\",\"read_failure\":\"0\",\"unknown_failure\":\"0\",\"extended\":\"6\",\"short\":\"0\",\"conveyance\":\"0\",\"selective\":\"selective\",\"is_ssd\":0}},\"legacy\":1,\"disks_with_failed_tests\":[],\"disks_with_failed_health\":[],\"has\":{\"id5\":1,\"id9\":0,\"id10\":1,\"id173\":0,\"id177\":0,\"id183\":1,\"id184\":1,\"id187\":1,\"id188\":1,\"id190\":1,\"id194\":1,\"id196\":0,\"id197\":1,\"id198\":1,\"id199\":1,\"id231\":0,\"id232\":0,\"id233\":0}}", + "data": "{\"disks\":{\"Z304VCFY\":{\"10\":\"0\",\"173\":\"null\",\"177\":\"null\",\"183\":\"0\",\"184\":\"0\",\"187\":\"0\",\"188\":\"0\",\"190\":\"35\",\"194\":\"35\",\"196\":\"null\",\"197\":\"0\",\"198\":\"0\",\"199\":\"0\",\"231\":\"null\",\"233\":\"null\",\"5\":\"0\",\"9\":\"63438\",\"completed\":\"5\",\"interrupted\":\"1\",\"read_failure\":\"0\",\"unknown_failure\":\"0\",\"extended\":\"6\",\"short\":\"0\",\"conveyance\":\"0\",\"selective\":\"selective\",\"is_ssd\":0}},\"legacy\":1,\"disks_with_failed_tests\":[],\"disks_with_failed_health\":[],\"has\":{\"id5\":1,\"id9\":1,\"id10\":1,\"id173\":0,\"id177\":0,\"id183\":1,\"id184\":1,\"id187\":1,\"id188\":1,\"id190\":1,\"id194\":1,\"id196\":0,\"id197\":1,\"id198\":1,\"id199\":1,\"id231\":0,\"id232\":0,\"id233\":0}}", "deleted_at": null } ], @@ -168,7 +168,7 @@ }, { "metric": "disk_Z304VCFY_id9", - "value": 0, + "value": 63438, "value_prev": null, "app_type": "smart" },