Skip to content

Commit

Permalink
Merge pull request #56 from Boavizta/dev
Browse files Browse the repository at this point in the history
Fixes for `Process` and `Lshw`
  • Loading branch information
bdromard authored Oct 24, 2024
2 parents 2aa6d42 + 53aefac commit 7d8646e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
31 changes: 21 additions & 10 deletions boagent/api/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,27 @@ def get_total_ram_in_bytes(self):

def get_disk_usage_in_bytes(self):

disk_total_bytes = int(
self.metrics_data["raw_data"]["power_data"]["raw_data"][1]["host"][
"components"
]["disks"][0]["disk_total_bytes"]
)
disk_available_bytes = int(
self.metrics_data["raw_data"]["power_data"]["raw_data"][1]["host"][
"components"
]["disks"][0]["disk_available_bytes"]
)
# Data from Scaphandre can be empty on first returned element in the array
try:
key_for_disk_total_bytes = self.metrics_data["raw_data"]["power_data"][
"raw_data"
][0]["host"]["components"]["disks"][0]["disk_total_bytes"]
except IndexError:
key_for_disk_total_bytes = self.metrics_data["raw_data"]["power_data"][
"raw_data"
][1]["host"]["components"]["disks"][0]["disk_total_bytes"]

try:
key_for_disk_available_bytes = self.metrics_data["raw_data"]["power_data"][
"raw_data"
][0]["host"]["components"]["disks"][0]["disk_available_bytes"]
except IndexError:
key_for_disk_available_bytes = self.metrics_data["raw_data"]["power_data"][
"raw_data"
][1]["host"]["components"]["disks"][0]["disk_available_bytes"]

disk_total_bytes = int(key_for_disk_total_bytes)
disk_available_bytes = int(key_for_disk_available_bytes)
disk_usage_in_bytes = disk_total_bytes - disk_available_bytes
return disk_usage_in_bytes

Expand Down
37 changes: 19 additions & 18 deletions boagent/hardware/lshw.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,25 @@ def find_storage(self, obj):
"type": self.get_disk_type(device["logicalname"]),
}
self.disks.append(d)
if "nvme" in obj["configuration"]["driver"]:
if not is_tool("nvme"):
raise Exception("nvme-cli >= 1.0 does not seem to be installed")
try:
nvme = serialized_nvme_output()
for device in nvme["Devices"]:
d = {
"units": +1,
"logicalname": device["DevicePath"],
"manufacturer": self.check_disk_vendor(
device["ModelNumber"]
).lower(),
"type": "ssd",
"capacity": device["PhysicalSize"] // 1073741824,
}
self.disks.append(d)
except Exception:
pass
if "configuration" in obj:
if "nvme" in obj["configuration"]["driver"]:
if not is_tool("nvme"):
raise Exception("nvme-cli >= 1.0 does not seem to be installed")
try:
nvme = serialized_nvme_output()
for device in nvme["Devices"]:
d = {
"units": +1,
"logicalname": device["DevicePath"],
"manufacturer": self.check_disk_vendor(
device["ModelNumber"]
).lower(),
"type": "ssd",
"capacity": device["PhysicalSize"] // 1073741824,
}
self.disks.append(d)
except Exception:
pass

def find_cpus(self, obj):
if "product" in obj:
Expand Down

0 comments on commit 7d8646e

Please sign in to comment.