Bitcoin Forum
November 09, 2024, 03:34:30 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Cacti monitoring/stats graphing template for mining pools  (Read 5366 times)
JinTu (OP)
Full Member
***
Offline Offline

Activity: 133
Merit: 100



View Profile
June 27, 2011, 09:44:45 PM
Last edit: May 09, 2012, 06:49:03 AM by JinTu
 #1

Hi folks,

I wanted to share my work on a Cacti template for monitoring mining pools (BTC Guild and Slush are currently supported). The templates (and included scripts) leverage the mining pool's JSON feeds to generate reasonably pretty graphs for the health of your account, worker (miner) performance and overall pool performance (if the pool supports this). With Cacti's PIA and the THold plugin you could take this further and define alert thresholds to notify you of a change if anything falls out of tolerance.

Unlike some of the pool monitoring services out there, this is entirely free. However, if you feel so inclined, donations are much appreciated and help encourage the development of additional features and support for more pools.  With a little effort, you too can set up your own monitor to keep an eye on all your miners and the pools they use using these templates.

Here are a few teaser graphs from my miners:



Slush's Pool

User Rewards


Worker Hash Rate (OpenCL)


Worker Hash Rate (Total all workers)


Worker Last Share (OpenCL)


Worker Last Share (Total all workers)


Worker Score (OpenCL)


Worker Score (Total all workers)


Worker Shares (OpenCL)


Worker Shares (Total all workers)






BTC Guild

Difficulty


Difficulty (NMC)


Pool PPS Rate


Pool PPS Rate (NMC)


Pool Speed


24 Hour Rewards


24 Hour Rewards (NMC)


Paid Rewards


Paid Rewards (NMC)


Total Rewards


Total Rewards (NMC)


Unpaid Rewards


Unpaid Rewards (NMC)


Worker Hash Rate


Worker Last Share


Worker Shares


Worker Shares (NMC)


Worker Shares Since Reset


Worker Shares Since Reset



Revision History
  • v0.07 5/8/2012
    Major rework for comprehensive support of the new BTC Guild PPS API and simplification of the script. Required nearly all related Cacti templates to be reworked as well. Added NMC stats. Removed Pool stats as there is no API support by BTCGuild for pool stats anymore.  At the time of writing, BTC Guild only allows one API connection per 60 seconds, so memcached is essentially required now.
  • v0.06 10/24/2011
    Initial support of BTC Guild following their move to PPS. Worker Cumulative Total, Worker Last Share, Worker Reset Shares and Worker Total are not currently working properly and more work is needed to correct this.
  • 7/18/2011
    Removed pool and worker round stats for BTC Guild as these are no longer supported in the API.
  • v0.05 7/14/2011
    Added 24 hour totals now that this has been added to the BTC Guild JSON. Minor bugfix to not blow up when we "never" in last_share responses. Added Worker Last Share.
  • v0.04 7/6/2011
    Added support for Slush's pool. Minor bugfixes for worker indexing in BTC Guild script after the addition of worker totals. Added more specific memcached namespace to allow multiple accounts to be monitored from the same Cacti instance sharing memcached. Added simple check for when the API JSON gives us null.
  • v0.03 7/4/2011
    Added total all workers (sum of all workers) to script as this is lacking in the API JSON. Added the following graph templates: Worker Reset, Worker Cumulative Total, Blocks Found and Payouts.
  • v0.02 6/29/2011
    Added simple JSON caching via memcached resulting in big performance boost:
      Before -> SYSTEM STATS: Time:114.1648 Method:spine Processes:2 Threads:4 Hosts:12 HostsPerProcess:6 DataSources:159 RRDsProcessed:105
      After  -> SYSTEM STATS: Time:19.5116 Method:spine Processes:2 Threads:4 Hosts:12 HostsPerProcess:6 DataSources:159 RRDsProcessed:105
  • v0.01 6/28/2011
    First working version.  No JSON query caching support (Slow!).
JinTu (OP)
Full Member
***
Offline Offline

Activity: 133
Merit: 100



View Profile
June 27, 2011, 09:45:13 PM
Last edit: May 08, 2012, 11:50:05 PM by JinTu
 #2

