AhFei

AhFei

简洁的写作需要勇气

Installation and Configuration of the Network Latency Tool SmokePing

If not specifically stated, follow the order of commands in the article code block to achieve the goal.

Applicable systems: Debian-based distributions, including Ubuntu and Armbian. Other distributions can generally use the same commands with slight modifications.

Estimated time to complete: 20 minutes (It is recommended to go through the process once before customizing the configuration file.)

image.png

SmokePing is a powerful and flexible network latency monitoring tool that allows you to view the results graphically on a webpage.

In simple terms, you tell it the IP address, and it will continuously ping it, save the results, and display them in a graph. I use it on my "Portable Server" to monitor the network status between the server and my VPS. In fact, SmokePing has many tools for testing networks, including FPing, cURL, DNS, and FPing6.

Official website: SmokePing - About SmokePing (oetiker.ch)

Docker image built by linuxserver: linuxserver/docker-smokeping (github.com)

Installing SmokePing using Docker#

Copy and execute the following command to create a working directory and open the port with one click:

myserve="smokeping"
sudo ufw allow 8899/tcp comment $myserve && sudo ufw reload
mkdir -p ~/myserve/$myserve && cd ~/myserve/$myserve

Customize according to the comments and then execute the following command to create the docker-compose.yml file (supports armbian):

cat > docker-compose.yml << EOF
version: "2.1"
services:
  smokeping:
    image: lscr.io/linuxserver/smokeping:latest
    container_name: smokeping
    restart: unless-stopped
    environment:
      - PUID=1000   # Customize, can be a username or UID, if unsure, use root
      - PGID=1000   # Customize, can be a group name or UID, if unsure, use root
      - TZ=Asia/Shanghai
    volumes:
      - ./config:/config
      - ./data:/data
    ports:
      - 8899:80
EOF

Pull the container image:

docker compose pull

