Initial commit 2
This commit is contained in:
parent
dbf8074427
commit
6d265f67b2
3 changed files with 21 additions and 0 deletions
3
shard.yml
Normal file
3
shard.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
name: telegraf-pressure-stall
|
||||
version: 0.1.0
|
||||
license: MIT
|
2
shard.lock
Normal file
2
shard.lock
Normal file
|
@ -0,0 +1,2 @@
|
|||
version: 2.0
|
||||
shards: {}
|
16
telegraf_pressure_stall.cr
Normal file
16
telegraf_pressure_stall.cr
Normal file
|
@ -0,0 +1,16 @@
|
|||
dir = ENV.fetch("PSI_DIR", "/proc/pressure")
|
||||
time = Time.local.to_s("%s%9N")
|
||||
|
||||
Dir.entries(dir).each do |ressource|
|
||||
next if File.directory? ressource
|
||||
|
||||
File.read_lines("#{dir}/#{ressource}").each do |line|
|
||||
parts = line.split
|
||||
type = parts[0]
|
||||
metrics = parts[1..-1].map{ |part| part.split('=')}.to_h
|
||||
|
||||
puts %(pressure_stall_avg,ressource="#{ressource}",type=#{type} avg10=#{metrics["avg10"]},avg60=#{metrics["avg60"]},avg300=#{metrics["avg300"]} #{time})
|
||||
puts %(pressure_stall_total,ressource="#{ressource}",type=#{type} total=#{metrics["total"]} #{time})
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in a new issue