Skip to content
This repository has been archived by the owner. It is now read-only.
Ping monitoring engine used in https://ping.gg
Go
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples parametrize redis config May 2, 2016
httping
io parametrize redis config May 2, 2016
ping Fix typo Jan 12, 2016
LICENSE
README.md README example typo Jul 21, 2015
monitor.go Host{} becomes HostStatus{} Apr 8, 2016
pool.go Host{} becomes HostStatus{} Apr 8, 2016
pool_test.go Host{} becomes HostStatus{} Apr 8, 2016

README.md

Disclaimer: If you are new to Go this is not a good place to learn best practices, the code is not very idiomatic and there's probably a few bad ideas.

What's this?

pingd is the ping engine used by the ping.gg monitoring service. It allows to simultaneously ping hundreds of IPs and can manage which hosts are being pinged during runtime.

The system is meant to be composed (or embedded) by you and requires up to 3 compatible functions to:

  1. load an initial set of hosts to monitor
  2. receive commands to start and stop monitoring a given host
  3. publish host UP or host DOWN events

These functions must be the following types respectively.

type Loader func(chan<- Host)
type Receiver func(chan<- Host, chan<- Host)
type Notifier func(<-chan Host)

There are some implementations of these functions available under pingd/io.

Usage example

NOTE: Before you run anything, remember that ICMP echo (ping) requires root privileges for raw socket access. If you don't want to sudo every time consider using setuid

To create your own private ping.gg alternative:

 # get the example
export GOPATH=$PWD
go get github.com/pinggg/pingd/examples/httpmail

 # start pinging 8.8.8.8 and 8.8.4.4 and email you if they go down
sudo bin/httpmail -email=mymail@example.org 8.8.8.8 8.8.4.4

 # add a new host while running
curl localhost:7700/4.4.2.2

 # stop pinging 8.8.4.4
curl -XDELETE localhost:7700/8.8.4.4

Keep in mind that this is just an example which assumes that there is a local mail server running on port 25. Take a look at the sendMail function and adapt it to your needs. For example, to send the emails via Gmail.

https://ping.gg uses in production a configuration like the redis example allowing the website to interact with pingd via redis pub/sub.

You can add your own functions to have pingd interact with the world. For example, switching on some red light with the help of a Raspberry Pi.

You can’t perform that action at this time.