traaittplatform-node-monitor
v1.0.4
Published
A traaittPlatform public node monitor agent that monitors, polls, and logs public node availability and basic information to MySQL/MariaDB backend.
Downloads
4
Readme
Prerequisites
- Node.js >= 6.x
- MySQL/MariaDB
- Load the database schema
Install
Collection Service
npm install -g traaittplatform-node-monitor
export MYSQL_HOST=<server ip>
export MYSQL_PORT=<server port>
export MYSQL_USERNAME=<server username>
export MYSQL_PASSWORD=<server password>
export MYSQL_DATABASE=<database>
traaittplatform-node-monitor
Additional Options
export MYSQL_SOCKET=<server socket path (default: not set)>
export MYSQL_CONNECTION_LIMIT=<# of maximum server connections (default: 10)>
export HISTORY_DAYS=<# of days to keep history (default: 6 hours)>
export UPDATE_INTERVAL=<# of seconds between updating node list (default: 1 hour)>
export POLLING_INTERVAL=<# of seconds between checking nodes (default: 120s)>
export NODE_LIST_URL=<Full URL to node list (default: traaittplatform-nodes-json)>
As a Module for Pulling Stats
npm install --save traaittplatform-node-monitor
Sample Code
const StatsDatabase = require('traaittplatform-node-monitor')
const db = new StatsDatabase({
host: 'localhost',
port: 3306,
username: 'root',
password: 'password',
database: 'traaittplatform',
connectionLimit: 10
})
db.getNodeStats().then((stats) => {
console.log(stats)
})
Database Schema
CREATE TABLE IF NOT EXISTS `nodes` (
`id` varchar(64) NOT NULL,
`name` varchar(255) NOT NULL,
`hostname` varchar(255) NOT NULL,
`port` int(11) NOT NULL DEFAULT 23896,
`ssl` int(11) NOT NULL DEFAULT 0,
`cache` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `ssl` (`ssl`),
KEY `cache` (`cache`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `node_polling` (
`id` varchar(64) NOT NULL,
`timestamp` bigint(1) unsigned NOT NULL,
`status` int(11) NOT NULL DEFAULT 0,
`feeAddress` varchar(255) DEFAULT NULL,
`feeAmount` bigint(20) NOT NULL DEFAULT 0,
`height` bigint(20) NOT NULL DEFAULT 0,
`version` varchar(20) NOT NULL DEFAULT '0.0.0',
`connectionsIn` int(11) NOT NULL DEFAULT 0,
`connectionsOut` int(11) NOT NULL DEFAULT 0,
`difficulty` bigint(20) NOT NULL DEFAULT 0,
`hashrate` bigint(20) NOT NULL DEFAULT 0,
`txPoolSize` bigint(20) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`,`timestamp`),
KEY `status` (`status`),
KEY `feeAmount` (`feeAmount`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;
Author
traaittPlatform
The traaittPlatform Developers
License
Copyright © 2020 traaittPlatform Copyright © 2019 The traaittPlatform Developers. This project is AGPL-3.0 licensed.