All Projects → lfortin → Node Os Monitor

lfortin / Node Os Monitor

Licence: mit
simple OS monitoring for Node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Os Monitor

Aqeous
(Inactive, Checkout AvanaOS, Rewrite of this) This is a New Operating System (Kernel right now). Made completely from scratch, We aim to make a complete OS for Learning purpose
Stars: ✭ 23 (-72.29%)
Mutual labels:  system, os
mix-agent
基于rust语言开发的一套运维监控探针,支持widnows、linux、macos系统
Stars: ✭ 14 (-83.13%)
Mutual labels:  monitor, system
sOS
Solar Operating System - The ASCII OS nobody asked for.
Stars: ✭ 11 (-86.75%)
Mutual labels:  system, os
Mollenos
MollenOS/Vali is a modern operating system that is built with focus on abstraction and a modular design, allowing anyone to port it to any architecture. It currently targets the x86-32 and x86-64 platform.
Stars: ✭ 182 (+119.28%)
Mutual labels:  os, system
Awesome Programming Books
📚 经典技术书籍推荐,持续更新...
Stars: ✭ 3,472 (+4083.13%)
Mutual labels:  os, system
Python Wechat Itchat
微信机器人,基于Python itchat接口功能实例展示:01-itchat获取微信好友或者微信群分享文章、02-itchat获取微信公众号文章、03-itchat监听微信公众号发送的文章、04 itchat监听微信群或好友撤回的消息、05 itchat获得微信好友信息以及表图对比、06 python打印出微信被删除好友、07 itchat自动回复好友、08 itchat微信好友个性签名词云图、09 itchat微信好友性别比例、10 微信群或微信好友撤回消息拦截、11 itchat微信群或好友之间转发消息
Stars: ✭ 216 (+160.24%)
Mutual labels:  os, system
disfetch
Yet another *nix distro fetching program, but less complex.
Stars: ✭ 45 (-45.78%)
Mutual labels:  system, os
MooInfo
Visual implementation of OSHI, to view information about the system and hardware.
Stars: ✭ 83 (+0%)
Mutual labels:  system, os
WindowsMonitor
WMI namespaces and classes
Stars: ✭ 15 (-81.93%)
Mutual labels:  monitor, system
findlargedir
find all "blackhole" directories with a huge amount of filesystem entries in a flat structure
Stars: ✭ 15 (-81.93%)
Mutual labels:  system, os
Mbp Fedora
Stars: ✭ 129 (+55.42%)
Mutual labels:  os, system
Librehardwaremonitor
Libre Hardware Monitor, home of the fork of Open Hardware Monitor
Stars: ✭ 685 (+725.3%)
Mutual labels:  monitor, system
Sysmon
A B/S mode system monitor for linux (demo http://199.247.1.240:2048)
Stars: ✭ 110 (+32.53%)
Mutual labels:  monitor, system
monitor
mac 实时网速监控 bandwidh monitor
Stars: ✭ 23 (-72.29%)
Mutual labels:  monitor, system
Iglance
Free system monitor for OSX and macOS. See all system information at a glance in the menu bar.
Stars: ✭ 1,358 (+1536.14%)
Mutual labels:  monitor, system
osutil
Go library to easily detect current operating system, current Linux distribution, macOS version and more...
Stars: ✭ 22 (-73.49%)
Mutual labels:  system, os
Interviewguide
计算机校招、社招面试八股文整理,也是《逆袭进大厂》唯一仓库,目前已收录 C/C++ 、操作系统、数据结构、计算机网络、MySQL、Redis等面试资料,未来打算继续收录Java、Python、Go等面试常见问题,坚持将此仓库维护下去。
Stars: ✭ 288 (+246.99%)
Mutual labels:  os, system
Ansible Role Munin
Ansible Role - Munin
Stars: ✭ 27 (-67.47%)
Mutual labels:  os, system
Sparrow
My Operating System.
Stars: ✭ 71 (-14.46%)
Mutual labels:  os
Chrysalisp
Parallel OS, with GUI, Terminal, OO Assembler, Class libraries, C-Script compiler, Lisp interpreter and more...
Stars: ✭ 1,205 (+1351.81%)
Mutual labels:  os

os-monitor

NPM

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

npm install os-monitor

Synopsis

const monitor = require("os-monitor");


// basic usage
monitor.start();

// more advanced usage with configs.
monitor.start({ delay: 3000 // interval in ms between monitor cycles
              , freemem: 1000000000 // freemem under which event 'freemem' is triggered
              , uptime: 1000000 // number of secs over which event 'uptime' is triggered
              , critical1: 0.7 // loadavg1 over which event 'loadavg1' is triggered
              , critical5: 0.7 // loadavg5 over which event 'loadavg5' is triggered
              , critical15: 0.7 // loadavg15 over which event 'loadavg15' is triggered
              , silent: false // set true to mute event 'monitor'
              , stream: false // set true to enable the monitor as a Readable Stream
              , immediate: false // set true to execute a monitor cycle at start()
              });


// define handler that will always fire every cycle
monitor.on('monitor', (event) => {
  console.log(event.type, 'This event always happens on each monitor cycle!');
});

// define handler for a too high 1-minute load average
monitor.on('loadavg1', (event) => {
  console.log(event.type, 'Load average is exceptionally high!');
});

// define handler for a too low free memory
monitor.on('freemem', (event) => {
  console.log(event.type, 'Free memory is very low!');
});

// define a throttled handler, using Underscore.js's throttle function (http://underscorejs.org/#throttle)
monitor.throttle('loadavg5', (event) => {

  // whatever is done here will not happen
  // more than once every 5 minutes(300000 ms)

}, monitor.minutes(5));


// change config while monitor is running
monitor.config({
  freemem: 0.3 // alarm when 30% or less free memory available
});


// stop monitor
monitor.stop();


// check whether monitor is running or not
monitor.isRunning(); // -> true / false


// use as readable stream
monitor.start({stream: true}).pipe(process.stdout);

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.

monitor.seconds(10); // -> 10000 ms

monitor.minutes(5); // -> 300000 ms

monitor.hours(1); // -> 3600000 ms

monitor.days(1); // -> 86400000 ms

// start with a delay of 5000 ms
monitor.start({ delay: monitor.seconds(5) });

Event object

There is some useful information in the provided event object:

{
  type: 'monitor', // event type
  loadavg: [ 0.4599609375, 0.53076171875, 0.4990234375 ], // load average values for 1, 5, 15 minutes
  uptime: 1614056, // os uptime in seconds
  freemem: 241262592, // free memory available in bytes
  totalmem: 2147483648, // total memory available in bytes
  timestamp: 1394766898 // UNIX Timestamp
}

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.start({ stream: true });


// write to STDOUT
monitor.pipe(process.stdout);


// write to a file
let fs = require('fs'),
    logFile = fs.createWriteStream('/tmp/log.txt', {flags: 'a'});

monitor.pipe(logFile);

Monitor class

Need concurrent monitor instances? The monitor class is available from the os-monitor object:

const monitor = require('os-monitor');

let monitor1 = new monitor.Monitor();
let monitor2 = new monitor.Monitor();
let monitor3 = new monitor.Monitor();

Node.js os module

The node os built-in module is also available from the os-monitor object:

const monitor = require('os-monitor');

let type = monitor.os.type();
let cpus = monitor.os.cpus();

Documentation for the os module is available here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].