File: //usr/lib/python2.7/site-packages/lap/backupmanager_ip_audit.py
#!/usr/bin/python2.7
import json
import yaml
import datetime
import sys
import os
import time
def __run__(params):
if os.path.isfile('/var/www/dashboard/data_error.json'):
status = params.get('status')
jsonfile = params.get('file')
jsonfile = open(jsonfile).read()
results = json.loads(jsonfile)
now = time.time()
twodays_ago = now - 172800
file_creation = os.path.getctime('/var/www/dashboard/data_error.json')
if file_creation < twodays_ago :
return [1, 'this file too old']
if results:
ret = []
for result in results:
ret.append(str(result))
return [2, ret]
else:
return [0, 'OK']
else:
return [1, 'file does no exist']