Skip to content

iMilnb/collectd-ticker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ticker: a collectd plugin to watch your assets grow (hopefully)

Ticker is a collectd plugin written in golang that monitors cryptocurrencies pairs values on various exchanges in order to graph them using systems like InfluxDB and Grafana.

ticker screenshot

Build

First, install golang version 1.7 or superior.

Then install go-collectd.

Finally, install the collectd-dev package from your distribution. On Debian and derivatives, a wrong patch is applied to /usr/include/collectd/core/daemon/configfile.h as mentioned in this bug report. In this file, change:

#include "collectd/core/config.h"

to

#include "collectd/liboconfig/oconfig.h"

In order to build the ticker collectd plugin, type

$ make plugin

To build the Exec version, type

$ make exec

To build both of them, simply type

$ make

You might need to modify collectd includes path in the COLLECTD_SRC variable from the Makefile depending on your distribution.

Installation

Use

$ make install

To install the plugin in collectd plugin directory as defined in the Makefile, or simply copy the ticker.so plugin to collectd plugin directory, for example in a Debian based system

$ cp ticker.so /usr/lib/collectd/

And add the following to collectd.conf

Interval 60
LoadPlugin ticker

collectd-go does not support collectd configuration framework, so ticker has its own configuration file, which is expected to be located in /etc/collectd and named ticker.json. It is a JSON formatted file composed of

  • Exchange name
  • Exchange API base URL
  • Cryptocurrencies pairs you'd like to monitor. The pairs must be in the format required by the associated exchange
  • Name of the JSON key for currency "last price" in this exchange
  • Optional: a conversion pair. For example, Bittrex does not offer USD pairs, but has a BTC/USDT pair, adding a conversion pair will multiply listed pairs with this factor.

Example

{
  "bitstamp":
    {
      "url": "https://www.bitstamp.net/api/v2/ticker/",
      "pairs": ["ethusd", "xrpusd", "ltcusd", "btcusd"],
      "pricekey": "last"
    },
  "bittrex":
    {
      "url": "https://bittrex.com/api/v1.1/public/getticker?market=",
      "pairs": ["BTC-XEM", "BTC-FUN", "BTC-XVG"],
      "convert": "USDT-BTC",
      "pricekey": "Last"
    },
  "hitbtc":
    {
      "url": "https://api.hitbtc.com/api/2/public/ticker/",
      "pairs": ["COSSBTC"],
      "convert": "BTCUSD",
      "pricekey": "last"
    },
  "bitfinex":
    {
      "url": "https://api.bitfinex.com/v1/pubticker/",
      "pairs": ["neousd", "btgusd"],
      "pricekey": "last_price"
    },
  "binance":
    {
      "url": "https://api.binance.com/api/v1/ticker/price?symbol=",
      "pairs": ["REQBTC", "LINKBTC"],
      "convert": "BTCUSDT",
      "pricekey": "price"
    },
  "coinmarketcap":
    {
      "url": "https://api.coinmarketcap.com/v1/ticker/",
      "pairs": ["kin", "electroneum"],
      "pricekey": "price_usd"
    }
}

You might want to test the plugin using its Exec version to see if everything works as expected.

$ ./ticker
PUTVAL "tatooine/ticker-ethusd/gauge" interval=60.000 1514193796.393:731.99
PUTVAL "tatooine/ticker-xrpusd/gauge" interval=60.000 1514193796.437:1.01117
PUTVAL "tatooine/ticker-ltcusd/gauge" interval=60.000 1514193796.488:278.78
PUTVAL "tatooine/ticker-btcusd/gauge" interval=60.000 1514193796.533:14212.55
PUTVAL "tatooine/ticker-btcxem/gauge" interval=60.000 1514193797.154:1.02831251000075
PUTVAL "tatooine/ticker-btcfun/gauge" interval=60.000 1514193797.361:0.0598963400000434
PUTVAL "tatooine/ticker-btcxvg/gauge" interval=60.000 1514193797.562:0.217641770000158

Exchanges

For now, ticker supports Coinmarketcap, Bitstamp, Bittrex, Bitfinex, Binance and HitBTC.

About

A collectd plugin to watch your assets grow - Moved to https://gitlab.com/iMil

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published