Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #35 from bookchin/master
Browse files Browse the repository at this point in the history
v2.1.1 (Telemetry Reporting)
  • Loading branch information
bookchin authored Jan 19, 2017
2 parents c228f0c + b0a2940 commit cf51c9f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ class RPC {
id: nodeId,
config: share.config,
state: share.readyState,
meta: share.meta
meta: share.meta,
path: share.path
});
});

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storjshare-daemon",
"version": "2.1.0",
"version": "2.1.1",
"description": "daemon + process manager for sharing space on the storj network",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -67,7 +67,8 @@
"pretty-ms": "^2.1.0",
"rc": "^1.1.6",
"readable-stream": "^2.2.2",
"storj-lib": "^6.0.12",
"storj-lib": "^6.0.14",
"storj-telemetry-reporter": "^5.0.0",
"strip-json-comments": "^2.0.1",
"tail": "^1.2.1"
},
Expand Down
26 changes: 25 additions & 1 deletion script/farmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const utils = require('../lib/utils');
const storj = require('storj-lib');
const Logger = require('kad-logger-json');
const Telemetry = require('storj-telemetry-reporter');
const config = JSON.parse(JSON.stringify(require('../lib/config/farmer')));
const bytes = require('bytes');

Expand Down Expand Up @@ -38,7 +39,7 @@ farmer.join((err) => {

function sendFarmerState() {
farmerState.totalPeers = farmer.router.length;
process.send(farmerState)
process.send(farmerState);
}

function updatePercentUsed() {
Expand All @@ -50,7 +51,30 @@ function updatePercentUsed() {
});
}

function sendTelemetryReport() {
let telemetryServer = 'https://status.storj.io';
let telemetry = new Telemetry(telemetryServer, config.keyPair);
let report = {
storageAllocated: spaceAllocation,
storageUsed: bytes.parse(farmerState.spaceUsed),
contactNodeId: config.keyPair.getNodeID(),
paymentAddress: config.paymentAddress
};
telemetry.send(report, (err) => {
if (err) {
return config.logger.warn('telemetry report rejected, reason: %s',
err.message);
}
config.logger.info('telemetry report delivered to %s: %j', telemetryServer,
report);
});
}

updatePercentUsed();
sendFarmerState();
setInterval(sendFarmerState, 10 * 1000); // Update state every 10 secs
setInterval(updatePercentUsed, 10 * 60 * 1000); // Update space every 10 mins

if (config.enableTelemetryReporting) {
setInterval(sendTelemetryReport, 10 * 60 * 1000);
}

0 comments on commit cf51c9f

Please sign in to comment.