Skip to content

the0807/Server-Status-Report

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server-Status-Report

🖥️ Tracking server status(CPU, Memory, GPU, Disk) and sending reports to email

🚀 Korean version

📌 Function

  • Create an email report on tracking servers from the previous day at 8 a.m. daily(attached as an image to the email)
daily daily
  • Check resources every minute and send email when it exceeds 80%(reminders of unresolved issues every 6 hours)
cpu mem disk
  • Notification of service start by email(e.g. on reboot)
start

✏️ Usase

Note

  • Gmail based on the use of the sending account
  1. Git clone and Install python requirements

    git clone https://github.com/the0807/Server-Status-Report
    cd Server-Status-Report
    pip install -r requirements.txt
  2. Create an APP password in Gmail

    a. Go to Google Account

    🚀 Google Account

    b. Search App Password

    c. Type an app name and click the Create button

    d. 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
  1. Create .env and fill in the contents below

    SERVER_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
  2. Set to systemd service

    a. Create server_status.service

    sudo 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

❗️ Troubleshooting

⭐️ If the status of the service is Fail

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

About

🖥️ Tracking server status(CPU, Memory, GPU, Disk) and sending reports to email

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages