Sha256: 1410ef68082d5dfa890966afd5cfe0427c5f2b4e435cdbf28d92c3e22788277b
Contents?: true
Size: 694 Bytes
Versions: 10
Compression:
Stored size: 694 Bytes
Contents
# -*- encoding: utf-8 -*- module Bluepill module ProcessConditions class MemUsage < ProcessCondition MB = 1024 ** 2 FORMAT_STR = "%d%s" MB_LABEL = "MB" KB_LABEL = "KB" def initialize(options = {}) @below = options[:below] end def run(pid, include_children) # rss is on the 5th col System.memory_usage(pid, include_children).to_f end def check(value) value.kilobytes < @below end def format_value(value) if value.kilobytes >= MB FORMAT_STR % [(value / 1024).round, MB_LABEL] else FORMAT_STR % [value, KB_LABEL] end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems