-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-wal-checker
More file actions
24 lines (21 loc) · 806 Bytes
/
backup-wal-checker
File metadata and controls
24 lines (21 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
from datetime import datetime, timedelta
import smtplib
#startdate = datetime.today() - timedelta(daysback);
plog = '/var/lib/pgsql/9.3/data/pg_log/postgresql-%s.log'
walmsg = ''
#loop through last few days to be sure
for x in range(0,2):
pdate = (datetime.today() - timedelta(x)).date()
for line in open(plog % pdate):
if 'ERROR: requested WAL segment' in line:
walmsg += line
#if we found a failure, report it
if walmsg:
headers = 'From: xxxxxxxx@pelagodesign.com\r\n'
headers += 'To: xxxxxxxx@pelagodesign.com\r\n'
headers += 'Subject: R2DA backup failed\r\n'
headers += '\r\n'
server = smtplib.SMTP('mx.myintervals.com')
server.sendmail('xxxxxxx@pelagodesign.com','xxxxxxx@pelagodesign.com', headers + walmsg)
server.quit()