Sha256: 24cd73a751fb5da37f82df636bcdba71cf5d1610aab745e0c88414c75eefb53f

Contents?: true

Size: 702 Bytes

Versions: 4

Compression:

Stored size: 702 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 => (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

4 entries across 4 versions & 1 rubygems

Version Path
riemann-babbler-1.0.5.1 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.5 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.4 lib/riemann/babbler/plugins/nvidia.rb
riemann-babbler-1.0.3 lib/riemann/babbler/plugins/nvidia.rb