Installation Instructions

Prerequisites
  • Installed and operational instance of Cacti (Spine and cmd.php pollers both work fine)
  • Perl 5.8.5 or later
  • HTTP::Request Perl module
  • LWP Perl module
  • JSON Perl module
  • JSON::XS Perl module
  • Optional Cache::Memcached Perl module

Install procedure
  • Grab latest script/templates zip package from here.
  • Unzip the archive
  • Edit btcguild_worker_stats.xml and slush_worker_stats.xml replacing REPLACE_WITH_YOUR_API_KEY with your API key from here: http://www.btcguild.com/my_api.php for BTC Guild and here: http://mining.bitcoin.cz/accounts/token-manage/ for Slush's pool.
  • Move btcguild_worker_stats.xml and slush_worker_stats.xml into your script_queries directory (i.e. cacti/resource/script_queries/)
  • Move query_btcguild_stats.pl and query_slush_stats.pl into your scripts directory (i.e. cacti/scripts/)
  • Ensure query_btcguild_stats.pl and query_slush_stats.pl run (perl query_btcguild_stats.pl generates the help text). If this doesn't work (you see an error about something missing) see the troubleshooting post for resolving Perl issues.
  • Import the cacti_host_template_btc_guild.xml and/or cacti_host_template_slush.xml host templates from the Cacti GUI
  • Create a new host in Cacti, selecting the BTC Guild or Slush host template. Be sure to disable Downed Host Detection and SNMP. Set the hostname to www.btcguild.com for BTC Guild or mining.bitcoin.cz for Slush.
  • Ensure the Re-Index Method for the Data Queries is set to Index Count Changed
  • Click on Create Graphs for this Host
  • Select the relevant Graph Templates and Worker and Pool Data Queries
  • Click on create
  • You will be prompted for the API Key for each the graph templates. Enter the key from here: http://www.btcguild.com/my_api.php
  • Click Go
  • put the graphs or host in the Graph Tree branch of your choosing
  • Have fun!

Optional install procedure
  • v0.02 of the script supports memcached for greatly improved polling performance.
  • For BTC Guild: uncomment lines 54-56 in query_btcguild_stats.pl, and edit line 56 to point to your memcached instance.
  • For Slush: uncomment lines 31-33 in query_slush_stats.pl, and edit line 33 to point to your memcached instance.

Notes
  • Polling the BTC Guild API JSON can take 5-10 seconds per iteration. This means the total polling time can be quite long.
  • If you are monitoring a lot of workers or pools it is possible that you may cause your poller to exceed 300 seconds (since checks for the same host are executed serially), and abort polling after running out of time. Monitor your Cacti logs for Poller Runtime Exceeded errors and keep an eye on the poller execution time. If the poller time is longer than what you would like, enable memcached support in the script.
JinTu (OP)
Full Member
***
Offline Offline

Activity: 133
Merit: 100



View Profile
June 27, 2011, 09:45:41 PM
Last edit: July 06, 2011, 11:38:01 PM by JinTu
 #3

Trouble Shooting

Perl issues
  • The most common Perl issue is missing modules. Have a look at this link for assistance in setting up CPAN and testing for missing modules.
  • If you have a Redhat-based distro (RHEL, CentOS, etc), and would prefer to use the RPMs instead of mucking about with CPAN, the perl-libwww-perl RPM (from upstream provider) contains HTTP::Request and other LWP modules. perl-JSON, perl-JSON-XS and perl-Cache-Memcached RPMs are available on RPM Forge and/or EPEL
  • These modules are also available in PPM form for ActiveState's ActivePerl on Windows, but as I don't run Windows I can't verify the details.

Poller Runtime Exceeded
  • Enable support for memcached. If this is not an option for you, then you must delete any unnecessary graphs and data sources.
JinTu (OP)
Full Member
***
Offline Offline

Activity: 133
Merit: 100



View Profile
May 09, 2012, 06:55:54 AM
 #4

I finally got around to updating the templates/scripts for BTC Guild so everything works (again). Too many things had changed with the API after the switch to PPS to warrant preserving the original graph templates so almost everything has been completely redone.

Let me know if you see anything weird.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!