Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
/ graphping Public archive
forked from tinuzz/graphping

Send ping statistics for multiple hosts to Graphite

License

Notifications You must be signed in to change notification settings

polytechas/graphping

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

graphping

Send ping statistics for multiple hosts to Graphite

Description

This Python program takes a list of hostnames to collect ping statistics for. It uses the 'fping' program to do the real work, and send the results to Graphite. By default, it detaches itself from the console and continues to run in the background.

Until stopped, the program starts an 'fping' for all the given targets and sends 30 ICMP ping packets. The results (min, max, average and mean ping round-trip times, as well as packet loss percentage) are sent to a Graphite server, which by default should be running on localhost:2003. It then sleeps until the next minute on the system clock before it starts another 'fping'. This way, you get one measurement per minute. This is not configurable at this time.

By default, it uses 'ping' as a prefix for the metric name in Graphite, followed by the hostname, with dots replaced by underscores. So for a host named 'host.domain.tld', you would get the following metrics in Graphite, all of which are gauges:

  • ping.host_domain_tld.avgrtt
  • ping.host_domain_tld.minrtt
  • ping.host_domain_tld.medianrtt
  • ping.host_domain_tld.maxrtt
  • ping.host_domain_tld.packetloss

Requirements

The program uses regular expressions to get useful numbers from the fping ouput, so it depends on specific formatting of the output. The following fping programs are known to be compatible:

  • version 3.4 on RHEL 6.4
  • version 3.2 on Debian Wheezy

The output should look like this (for 2 hosts, 3 packets per host):

www.github.io  : [0], 84 bytes, 4.26 ms (4.26 avg, 0% loss)
www.google.com : [0], 84 bytes, 8.35 ms (8.35 avg, 0% loss)
www.github.io  : [1], 84 bytes, 3.25 ms (3.75 avg, 0% loss)
www.google.com : [1], 84 bytes, 7.84 ms (8.09 avg, 0% loss)
www.github.io  : [2], 84 bytes, 3.32 ms (3.61 avg, 0% loss)
www.google.com : [2], 84 bytes, 7.86 ms (8.01 avg, 0% loss)

www.github.io  : xmt/rcv/%loss = 3/3/0%, min/avg/max = 3.25/3.61/4.26
www.google.com : xmt/rcv/%loss = 3/3/0%, min/avg/max = 7.84/8.01/8.35

Configuration

Set up a Carbon/Whisper retention schema for the ping statistics, keeping one sample per minute for some time, and optionally some aggregations:

[ping]
pattern = ^ping\.
retentions = 1m:1d,5m:31d,60m:366d

At the top of the script, there are some configurable items. They can be modified by changing the script or setting the corresponding environment variables:

# number of ping packets to send
packets = os.getenv("PACKETS", 30)

# Graphite
g_gost = os.getenv('GRAPHITE_HOST', 'localhost')
g_port = os.getenv('GRAPHITE_PORT', 2003)
g_prefix = os.getenv('GRAPHITE_PREFIX', 'ping')

# System
fping = os.getenv('FPING_PATH', '/usr/sbin/fping')
logfile = os.getenv('LOGFILE', '/tmp/ping-graphite.log')

# Daemonize -- use empty string to set to False
daemonize = bool(os.getenv('DAEMONIZE', True))

Usage

./graphping <target> [<target> ...]

License

Graphping is licensed under the Apache License, version 2.0. A copy of the license can be found in the 'COPYING' file and on the web.

About

Send ping statistics for multiple hosts to Graphite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%