Top Level Namespace
Defined Under Namespace
Modules: HotCatch, Rails
Classes: CustomActionControllerLogSubscriber, CustomActiveRecordLogSubscriber, HardWorker, NginxSystemWorker, ReceiveNginxLogs, Time
Instance Method Summary
collapse
Instance Method Details
#get_system_metrics ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/hot_catch/get_system_metrics.rb', line 10
def get_system_metrics
metrics = [ServerMetrics::Network, ServerMetrics::Cpu, ServerMetrics::Disk, ServerMetrics::Memory]
metrics_human_name = ["network", "cpu", "disk", "memory", "system_info", "descriptors", "time"]
result = {}
metrics.each_with_index do |m, index|
metric = m.new
metric.run
sleep 1 if m == ServerMetrics::Network || m == ServerMetrics::Cpu
metric.build_report
result[metrics_human_name[index]] = metric.data
end
result[metrics_human_name[-3]] = ServerMetrics::SystemInfo.to_h
result[metrics_human_name[-2]] = parse_descriptors_info
result[metrics_human_name[-1]] = Time.now
result
end
|
#parse_descriptors_info ⇒ Object
4
5
6
7
8
|
# File 'lib/hot_catch/get_system_metrics.rb', line 4
def parse_descriptors_info
descriptors = `cat /proc/sys/fs/file-nr`
descriptors = descriptors.strip.split("\t").map(&:to_i)
{current: descriptors[0], unused: descriptors[1], max: descriptors[2]}
end
|