import asyncio import logging from typing import Optional import api import grpc from google.protobuf.json_format import MessageToJson from google.protobuf.empty_pb2 import Empty async def main() -> None: async with grpc.aio.insecure_channel("localhost:8202") as channel: stub = api.AgentStub(channel) conf = api.AgentConfiguration(name="some_agent", services_to_monitor=["docker.service", "sshd.service"], storage_to_monitor=["/dev/sda", "/dev/nvme0"]) await stub.RequestConfiguration(conf) stats = await stub.Poll(Empty()) json = MessageToJson(stats, including_default_value_fields=True) print(json) if __name__ == "__main__": logging.basicConfig(level=logging.INFO) loop = asyncio.new_event_loop() try: loop.run_until_complete(main()) finally: loop.close()