Class: Monitoring::Client::Config
- Inherits:
-
Object
- Object
- Monitoring::Client::Config
- Defined in:
- lib/monitoring/client/config.rb
Constant Summary collapse
- DEFAULT_FILENAME =
"/usr/local/etc/monitoring-client.yml"
Instance Attribute Summary collapse
-
#hostgroup ⇒ Object
Returns the value of attribute hostgroup.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
Class Method Summary collapse
Instance Method Summary collapse
- #get_hostname ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load(filename = DEFAULT_FILENAME) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
18 19 20 21 22 |
# File 'lib/monitoring/client/config.rb', line 18 def initialize self.hostname = get_hostname self.hostgroup = nil load() end |
Instance Attribute Details
#hostgroup ⇒ Object
Returns the value of attribute hostgroup.
16 17 18 |
# File 'lib/monitoring/client/config.rb', line 16 def hostgroup @hostgroup end |
#hostname ⇒ Object
Returns the value of attribute hostname.
16 17 18 |
# File 'lib/monitoring/client/config.rb', line 16 def hostname @hostname end |
Class Method Details
.global ⇒ Object
9 10 11 |
# File 'lib/monitoring/client/config.rb', line 9 def global @@global ||= Config.new end |
Instance Method Details
#get_hostname ⇒ Object
35 36 37 |
# File 'lib/monitoring/client/config.rb', line 35 def get_hostname %x(hostname).strip end |
#load(filename = DEFAULT_FILENAME) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/monitoring/client/config.rb', line 25 def load(filename = DEFAULT_FILENAME) c = YAML.load_file(filename) self.hostname = c[:hostname] self.hostgroup = c[:hostgroup] self rescue Errno::ENOENT => e # Squelch missing file if default raise(e) unless filename == DEFAULT_FILENAME end |