[5 Mins Docker] Build Your Own Network Latency Monitoring Sites Using Smokeping

This post (https://go.51sec.org/QhYzte) provides instructions for  using docker to install and use SmokePing, a network latency monitoring tool.The instructions include installation using different dockers,  manual installation on linux, and some configuration explanation, . It also provides a sample configuration of Probes and Targets for monitoring network latency.

SmokePing is a deluxe latency measurement tool. It can measure, store and display latency, latency distribution and packet loss. SmokePing uses RRDtool to maintain a longterm data-store and to draw pretty graphs, giving up to the minute information on the state of each network connection.

Project website: https://oss.oetiker.ch/smokeping/

Smokeping

In simple terms, you configure the IP address in SmokePing Targets file, and it will continuously ping it, save the results, and display them in a graph. I installed in into one of my free VPS 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)

Main Features:

  • Measures latency as well as latency variation.
  • Wide variety of probes, ranging from simple ping to web requests and custom protocols.
  • Advanced alarm system, triggering on configurable 'latency patterns'.
  • Master/slave deployment model to run measurments from multiple sources in parallel.
  • Ajax based graph navigation.
  • Chart mode, to show the most interesting graphs first
  • Plug-able probes, alarms (matchers) and charting function.
  • Written in perl for easy enhancability.
  • Fully documented.

demo: https://smokeping.51sec.eu.org

Docker Playground

Lets start with Docker Playground to test it out

1 Log into https://labs.play-with-docker.com/

2 Create an instance then paste following docker run command in

COPY: ctrl + ins

PASTE: ctrl + shift + v

docker run -d / --name=smokeping / -e PUID=1000 / -e PGID=1000 / -e TZ=America/New_York / -p 9080:80 / -v /home/config/smokeping:/config / -v /home/data/smokeping:/data / --restart unless-stopped / linuxserver/smokeping 

3 Click port 9080 to open Smokeping page in a new tab

4 configuration files : Probes, Targets

[node1] (local) [email protected] /home/config/smokeping
Alerts             General            Probes             Targets            pathnames          smokeping_secrets
Database           Presentation       Slaves             httpd.conf         site-confs         ssmtp.conf
[node1] (local) [email protected] /home/config/smokeping
$ vi Targets 
[node1] (local) [email protected] /home/config/smokeping
$ docker restart smokeping 
smokeping

5 docker-compose.yml (Optional) 

If you like to use docker-compose.yml more than docker run command, here is the file content for yml file:

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:
      - 9080:80
EOF


Related Docker compose commands:
  • docker compose down
  • docker compose up -d
  • docker compose pull
Other Docker image:
  • based on Debian : casperklein/smokeping  
    • https://hub.docker.com/r/casperklein/smokeping
  • My image based on  casperklein/smokeping  
    • johnyan2/smokeping-netsec

Deploy with my docker image

Docker Image : 

  • johnyan2/smokeping-netsec
DockerHub: https://hub.docker.com/repository/docker/johnyan2/smokeping-netsec/general
Ubuntu environment tested. 
  • vi docker-compose.yml
version: '3' services: smokeping: image: johnyan2/smokeping-netsec:latest container_name: smokeping volumes: - ./config:/config - ./data:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: - "80:80" restart: always stop_grace_period: 1m 

Notes:

  • You might need to change port from 80 to some other ports you allowed in your security group or firewall acl, such as 8080. 
  • You might need to remove the line : /etc/timezone:/etc/timezone:ro if you are having this error:

Or create folder structure to keep the data on the docker host:

  • mkdir /root/docker_data/smokeping
  • cd /root/docker_data/smokeping
Docker run command:

docker run -d / --name=smokeping / -e PUID=1000 / -e PGID=1000 / -e TZ=America/New_York / -p 6080:80 / -v /root/data/docker_data/smokeping/config:/config / -v /root/data/docker_data/smokeping/data:/data / -v /etc/localtime:/etc/localtime:ro / --restart always / johnyan2/smokeping-netsec:latest 

