-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpushTask.js
More file actions
33 lines (28 loc) · 881 Bytes
/
pushTask.js
File metadata and controls
33 lines (28 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Created by efei on 15-9-2.
*/
var os = require('os'),
request = require('request');
var config = require('./config').config,
buildFalconArray = require('./falconDataBuilder').buildFalconArray;
var startPushTask = function (perfCounter) {
this.interval = setInterval(function () {
push(perfCounter);
}, config.step * 1000);
};
var push = function (perfCounter) {
var ms = buildFalconArray(perfCounter);
console.log('Push Metrics Count: ', ms.length);
var options = {
method: 'POST',
json: true,
body: ms,
url: config.agentUri
};
request(options, function (err, res, body) {
if (err) console.log('err: ', err);
else if (res.statusCode !== 200) console.log('Send Perf Counter to Falcon Agent Failed: ', body);
else console.log('Send Perf Counter to Falcon Agent Succeed');
});
};
exports.startPushTask = startPushTask;