87933ecba1c4810624920046f8d4582e6aa60f26
Benjamin Renard Initial commit

Benjamin Renard authored 14 years ago

1) #!/bin/bash
2) 
3) LOG=/var/log/postgresql/postgresql-8.3-main.log
4) WAL=/var/lib/postgresql/8.3/main/wal_archives
5) WARN=5
6) CRIT=10
7) WARN_SIZE=500
8) CRIT_SIZE=1000
9) 
10) verb=0
11) [ "$1" == "-v" ] && verb=1
12) 
Benjamin Renard Added fr_FR locale log pars...

Benjamin Renard authored 12 years ago

13) # Locale C
Benjamin Renard Initial commit

Benjamin Renard authored 14 years ago

14) last="`grep "restored log file" $LOG|tail -n 1|sed 's/.*restored log file "\([^"]*\)".*/\1/g'`"
Benjamin Renard Added fr_FR locale log pars...

Benjamin Renard authored 12 years ago

15) 
16) # Locale fr_FR
17) #last=$( grep "restauration du journal de transactions" /data/prod/pg_log/postgresql-14.log|tail -n 1|sed 's/.*restauration du journal de transactions « \([^ ]*\) ».*/\1/g' )
18) 
Benjamin Renard Initial commit

Benjamin Renard authored 14 years ago

19) [ $verb -eq 1 ] && echo "Last : $last"
20) if [ ! -f $WAL/$last ]
21) then
22) 	echo "PG RESTORE UNKNOWN: The last restored file ($last) is not available"
23) 	exit 3
24) fi
25) nb=`find $WAL -type f -cnewer $WAL/$last|wc -l`
26) [ $verb -eq 1 ] && echo "Nb files : $nb"
27) nbtot=`find $WAL -type f |wc -l`
28) [ $verb -eq 1 ] && echo "Nb total files : $nbtot"
29) let 'nbnodel=nbtot-nb'
30) [ $verb -eq 1 ] && echo "Nb not deleted files : $nbnodel"
31) size=`du -sm $WAL|sed 's/\([0-9]*\).*/\1/g'`
32) [ $verb -eq 1 ] && echo "Size : $size MB"
33) 
34) STATE=OK
35) EXIT=0
36) MSG="all files have been restored ($size MB - $nbnodel files not deleted)."
Benjamin Renard Added perfomance data return

Benjamin Renard authored 12 years ago

37) 
38) PERF_DATA="size=${size}MB,not_deleted_files=$nbnodel,not_restored_files=$nb"
Benjamin Renard Initial commit

Benjamin Renard authored 14 years ago

39) if [ $nb -gt $CRIT -o $size -gt $CRIT_SIZE ]
40) then
41) 	STATE="CRITICAL"
42) 	EXIT=2
43) 	MSG="$nb files not restored ($size MB - $nbnodel files not deleted)."
44) else
45) 	if [ $nb -gt $WARN -o $size -gt $WARN_SIZE ]
46) 	then
47) 		STATE="WARNING"
48) 		EXIT=1
49) 		MSG="$nb files not restored ($size MB - $nbnodel files not deleted)."
50) 	fi
51) fi
52) 
Benjamin Renard Added perfomance data return

Benjamin Renard authored 12 years ago

53) echo "PG RESTORE $STATE: $MSG | $PERF_DATA"