-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathone_shot.py
35 lines (28 loc) · 956 Bytes
/
one_shot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
__author__ = 'Ara Sadoyan'
import glob, os, sys
import configparser
import logging
import threading
sys.path.append(os.path.dirname(os.path.realpath("__file__"))+'/checks_enabled')
config = configparser.RawConfigParser()
config.read(os.getcwd()+'/conf/config.ini')
cron_interval = int(config.get('SelfConfig', 'check_period_seconds'))
log_file = config.get('SelfConfig', 'log_file')
pid_file = config.get('SelfConfig', 'pid_file')
library_list = []
os.chdir("checks_enabled")
checklist = str(sys.argv[1])
# ----------- #
def run_scripts():
module_name, ext = os.path.splitext(checklist)
module = __import__(module_name)
library_list.append(module)
module.runcheck()
def do_every (interval, worker_func, iterations=1):
if iterations != 1:
threading.Timer (
interval,
do_every, [interval, worker_func, 0 if iterations == 0 else iterations-1]
).start ()
worker_func()
do_every (int(cron_interval), run_scripts)