Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/js/script.js
  • Loading branch information
martinmedina committed Oct 31, 2016
2 parents 55a9721 + c9d4e17 commit 52fc2c2
Show file tree
Hide file tree
Showing 26 changed files with 234 additions and 81 deletions.
File renamed without changes.
113 changes: 113 additions & 0 deletions Metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Metrics

## Introduction

The server keeps a list of the last blocks in the mainchain. Using that list, it generates data
that it sends to the client to be rendered.

The list of blocks (the blockchain) is kept by `lib/history.js`, a fragment:


```js
var MAX_HISTORY = 2000;

var MAX_PEER_PROPAGATION = 40;
var MIN_PROPAGATION_RANGE = 0;
var MAX_PROPAGATION_RANGE = 10000;

var MAX_UNCLES = 1000;
var MAX_UNCLES_PER_BIN = 25;
var MAX_BINS = 40;

var History = function History(data)
{
this._items = [];
this._callback = null;
}

```

The callback function, if defined, is called when the data is changed, ie, a new block arrived to be
processed.

## Multiple Values

### Block Time

A list of times to produce a new block, ordered by ascending height.

### Difficulty

A list of block difficulty, ordered by ascending height.

### Block Propagation

A list of times (delta 0.5 seconds), counting the number of blocks that propagate in that interval.
Each block has many propagation times, one per reached node.

### Last Blocks Miners

A list of miners ids, that mined the blocks in the current history.

### Uncle Count

Count of uncles, in the current block history. Each count is the sum of uncle counts in 25 blocks.

### Transactions

Number of transactions in the last blocks in current history.

### Gas Spending

Gas amount spent in each executed block.

### Gas Limit

Gas limit per block in history.

## Single Values

### Best Block

The number of the best mined block added to the main chain.

### Uncles

Number of uncles in current block vs count of uncles in last 50 blocks.

### Last Block

Time elapsed from last mined block.

### Average Block Time

Sum of block times divided by number of blocks in history.

### Average Network Hashrate

Difficulty of best block divided by average of block time (time since previous block)

### Difficulty

Last block difficulty.

### Active Nodes

Number of active nodes vs number of total nodes.

### Gas Price

Gas price in node with best block.

### Gas Limit

Gas limit in best block.

### Page Latency

Latency obtaining data.

### Uptime

Percentage of nodes uptime.

