Class: Zabbix::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/zabbix/reader.rb

Overview

The Zabbix::Reader object used to get values from the monitor file

Instance Method Summary collapse

Constructor Details

#initializeReader

Returns a new instance of Reader.

Raises:



8
9
10
11
12
# File 'lib/zabbix/reader.rb', line 8

def initialize
  filename = 'tmp/zabbix-stats.yml'
  raise FileNotFoundError, 'Monitoring file not found' if !File.exists?(filename)
  @file = YAML.load_file(filename)
end

Instance Method Details

#get_value(key) ⇒ String

Get a value from the Zabbix monitor file

Parameters:

  • key (String)

    zabbix key

Returns:

  • (String)

    The monitoring value



19
20
21
# File 'lib/zabbix/reader.rb', line 19

def get_value key
  @file['statistics'][key]
end