Sha256: 0d65450126dace8b11ca1d43f6a967d77210a91e03e94b219e2efb1c2ee185ca
Contents?: true
Size: 877 Bytes
Versions: 3
Compression:
Stored size: 877 Bytes
Contents
# -*- encoding: utf-8 -*- require 'active_support/core_ext/numeric/bytes' require 'evented_bluepill/process_conditions/process_condition' require 'evented_bluepill/system' module EventedBluepill module ProcessConditions class MemUsage < ProcessCondition KB = 1024.0 MB = KB ** 2 FORMAT_STR = "%.1f%s" MB_LABEL = "MB" KB_LABEL = "KB" def initialize(name, process, options = {}) @below = options[:below] super end def run # rss is on the 5th col EventedBluepill::System.memory_usage(process.actual_pid).to_f.kilobytes end def check(value) value < @below end def format_value(value) if value >= MB FORMAT_STR % [(value / MB), MB_LABEL] else FORMAT_STR % [(value / KB), KB_LABEL] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems