Skip to content

Commit

Permalink
Add percpu data
Browse files Browse the repository at this point in the history
  • Loading branch information
engrbm87 committed Aug 29, 2023
1 parent 69140b4 commit 19c1f4b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions glances_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ async def get_ha_sensor_data(self) -> dict[str, Any] | None:
}
if data := self.data.get("quicklook"):
sensor_data["cpu"] = {"cpu_use_percent": data["cpu"]}
if data := self.data.get("percpu"):
sensor_data["percpu"] = {}
for cpu in data:
sensor_data["percpu"][cpu["cpu_number"]] = {
"cpu_use_percent": cpu["total"]
}
if networks := self.data.get("network"):
sensor_data["network"] = {}
for network in networks:
Expand Down
33 changes: 33 additions & 0 deletions tests/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,38 @@
"nice": 0.0,
"iowait": 0.6,
},
"percpu": [
{
"key": "cpu_number",
"cpu_number": 0,
"total": 22.1,
"user": 7.6,
"system": 12.4,
"idle": 77.9,
"nice": 0.0,
"iowait": 0.2,
"irq": 0.0,
"softirq": 1.8,
"steal": 0.0,
"guest": 0.0,
"guest_nice": 0.0,
},
{
"key": "cpu_number",
"cpu_number": 1,
"total": 17.2,
"user": 8.7,
"system": 7.8,
"idle": 82.8,
"nice": 0.0,
"iowait": 0.4,
"irq": 0.0,
"softirq": 0.3,
"steal": 0.0,
"guest": 0.0,
"guest_nice": 0.0,
},
],
"diskio": [
{
"time_since_update": 1,
Expand Down Expand Up @@ -228,6 +260,7 @@
},
"docker": {"docker_active": 2, "docker_cpu_use": 77.2, "docker_memory_use": 1149.6},
"uptime": "3 days, 10:25:20",
"percpu": {"0": "22.1", "1": "17.2"},
}


Expand Down

0 comments on commit 19c1f4b

Please sign in to comment.