prometheus: add nginx exception and sort postgresql backups
This commit is contained in:
parent
f349849f72
commit
b0c126b0df
|
@ -109,7 +109,7 @@ def munin(ctn):
|
|||
def nginx(ctn):
|
||||
try:
|
||||
r = requests.get("http://localhost/nginx_status")
|
||||
except requests.exceptions.SSLError:
|
||||
except (requests.exceptions.SSLError, requests.exceptions.ConnectionError):
|
||||
return
|
||||
if r.ok:
|
||||
for line in r.text.splitlines():
|
||||
|
@ -142,7 +142,8 @@ def postgresql(ctn):
|
|||
backup_files = glob.glob('/var/lib/postgresql/backups/base/*')
|
||||
if not backup_files:
|
||||
return -1
|
||||
created = os.stat(backup_files.sort(key=os.path.getmtime)[-1]).st_ctime
|
||||
sorted_backup_files = sorted(backup_files, key=os.path.getmtime)
|
||||
created = os.stat(sorted_backup_files[-1]).st_ctime
|
||||
return((datetime.datetime.now() - datetime.datetime.fromtimestamp(created)).seconds)
|
||||
|
||||
recovery = glob.glob("/var/lib/postgresql/*/*/recovery.conf")
|
||||
|
|
Loading…
Reference in New Issue