forked from home-assistant-ecosystem/python-glances-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
32 lines (21 loc) · 703 Bytes
/
example.py
File metadata and controls
32 lines (21 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Sample script to use the Python API client for Glances."""
import asyncio
from glances_api import Glances
HOST = "127.0.0.1"
VERSION = 3
async def main():
"""The main part of the example script."""
data = Glances(version=VERSION)
# Get the metrics for the memory
await data.get_metrics("mem")
# Print the values
print("Memory values:", data.values)
# Get the metrics about the disks
await data.get_metrics("diskio")
# Print the values
print("Disk values:", data.values)
# Get the data for Home Assistant
print("Output to use with Home Assistant")
print(await data.get_ha_sensor_data())
if __name__ == "__main__":
asyncio.run(main())