Error Message: 
[root@centos7-docker-portainer smokeping]# docker-compose up -d Creating network "smokeping_default" with the default driver Pulling smokeping (johnyan2/smokeping-netsec:latest)... latest: Pulling from johnyan2/smokeping-netsec 61a6233aae96: Pull complete a5444ecb192e: Pull complete 89496cf15342: Pull complete 8493e5e6f905: Pull complete 0751c3853bb6: Pull complete 5e5219ef760a: Pull complete Digest: sha256:ada4d81f705780ebf8cfbb590add0745d6af5c96021b86626056ba434ddfeb90 Status: Downloaded newer image for johnyan2/smokeping-netsec:latest Creating smokeping ... error ERROR: for smokeping Cannot start service smokeping: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused /"rootfs_linux.go:58: mounting ///"/etc/timezone///" to rootfs ///"/var/lib/docker/overlay2/721182180a8ec91031da775086afa4b4f5d64c2c5b3db829867bbbce5474258b/merged///" at ///"/var/lib/docker/overlay2/721182180a8ec91031da775086afa4b4f5d64c2c5b3db829867bbbce5474258b/merged/etc/timezone///" caused ///"not a directory///"/"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type 

Run following commands in order to get the default configuration file replaced:

  • timedatectl set-timezone America/New_York
  • docker-compose up -d   or "docker compose up -d"
  • docker exec -d smokeping /bin/bash -c "cp /config.d/* /config/config.d"
  • docker-compose restart    or  "docker compose restart"
Probes Sample  in Docker Image:
*** Probes *** + FPing binary = /usr/bin/fping + DNS binary = /usr/bin/dig lookup = google.com pings = 5 step = 300 +EchoPingHttp binary = /usr/bin/echoping forks = 5 offset = 50% step = 300 port = 80 url = / +EchoPingHttps binary = /usr/bin/echoping forks = 5 offset = 50% step = 300 port = 443 url = / 
Targets Sample in Docker Image:
*** Targets *** probe = FPing menu = Top title = Network Latency Grapher remark = Welcome to the SmokePing website of xxx Company. / Here you will learn all about the latency of our network. + NETSECSites menu = 51SEC Sites title = 51SEC Sites ++ 51sec menu = 51sec.org title = 51sec host = 51sec.org ++ itprosec menu = itprosec.com title = itprosec host = itprosec.com +EPingHttpHttps menu = HTTP HTTPS Response title = HTTP HTTP Response Remote ++google menu = Google HTTP title = Google.org HTTPS response time probe = EchoPingHttp host = www.google.org url = / accept_redirects = yes ++nsrc menu = NSRC HTTPS title = nsrc.org HTTPS response time probe = EchoPingHttps host = nsrc.org url = / accept_redirects = yes ++MSN menu = MSN HTTPS title = MSN HTTPS response time probe = EchoPingHttps host = www.msn.com url = / accept_redirects = yes + DNS menu = DNS title = DNS probe = DNS ++ GoogleDNS1 menu = Google DNS 1 title = Google DNS 8.8.8.8 host = 8.8.8.8 ++ GoogleDNS2 menu = Google DNS 2 title = Google DNS 8.8.4.4 host = 8.8.4.4 ++ OpenDNS1 menu = OpenDNS1 title = OpenDNS1 host = 208.67.222.222 + Local menu = Local title = Local Network #parents = owner:/Test/James location:/ ++ LocalMachine menu = Local Machine title = This host host = localhost #alerts = someloss 
The commands to make a new docker image with changes and push it to my docker hub repository. 
  • docker login
  • docker image list
  • docker-compose down
  • docker exec -it smokeping bash
  • cp /config/config.d/Targets /config.d
  • cp /cofig/config.d/Probes /config.d
  • docker ps
  • docker commit fe39ef5479d1 johnyan2/smokeping-netsec
  • docker push johnyan2/smokeping-netsec
  • docker image rm johnyan2/smokeping-netsec
  • docker image prune
  • docker-compose up -d

Probes 

 

/home/config/smokeping
[node1] (local) [email protected] /home/config/smokeping
$  cat Probes 
*** Probes ***
+ FPing
binary = /usr/sbin/fping
+ FPing6
binary = /usr/sbin/fping
protocol = 6
+ DNS
binary = /usr/bin/dig
lookup = google.com
pings = 5
step = 300
+ TCPPing
binary = /usr/bin/tcpping
forks = 10
offset = random
pings = 5
port = 80


Add Curl probe

