Add raid monitoring to glances (#56623)

pull/56744/head
Adrian Huber 2021-09-28 10:04:08 +02:00 committed by GitHub
parent 495e5cb1c0
commit b64b926e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -194,4 +194,16 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:docker",
),
GlancesSensorEntityDescription(
key="used",
type="raid",
name_suffix="Raid used",
icon="mdi:harddisk",
),
GlancesSensorEntityDescription(
key="available",
type="raid",
name_suffix="Raid available",
icon="mdi:harddisk",
),
)

View File

@ -38,6 +38,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
description,
)
)
elif description.type == "raid":
for raid_device in client.api.data[description.type]:
dev.append(GlancesSensor(client, name, raid_device, description))
elif client.api.data[description.type]:
dev.append(
GlancesSensor(
@ -214,3 +217,7 @@ class GlancesSensor(SensorEntity):
self._state = round(mem_use / 1024 ** 2, 1)
except KeyError:
self._state = STATE_UNAVAILABLE
elif self.entity_description.type == "raid":
for raid_device, raid in value["raid"].items():
if raid_device == self._sensor_name_prefix:
self._state = raid[self.entity_description.key]