An application for checking the status of websites. The checking frequency is determined by the SCHEDULER value. The list of websites should be provided without spaces, separated by commas in WEBSITES_FOR_CHECK. In case of a 4xx or 5xx response, the application sends an email to the specified address. All variables needed for email configuration are provided in README.md.
Create app folder and nologin user.
sudo useradd -r -s /usr/sbin/nologin health_service
sudo mkdir /home/health_service
Build an app and change it name to app.jar.
git clone url
cd /home/health_service
mvn clean package -DskipTests=true
cd target/
sudo mv *.jar app.jar
Add permissions to run as no-root user.
sudo chown health_service:health_service app.jar
sudo chmod 500 app.jar
sudo chown -R health_service:health_service /home/health_service
sudo chattr +i app.jar
sudo nano /etc/systemd/system/health-check.service
[Unit]
Description=Health Check Service
After=syslog.target network.target
[Service]
User=healthcheck
Group=healthcheck
Environment="APP_PORT=8082"
Environment="MAIL_HOST=mail.yourdomain.com"
Environment="MAIL_PORT=587"
Environment="MAIL_PASSWORD=passs"
Environment="MAIL_LOGIN=noreplay@yourdomain.com"
# For Gmail and others SMT providers must be true
Environment="MAIL_SSL_ENABLE=false"
Environment="MAIL_SMT_AUTH=false"
Environment="MAIL_START_TTLS=false"
Environment="MAIL_START_TTLS_REQUIRED=false"
Environment=„EMAIL_TO=yourmail@gmail.com"
Environment="EMAIL_SUBJECT=Health Check service"
# Lunch every 6 hours
Environment="SCHEDULER=0 0 0/6 * * ?"
Environment="EMAIL_FROM=noreplay@yourdomain.com"
Environment="WEBSITES_FOR_CHECK=https://websitecheck123.com,http://websitecheck433.com"
ExecStart=/home/health_service
ExecStop=/bin/kill -15 $MAINPID
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target