Method: ContentServer.monitor_general_process_vars

Defined in:
lib/content_server/server.rb

.monitor_general_process_varsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/content_server/server.rb', line 58

def monitor_general_process_vars
  objects_counters = {}
  objects_counters["Time"] = Time.now.to_i
  while true do
    current_objects_counters = {}
    sleep(Params['process_vars_delay'])
    time = Time.now
    $process_vars.set('time', time)
    current_objects_counters['Time'] = time.to_i
    count = ObjectSpace.each_object(String).count
    $process_vars.set('String count', count)
    current_objects_counters['String'] = count
    count = ObjectSpace.each_object(ContentData::ContentData).count
    $process_vars.set('ContentData count', count)
    current_objects_counters['ContentData'] = count
    dir_count = ObjectSpace.each_object(FileMonitoring::DirStat).count
    $process_vars.set('DirStat count', dir_count)
    current_objects_counters['DirStat'] = dir_count
    file_count = ObjectSpace.each_object(FileMonitoring::FileStat).count
    $process_vars.set('FileStat count', file_count-dir_count)
    current_objects_counters['FileStat'] = file_count

    # Generate report and update global counters
    report = ""
    current_objects_counters.each_key { |type|
      objects_counters[type] = 0 unless objects_counters[type]
      diff =  current_objects_counters[type] - objects_counters[type]
      report += "Type:#{type} raised in:#{diff}   \n"
      objects_counters[type] = current_objects_counters[type]
    }
    Log.info("MEM REPORT:\n%s\n", report)
  end
end