https://oss.oetiker.ch/smokeping/probe/Curl.en.html

+Curl
binary = /usr/bin/curl
forks = 5
offset = 50%
step = 300
# The following variables can be overridden in each target section
agent = User-Agent: Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6c
extraargs = -6 --head --user user:password
extrare = / /
follow_redirects = yes
include_redirects = yes
insecure_ssl = 1
interface = eth0
pings = 5
ssl2 = 1
timeout = 20
urlformat = http://%host%/ # mandatory

Once you are done, save and exit from the Targets file and verify your work:

  • docker restart smokeping

Targets

 

$ cat Targets 
*** Targets ***
probe = FPing
menu = Top
title = 51SEC Network Latency Grapher
remark = Welcome to the 51SEC SmokePing website. /
         Here you will know  all about the latency of our network.
+ NETSECSites
menu = 51SEC Sites
title = 51SEC Sites
++ 51sec
menu = 51sec.org
title = 51sec
host = 51sec.org
++ itprosec
menu = itprosec.com
title = itprosec
host = itprosec.com

+ DNS
menu = DNS
title = DNS
++ GoogleDNS1
menu = Google DNS 1
title = Google DNS 8.8.8.8
host = 8.8.8.8
++ GoogleDNS2
menu = Google DNS 2
title = Google DNS 8.8.4.4
host = 8.8.4.4
++ OpenDNS1
menu = OpenDNS1
title = OpenDNS1
host = 208.67.222.222
++ OpenDNS2
menu = OpenDNS2
title = OpenDNS2
host = 208.67.220.220
++ CloudflareDNS1
menu = Cloudflare DNS 1
title = Cloudflare DNS 1.1.1.1
host = 1.1.1.1
++ CloudflareDNS2
menu = Cloudflare DNS 2
title = Cloudflare DNS 1.0.0.1
host = 1.0.0.1
++ L3-1
menu = Level3 DNS 1
title = Level3 DNS 4.2.2.1
host = 4.2.2.1
++ L3-2
menu = Level3 DNS 2
title = Level3 DNS 4.2.2.2
host = 4.2.2.2
++ Quad9
menu = Quad9
title = Quad9 DNS 9.9.9.9
host = 9.9.9.9
+ DNSProbes
menu = DNS Probes
title = DNS Probes
probe = DNS
++ GoogleDNS1
menu = Google DNS 1
title = Google DNS 8.8.8.8
host = 8.8.8.8
++ GoogleDNS2
menu = Google DNS 2
title = Google DNS 8.8.4.4
host = 8.8.4.4
++ OpenDNS1
menu = OpenDNS1
title = OpenDNS1
host = 208.67.222.222
++ OpenDNS2
menu = OpenDNS2
title = OpenDNS2
host = 208.67.220.220
++ CloudflareDNS1
menu = Cloudflare DNS 1
title = Cloudflare DNS 1.1.1.1
host = 1.1.1.1
++ CloudflareDNS2
menu = Cloudflare DNS 2
title = Cloudflare DNS 1.0.0.1
host = 1.0.0.1
++ L3-1
menu = Level3 DNS 1
title = Level3 DNS 4.2.2.1
host = 4.2.2.1
++ L3-2
menu = Level3 DNS 2
title = Level3 DNS 4.2.2.2
host = 4.2.2.2
++ Quad9
menu = Quad9
title = Quad9 DNS 9.9.9.9
host = 9.9.9.9
+CurlHTTPS
menu = Remote HTTPS Response
title = HTTPS Response Remote Machines
++google
menu = Google
title = Google.com HTTPS response time
probe = Curl
host = http://www.google.org/
++nsrc
menu = Network Startup Resource Center
title = nsrc.org HTTPS response time
probe = Curl
host = http://nsrc.org/
++facebook
menu = Network Startup Resource Center
title = Facebook HTTPS response time
probe = Curl
host = http://www.facebook.com/


Once you are done, save and exit from the Targets file and verify your work:

  • docker restart smokeping

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.

Modify The Node Name

 

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

Customize the query frequncy

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%

Change probe type to use a specific probe

 

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.

 *** Targets ***  probe = FPing  menu = Top  title = Network Latency Grapher  remark = Welcome to this SmokePing website.    + 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  

Manual Install Smokeping

Ubuntu OS: 

