Giter Club home page Giter Club logo

pingd's Introduction

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 protected] 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.

pingd's People

Contributors

bictorman avatar

Watchers

 avatar  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.