GithubHelp home page GithubHelp logo

kissbeni / microstats Goto Github PK

View Code? Open in Web Editor NEW

This project forked from santi2525/microstats

0.0 0.0 0.0 26 KB

microstats is a node.js utility that can be used to monitor OS events such as CPU utilization, memory and disk consumption. It can be used to 'alert' the user when user defined thresholds are breached. Currently available for linux, macos and windows.

License: MIT License

JavaScript 100.00%

microstats's Introduction

microstats

microstats is a node utility that can be used to monitor OS events such as CPU utilization, memory and disk consumption. It can be used to 'alert' the user when user defined thresholds are breached. Currently available for linux, macos and windows.

Install

npm install microstats

Usage

const microstats = require('microstats')

// Event emits
microstats.on('memory', value => { console.log('MEMORY: ${value}') })
microstats.on('cpu',    value => { console.log('CPU: ${value}') })
microstats.on('disk',   value => { console.log('DISK: ${value}') })
microstats.on('error',  value => { console.log('ERROR: ${value}') })

let options = {}
microstats.start(options, function(err) {
  if (err) console.log(err);
})

// ...

microstats.stop();

options

3 modes of operation -

  • 'once': Will check all stats, report current numbers and stop.
let options = { frequency: 'once' }
  • 'timer': Will check all stats periodically on a user defined timer and report each check.
let options = { frequency: '5s' }

Values for frequency could be something like

'5s' // 5 seconds
'5m' // 5 minutes
'5h' // 5 hours
  • 'onalert': Will check all stats periodically, but report only when the numbers exceed user defined threshold.
options = {
  frequency: 'onalert',
  memoryalert: { used: '>60%' },
  cpualert: { load: '>80%' },
  diskalert: { used: '>70%' }
}

If 'onalert' is used without specifying the thresholds, a default threshold value of 50% will be used for all stats.

diskalert

diskalert options can be customized to specify the disks / mounts to be monitored. If no 'filesystem(s)' or 'mount(s)' are specified, all the available disks will be considered.

  • linux/macos example(s)
options = {
  frequency: 'once',
  diskalert: { 
    used: '>70%',
    mount: '/'
  }
}

options = {
  frequency: 'once',
  diskalert: {
    used: '>70%',
    mounts: ['/home', '/dev']
  }
}
  • windows example(s)
options = {
  frequency: 'once',
  diskalert: {
    used: '>70%',
    filesystem: 'C:'
  }
}

options = {
  frequency: 'once'
  diskalert: {
    used: '>70%',
    filesystems: ['C:', 'D:']
  }
}

Sample output

MEMORY: { usedpct: 55.33, total: 34359738368, free: 15349305344 }
DISK: { filesystem: '/dev/disk0s2',
  mount: '/',
  usedpct: 40.64,
  total: 976265452,
  free: 579478940 }
DISK: { filesystem: '/dev/disk1s2',
  mount: '/Volumes/MyPhotos',
  usedpct: 88.05,
  total: 246865880,
  free: 29491752 }
CPU: { loadpct: 39.28, userpct: 10.71, syspct: 28.57, idlepct: 60.71 }

License

MIT

microstats's People

Contributors

santi2525 avatar sv-code avatar kissbeni avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.