Skip to content

BirdHighway/Node-Memory-Monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node Memory Monitor

A simple way to monitor node memory usage.

Logging Bar Graph to Console

Image above shows logging values of rss and heapTotal to the console in bar graph form.

Supported Formatters

  • CSV - Monitor.createFormatterCSV()
  • JSON - Monitor.createFormatterJSON()
  • Bar Graph - Monitor.createFormatterBarGraph(maxValueMB)

Supported Loggers

  • Console - Monitor.createLoggerConsole(fieldsToLog)
  • File - Monitor.createLoggerFile(fieldsToLog, filePath)

Options

The constructor accepts an options object which currently has just one field: separator, specifying which separator to use when joining fields. Default separator value is a comma - ,.

Usage

// bring in the module
const Monitor = require('/path/to/monitor');

// create an instance
const monitor = new Monitor();

// specify the fields you want to track
const fields = ['rss', 'heapTotal'];

// create a formatter
const maxSizeMB = 20;
const formatter = monitor.createFormatterBarGraph(maxSizeMB);

// create a logger
const logger = monitor.createLoggerConsole(fields);

// create the tracker
const tracker = monitor.createTracker(fields, formatter, logger);

// start the tracker
const interval = 1000;
const intervalId = monitor.startMonitor(tracker, interval);

// stop the tracker
clearInterval(intervalId);

Monitoring a File Log

When using the file logger you can monitor the file change in real time by running tail -f fileName

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published