kiwi-simple-metrics/kiwi_simple_metrics/main.py

33 lines
567 B
Python
Raw Normal View History

2023-08-31 22:10:40 +00:00
#!/usr/bin/python3
2023-08-31 22:55:31 +00:00
import asyncio
2023-08-31 11:17:19 +00:00
from . import metrics
2023-08-31 22:55:31 +00:00
from .settings import SETTINGS
async def run_metrics() -> None:
while True:
interval = asyncio.sleep(SETTINGS.interval)
2023-08-31 23:09:50 +00:00
report = metrics.Report.concat(
2023-08-31 22:55:31 +00:00
metrics.cpu(),
metrics.memory(),
metrics.disk(),
2023-08-31 23:09:50 +00:00
)
if not SETTINGS.quiet:
print(report)
2023-08-31 22:55:31 +00:00
await interval
2023-08-30 22:01:31 +00:00
def main() -> None:
2023-08-31 22:55:31 +00:00
loop = asyncio.get_event_loop()
loop.create_task(run_metrics())
loop.run_forever()
2023-08-30 23:49:07 +00:00
if __name__ == "__main__":
main()