Class: Fluent::TDMonitorAgentInput::MemoryStat
- Inherits:
-
Object
- Object
- Fluent::TDMonitorAgentInput::MemoryStat
- Defined in:
- lib/fluent/plugin/in_td_monitor_agent.rb
Instance Method Summary collapse
Instance Method Details
#stats ⇒ Object
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/fluent/plugin/in_td_monitor_agent.rb', line 386 def stats res = {} `free -o`.each_line.with_index { |line, i| case when line.start_with?('Mem:') columns = line.strip.split(' ') total = columns[1].to_i free = columns[3].to_i + columns[5].to_i + columns[6].to_i res['usage'] = ((total - free).to_f / total * 100).to_i #when line.start_with?('Swap:') # columns = line.strip.split(' ') # res['swap'] = (columns[2].to_f / columns[1].to_i * 100).to_i end } res end |