- Create an email report on tracking servers from the previous day at 8 a.m. daily(attached as an image to the email)
- Check resources every minute and send email when it exceeds 80%(reminders of unresolved issues every 6 hours)
- Notification of service start by email(e.g. on reboot)
Note
Gmailbased on the use of the sending account
-
Git clone and Install python requirements
git clone https://github.com/the0807/Server-Status-Report cd Server-Status-Report pip install -r requirements.txt -
Create an
APP passwordin Gmaila. Go to Google Account
b. Search
App Passwordc. Type an
app nameand click the Create buttond. Copy the password that appears when the window appears
Caution
- If you close the window, you won't see the password again, so make sure to copy it
-
Create
.envand fill in the contents belowSERVER_NAME = # Server name SMTP_SERVER = 'smtp.gmail.com' SMTP_PORT = 587 EMAIL_ADDRESS = # Gmail address to send EMAIL_PASSWORD = # Gmail APP password RECIPIENT_EMAIL = # Email address to receive
-
Set to
systemdservicea. Create
server_status.servicesudo vim /etc/systemd/system/server_status.service # Add content below(Please modify it according to your path) [Unit] Description=Server Status Monitoring Script After=multi-user.target [Service] # Make sure the ExecStart, WorkingDirectory path is correct ExecStart=/usr/bin/python3 /home/ubuntu/Server-Status-Report/main.py WorkingDirectory=/home/ubuntu/Server-Status-Report Restart=on-failure RestartSec=30s # Make sure the User is correct User=ubuntu [Install] WantedBy=multi-user.target
b. Enable and Start Services
# When you modify `server_status.service`, run the command again below sudo systemctl daemon-reload sudo systemctl enable server_status.service sudo systemctl start server_status.service
c. Check the status of the service
sudo systemctl status server_status.service
Note
- If you receive a email notification when you start the server, it will run normally
Run ExecStart of the server_status.service file directly from the terminal to identify the problem.
# Check real-time logs
journalctl -f server_status.service




