Sign inSign up

oijkn/infpyng

By oijkn

•Updated over 6 years ago

Infpyng can ping multiple hosts at once and write data to InfluxDB -- Alternative to Smokeping

Image
1

10K+

oijkn/infpyng repository overview

⁠Welcome to Infpyng !

⁠Introduction

Infpyng is a powerful python script which use fping⁠ to probe endpoint through ICMP and parsing the output to Influxdb⁠. The result can then be visualize easily through Grafana⁠.

  • Infpyng is perhaps your alternative to SmokePing
  • You can add dynamic hosts without restarting script
  • Custom Polling time configuration
  • Low resource consumption
  • Docker compatibility

Benchmark

Those tests were performed from CentOS 8 with 1 CPU and 2 GB of memory

IP to pingIP reachableFinished in
47445411 seconds
1299119713 seconds
2653255228 seconds
3388326232 seconds

Screenshots

⁠Requirements

⁠Installation

The basic configuration is embedded in the image of the Docker you will have to create the files config.toml and hosts.toml from your host which will then have to be pushed in the image.

The config.toml file will contain your custom settings and especially the hostname/user/pass of your InfluxDB.

The hosts.toml file will have the list of all the hosts to ping.

Note: For the following commands remember to adapt the tag version (example: infpyng:1.0.0) according to the image of the docker you are using.

⁠Docker usage
  1. Pull the image from hub.docker

    # docker pull oijkn/infpyng

  2. Run the container to add your config/hosts files

    docker run -d \
        --name infpyng \
        --hostname docker-infpyng \
        --restart unless-stopped \
        --mount src=/dir/from/host/infpyng/config,target=/infpyng/config,type=bind \
        --mount src=/dir/from/host/infpyng.log,target=/infpyng/infpyng.log,type=bind \
        --log-driver=journald \
        --log-opt tag="{{.Name}}" \
        --env TZ=Europe/Paris \
    oijkn/infpyng
    

    Note: You must have config files⁠ on your host and edit them according to your environment and adapt the TZ=Europe/Paris depending on your location.

⁠SSH to Infpyng Docker

The command started using docker exec only runs while the container’s is running, and it is not restarted if the container is restarted.

  1. Retrieve container id

    # docker ps -a

    CONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
    5591dbd111e5oijkn/infpyng:1.0.0"python infpyng.py"13 seconds agoUp 11 secondsinfpyng
  2. Retrieve container id

    # docker exec -it 5591dbd111e5 sh

  3. Show log file

    /app/infpyng # cat /var/log/infpyng.log
    2020-05-28 08:54:16 root INFO :: Settings loaded successfully
    2020-05-28 08:54:16 root INFO :: Init InfluxDB successfully
    2020-05-28 08:54:16 root INFO :: Starting Infpyng Multiprocessing v1.0.0
    2020-05-28 08:54:16 root INFO :: Polling time every 300s
    2020-05-28 08:54:16 root INFO :: Total of targets : 5
    2020-05-28 08:54:16 root INFO :: Multiprocessing : 40
    2020-05-28 08:54:16 root INFO :: Buckets : 5
    2020-05-28 08:54:20 root INFO :: Targets alive : 5
    2020-05-28 08:54:20 root INFO :: Targets unreachable : 0
    2020-05-28 08:54:20 root INFO :: Data written to DB successfully
    2020-05-28 08:54:20 root INFO :: Finished in : 4.44 seconds
    2020-05-28 08:54:20 root INFO :: ---------------------------------------
    
⁠Docker Compose usage (Stack)

Multi-container Docker app built from the following services:

Useful for quickly setting up a monitoring stack for performance testing. Please refer to this link Infpyng-stack⁠ to create a performance testing environment in minutes.

⁠Github usage
  1. Download Infpyng project

     # cd /dir/from/host/
     # git clone https://github.com/oijkn/infpyng.git
     # pip install -r requirements.txt
    
  2. Ensure correct permission on *.py files

     # chmod -R +x /somewhere/in/your/host/infpyng/*.py
    
  3. Edit your custom settings (conf + hosts)

     # vi /dir/from/host/infpyng/config/config.toml
     # vi /dir/from/host/infpyng/config/hosts.toml
    
  4. Run Infpyng python script

     # python /dir/from/host/infpyng/infpyng.py &
    

⁠Grafana

Grafana allows you to query and visualize metrics stored in InfluxDB.

You can use my dashboard example⁠ or you can create your own.

⁠Logger

By default the Infpyng logs are located in /var/log/infpyng.log

2020-05-26 09:19:41 root INFO :: Settings loaded successfully
2020-05-26 09:19:41 root INFO :: Init InfluxDB successfully
2020-05-26 09:19:41 root INFO :: Starting Infpyng Multiprocessing v1.0.0
2020-05-26 09:19:41 root INFO :: Polling time every 300s
2020-05-26 09:19:41 root INFO :: Total of targets : 1883  
2020-05-26 09:19:41 root INFO :: Multiprocessing : 40  
2020-05-26 09:19:41 root INFO :: Buckets : 47  
2020-05-26 09:19:51 root INFO :: Targets alive : 1883  
2020-05-26 09:19:51 root INFO :: Targets unreachable : 0  
2020-05-26 09:19:51 root INFO :: Data written to DB successfully  
2020-05-26 09:19:51 root INFO :: Finished in : 9.94 seconds  

⁠Metrics

⁠Format
  • infpyng
    • tags:
      • host (host name)
      • target
    • fields:
      • packets_transmitted (integer)
      • packets_received (integer)
      • percent_packets_loss (float)
      • average_response_ms (float)
      • minimum_response_ms (float)
      • maximum_response_ms (float)
⁠Example Output
infpyng,country=de,host=TIG,server=germany,target=facebook.de average_response_ms=21.2,maximum_response_ms=21.8,minimum_response_ms=20.7,packets_received=2i,packets_transmitted=2i,percent_packet_loss=0i 1589193188000000000  

⁠Github contributors lib

⁠Licensing

This project is released under the terms of the MIT Open Source License. View LICENSE file for more information.

Tag summary

Content type

Image

Digest

Size

27.4 MB

Last updated

over 6 years ago

docker pull oijkn/infpyng