✨ Rust Version of ServerStatus Probe, Enhanced Version
Project Address: zdz/ServerStatus-Rust: ✨ Rust Version of ServerStatus Probe, Enhanced Version (github.com)
Official Tutorial: Installation and Deployment - Rust Version of ServerStatus Cloud Probe (ssr.rs)
Online Address: ServerStatus (ssr.rs)
This is a multi-server monitoring tool.
The effect is as follows:
1 Preparation#
Environment: Two CentOS 7 servers (It is recommended to use servers in Hong Kong)
It is recommended to use foreign servers, as domestic servers are slower in pulling repository code, which can be frustrating.
For example: If your server environment does not support foreign environments, the script execution to pull remote repository code may time out and fail to complete.
I will use a manual step-by-step installation, which is roughly based on the script.
Note: Before this, you need to understand what the server and client are, and how to associate the client with the server.
The server (Server) usually refers to a computer or device that provides a certain service or resource.
The client (Client) refers to a computer or device that uses the services or resources provided by the server.
The server and client are two roles in a computer network, where the server provides services or resources, and the client uses services or obtains resources. They communicate over the network to achieve data transmission and interaction.
In a typical client-server model, there are usually multiple clients communicating with a single server. This is because the server's goal is to provide services or resources to multiple clients.
The number of clients and servers is not limited to a one-to-many relationship; there can also be multiple servers.
There are usually multiple clients and one or more servers communicating. This many-to-one or many-to-many relationship is to meet the needs of large-scale applications or systems and provide better performance, reliability, and scalability.
For example:
When setting up frp, using Frp as a relay server to connect to a remote desktop.
This ServerStatus_Rust setup is similar to frp, also involving one server and one client.
General process: The external network connects to the server, which then connects to the local Windows desktop through the frp-configured server.
Here, the configured frp server is the server, and the client is the local Windows desktop.
A picture is more illustrative:
The server can also act as a client, sending real-time data to itself to monitor its own data changes (not limited to load, traffic, memory, etc.).
Monitoring server architecture:
uname -a
Download: Release v1.7.2 · zdz/ServerStatus-Rust (github.com)
If your server is x86 64, choose the installation package as shown below.
Upload it to the server's
/opt/ServerStatus/
directory. The server needs to upload both the client and server.
Create directory:
mkdir -p /opt/ServerStatus && cd /opt/ServerStatus
2 Server Setup#
You need to install both the server and client.
server.sh configuration:
#!/bin/bash
set -ex
WORKSPACE=/opt/ServerStatus
mkdir -p ${WORKSPACE}
cd ${WORKSPACE}
# Download, replace x86_64 with aarch64 for arm machines
OS_ARCH="x86_64"
latest_version=$(curl -m 10 -sL "https://api.github.com/repos/zdz/ServerStatus-Rust/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
wget --no-check-certificate -qO "server-${OS_ARCH}-unknown-linux-musl.zip" "https://github.com/zdz/ServerStatus-Rust/releases/download/${latest_version}/server-${OS_ARCH}-unknown-linux-musl.zip"
wget --no-check-certificate -qO "client-${OS_ARCH}-unknown-linux-musl.zip" "https://github.com/zdz/ServerStatus-Rust/releases/download/${latest_version}/client-${OS_ARCH}-unknown-linux-musl.zip"
unzip -o "server-${OS_ARCH}-unknown-linux-musl.zip"
unzip -o "client-${OS_ARCH}-unknown-linux-musl.zip"
# systemd service
mv -v stat_server.service /etc/systemd/system/stat_server.service
mv -v stat_client.service /etc/systemd/system/stat_client.service
systemctl daemon-reload
# Start
systemctl start stat_server
systemctl start stat_client
# Status check
systemctl status stat_server
systemctl status stat_client
# Use the following commands for startup on boot
# systemctl enable stat_server
# systemctl enable stat_client
# Stop
# systemctl stop stat_server
# systemctl stop stat_client
# https://fedoraproject.org/wiki/Systemd/zh-cn
# https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html
# Modify the /etc/systemd/system/stat_client.service file, changing the IP to your server's IP or your domain name.
Execute:
bash -ex server.sh
If it cannot be executed, switch to manual mode and execute step by step.
mkdir -p /opt/ServerStatus && cd /opt/ServerStatus
// Upload the server and client zip files to the /opt/ServerStatus directory
// Unzip
unzip -o server-x86_64-unknown-linux-musl.zip
unzip -o client-x86_64-unknown-linux-musl.zip
// Use the ll command to check if the stat_client.service file has been successfully unzipped
// Move the file to /etc/systemd/system/stat_client.service
mv -v stat_client.service /etc/systemd/system/stat_client.service
# systemd service
mv -v stat_server.service /etc/systemd/system/stat_server.service
mv -v stat_client.service /etc/systemd/system/stat_client.service
systemctl daemon-reload
# Start
systemctl start stat_server
systemctl start stat_client
# Status check
systemctl status stat_server
systemctl status stat_client
# Use the following commands for startup on boot
# systemctl enable stat_server
# systemctl enable stat_client
# Stop
# systemctl stop stat_server
# systemctl stop stat_client
Modify configuration:
Remove comments, which means removing the # sign.
Replace the subsequent address with your server's reverse proxy domain name.
For example, if your domain is: https://w.lxip.top
Then replace it with https://w.lxip.top/report.
If you do not want to use reverse proxy or find it troublesome, you can directly use the server's public IP address + port number.
For example, the address: http://139.212.12.120:8080 (on the server), you can replace it directly.
The relationship between the server and client:
The config.toml file corresponds to the server.
The completed configuration is as follows:
The server can also be set up using third-party platforms, such as Railway deployment.
3 Client Setup#
client.sh configuration
#!/bin/bash
set -ex
WORKSPACE=/opt/ServerStatus
mkdir -p ${WORKSPACE}
cd ${WORKSPACE}
# Download, replace x86_64 with aarch64 for arm machines
OS_ARCH="x86_64"
latest_version=$(curl -m 10 -sL "https://api.github.com/repos/zdz/ServerStatus-Rust/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
wget --no-check-certificate -qO "client-${OS_ARCH}-unknown-linux-musl.zip" "https://github.com/zdz/ServerStatus-Rust/releases/download/${latest_version}/client-${OS_ARCH}-unknown-linux-musl.zip"
unzip -o "client-${OS_ARCH}-unknown-linux-musl.zip"
# systemd service
mv -v stat_client.service /etc/systemd/system/stat_client.service
systemctl daemon-reload
# Start
systemctl start stat_client
# Status check
systemctl status stat_client
# Use the following commands for startup on boot
systemctl enable stat_client
# Stop
# systemctl stop stat_client
# https://fedoraproject.org/wiki/Systemd/zh-cn
# https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html
# Modify the /etc/systemd/system/stat_client.service file, changing the IP to your server's IP or your domain name.
Execute:
bash -ex client.sh
If it cannot be executed, switch to manual mode and execute step by step.
// Recursively create the directory
mkdir -p /opt/ServerStatus && cd /opt/ServerStatus
// Upload the client zip file to the /opt/ServerStatus directory
// Unzip
unzip -o client-x86_64-unknown-linux-musl.zip
// Use the ll command to check if the stat_client.service file has been successfully unzipped
// Move the file to /etc/systemd/system/stat_client.service
mv -v stat_client.service /etc/systemd/system/stat_client.service
// Restart to reload
systemctl daemon-reload
# Start
systemctl start stat_client
# Status check
systemctl status stat_client
Once everything is installed, it looks like this:
Register the client to the server:
Open the stat_client.service file:
vim /etc/systemd/system/stat_client.service
Modify as shown in the picture:
Configuration changes are as follows:
4 Setting Up Nginx Reverse Proxy#
Mainly used to reverse proxy an address with a port number to a domain name (subdomain).
If you access using the IP address + port number, you do not need to set up a reverse proxy, thus saving this step.
Reference: ServerStatus-Rust Reverse Proxy Setup
5 Uninstalling the Server and Client:#
- First, stop the services that were started earlier.
Check the service status:
systemctl status stat_server
systemctl status stat_client
If the service status is active, you need to stop it first using the following commands:
systemctl stop stat_server
systemctl stop stat_client
Then execute a simple and straightforward method to delete the folder's files.
Delete the ServerStatus folder (including all contents) under /opt/.
rm -rf ServerStatus
Note: Do not use /* to delete files, as it can accidentally delete the database. It is easy to make such mistakes when using the delete command for the first time to remove all contents of a folder.
Reason: This is often due to the habit of using a visual interface, bringing that mindset to Linux, thinking that Linux deletion works the same way as visual interfaces, which can lead to accidental operations and serious issues.
After deletion, use the ll command to check if the deletion is complete.
You also need to delete residual files:
rf -rf /etc/systemd/system/stat_server.service
rf -rf /etc/systemd/system/stat_client.service
If you are unsure whether these two files exist, you can switch to the /etc/systemd/system/ directory to check for these two files before performing the deletion operation.
6 Extended Features#
Server down, tg bot sends notifications or WeChat notifications.
7 Summary#
Forgive my ignorance; it took me more than a day to set this up. I tried various methods and finally understood how to read the corresponding scripts and documents, gaining some insights. I finally figured out how the serverstatus_rust relates between different servers and gained a better understanding of the scripts.
Attachments#
Reference 1: Setting Up Two Dedicated Server Monitoring - Ward && ServerStatus
Reference 2: ServerStatus-Rust Server Probe Setup and Use
Reference 3: Installation and Deployment - Rust Version of ServerStatus Cloud Probe (ssr.rs)