๐ English version
- ๋งค์ผ ์ค์ 8์์ ์ ๋ ์ ์๋ฒ ์ถ์ ์ ๊ดํ ์ด๋ฉ์ผ ๋ณด๊ณ ์๋ฅผ ๋ณด๋ด๊ธฐ(์ด๋ฉ์ผ์ ์ด๋ฏธ์ง๋ก ์ฒจ๋ถ)
- ๋งค๋ถ ๋ฆฌ์์ค ์ฌ์ฉ๋์ ํ์ธํ๊ณ 80%๋ฅผ ์ด๊ณผํ๋ฉด ์ด๋ฉ์ผ ๋ณด๋ด๊ธฐ(ํด๊ฒฐ ๋์ง์์ ๋ฌธ์ ๋ 6์๊ฐ๋ง๋ค ๋ค์ ์๋ฆผ)
- ์ด๋ฉ์ผ๋ก ์๋น์ค ์์ ์๋ฆผ(e.g. ์ฌ๋ถํ ์)
Note
- ๋ณธ ํ๋ก์ ํธ๋ ๋ฐ์ ๊ณ์ ์ผ๋ก
Gmail์ ์ฌ์ฉํจ
-
Git clone ํ python ํจํค์ง ์ค์นํ๊ธฐ
git clone https://github.com/the0807/Server-Status-Report cd Server-Status-Report pip install -r requirements.txt -
Gmail์์
์ฑ ํจ์ค์๋์์ฑํ๊ธฐa. Google Account ์ ์ํ๊ธฐ
๐
Google Accountb.
App Password๊ฒ์ํ๊ธฐc.
์ฑ ์ด๋ฆ์ ์ ๋ ฅํ๊ณ ์์ฑ ๋ฒํผ ํด๋ฆญํ๊ธฐd. ์ฐฝ์ด ๋ํ๋ ๋ ๋ํ๋๋ ๋น๋ฐ๋ฒํธ ๋ณต์ฌํ๊ธฐ
Caution
- ์ฐฝ์ ๋ซ์ผ๋ฉด ๋น๋ฐ๋ฒํธ๊ฐ ๋ค์ ํ์๋์ง ์์ผ๋ฏ๋ก ๋ฐ๋์ ๋ณต์ฌํ์ธ์
-
.envํ์ผ์ ์์ฑ ํ ํ ์๋์ ๋ด์ฉ ์ ๋ ฅํ๊ธฐ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
-
systemd์๋น์ค ๋ฑ๋กํ๊ธฐa.
server_status.service์์ฑํ๊ธฐsudo vim /etc/systemd/system/server_status.service # ์๋์ ๋ด์ฉ์ ์ถ๊ฐํ์ธ์(๊ฒฝ๋ก์ ๋ฐ๋ผ ์์ ) [Unit] Description=Server Status Monitoring Script After=multi-user.target [Service] # ExecStart, WorkingDirectory ๊ฒฝ๋ก๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ์ธ์. ExecStart=/usr/bin/python3 /home/ubuntu/Server-Status-Report/main.py WorkingDirectory=/home/ubuntu/Server-Status-Report Restart=on-failure RestartSec=30s # ์ฌ์ฉ์๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ์ธ์. User=ubuntu [Install] WantedBy=multi-user.target
b. ์๋น์ค ํ์ฑํ ๋ฐ ์์
# `server_status.service`์ ์์ ํ๋ฉด ์๋์ ๋ช ๋ น์ด๋ฅผ ๋ค์ ์คํํ์ธ์ sudo systemctl daemon-reload sudo systemctl enable server_status.service sudo systemctl start server_status.service
c. ์๋น์ค ์ํ ํ์ธ
sudo systemctl status server_status.service
Note
- ์๋ฒ๋ฅผ ์์ํ ๋ ์ด๋ฉ์ผ ์๋ฆผ์ ๋ฐ์ผ๋ฉด ์ ์์ ์ผ๋ก ์คํ๋๋ ๊ฒ์ ๋๋ค.
ํฐ๋ฏธ๋์์ server_status.service ํ์ผ์ ExecStart๋ฅผ ์ง์ ์คํํ์ฌ ๋ฌธ์ ๋ฅผ ํ์ธํ์ธ์.
# ์ค์๊ฐ ๋ก๊ทธ ํ์ธ
journalctl -f server_status.service




