Skip to content

Commit

Permalink
Fix memory monitor (#1268)
Browse files Browse the repository at this point in the history
* Fix memory monitor

* Add node process mem usage
  • Loading branch information
raymondjacobson committed Mar 1, 2021
1 parent 2a8d5e7 commit c9c7c25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions creator-node/src/monitors/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ const getTotalMemory = async () => {

const getUsedMemory = async () => {
const mem = await si.mem()
return mem.used
// Excluding buffers/cache
return mem.active
}

const getNodeProcessMemoryUsage = async () => {
const mem = process.memoryUsage()
return JSON.stringify(mem)
}

module.exports = {
getTotalMemory,
getUsedMemory
getUsedMemory,
getNodeProcessMemoryUsage
}
14 changes: 11 additions & 3 deletions creator-node/src/monitors/monitors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const { getDatabaseSize, getDatabaseConnections, getDatabaseConnectionInfo, getDatabaseLiveness } = require('./database')
const { getTotalMemory, getUsedMemory } = require('./memory')
const {
getTotalMemory,
getUsedMemory,
getNodeProcessMemoryUsage
} = require('./memory')
const {
getStoragePathSize,
getStoragePathUsed,
Expand Down Expand Up @@ -61,15 +65,18 @@ const DATABASE_CONNECTION_INFO = {
const TOTAL_MEMORY = {
name: 'totalMemory',
func: getTotalMemory,
ttl: 60 * 2,
type: 'int'
}
const USED_MEMORY = {
name: 'usedMemory',
func: getUsedMemory,
ttl: 60 * 2,
type: 'int'
}
const NODE_PROCESS_MEMORY_USAGE = {
name: 'nodeProcessMemoryUsage',
func: getNodeProcessMemoryUsage,
type: 'json'
}

const STORAGE_PATH_SIZE = {
name: 'storagePathSize',
Expand Down Expand Up @@ -152,6 +159,7 @@ const MONITORS = {
DATABASE_CONNECTION_INFO,
TOTAL_MEMORY,
USED_MEMORY,
NODE_PROCESS_MEMORY_USAGE,
STORAGE_PATH_SIZE,
STORAGE_PATH_USED,
FILESYSTEM_SIZE,
Expand Down

0 comments on commit c9c7c25

Please sign in to comment.