0

var rrdtool = require('rrdtool');

var start = rrdtool.now() - 10; var db = rrdtool.create('test.rrd', { start: start, step: 1 } , ['DS:test:GAUGE:1:0:100','RRA:AVERAGE:0.5:1:10']);

T. Dave
  • 1
  • 1
  • Please format your code to make it readable. Indent 4 spaces, or use the format button. – Robert Oct 25 '16 at 16:23
  • The code looks correct; despite being awkwardly formatted the correct parameters are there. Are you sure this is the part giving the errors? The error message may be coming from a different part of the code. – Steve Shipway Oct 27 '16 at 19:40

2 Answers2

0

The problem is not in the ds name, but in the next command.

db.update(start + 0, 15);

If you leave only the lines that you provided the code will compile without errors. To correct the error from the update method go to the proc.js file (node_modules/rrdtool/lib/proc.js) and change the update method to something like this.

exports.update = function (file, ts, values, cb) {
  var cmd = [ts];

  cmd.push(values);

  exec(['update', file, cmd.join(':')], function (err) {
    cb(err);
  });
};

Before the change, it did not form the rrdtool command correctly, the command looked like update --template timestamp, instead of update timestamp:value. In my example the timestamp is start + 0, and the value is 15.

0

The issue is in update method. If you try to do something like this:

db.update(start + 1, 90)

It will produce the error. You should pass the object instead of the value. Something like this will work:

db.update(start + 0, {test: 15});