Skip to content

Commit

Permalink
update files, 确保一分钟内同一个节点的所有指标只向Falcon上报一次。
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulGuo committed May 31, 2016
1 parent 3bd4a6e commit 6268122
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions PM25-Service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"cors": "^2.7.1",
"express": "^4.13.3",
"mongodb": "^1.4.34",
"node-cache": "^3.2.1",
"nssocket": "^0.5.3",
"open-falcon": "^1.3.2",
"socket.io": "^1.3.5",
Expand Down
9 changes: 9 additions & 0 deletions PM25-Service/src/PushFalconService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@

var Falcon = require('open-falcon').init('http://127.0.0.1:1988/v1/push', 'pm25');
var falcon = new Falcon({ step: 60 });
var NodeCache = require('node-cache');
var metricsCache = new NodeCache({ stdTTL: 60, checkperiod: 80 });

function pushDataHandler(data, options = undefined) {
// 确保一分钟内同一个节点的所有指标只向Falcon上报一次
if(metricsCache.get(data.server_name) === true) {
return;
}

metricsCache.set(data.server_name, true);

options = {
type: 'pm25',
server_name: data.server_name,
Expand Down

0 comments on commit 6268122

Please sign in to comment.