Esempio n. 1
0
File: misc.py Progetto: EQ4/DRR
def base_stats():
    # Reports base-level statistical information about the health of the server.
    # This is used for the /stats and /heartbeat call.
    try:
        # for some reason this can lead to a memory error
        load = [
            float(unit) for unit in os.popen(
                "uptime | awk -F : ' { print $NF } '").read().split(', ')
        ]

    except:
        load = 0

    return {
        'uptime':
        TS.uptime(),
        'last_recorded':
        float(DB.get('last_recorded', use_cache=False) or 0),
        'now':
        time.time(),
        'version':
        __version__,
        'load':
        load,
        'plist': [
            line.strip()
            for line in os.popen("ps auxf | grep [%s]%s" %
                                 (config['callsign'][0], config['callsign'][1:]
                                  )).read().strip().split('\n')
        ],
        'disk':
        cloud.size('.') / (1024.0**3)
    }
Esempio n. 2
0
File: misc.py Progetto: EQ4/DRR
def base_stats():
  # Reports base-level statistical information about the health of the server.
  # This is used for the /stats and /heartbeat call.
  try:
    # for some reason this can lead to a memory error
    load = [float(unit) for unit in os.popen("uptime | awk -F : ' { print $NF } '").read().split(', ')]

  except:
    load = 0

  return {
    'uptime': TS.uptime(),
    'last_recorded': float(DB.get('last_recorded', use_cache=False) or 0),
    'now': time.time(),
    'version': __version__,
    'load': load,
    'plist': [ line.strip() for line in os.popen("ps auxf | grep [%s]%s" % (config['callsign'][0], config['callsign'][1:])).read().strip().split('\n') ],
    'disk': cloud.size('.') / (1024.0 ** 3)
  }
Esempio n. 3
0
File: misc.py Progetto: EQ4/DRR
def shutdown_real(do_restart=False):
  # During a restart shutdown we just kill the webserver.
  # The other processes will die off later.
  if 'webserver' in pid_map:
    os.kill(pid_map['webserver'].pid, signal.SIGUSR1)

  if not do_restart:
    for key, value in pid_map.items():
      try:
        value.terminate()
      except:
        pass

    title = SP.getproctitle()
    logging.info("[%s:%d] Shutting down" % (title, os.getpid()))
    DB.shutdown()

    logging.info("Uptime: %ds", TS.uptime())

    if os.path.isfile(PIDFILE_MANAGER):
      os.unlink(PIDFILE_MANAGER)

    sys.exit(0)
Esempio n. 4
0
File: misc.py Progetto: EQ4/DRR
def shutdown_real(do_restart=False):
    # During a restart shutdown we just kill the webserver.
    # The other processes will die off later.
    if 'webserver' in pid_map:
        os.kill(pid_map['webserver'].pid, signal.SIGUSR1)

    if not do_restart:
        for key, value in pid_map.items():
            try:
                value.terminate()
            except:
                pass

        title = SP.getproctitle()
        logging.info("[%s:%d] Shutting down" % (title, os.getpid()))
        DB.shutdown()

        logging.info("Uptime: %ds", TS.uptime())

        if os.path.isfile(PIDFILE_MANAGER):
            os.unlink(PIDFILE_MANAGER)

        sys.exit(0)