23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Ethereum Network Stats
============
[![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url]
RSK Network Stats
==================

This is a visual interface for tracking ethereum network status. It uses WebSockets to receive stats from running nodes and output them through an angular interface. It is the front-end implementation for [eth-net-intelligence-api](https://github.com/cubedro/eth-net-intelligence-api).
This is a visual interface for tracking rsk status. It uses WebSockets to receive stats from running nodes and output them through an angular interface. It is the front-end implementation for [network-intelligence-api](https://github.com/rootstock/network-intelligence-api).

![Screenshot](https://raw.githubusercontent.com/cubedro/eth-netstats/master/src/images/screenshot.jpg?v=0.0.6 "Screenshot")
![Screenshot](https://github.com/rootstock/stats/blob/master/src/images/screenshot.png?raw=true "Screenshot")

## Prerequisite
* node
Expand All @@ -16,8 +15,8 @@ Make sure you have node.js and npm installed.
Clone the repository and install the dependencies

```bash
git clone https://github.com/cubedro/eth-netstats
cd eth-netstats
git clone https://github.com/rootstock/stats.git
cd stats
npm install
sudo npm install -g grunt-cli
```
Expand Down Expand Up @@ -49,7 +48,9 @@ npm start

see the interface at http://localhost:3000

[travis-image]: https://travis-ci.org/cubedro/eth-netstats.svg
[travis-url]: https://travis-ci.org/cubedro/eth-netstats
[dep-image]: https://david-dm.org/cubedro/eth-netstats.svg
[dep-url]: https://david-dm.org/cubedro/eth-netstats

To update geoip-lite db run

``` bash
npm explore geoip-lite -- npm run updatedb
```
7 changes: 5 additions & 2 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ Collection.prototype.update = function(id, stats, callback)
{
var propagationHistory = this._blockchain.getNodePropagation(id);

var time = (new Date()).getTime();
var diffblockrecived = Math.floor((time + this.timeDifference - block.block.received )/1000);
var diffpropagation = Math.floor((time + this.timeDifference - block.block.propagation )/1000);
stats.block.arrived = block.block.arrived;
stats.block.received = block.block.received;
stats.block.propagation = block.block.propagation;
stats.block.received = Math.abs(diffblockrecived);
stats.block.propagation = Math.abs(diffpropagation);

node.setStats(stats, propagationHistory, callback);
}
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eth-netstats",
"description": "Ethereum Network Intelligence dashboard",
"name": "rsk-netstats",
"description": "RSK Stats",
"version": "0.0.9",
"private": true,
"engines": {
Expand All @@ -11,26 +11,26 @@
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "1.13.3",
"chalk": "1.1.1",
"body-parser": "1.15.2",
"chalk": "1.1.3",
"d3": "3.5.6",
"debug": "2.2.0",
"express": "4.13.3",
"geoip-lite": "1.1.6",
"express": "4.14.0",
"geoip-lite": "1.1.8",
"jade": "1.11.0",
"lodash": "3.10.1",
"primus": "3.2.1",
"primus-emit": "0.1.2",
"primus-spark-latency": "0.1.1",
"ws": "0.8.0"
"ws": "1.1.1"
},
"repository": {
"type": "git",
"url": "https://github.com/cubedro/eth-netstats.git"
"url": "https://github.com/rootstock/rsk-netstats.git"
},
"homepage": "https://github.com/cubedro/eth-netstats",
"homepage": "https://github.com/rootstock/rsk-netstats",
"bugs": {
"url": "https://github.com/cubedro/eth-netstats/issues"
"url": "https://github.com/rootstock/rsk-netstats/issues"
},
"authors": [
{
Expand Down
Binary file modified src-lite/images/favicon.ico
Binary file not shown.
Binary file modified src-lite/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src-lite/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-63657296-1', 'auto');
ga('create', 'UA-85399009-1', 'auto');
ga('send', 'pageview');
6 changes: 6 additions & 0 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ span.small-title span.small {
.second-row .box .small-value {
float: right;
}

.second-row .box .based-on {
float: right;
font-size: small;
color: grey;
}
.big-info .small-value {
position: absolute;
right: 14px;
Expand Down
Binary file modified src/images/favicon.ico
Binary file not shown.
Binary file modified src/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/images/screenshot-v0.0.1.jpg
Binary file not shown.
Binary file removed src/images/screenshot-v0.0.2.jpg
Binary file not shown.
Binary file removed src/images/screenshot-v0.0.5.jpg
Binary file not shown.
Binary file removed src/images/screenshot.jpg
Binary file not shown.
Binary file added src/images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 24 additions & 3 deletions src/js/controllers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

/* Controllers */

netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, socket, _, toastr) {
netStatsApp.controller('StatsCtrl', function($scope, $timeout, $filter, $localStorage, socket, _, toastr) {

var MAX_BINS = 40;

//$timeout(reloadScreen, 60000);

// Main Stats init
// ---------------

Expand Down Expand Up @@ -122,7 +124,7 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
});

socket.on('init', function(data)
{
{
$scope.$apply(socketAction("init", data.nodes));
});

Expand Down Expand Up @@ -401,8 +403,23 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
break;

case "client-ping":

var serverTime = data.serverTime;
/*
console.log("===========================================");
console.log("client time: " + new Date());
console.log("server time: " + new Date(serverTime));
console.log("===========================================");
*/

$scope.serverTime = serverTime;
$scope.timeDifference = serverTime - _.now();
if ($scope.timeDifference < 3000)
$scope.timeDifference = 0;


socket.emit('client-pong', {
serverTime: data.serverTime,
serverTime: serverTime,
clientTime: _.now()
});

Expand Down Expand Up @@ -651,4 +668,8 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, $localStorage, soc
} else
return obj;
}

function reloadScreen() {
location.reload();
}
});
44 changes: 35 additions & 9 deletions src/js/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,43 @@ angular.module('netStatsApp.filters', [])
})
.filter('blockTimeFilter', function() {
return function(timestamp) {

if(timestamp === 0)
return '∞';

// var time = Math.floor((new Date()).getTime() / 1000);

// Ruben - testing new time difference calcuation not based on client time
var time = (new Date()).getTime();
var diff = Math.floor((time - timestamp)/1000);

if(diff < 60)
return Math.round(diff) + ' s ago';

return moment.duration(Math.round(diff), 's').humanize() + ' ago';
//var diff = Math.floor((time - timestamp)/1000);

var diff = Math.floor((time + this.timeDifference - timestamp )/1000);


console.log("===========================================");
console.log("client time: " + new Date(time));
console.log("adjusted time time: " + new Date(time + this.timeDifference));
console.log("last block: " + new Date(timestamp));
console.log("===========================================");


var absVal = Math.abs(diff);

var result = '';
if(absVal < 60) {
result += Math.round(absVal) + ' s ';
} else {
result += moment.duration(Math.round(absVal), 's').humanize() + ' ';
}

if(diff >= 0) {
result += ' ago';
} else {
result = '0 s';
// result += ' ITF';
}

return result;
};
})
.filter('networkHashrateFilter', ['$sce', '$filter', function($sce, filter) {
Expand Down Expand Up @@ -658,13 +684,13 @@ function timeClass(timestamp)

function blockTimeClass(diff)
{
if(diff <= 13)
if(diff <= 35)
return 'text-success';

if(diff <= 20)
if(diff <= 50)
return 'text-warning';

if(diff <= 30)
if(diff <= 70)
return 'text-orange';

return 'text-danger'
Expand Down
13 changes: 6 additions & 7 deletions src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
$.fn.sparkline.defaults.bar.tooltipFormat = $.spformat('<div class="tooltip-arrow"></div><div class="tooltip-inner">{{prefix}}{{value}} {{suffix}}</div>');
$.fn.sparkline.defaults.bar.colorMap = $.range_map({
'0:6': '#10a0de',
'6:15': '#7bcc3a',
'15:40': '#FFD162',
'40:60': '#ff8a00',
'60:': '#F74B4B'
'6:35': '#7bcc3a',
'35:50': '#FFD162',
'50:70': '#ff8a00',
'70:': '#F74B4B'
});

moment.relativeTimeThreshold('s', 60);
Expand All @@ -30,8 +30,7 @@
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

// ga('create', 'UA-68390837-2', 'auto');
ga('create', 'UA-80834434-1', 'auto');
ga('create', 'UA-85399009-1', 'auto');
ga('send', 'pageview');
Loading

0 comments on commit 52fc2c2

Please sign in to comment.