apt update -y
apt install smokeping -y
http://<public ip>/smokeping
root@instance-20240705-213604:/# cd /etc/smokeping/config.d/
root@instance-20240705-213604:/etc/smokeping/config.d# ls
Alerts  Database  General  Presentation  Probes  Slaves  Targets  pathnames
root@instance-20240705-213604:/etc/smokeping/config.d#
Probes configuration file:
root@instance-20240705-213604:/etc/smokeping/config.d# cat Probes *** Probes *** + FPing binary = /usr/bin/fping + DNS binary = /usr/bin/dig lookup = google.com pings = 5 step = 300 +EchoPingHttp binary = /usr/bin/echoping forks = 5 offset = 50% step = 300 port = 80 url = / +EchoPingHttps binary = /usr/bin/echoping forks = 5 offset = 50% step = 300 port = 443 url = / 

Targets configuration file:
root@instance-20240705-213604:/etc/smokeping/config.d# cat Targets *** Targets *** probe = FPing menu = Top title = Network Latency Grapher remark = Welcome to the SmokePing website of xxx Company. / Here you will learn all about the latency of our network. + NETSECSites menu = 51SEC Sites title = 51SEC Sites ++ 51sec menu = 51sec.org title = 51sec host = 51sec.org ++ itprosec menu = itprosec.com title = itprosec host = itprosec.com +EPingHttpHttps menu = HTTP HTTPS Response title = HTTP HTTP Response Remote ++google menu = Google HTTP title = Google.org HTTPS response time probe = EchoPingHttp host = www.google.org url = / accept_redirects = yes ++nsrc menu = NSRC HTTPS title = nsrc.org HTTPS response time probe = EchoPingHttps host = nsrc.org url = / accept_redirects = yes ++MSN menu = MSN HTTPS title = MSN HTTPS response time probe = EchoPingHttps host = www.msn.com url = / accept_redirects = yes + DNS menu = DNS title = DNS ++ GoogleDNS1 menu = Google DNS 1 title = Google DNS 8.8.8.8 host = 8.8.8.8 ++ GoogleDNS2 menu = Google DNS 2 title = Google DNS 8.8.4.4 host = 8.8.4.4 ++ OpenDNS1 menu = OpenDNS1 title = OpenDNS1 host = 208.67.222.222 + Local menu = Local title = Local Network #parents = owner:/Test/James location:/ ++ LocalMachine menu = Local Machine title = This host host = localhost #alerts = someloss 

System comands:

  • systemctl restart smokeping
  • systemctl start smokeping
  • systemctl status smokeping.service 
  • journalctl -xeu smokeping.servic
Configuration file location: /etc/smokeping/config.d/
Database file location: /var/lib/smokeping/DNS
Further docker commands can be found from : https://blog.51sec.org/2020/04/docker-usage.html

Install echoping

 

Ubuntu 

Fixed the issue not able to install echoping in Ubuntu, by using the packages from Ubuntu 18.04LTS:
root@instance-20240705-213604:/etc/smokeping/config.d# echoping -C -v -h /smokeping www.51sec.org
This is echoping, version 6.0.2.
Trying to connect to internet address 172.67.181.8 443 to transmit 99 bytes...
Trying to send 256 bytes to internet address 172.67.181.8...
Connected...
TCP Latency: 0.013837 seconds
Cannot start the TLS session: A TLS fatal alert has been received. (Network is unreachable)
root@instance-20240705-213604:/etc/smokeping/config.d# echoping -R -v -h /smokeping www.51sec.org
This is echoping, version 6.0.2.
Trying to connect to internet address 104.21.83.198 80 to transmit 95 bytes...
Trying to send 256 bytes to internet address 104.21.83.198...
Connected...
TCP Latency: 0.015713 seconds
Sent (95 bytes)...
Application Latency: 0.906786 seconds
HTTP error "HTTP/1.1 404 Not Found
"
root@instance-20240705-213604:/etc/smokeping/config.d# 
 echoping -C -v -h / www.google.com




Debian



Install dig for DNS

 

In certain Linux OS release, dig program might not include. Here is a command to install dig application.
  • apt install dnsutils

After installed it, you can find it from /usr/bin folder.

Troubleshooting

 