Start the container (you can now access the webpage by visiting http://ip_addr_or_domain:8899):

docker compose up -d

If installed on a machine in mainland China, a small modification is required for international use#

I forgot the reason, but it seems that if resolve.conf is not modified, no data will be displayed

Modify the resolve.conf file in the image. Perform all operations in the ~/myserve/smokeping/ directory with the following steps:

cd ~/myserve/smokeping/

Create a custom resolve.conf file: Add a usable DNS server in China, here we use 223.5.5.5

touch resolve.conf && \
echo "nameserver 223.5.5.5" > resolve.conf && \
echo "options edns0 trust-ad ndots:0" >> resolve.conf

Create a Dockerfile to pull and modify the image:

cat > Dockerfile << EOF
FROM linuxserver/smokeping:latest
COPY ./resolve.conf /etc/resolve.conf
EOF

Change the docker-compose.yml file to the following content, replacing image: with build::

cat > docker-compose.yml << EOF
version: "2.1"
services:
  smokeping:
    build: ./
    container_name: smokeping
    restart: unless-stopped
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Shanghai
    volumes:
      - ./config:/config
      - ./data:/data
    ports:
      - 8899:80
EOF
docker compose up -d

After starting the container, some additional modifications are required:

vim /usr/local/smokeping/config/Probe

Change the lookup in the following DNS section to a website that can be accessed from the domestic network, such as baidu.com.

+ DNS
binary = /usr/bin/dig
lookup = baidu.com
pings = 5
step = 300

Modify the Master Node Name#

image.png

As shown in the image

cd ~/myserve/smokeping && vim config/General

Add a display_name

*** General ***

owner    = LinuxServer.io
contact  = [email protected]
mailhost = my.mail.host
cgiurl   = http://localhost/smokeping.cgi
syslogfacility = local0
# Save space, removed comments

display_name = Zhengzhou Mobile Broadband   # Here
@include /config/pathnames

SmokePing Probe Configuration File#

First, customize the query frequency:

cd ~/myserve/smokeping && vim config/Database
*** Database ***
step     = 180
pings    = 20

Query 20 times every 3 minutes.

  • step: Query cycle in seconds, how many seconds to ping in one cycle, not just ping, it refers to the operation of all probes
  • pings: How many times to query in each cycle, for example, how many pings for each node

Edit the probe configuration file:

cd ~/myserve/smokeping && vim config/Probes

The commonly used ones are:

*** Probes ***

+ FPing
binary = /usr/sbin/fping
packetsize = 1000
 
+ FPing6
binary = /bin/ping6   # This cannot be changed according to the official website because it is the container version


+ DNS
binary = /usr/bin/dig
lookup = baidu.com
pings = 5
step = 300

+ Curl
binary = /usr/bin/curl
forks = 5
offset = 50%

The pings here will override the previous setting.


You can change the probe type in the configuration file to use a specific probe. Add probe = probe_name at the beginning of the line to specify which probe to use.

(If it seems overwhelming, you can skip it for now)

 *** Targets ***
 probe = FPing
 menu = Top
 title = Network Latency Grapher
 remark = Welcome to this SmokePing website.
 
 + network
 menu = Net latency
 title = Network latency (ICMP pings)
 
 ++ myhost1
 host = myhost1.example
 ++ myhost2
 host = myhost2.example
 
 + services
 menu = Service latency
 title = Service latency (DNS, HTTP)
 
 ++ DNS
 probe = DNS   # Change probe to DNS here
 menu = DNS latency
 title = Service latency (DNS)
 
 +++ dns1
 host = dns1.example
 
 +++ dns2
 host = dns2.example

Configuration File for Monitoring IP Addresses#

Example: SmokePing - smokeping_examples (oetiker.ch)

Simple explanation:

  1. ++ Fill in the identifier here, which can be uppercase and lowercase letters, numbers, underscores, and hyphens.
  2. menu = The content displayed in the menu.
  3. title = The content displayed at the top of the page.
  4. host = The target to ping, can be a domain name or IP address.
  5. Restart the container after making any changes to the configuration file.

You can start by filling in the format below, see what changes on the webpage, and then customize it.

cd ~/myserve/smokeping && vim config/Targets

Here is a simplified version I use, you can leave it unchanged for now, go through the process, run it, and then customize it:

*** Targets ***

probe = FPing

menu = Top
title = Network Latency Grapher for AhFei
remark = Welcome to my SmokePing website. \
         Here you will learn all about the latency of my network.



+ TheBigThree
menu = Three Major Operators
title = Monitoring Statistics


++ CMCC
menu = China Mobile
title = China Mobile
host = /TheBigThree/CMCC/CMCC-BJ /TheBigThree/CMCC/CMCC-TJ /TheBigThree/CMCC/CMCC-HLJ
 
+++ CMCC-BJ
menu = Beijing Mobile
title = Beijing Mobile
alerts = someloss
host = 221.130.33.52
 
+++ CMCC-TJ
menu = Tianjin Mobile
title = Tianjin Mobile
alerts = someloss
host = 211.137.160.5

+++ CMCC-HLJ
menu = Heilongjiang Mobile
title = Heilongjiang Mobile
alerts = someloss
host = 211.137.241.35

# The remaining two are omitted, they are too long



+ DomesticServer
menu = Domestic Servers
title = Monitoring Statistics
host = /DomesticServer/Tc

++ Tc
menu = TencentCloud
title = TencentCloud
alerts = someloss
host = 110.242.68.66




+ USServer
menu = US Servers
title = Monitoring Statistics
host = /USServer/Bwg /USServer/NA

++ Bwg
menu = Bandwagon
title = Bandwagon
alerts = someloss
host = 193.43.142.215

++ NA
menu = nextarray
title = nextarray
alerts = someloss
host = 193.43.142.215




+ OtherRegionServer
menu = Other Region Servers
title = Monitoring Statistics
host = 

For monitoring IPs of the three major operators in China: raw.githubusercontent.com/AhFeil/bash-script/main/smokeping-Targets, some may be invalid and there are no plans to update them, so they are not needed.


Stop the container:

docker compose down

Restart the container:

docker compose up -d

Original article link: https://blog.vfly2.com/2023/07/smokeping-installation-configuration/
Copyright: All articles on this blog are licensed under a CC BY-NC-SA 4.0 license.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.