Add a ping monitor

This commit is contained in:
Andreas Wrede
2026-04-11 15:25:23 -04:00
parent 6217f7a124
commit ee3b72878f
5 changed files with 171 additions and 12 deletions
+8 -4
View File
@@ -2,6 +2,9 @@
import logging
import os
import logging
logger = logging.getLogger(__name__)
try:
import yaml
@@ -30,18 +33,19 @@ def load_config(path=None):
If YAML is not available or the file does not exist, defaults are returned.
Args:
path: Path to YAML config file (default: ~/.hb.yaml)
path: Path to YAML config file (default: ~/.hbc.yaml)
Returns:
Dictionary with configuration
"""
cfg = CLIENT_DEFAULTS.copy()
if not path:
# default path (~/.hb.yaml)
path = os.path.join(os.path.expanduser("~"), ".hb.yaml")
# default path (~/.hbc.yaml)
path = os.path.join(os.path.expanduser("~"), ".hbc.yaml")
if os.path.exists(path):
if yaml:
logger.info("Loading configuration from %s", path)
with open(path) as fh:
data = yaml.safe_load(fh)
# Merge YAML data with defaults
@@ -50,5 +54,5 @@ def load_config(path=None):
cfg[k] = v
else:
# yaml not installed: do not attempt to parse; user must ensure defaults
pass
logger.warning("PyYAML not available - cannot load config from %s, using defaults", path)
return cfg