root@3d598822f424:/# smokeping --config="/etc/smokeping/config" --debug
WARNING: Hostname 'ipv6.google.com' does currently not resolve to an IPv4 address
WARNING: Hostname 'ipv6.google.com' does currently not resolve to an IPv4 address
Curl: Note: your curl doesn't support the interface feature (option --interface), disabling it
Curl: Note: your curl doesn't support the timeout feature (option -m), disabling it
### parsing dig output...OK
### assuming you are using an tcpping copy reporting in milliseconds
### assuming you are using an fping copy reporting in milliseconds
### Compiling alert detector pattern 'someloss'
### >0%,*12*,>0%,*12*,>0%
sub { 
    my $d = shift;
    my $y = $d->{loss};
    for(1){
        my $imax2 = min(@$y - 3, 12);
        my $imax1 = min(@$y - 3, 12);
        my $minlength = 3;
        my $maxlength = 27;
        next if scalar @$y < $minlength ;
        my $i1;
        for($i1=0; $i1 < min($maxlength,$imax1); $i1++){
            my $i2;
            for($i2=0; $i2 < min($maxlength-$i1,$imax2); $i2++){
                next unless defined $y->[-3-$i1-$i2]
                                and $y->[-3-$i1-$i2] =~ /^/d/
                                and $y->[-3-$i1-$i2] > 0
                                     ;                last;
            }
            return 0 if $i2 >= min($maxlength-$i1-$i2,$imax2);
            next unless defined $y->[-2-$i1]
                            and $y->[-2-$i1] =~ /^/d/
                            and $y->[-2-$i1] > 0
                                 ;            last;
        }
        return 0 if $i1 >= min($maxlength-$i1,$imax1);
        next unless defined $y->[-1]
                        and $y->[-1] =~ /^/d/
                        and $y->[-1] > 0
                             ;        return 1;
    }
    return 0;
}


Smokeping version 2.008002 successfully launched.
Not entering multiprocess mode with '--debug'. Use '--debug-daemon' for that.
DNS: probing 9 targets with step 300 s and offset 87 s.
Curl: probing 0 targets with step 300 s and offset 87 s.
TCPPing: probing 0 targets with step 300 s and offset 87 s.
FPing: probing 26 targets with step 300 s and offset 87 s.
FPing6: probing 1 targets with step 300 s and offset 87 s.
DNS: forks 5, timeout for each target 26
DNS: query=/usr/bin/dig @1.0.0.1 google.com
DNS: query=/usr/bin/dig @4.2.2.2 google.com
DNS: query=/usr/bin/dig @9.9.9.9 google.com
DNS: query=/usr/bin/dig @8.8.8.8 google.com
DNS: query=/usr/bin/dig @8.8.4.4 google.com
DNS: 9.9.9.9: got 0.0000000000e+00 3.0000000000e-03 3.0000000000e-03 7.0000000000e-03 7.0000000000e-03
DNS: 8.8.8.8: got 0.0000000000e+00 3.0000000000e-03 3.0000000000e-03 3.0000000000e-03 7.0000000000e-03
DNS: 1.0.0.1: got 0.0000000000e+00 3.0000000000e-03 3.0000000000e-03 3.0000000000e-03 1.1000000000e-02
DNS: 4.2.2.2: got 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 3.0000000000e-03
DNS: 8.8.4.4: got 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 3.0000000000e-03 3.0000000000e-03
DNS: query=/usr/bin/dig @208.67.220.220 google.com
DNS: query=/usr/bin/dig @4.2.2.1 google.com
DNS: query=/usr/bin/dig @208.67.222.222 google.com
DNS: query=/usr/bin/dig @1.1.1.1 google.com
DNS: 1.1.1.1: got 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 3.0000000000e-03 7.0000000000e-03
DNS: 208.67.222.222: got 3.0000000000e-03 3.0000000000e-03 7.0000000000e-03 1.1000000000e-02 1.1000000000e-02
DNS: 4.2.2.1: got 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 3.0000000000e-03 3.0000000000e-03
DNS: 208.67.220.220: got 0.0000000000e+00 3.0000000000e-03 3.0000000000e-03 1.1000000000e-02 1.9000000000e-02
FPing: Executing /usr/sbin/fping -C 20 -q -B1 -r1 -i10 www.berkeley.edu cam.ac.uk 208.67.222.222 web.mit.edu ucsd.edu www.indiana.edu osuosl.org facebook.com youtube.com 208.67.220.220 8.8.8.8 4.2.2.1 8.8.4.4 1.0.0.1 www.telefonica.de twin-cities.umn.edu jupiterbroadcasting.com cixp.web.cern.ch google.com 9.9.9.9 1.1.1.1 www.uea.ac.uk linuxserver.io 4.2.2.2
^Cgot INT signal, terminating.
root@3d598822f424:/# 


