mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-30 19:43:47 +00:00 
			
		
		
		
	[manual]: Rename zulip-internal puppet module to zulip_internal.
(imported from commit 64ac7ec0f3495b1fe7810da3d4d41263c52b9b3b)
This commit is contained in:
		
							
								
								
									
										32
									
								
								puppet/zulip_internal/files/nagios_plugins/check_postgres_backup
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										32
									
								
								puppet/zulip_internal/files/nagios_plugins/check_postgres_backup
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| #!/usr/bin/python | ||||
|  | ||||
| import dateutil.parser | ||||
| import pytz | ||||
| import subprocess | ||||
| from datetime import datetime, timedelta | ||||
|  | ||||
| states = { | ||||
|     "OK": 0, | ||||
|     "WARNING": 1, | ||||
|     "CRITICAL": 2, | ||||
|     "UNKNOWN": 3 | ||||
|     } | ||||
|  | ||||
| def report(state, msg): | ||||
|     print "%s: %s" % (state, msg) | ||||
|     exit(states[state]) | ||||
|  | ||||
| if subprocess.check_output(['psql', '-h', 'localhost', 'zulip', 'zulip', '-t', '-c', | ||||
|                             'SELECT pg_is_in_recovery()']).strip() != 'f': | ||||
|     report('OK', 'this is not the primary') | ||||
|  | ||||
| try: | ||||
|     with open('/var/lib/nagios_state/last_postgres_backup', 'r') as f: | ||||
|         last_backup = dateutil.parser.parse(f.read()) | ||||
| except IOError: | ||||
|     report('UNKNOWN', 'could not determine completion time of last Postgres backup') | ||||
|  | ||||
| if datetime.now(tz=pytz.utc) - last_backup > timedelta(hours=25): | ||||
|     report('CRITICAL', 'last Postgres backup completed more than 25 hours ago: %s' % (last_backup,)) | ||||
|  | ||||
| report('OK', 'last Postgres backup completed less than 25 hours ago: %s' % (last_backup,)) | ||||
		Reference in New Issue
	
	Block a user