os-monitor / 1.0.4 last updated 8 months ago created on May 31st 2012
Install
npm install --save os-monitor
Clone
git clone git@github.com:lfortin/node-os-monitor.git
dependencies
show all 8
| main |
|
readable-stream | 2.0.6 | MIT |
|
|
underscore | 1.8.3 | MIT |
maintainers
versions
23 total
| 1.0.4 | 8 months ago | lfortin |
| 1.0.3 | a year ago | lfortin |
| 1.0.2 | a year ago | lfortin |
| 1.0.1 | 2 years ago | lfortin |
| 1.0.0 | 2 years ago | lfortin |
| 0.3.2 | 2 years ago | lfortin |
| 0.3.1 | 2 years ago | lfortin |
| 0.3.0 | 2 years ago | lfortin |
| 0.2.0 | 2 years ago | lfortin |
| 0.1.6 | 2 years ago | lfortin |
| 0.1.5 | 3 years ago | lfortin |
| 0.1.4 | 3 years ago | lfortin |
| 0.1.3 | 3 years ago | lfortin |
| 0.1.2 | 3 years ago | lfortin |
| 0.1.1 | 3 years ago | lfortin |
| 0.1.0 | 3 years ago | lfortin |
| 0.0.10 | 4 years ago | lfortin |
| 0.0.9 | 4 years ago | lfortin |
| 0.0.8 | 4 years ago | lfortin |
| 0.0.7 | 4 years ago | lfortin |
| 0.0.4 | 4 years ago | lfortin |
| 0.0.3 | 4 years ago | lfortin |
| 0.0.2 | 4 years ago | lfortin |
readme
os-monitor
A very simple monitor for the built-in os module in Node.js.
Allows you to observe some OS parameters, such as free memory available or load average.
Installation
Synopsis
config options
delay
Delay in milliseconds between each monitor cycle. Default: 3000
freemem
Amount of memory in bytes under which event 'freemem' is triggered. Can also be a percentage of total memory. Default: 0
uptime
Number of seconds over which event 'uptime' is triggered. Default: undefined
critical1
Value of 1 minute load average over which event 'loadavg1' is triggered. Default: os.cpus().length
(The load average is a measure of system activity, calculated by the operating system and expressed as a fractional number. As a rule of thumb, the load average should ideally be less than the number of logical CPUs in the system. ref.: http://nodejs.org/api/os.html#os_os_loadavg)
critical5
Value of 5 minutes load average over which event 'loadavg5' is triggered. Default: os.cpus().length
critical15
Value of 15 minutes load average over which event 'loadavg15' is triggered. Default: os.cpus().length
silent
Set true to mute event 'monitor'. Default: false
stream
Set true to enable the monitor as a Readable Stream. Default: false
immediate
Set true to execute a monitor cycle at start(). Default: false
methods
.start( [options] )
Starts the monitor. Accepts an optional options object.
.stop( )
Stops the monitor.
.isRunning( )
Checks whether the monitor is running or not; returns a boolean.
.config( [options] )
Accepts an optional options object and updates monitor config. Always returns monitor config options.
.reset( )
Resets monitor config to its default values.
.on( eventType, handler ), .addListener( eventType, handler )
Adds a listener for the specified event type. Supported events are: 'monitor', 'uptime', 'freemem', 'loadavg1', 'loadavg5', 'loadavg15', 'start', 'stop', 'config', 'reset', 'destroy'.
.once( eventType, handler )
Adds a one-time listener for the specified event type. This listener is invoked only the next time the event is fired, after which it is removed.
.throttle( eventType, handler, delay )
Adds a throttled listener, using Underscore.js's throttle function. The throttled listener will not be executed more than once every delay milliseconds.
.destroy( )
Permanently stops and disables the monitor.
.seconds(n), .minutes(n), .hours(n), .days(n)
Convenience methods to get the right amount of milliseconds.
Event object
There is some useful information in the provided event object:
All supported events are: 'monitor', 'uptime', 'freemem', 'loadavg1', 'loadavg5', 'loadavg15', 'start', 'stop', 'config', 'reset', 'destroy'.
Note that os-monitor is an instance of EventEmitter.
Events API docs: nodejs.org/api/events
Using the monitor as a Readable Stream
os-monitor can also be used as a Readable Stream.
Monitor class
Need concurrent monitor instances? The monitor class is available from the os-monitor object:
Node.js os module
The node os built-in module is also available from the os-monitor object:
Documentation for the os module is available here.
