telegraf-pressure-stall/telegraf_pressure_stall.cr
2022-08-11 19:31:19 +02:00

12 lines
457 B
Crystal

dir = Path[ENV.fetch("PSI_DIR", "/proc/pressure")]
time = Time.utc.to_s("%s%9N")
Dir.children(dir).each do |resource|
File.read_lines(dir/resource).each do |line|
parts = line.split
type = parts[0]
metrics = parts[1..-1].map{ |part| part.split('=') }.to_h
puts %(pressure_stall,resource=#{resource},type=#{type} avg10=#{metrics["avg10"]},avg60=#{metrics["avg60"]},avg300=#{metrics["avg300"]},total=#{metrics["total"]} #{time})
end
end