diff --git a/README.md b/README.md index 3aaa462..da91a73 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ The `monitors` key contains a list of monitor modules to run: The name of the module to run for a monitor is `type`. The `freq` option is the frequency, in seconds, that this monitor will check and report data. If the monitor being used takes any options, they can be passed as a object with the `args` option, +A yaml config can also be used. The data structure must be identical and the filename MUST end in `.yml`. + Developing Modules ------------------ diff --git a/examples/config.yml b/examples/config.yml new file mode 100644 index 0000000..55788fa --- /dev/null +++ b/examples/config.yml @@ -0,0 +1,25 @@ +backend: + url: 'http://10.0.3.15:9200/' +monitors: +- type: uptime + freq: '30' + args: {} +- type: load + freq: '30' + args: {} +- type: meminfo + freq: '30' + args: {} +- type: procs + freq: '30' + args: {} +- type: diskspace + freq: '30' + args: + filesystems: + - '/' + - '/var' + - '/home' +- type: diskio + freq: '30' + args: {} diff --git a/pymonitor/daemon.py b/pymonitor/daemon.py index bcfe1d2..6762507 100755 --- a/pymonitor/daemon.py +++ b/pymonitor/daemon.py @@ -215,7 +215,13 @@ def run_cli(): sys.exit() with open(options.config, "r") as c: - conf = json.load(c) + if options.config[-4:0] == 'json': + conf = json.load(c) + elif options.config[-4:0] == 'yml': + from yaml import load as yaml_load + conf = yaml_load(c) + else: + raise Exception("Invalid config format") logger.info("starting daemon with conf: %s" % conf)