-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample.py
More file actions
34 lines (24 loc) · 798 Bytes
/
example.py
File metadata and controls
34 lines (24 loc) · 798 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
33
34
"""Sample code to interact with a Netdata instance."""
import asyncio
import json
from netdata import Netdata
async def main():
"""Get the data from a Netdata instance."""
client = Netdata("localhost")
# Get all metrics
await client.get_info()
print(client.info)
# Get details of a available chart
await client.get_chart("system.cpu")
print(json.dumps(client.values, indent=4, sort_keys=True))
# Print the current value of the system's CPU
print("CPU System:", round(client.values["system"], 2))
# Get the alarms which are present
await client.get_alarms()
print(client.alarms)
# Get all metrics
await client.get_allmetrics()
print(client.metrics)
await client.close()
if __name__ == "__main__":
asyncio.run(main())