From 332d307fa855bf01779765e1f974c6524c26f592 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 31 Oct 2022 12:51:13 +0100 Subject: [statistics] Deal with broken HDDs that lead to incomplete data We had a machine with a broken HDD that showed up as /dev/sda but didn't do much else, confusing tools like lsblk and fdisk, and ultimately leading to incomplete data in our DB that would make PHP freak out too much about missing array indices and wrong types. --- modules-available/statistics/pages/machine.inc.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules-available/statistics/pages') diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php index b6c1f53c..1e00b8f2 100644 --- a/modules-available/statistics/pages/machine.inc.php +++ b/modules-available/statistics/pages/machine.inc.php @@ -551,6 +551,9 @@ class SubPage private static function mangleHdd(array &$hdd) { static $hddidx = 0; + if (!isset($hdd['size']) || !is_numeric($hdd['size'])) { + $hdd['size'] = 0; + } $hdd['hddidx'] = $hddidx++; $hours = $hdd['power_on_time//hours'] ?? $hdd['attr_9']['raw'] ?? $hdd['power_on_hours'] ?? $hdd['power_on_time']['hours'] ?? null; -- cgit v1.2.3-55-g7522