서버모니터 앱 - 에이전트 설치 가이드(Install manual)

 

< How to Install agent >

-- Summary--

<Install Python>

<Install pip>

<Install package>

<Python File>

<File Mode Change>

<Check Service>

<Create & Run Service>

<Error Check>

<Code Modification and ReStart Service>

 

Etc

<How to stress resources>

<How to change server’s name>

 

-- Detailed Procedures --

<Install Python>

Check if Python is installed.

[root@localhost ~]# python --version

Python 3.9.18

[root@localhost ~]#

 

<Install pip>

 Install python3-pip

[root@localhost system]# dnf install python3-pip

 

<Install package>

 Install packages

[root@localhost system]# pip3 install psutil requests netifaces

 

<Python File>

Apply Code

cd /opt

mkdir server-monitor-agent

vi agent.py

 

<File Mode Change>

Change mode

chmod +x /opt/server-monitor-agent/agent.py

 

<Check Service>

Check Service (When Service is running)

[root@FTP-Server server-monitor-agent]# systemctl list-units --type=service --all | grep agent

  server-monitor-agent.service                          loaded    active   running Server Monitor Agent

 

Check Service (When Service is NOT running)

[root@localhost opt]# systemctl list-units --type=service --all | grep agent

[root@localhost opt]#

 

<Create & Run Service>

Create a Systemd Service File and run service.

Step1: Create a Systemd Service File

sudo vi /etc/systemd/system/server-monitor-agent.service

paste the below code

[Unit]

Description=Server Monitor Agent

 

[Service]

ExecStart=/usr/bin/python3 /opt/server-monitor-agent/agent.py

Restart=always

User=root

 

[Install]

WantedBy=multi-user.target

 

Step 2: Reload Systemd and Enable the Service

sudo systemctl daemon-reload

Step 3: Enable the service to start at boot

[root@localhost system]# systemctl enable server-monitor-agent.service

Created symlink /etc/systemd/system/multi-user.target.wants/server-monitor-agent.service /etc/systemd/system/server-monitor-agen                    t.service.

Step 4: Start the Service

[root@localhost system]# systemctl start server-monitor-agent.service

Step 5: Check status

[root@FTP-Server server-monitor-agent]# systemctl status server-monitor-agent.service

 

<Error Check>

Check Logs for Errors:

[root@localhost system]# journalctl -u server-monitor-agent.service

 

<Code Modification and ReStart Service>

Modify code and Restart service

Step 1: Reload Systemd and Enable the Service

sudo systemctl daemon-reload

Step 2: Enable the service to start at boot

[root@localhost system]# systemctl enable server-monitor-agent.service

Created symlink /etc/systemd/system/multi-user.target.wants/server-monitor-agent.service /etc/systemd/system/server-monitor-agen                    t.service.

Step 3: Start the Service

[root@localhost system]# systemctl restart server-monitor-agent.service

Step 4: Check log

tail -f /var/log/server-monitor-agent.log

 

etc:

<How to stress resources>

dnf install epel-release -y

dnf install stress -y

# Stress the CPU with 4 workers for 60 seconds

stress --cpu 4 --timeout 60

# Stress the memory with 2 workers each allocating 256MB for 60 seconds

stress --vm 2 --vm-bytes 256M --timeout 60

 

<How to change server’s name>

Step1: check server’s name

Hostnamectl

Step2: change server’s name

sudo hostnamectl set-hostname web_hosting

Step3: change server’s name

vi /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 new-hostname ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

 

 

 

 

 

 

 

 

 

 

 

 

댓글

이 블로그의 인기 게시물

image_insert_vba (vba로 만든 이미지 자동 삽입기)

IT 개발자 다이어리 - 2024년 6월 7일 금요일 / 날씨: 흐리다가 맑아짐

Privacy Policy(Chicken Fight - 닭싸움)