PHP application to display status and information from the Terracoin node daemon.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 49 commits ahead, 10 commits behind craigwatson:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
css
html
img
js
manifests
php
.gitignore
.travis.yml
LICENSE
README.md
Vagrantfile
android-chrome-192x192.png
android-chrome-256x256.png
apple-touch-icon.png
chartdata.php
composer.json
composer.lock
difficulty.php
favicon-16x16.png
favicon-32x32.png
favicon.ico
index.php
manifest.json
masternodecount.php
mstile-144x144.png
peercount.php
run_tests.sh
safari-pinned-tab.svg
screenshot-dark.png
screenshot-light.png
stats.php
sysstats.php

README.md

terracoind-status

This is a small PHP application designed to display status and information from the Terracoin node daemon.

Table of Contents

  1. Requirements
  2. Getting Started
  3. Contributing
  4. Advanced Configuration Options
  5. Licensing

Requirements

To run the application, you will need:

  • A Terracoin node with RPC enabled.
  • A web-server with PHP installed.
  • The PHP curl module - this is used to make RPC calls to the Terracoin daemon.

Getting Started

To get started, all you need to do is copy/rename php/config.sample.php to php/config.php and configure your node's RPC credentials. The application will connect to your node via RPC and report statistics.

To use Google Analytics, simply create a file called google_analytics.inc inside the php directory and paste your GA code into it.

Collecting Connection Statistics

The script can also periodically collect the current number of connections as well as peer protocol versions and store it for display via Google Charts on your status page.

To do this, just schedule the /stats.php, /peercount.php, masternodecount.php, difficulty.php, sysstats.php scripts to be called at whatever interval you like, then config.php to enable the chart display. You can optionally tweak the settings under each section if you want to keep more or less data.

  • /stats.php will create a graph showing the number of connections over time.
  • /peercount.php will create a graph showing the most common protocol versions over time.
  • /masternodecount.php will create a graph showing the masternode and enabled counts over time.
  • /difficulty.php will create a graph showing the difficulty over time.
  • /sysstats.php will create a graph showing the load/memory over time.

Below are two example crontab entries to call the scripts every five minutes via curl. It is highly recommended to only allow 127.0.0.1 to call the script, as allowing other IP addresses could lead to your node becoming vulnerable to DDoS attacks.

*/5 *  *   *   *  curl -Ssk http://127.0.0.1/stats.php > /dev/null
*/5 *  *   *   *  curl -Ssk http://127.0.0.1/peercount.php > /dev/null
*/5 *  *   *   *  curl -Ssk http://127.0.0.1/masternodecount.php > /dev/null
*/5 *  *   *   *  curl -Ssk http://127.0.0.1/difficulty.php > /dev/null
*/5 *  *   *   *  curl -Ssk http://127.0.0.1/sysstats.php > /dev/null

Node Profile Icons

To configure profile icons for your node, just set them up using the node_links variable in config.php. The format is a multi-dimensional array, as below. Icon images for Bitnodes.21.co and Blockchain.info are included in the img directory.

    'node_links' => array (
        array (
            'name' => 'bitnodes.earn.com',
            'image'=> 'img/bitnodes.earn.com.png',
            'link' => 'https://bitnodes.earn.com/nodes/[IP]-[PORT]/'
        ),
        array (
            ...
        )
    ),

Ignoring Certain Peers

To ignore any specific peer from appearing in the connections table. Write the IPv4 or IPv6 address of the peer in the array like the example below.

    'peers_to_ignore' => array (
        '192.168.0.10',
        '[2a01:4f8:121:14f7::2]'
  ),

Peer Count Nodes

To add more node types to the chart, simply add an entry into the peercount_extra_nodes array in config.php.

The key of the entry is an internal-only identifier, and the value is the lower-case text that should be matched in order to increment the counter.

Contributing

Contributions and testing reports are extremely welcome. Please submit a pull request or issue on GitHub, and make surei that your code conforms to the PEAR PHP coding standards.

I accept tips via Terracoin to 1LMF4gAhwUX8TN6e5Ff6m89oZG2HRcg7jL - if you would like to buy me a beer, please do!

Advanced Options

The config.php file also contains lots of options to control how the application behaves, and is separated out into loose sections:

RPC

Value Type Default Explanation
rpc_user String rpcuser Username for RPC calls
rpc_pass String rpcpass Password for RPC calls
rpc_host String localhost Which RPC host to connect to
rpc_port String 13332 Port to use for the RPC connection
rpc_ssl Boolean false Enables SSL for the RPC connection
rpc_ssl_ca String null The SSL CA chain file

