How to use the os-monitor.start 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.

github DeviaVir / zenbot / bot / simulator.js View on Github external
module.exports = function container (get, set, clear) {
  var bot = get('bot')
  var get_timestamp = get('utils.get_timestamp')
  var min_time = bot.start || tb('7d').subtract(12).toMilliseconds()
  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
      }
    })
  }

os-monitor

simple OS monitoring for Node.js

MIT
Latest version published 3 days ago

Package Health Score

68 / 100
Full package analysis

Popular os-monitor functions