Giter Club home page Giter Club logo

ping-exporter's Introduction

ping-exporter

Introduction

Prometheus Ping Exporter is a simple python script which utilize fping to probe endpoint through ICMP and parsing the output to Prometheus. The result can then be visualize through Grafana with ease.

Requirements

  • Python 2.x
  • fping 4.x

Screenshots alt text

For Debian user, you can get the fping deb file from http://ftp.debian.org/debian/pool/main/f/fping/fping_4.0-1_armhf.deb

For docker user, you can build the container with the Docker file (based on alpine around 54M). For arm user, you can change FROM to "armhf/alpine:edge"

PS: The script is working fine with > 40 ping target in a PI 3B.

Getting Started

  1. Download ping-exporter.py and place it inside /opt/
# cd /opt/ 
# curl  -O https://raw.githubusercontent.com/frankiexyz/ping-exporter/master/ping-exporter.py
  1. Ensure Correct Permission on ping-exporter.py
# chmod 755 /opt/ping-exporter.py
  1. Running The Ping Exporter
# /usr/bin/python /opt/ping-exporter.py
  1. Testing The Script
# curl "127.0.0.1:8085/?target=8.8.8.8"

Running Script On System Startup

CentOS 7 (Using Systemd)

  1. Create a new ping_exporter.service file at /lib/systemd/system/
vi /lib/systemd/system/ping_exporter.service
  1. Paste The Following into ping_exporter.service
[Unit]
Description=Ping Exporter for Prometheus (Created By Frankie)
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python /opt/ping-exporter.py

[Install]
WantedBy=multi-user.target
  1. Save The File and Execute systemctl daemon-reload
# systemctl daemon-reload
  1. Start and Enable Ping Exporter Service
# systemctl start ping_exporter.service
# systemctl enable ping_exporter.service

Configuration

Prometheus Configuration

Append the following in prometheus's config (Default is prometheus.yml)

  - job_name: 'ping-exporter'
    scrape_interval: 60s
    metrics_path: /probe
    params:
         prot: ['4']
    static_configs:
      - targets:
          - www.ifconfig.xyz
          - www.google.com
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
        replacement: ${1}
      - source_labels: [__param_target]
        regex: (.*)
        target_label: instance
        replacement: ${1}
      - source_labels: []
        regex: .*
        target_label: __address__
        replacement: <Your exporter IP>:8085

You might want to add or change the following parameters in params's section to match your requirements

    params:
         # Default Is IPv4, Can Be Changed To IPv6
         prot: ['4']

         # Ping Packet Size (Default value is 56)
         size: ['56']

         # Ping Count (Default value is 10 times)
         count: ['10']

         Ping Interval (Default value is 500ms)
         interval: ['500']

ping-exporter's People

Contributors

frankiexyz avatar hmmxp avatar tiphedor avatar caimaoy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.