Sha256: 4ab736794114b34989c8707944b7ff4beb2a01d313a75efdae4bf3e4b69e2d2f

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

# module PoolParty
#   module Monitors
#     
#     class MemoryMonitor < BaseMonitor
#       
#       def run
#         uname = %x[uname]
#         case uname.chomp
#         when "Darwin"
#           darwin_memory_usage
#         else
#           nix_memory_usage
#         end                
#       end
#       
#       def darwin_memory_usage
#         str = %x[vm_stat]
#         keep_array = []
#         array_of_strings = str
#         begin
#           free_memory = array_of_strings[/free:(\W*)+([0-9]+)/, 2].to_f
#           active_memory = array_of_strings[/active:(\W*)([0-9]+)/, 2].to_f
#           inactive_memory = array_of_strings[/inactive:(\W*)([0-9]+)/, 2].to_f
# 
#           used_memory = (active_memory + inactive_memory)
#           total_memory = (free_memory + active_memory + inactive_memory)
# 
#           used_memory / total_memory
#         rescue Exception => e
#           0.0
#         end                 
#       end
#       
#       def nix_memory_usage
#         str = %x[free -m | grep -i mem]
#         begin
#           total_memory = str.split[1].to_f
#           used_memory = str.split[2].to_f
# 
#           used_memory / total_memory
#         rescue Exception => e
#           0.0
#         end
#       end
#             
#     end
#     
#     register_monitor :memory
#   end
# end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
auser-poolparty-1.1.1 lib/poolparty/monitors/monitors/memory_monitor.rb
auser-poolparty-1.1.3 lib/poolparty/monitors/monitors/memory_monitor.rb
auser-poolparty-1.1.4 lib/poolparty/monitors/monitors/memory_monitor.rb
auser-poolparty-1.1.5 lib/poolparty/monitors/monitors/memory_monitor.rb
fairchild-poolparty-1.1.3 lib/poolparty/monitors/monitors/memory_monitor.rb
fairchild-poolparty-1.1.4 lib/poolparty/monitors/monitors/memory_monitor.rb