Commit 8098add8 authored by Nicolas Wavrant's avatar Nicolas Wavrant

stack-monitor: script now provides datetime of last running

parent 5f052cce
#!/usr/bin/python #!/usr/bin/python
import datetime
import json import json
import os import os
import subprocess import subprocess
...@@ -86,12 +87,14 @@ def runScripts(directory): ...@@ -86,12 +87,14 @@ def runScripts(directory):
def writeFiles(monitors): def writeFiles(monitors):
open(monitoring_file_json, "w+").write(json.dumps(monitors))
if len(monitors) == 0: if len(monitors) == 0:
open(monitoring_file_bool, "w+").write("SUCCESS : everything is ok") message = "SUCCESS : everything is ok"
else: else:
open(monitoring_file_bool, "w+").write("FAILURE : something went wrong") message ="FAILURE : something went wrong"
date = datetime.datetime.now().ctime()
monitors['datetime'] = date
open(monitoring_file_bool, "w+").write(date + "," + message)
open(monitoring_file_json, "w+").write(json.dumps(monitors))
if __name__ == "__main__": if __name__ == "__main__":
parser = OptionParser(option_list=option_list) parser = OptionParser(option_list=option_list)
......
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