From 2ce040fd450515917d015b52b18221c3c7dc8546 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 16 Jun 2020 11:45:09 +0200 Subject: [PATCH] Update example --- example.py | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/example.py b/example.py index a6db274..ed20283 100644 --- a/example.py +++ b/example.py @@ -8,33 +8,18 @@ async def main(): """Get the data from a Netdata instance.""" - with aiohttp.ClientSession() as session: - data = Netdata("localhost", loop, session, data="data") + async with aiohttp.ClientSession() as session: + data = Netdata("localhost", loop, session) + # Get data for the CPU await data.get_data("system.cpu") - print(json.dumps(data.values, indent=4, sort_keys=True)) # Print the current value of the system's CPU print("CPU System:", round(data.values["system"], 2)) - with aiohttp.ClientSession() as session: - data = Netdata("localhost", loop, session, data="alarms") + # Get the alarms which are present await data.get_alarms() - print(data.alarms) - with aiohttp.ClientSession() as session: - data = Netdata("localhost", loop, session) - await data.get_allmetrics() - - print(data.metrics) - - # Print the current value for the system's CPU - print( - "CPU System:", - round(data.metrics["system.cpu"]["dimensions"]["system"]["value"], 2), - ) - - loop = asyncio.get_event_loop() loop.run_until_complete(main()) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy