How to use the os-monitor.on function in os-monitor

To help you get started, we’ve selected a few os-monitor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DeviaVir / zenbot / bot / simulator.js View on Github external
var max_time = bot.end || tb(min_time).resize('7d').add(12).toMilliseconds()
  get('console').info(('[sim] start = ' + get_timestamp(min_time) + ', end = ' + get_timestamp(max_time)).cyan)
  var brain = get('bot.brain')
  var start = brain.run_state.currency
  var first_tick, last_tick

  if (bot.throttle) {
    var monitor = require('os-monitor')
    var pausing = false
    var pause_msg = ''
    monitor.start({
      critical1: bot.throttle,
      immediate: true,
      delay: 5000
    })
    monitor.on('monitor', function (event) {
      if (pausing && event.loadavg && event.loadavg[0] < bot.throttle) {
        get('console').info(('[resuming] load = ' + n(event.loadavg[0]).format('0.000')).yellow)
        pausing = false
      }
      else if (event.loadavg && event.loadavg[0] >= bot.throttle) {
        pause_msg = ('[paused] load = ' + n(event.loadavg[0]).format('0.000')).yellow
        pausing = true
      }
    })
  }

  function getNext () {
    if (bot.throttle && pausing) return setTimeout(getNext, 5000)
    var params = {
      query: {
        time: {

os-monitor

simple OS monitoring for Node.js

MIT
Latest version published 1 month ago

Package Health Score

68 / 100
Full package analysis

Popular os-monitor functions