Improve healthcheck
This commit is contained in:
		
							parent
							
								
									e7c78aa678
								
							
						
					
					
						commit
						ee59f0258b
					
				
					 11 changed files with 20 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -2,11 +2,6 @@
 | 
			
		|||
	email tobias@msrg.cc
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
db.serguzim.me:80,
 | 
			
		||||
dns.serguzim.me:80 {
 | 
			
		||||
	reverse_proxy host.docker.internal:4444
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
import /etc/caddy/snippets
 | 
			
		||||
import /etc/caddy/conf.d/*.conf
 | 
			
		||||
import /etc/caddy/conf-hidden.d/*.conf
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								healthcheck/.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								healthcheck/.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
/mailcheck.mail
 | 
			
		||||
/msmtprc
 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ check_url "www.reitanlage-oranienburg.de"
 | 
			
		|||
 | 
			
		||||
if [ "$error" = "" ]
 | 
			
		||||
then
 | 
			
		||||
    curl_hc "$hc_url" >/dev/null 2>&1
 | 
			
		||||
    curl_hc "$hc_url"
 | 
			
		||||
else
 | 
			
		||||
	curl_hc --data-raw "$error" "$hc_url/fail" >/dev/null 2>&1
 | 
			
		||||
	curl_hc --data-raw "$error" "$hc_url/fail"
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										9
									
								
								healthcheck/data/mail
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								healthcheck/data/mail
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
#!/usr/bin/sh
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
cd /opt/ || exit
 | 
			
		||||
 | 
			
		||||
envsubst < template.msmtprc > /tmp/msmtprc
 | 
			
		||||
envsubst < mailcheck.template.mail > /tmp/mailcheck.mail
 | 
			
		||||
 | 
			
		||||
msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail
 | 
			
		||||
| 
						 | 
				
			
			@ -10,7 +10,7 @@ x-common-elements:
 | 
			
		|||
    - .env
 | 
			
		||||
    - .secret.env
 | 
			
		||||
  volumes:
 | 
			
		||||
    - ./:/opt
 | 
			
		||||
    - ./data/:/opt
 | 
			
		||||
 | 
			
		||||
services:
 | 
			
		||||
  http:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								healthcheck/healthcheck@.service
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								healthcheck/healthcheck@.service
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
[Service]
 | 
			
		||||
Type=oneshot
 | 
			
		||||
ExecStart=/usr/bin/docker compose run --rm %i
 | 
			
		||||
WorkingDirectory=/opt/services/healthcheck/
 | 
			
		||||
							
								
								
									
										4
									
								
								healthcheck/healthcheck@.timer
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								healthcheck/healthcheck@.timer
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
[Timer]
 | 
			
		||||
OnCalendar=*:0/5
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=timers.target
 | 
			
		||||
| 
						 | 
				
			
			@ -1,9 +0,0 @@
 | 
			
		|||
#!/usr/bin/sh
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
cd /opt/ || exit
 | 
			
		||||
 | 
			
		||||
envsubst < template.msmtprc > msmtprc
 | 
			
		||||
envsubst < mailcheck.template.mail > mailcheck.mail
 | 
			
		||||
 | 
			
		||||
msmtp -C /opt/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /opt/mailcheck.mail
 | 
			
		||||
		Reference in a new issue