Commit 8a8842e1 authored by Jonathan Michalon's avatar Jonathan Michalon

Support commandline-passed config file in picomon_watchdog

parent 9894b6af
import subprocess
import config
import sys
import os
import importlib
from picomon import config
from picomon import mails
retcode = subprocess.call(["python3", "picomon.py"])
# launch picomon
retcode = subprocess.call(["python3", "picomon.py"] + sys.argv[1:])
# load config file
# (unprotected, will trigger exceptions if problems but real picomon beforehand)
configfile = "config.py"
if "-c" in sys.argv:
configfile = sys.argv[sys.argv.index("-c")+1]
if "--config" in sys.argv:
configfile = sys.argv[sys.argv.index("--config")+1]
sys.path.append(os.path.dirname(configfile))
filename = os.path.basename(configfile)
base, ext = os.path.splitext(filename)
importlib.import_module(base)
# send warning
mails.send_email(config.emails.watchdog_subject,
"Picomon exited with status %s" % retcode)
mails.quit()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment