Skip to content

Commit 5460d7b

Browse files
committedDec 2, 2015
Fix physical used garbage value issue RuntimeTools#74
1 parent c126efc commit 5460d7b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎appmetrics-api.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ function API(agent, appmetrics) {
120120
* MemorySource,1415976582652,totalphysicalmemory=16725618688,physicalmemory=52428800,privatememory=374747136,virtualmemory=374747136,freephysicalmemory=1591525376
121121
*/
122122
var values = message.split(/[,=]+/);
123-
var systemUsed = values[3] - values[11];
124-
var memory = {time: parseInt(values[1]), physical_total: parseInt(values[3]), physical_used: parseInt(systemUsed), physical: parseInt(values[5]), private: parseInt(values[7]), virtual: parseInt(values[9]), physical_free: parseInt(values[11])};
123+
var physicalTotal = parseInt(values[3]);
124+
var physicalFree = parseInt(values[11]);
125+
var physicalUsed = (physicalTotal >= 0 && physicalFree >= 0) ? (physicalTotal - physicalFree) : -1;
126+
var memory = {time: parseInt(values[1]), physical_total: physicalTotal, physical_used: physicalUsed, physical: parseInt(values[5]), private: parseInt(values[7]), virtual: parseInt(values[9]), physical_free: physicalFree};
125127
that.emit('memory', memory);
126128
};
127129

0 commit comments

Comments
 (0)
Please sign in to comment.