Commit 0a18cdf2 authored by Tristan Cavelier's avatar Tristan Cavelier

monitor: monitor.py.in naming conventions

parent d8a6c670
...@@ -129,12 +129,12 @@ def runScripts(directory): ...@@ -129,12 +129,12 @@ def runScripts(directory):
return result return result
def writeFiles(monitors): def writeFile(monitor_dict):
timestamp = int(time.time()) timestamp = int(time.time())
db = sqlite3.connect(db_path) db = sqlite3.connect(db_path)
init_db(db) init_db(db)
status = SUCCESS status = SUCCESS
for key, value in monitors.iteritems(): for key, value in monitor_dict.iteritems():
if value: if value:
element_status = status = FAILURE element_status = status = FAILURE
else: else:
...@@ -143,12 +143,12 @@ def writeFiles(monitors): ...@@ -143,12 +143,12 @@ def writeFiles(monitors):
db.execute("insert into status(timestamp, status) values (?, ?)", (timestamp, status)) db.execute("insert into status(timestamp, status) values (?, ?)", (timestamp, status))
db.commit() db.commit()
db.close() db.close()
monitors['datetime'] = time.ctime(timestamp) monitor_dict['datetime'] = time.ctime(timestamp)
json.dump(monitors, open(monitoring_file_json, "w+")) json.dump(monitor_dict, open(monitoring_file_json, "w+"))
def main(): def main():
parser = OptionParser(option_list=option_list) parser = OptionParser(option_list=option_list)
monitors = {} monitor_dict = {}
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if not (options.monitor or options.promise if not (options.monitor or options.promise
...@@ -156,16 +156,16 @@ def main(): ...@@ -156,16 +156,16 @@ def main():
exit("Please provide at list one arg in : -a, -m, -p, -s") exit("Please provide at list one arg in : -a, -m, -p, -s")
if options.monitor or options.all: if options.monitor or options.all:
monitors.update(runScripts(monitor_dir)) monitor_dict.update(runScripts(monitor_dir))
if options.promise or options.all: if options.promise or options.all:
monitors.update(runScripts(promise_dir)) monitor_dict.update(runScripts(promise_dir))
if options.service or options.all: if options.service or options.all:
monitors.update(runServices(pid_dir)) monitor_dict.update(runServices(pid_dir))
if options.only_stdout: if options.only_stdout:
print json.dumps(monitors) print json.dumps(monitor_dict)
else: else:
writeFiles(monitors) writeFile(monitor_dict)
if __name__ == "__main__": if __name__ == "__main__":
......
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