Sha256: 42254947955a3b9243b43a514093d58894d34fc3235947741b51baa509960050

Contents?: true

Size: 706 Bytes

Versions: 10

Compression:

Stored size: 706 Bytes

Contents

require 'json'

class Riemann::Babbler::Nvidia < Riemann::Babbler

  def init
    plugin.set_default(:service, 'nvidia')
    plugin.set_default(:cmd, '/usr/bin/nvidia-info -j')
    plugin.set_default(:interval, 60)
    plugin.states.set_default(:warning, 70)
    plugin.states.set_default(:critical, 90)
  end

  def run_plugin
    File.exists? '/usr/bin/nvidia-info'
  end


  def collect
    hash = JSON.parse shell(plugin.cmd)
    array = Array.new
    hash.each do |info| 
      array << { :service => plugin.service + ' memory usage', :metric => (1 - info['memory_usage']['free'].to_f/info['memory_usage']['total'].to_i) * 100, :description => "GPU memory usage in %" }
    end  
    array
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
riemann-babbler-1.0.7.2 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.7.1 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.7 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.6 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.5.7 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.5.6 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.5.5 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.5.4 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.5.3 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.5.2 lib/riemann/babbler/plugins/nvidia.rb