Initial commit 2

This commit is contained in:
mwiegand 2022-08-10 13:23:23 +02:00
parent dbf8074427
commit 6d265f67b2
3 changed files with 21 additions and 0 deletions

3
shard.yml Normal file
View file

@ -0,0 +1,3 @@
name: telegraf-pressure-stall
version: 0.1.0
license: MIT

2
shard.lock Normal file
View file

@ -0,0 +1,2 @@
version: 2.0
shards: {}

View 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