added uptime functionality
This commit is contained in:
parent
281a5d7f5b
commit
71ae336715
@ -15,6 +15,11 @@ var Node = function Node(options, id)
|
|||||||
height: 0,
|
height: 0,
|
||||||
hash: '?',
|
hash: '?',
|
||||||
timestamp: 0
|
timestamp: 0
|
||||||
|
},
|
||||||
|
uptime: {
|
||||||
|
down: 0,
|
||||||
|
inc: 0,
|
||||||
|
total: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +51,12 @@ Node.prototype.update = function()
|
|||||||
this.info.stats.active = true;
|
this.info.stats.active = true;
|
||||||
} else {
|
} else {
|
||||||
this.info.stats.active = false;
|
this.info.stats.active = false;
|
||||||
|
this.info.stats.uptime.down++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.info.stats.uptime.inc++;
|
||||||
|
this.info.stats.uptime.total = ((this.info.stats.uptime.inc - this.info.stats.uptime.down) / this.info.stats.uptime.inc) * 100;
|
||||||
|
|
||||||
return this.info;
|
return this.info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,5 +25,6 @@ function StatsCtrl($scope, socket, _) {
|
|||||||
$scope.nodesActive = _.filter($scope.nodes, function(node){ return node.stats.active == true; }).length;
|
$scope.nodesActive = _.filter($scope.nodes, function(node){ return node.stats.active == true; }).length;
|
||||||
$scope.bestBlock = _.max($scope.nodes, function(node){ return parseInt(node.stats.block.height); }).stats.block.height;
|
$scope.bestBlock = _.max($scope.nodes, function(node){ return parseInt(node.stats.block.height); }).stats.block.height;
|
||||||
$scope.lastBlock = _.max($scope.nodes, function(node){ return parseInt(node.stats.block.timestamp); }).stats.block.timestamp;
|
$scope.lastBlock = _.max($scope.nodes, function(node){ return parseInt(node.stats.block.timestamp); }).stats.block.timestamp;
|
||||||
|
$scope.upTimeTotal = _.reduce($scope.nodes, function(total, node){ return total + node.stats.uptime.total; }, 0) / $scope.nodes.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,7 +54,24 @@ angular.module('netStatsApp.filters', [])
|
|||||||
return function(timestamp) {
|
return function(timestamp) {
|
||||||
return timeClass(timestamp);
|
return timeClass(timestamp);
|
||||||
};
|
};
|
||||||
}).filter('geoTooltip', function() {
|
})
|
||||||
|
.filter('upTimeFilter', function() {
|
||||||
|
return function(uptime) {
|
||||||
|
return Math.round(uptime) + '%';
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter('upTimeClass', function() {
|
||||||
|
return function(uptime) {
|
||||||
|
if(uptime >= 90)
|
||||||
|
return 'text-success';
|
||||||
|
|
||||||
|
if(uptime >= 75)
|
||||||
|
return 'text-warning';
|
||||||
|
|
||||||
|
return 'text-danger';
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter('geoTooltip', function() {
|
||||||
return function(geo) {
|
return function(geo) {
|
||||||
return geo.city + ", " + geo.country;
|
return geo.city + ", " + geo.country;
|
||||||
};
|
};
|
||||||
|
@ -35,12 +35,12 @@ block content
|
|||||||
span.big-details(am-time-ago="lastBlock", am-preprocess="unix")
|
span.big-details(am-time-ago="lastBlock", am-preprocess="unix")
|
||||||
div.clearfix
|
div.clearfix
|
||||||
div.col-xs-6.stat-holder
|
div.col-xs-6.stat-holder
|
||||||
div.row.big-info.uptime.text-info
|
div.row.big-info.uptime(class="{{ upTimeTotal | upTimeClass }}")
|
||||||
div.pull-left.icon-full-width
|
div.pull-left.icon-full-width
|
||||||
i.icon-clock
|
i.icon-clock
|
||||||
div.pull-left
|
div.pull-left
|
||||||
span.small-title up-time
|
span.small-title up-time
|
||||||
span.big-details 100%
|
span.big-details {{ upTimeTotal | upTimeFilter }}
|
||||||
div.clearfix
|
div.clearfix
|
||||||
|
|
||||||
div.clearfix
|
div.clearfix
|
||||||
@ -84,4 +84,4 @@ block content
|
|||||||
td(class="{{ node.stats.block.height | blockClass : bestBlock }}").hidden-sm.hidden-xs
|
td(class="{{ node.stats.block.height | blockClass : bestBlock }}").hidden-sm.hidden-xs
|
||||||
span.small {{node.stats.block.hash}}
|
span.small {{node.stats.block.hash}}
|
||||||
td(am-time-ago="node.stats.block.timestamp", am-preprocess="unix", class="{{ node.stats.block.timestamp | timeClass }}")
|
td(am-time-ago="node.stats.block.timestamp", am-preprocess="unix", class="{{ node.stats.block.timestamp | timeClass }}")
|
||||||
td {{ node.stats.active ? '100%' : '0%' }}
|
td(class="{{ node.stats.uptime.total | upTimeClass }}") {{ node.stats.uptime.total | upTimeFilter }}
|
||||||
|
Loading…
Reference in New Issue
Block a user