Issue 

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

Self Hosted Docker Installation Pre-requirements

Free resources you might need to complete this docker project:

Pre-installed services:

  • Docker, 
    • apt update
    • apt install docker.io
    • apt install docker-compose
    • apt upgrade docker.io
    • mkdir /root/data/docker_data/<docker_name>
  • Docker-Compose (Using Ubuntu OS for the commands)
    • Docker-compose down
    • Optional command : use following command to backup your Docker data. You might need to change your folder name based on your docker configuraiton
      • cp -r /root/data/docker_data/<docker_name> /root/data/docker_data_backup/<docker_name>
    • docker-compose pull
    • docker-compose up -d
    • docker image prune
  • Portainer (Optional)
    • docker volume create portainer_data
    • docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
  • Install some applications: apt install wget curl sudo vim git (Optional)
  • aapanel with Nginx (Optional)
  • Nginx Proxy Manager (Optional)
  • Install screen (Optional)
    • Install screen (Depends on the Linux Distribution if it came pre installed or not) : yum install screen
    • Initiate a Screen : screen or  screen -S <screen name> <command to execute>
    • Detach from the screen : "CTRL+A,D" not "CTRL+A+D"
    • List all the screen currently working : screen -ls
    • Reattach to a screen : screen  -r  <session number> or screen -r <screen name>
    • Kill specific screen: screen -X -S <screen name> quit
    • Kill all screens : pkill screen

Monitoring Usage

  • Docker stats
  • ncdu
    • apt install ncdu

Remove Docker and Related folders

  • docker stop <Docker Name> # stop the docker but not remove anything. 
  • docker rm -f <Docker Name>  # remove speficic container, but will not delete mapped volumes
  • rm -rf /root/data/docker_data/<Docker Mapped Volumns>  # remove all mapped volumes

Restrick Journal Log File Size:

  • journalctl --vacuum-size=100M
  • Limit it to 25M:

nano /etc/systemd/journald.conf
SystemMaxUse=25M
systemctl restart systemd-journald.service

or 

sudo bash -c 'echo "SystemMaxUse=100M" >> /etc/systemd/journald.conf' sudo systemctl restart systemd-journald 

Enable IPv6 and Limit Log File Size (Ubuntu)

Special command to cleans all logs and you don't need to stop the containers.
  • sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'
Add customized self defined IPv6 address segment to enable container's IPv6 fucntion. And limit log file's size and numbers in case log file to fill all hard drive's space. 

cat > /etc/docker/daemon.json << EOF { "log-driver": "json-file", "log-opts": { "max-size": "20m", "max-file": "3" }, "ipv6": true, "fixed-cidr-v6": "fd00:dead:beef:c0::/80", "eixperimental":true, "ip6tables":true } EOF

If there is any error, or IPv6 part might not work in the platform you might want to change it to list:


cat <<EOF > /etc/docker/daemon.json { "live-restore": true, "storage-driver": "overlay2", "log-opts": { "max-size": "10m" } } EOF 
Restart Docker service:

systemctl restart docker

Limit number of log files:

cat /etc/logrotate.d/rsyslog 
/var/log/syslog /var/log/mail.info /var/log/mail.warn /var/log/mail.err /var/log/mail.log /var/log/daemon.log /var/log/kern.log /var/log/auth.log /var/log/user.log /var/log/lpr.log /var/log/cron.log /var/log/debug /var/log/messages { rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate /usr/lib/rsyslog/rsyslog-rotate endscript } 

You can change 4 to some other value, such as 1, so that only one file is stored.

Videos

 

Smokeping - Create Your Own Free Network Latency Monitoring Site:

References

版权声明:
作者:zhangchen
链接:https://www.techfm.club/p/144459.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>