Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
Update influx api to use writeMeasurement for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
mvantassel committed Feb 12, 2017
1 parent 934dd23 commit 93acaad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions nzb2influx.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ const nzbgetConfig = {
password: process.env.NZBGET_PASSWORD || ''
};

function writeToInflux(seriesName, values, tags, callback) {
return influxClient.writePoint(seriesName, values, tags, callback);
function writeToInflux(seriesName, values, tags) {
var payload = {
fields: values
};

if (tags) {
payload.tags = tags;
}

return influxClient.writeMeasurement(seriesName, [payload]);
}

const ng = new nzbget({
Expand All @@ -43,14 +51,14 @@ function onGetNZBData(data) {
category: nzb.Category
};

writeToInflux('nzb', value, tags, function() {
writeToInflux('nzb', value, tags).then(function() {
console.dir(`wrote ${nzb.NZBName} nzb data to influx: ${new Date()}`);
});
});

writeToInflux('nzbs', {
count: nzbs.length
}, null, function() {
}, null).then(function() {
console.dir(`wrote ${nzbs.length} nzbs data to influx: ${new Date()}`);
restart();
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nzb2influx",
"version": "0.1.1",
"version": "0.1.2",
"private": true,
"scripts": {
"start": "node nzb2influx.js"
Expand Down

0 comments on commit 93acaad

Please sign in to comment.