Donations

Value Type Default Explanation
display_donation_text Boolean false Display text to encourage donations
donation_address String not_set Terracoin address to advertise for donations
donation_amount String 0.001 Donation amount - not currently implemented

Peers

Value Type Default Explanation
display_peer_info Boolean false Display connected peers
display_peer_port Boolean false Display remote peer's port
hide_dark_peers Boolean true Hides peers connected from "Dark" networks
ignore_unknown_ping Boolean false Hides peers that do not report pingtime
peers_to_ignore Array array() List of peers not to display in the peer list

Cache

Value Type Default Explanation
cache_geo_data Boolean true Enables caching of geolocation data
geo_cache_file String /tmp/terracoind-geolocation.cache File location for the geolocation cache
geo_cache_time Int 604800 Time in seconds until geolocation cache expires - defaults to 7 days
use_cache Boolean true Enable cache
cache_file String /tmp/terracoind-status.cache File location to write to for cache
max_cache_time Int 300 Expiry time for cache
nocache_whitelist Array array('127.0.0.1') The IP addresses that are allowed to bypass or clear cache

Geolocation

Value Type Default Explanation
geolocate_peer_ip Boolean false Geolocate peers' IP addresses
display_ip_location Boolean false Geolocate node IP address

UI

Value Type Default Explanation
display_ip Boolean false Display the server IP address
display_free_disk_space Boolean false Displayfree disk space
display_testnet Boolean false Display testnet status
display_masternode Boolean false Display masternode status
display_version Boolean true Display node terracoind version
display_github_ribbon Boolean true Displays the 'Fork me on GitHub' ribbon
use_terracoind_ip Boolean true Use the Terracoin daemon to get the public IP, instead of $_SERVER
intro_text String not_set Introductory text to display above the node statistics.
display_chart Boolean false Displays a chart showing the stats collected by the stats.php script
chart_min_data_points Int 5 Minimum data points to collect before displaying chart
display_peer_chart Boolean false Displays a chart showing the mix of node versions connected to your node
display_masternode_chart Boolean false Displays a chart showing the enabled vs total masternodes
display_difficulty_chart Boolean false Displays a chart showing the difficulty
display_load_chart Boolean false Displays a chart showing the system load
display_memory_chart Boolean false Displays a chart showing the system memory, swap and total percentage used
node_links Array array() Displays links to various other profiles for your node. Takes the form of a multidimensional array, see example

Stats

Value Type Default Explanation
stats_whitelist Array array('127.0.0.1') Hosts that can run the stats script
stats_file String /tmp/terracoind-status.data File to store stats
stats_max_age String 172800 Maximum age for stats

Peer Count Stats

Value Type Default Explanation
peercount_whitelist Array array('127.0.0.1') Hosts that can run the host-count script
peercount_file String /tmp/terracoind-peers.data File to store host-count
peercount_max_age String 172800 Maximum age for host-count
peercount_extra_nodes Array array() Key-Value array of extra node types to count (value = regex)

Masternode Count Stats

Value Type Default Explanation
masternodecount_file String /tmp/terracoind-mns.data File to store masternode-count
masternodecount_max_age String 172800 Maximum age for masternode-count

Network Difficulty

Value Type Default Explanation
difficulty_file String /tmp/terracoind-difficulty.data File to store diffculty
difficulty_max_age String 172800 Maximum age for difficulty

System Load Average

Value Type Default Explanation
load_file String /tmp/terracoind-sysload.data File to store system load
load_max_age String 172800 Maximum age for system load

System Memory Usage

Value Type Default Explanation
memory_file String /tmp/terracoind-sysmem.data File to store system memory usage
memory_max_age String 172800 Maximum age for system memory

Uptime

Value Type Default Explanation
display_terracoind_uptime Boolean true Displays the uptime of the Terracoin daemon
terracoind_process_name String terracoind Name to use when getting the terracoin daemon process' uptime

System

Value Type Default Explanation
date_format String H:i:s T, j F Y PHP date fuction format to use when outputting dates
timezone String null Timezone to use for dates. Set to null to use system default
stylesheet String v2-light.css CSS Stylesheet to use
debug Boolean false If enabled, the contents of $data is echoed in HTML comments
admin_email String admin@example.com Email address to display on error

Important Note

  • Do not disable cache unless you either have an alternative mechanism or your node is protected from potential DDoS attacks.
  • If you use /tmp for cache data it will reset on reboot.

Licensing