Sha256: e2df6afaa7007e1f238ee2d642f94bff6ad512c2dec9ed4bde3baca7ecfc7956

Contents?: true

Size: 1.49 KB

Versions: 18

Compression:

Stored size: 1.49 KB

Contents

#
# Author:: Sander Botman <sbotman@schubergphilis.com>
# Cookbook Name:: nagios
# Library:: resource
#
# Copyright 2015, Sander Botman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative 'base'

class Nagios
  #
  # This class holds all methods with regard to resource options,
  # that are used within nagios configurations.
  #
  class Resource < Nagios::Base
    attr_reader   :key
    attr_accessor :value

    def initialize(key, value = nil)
      @key = key
      @value = value
      super()
    end

    def definition
      if blank?(value)
        "# Skipping #{key} because the value is missing."
      elsif key =~ /^USER([1-9]|[1-9][0-9]|[1-2][0-4][0-9]|25[0-6])$/
        "$#{@key}$=#{@value}"
      else
        "# Skipping #{key} because the it's not valid. Use USER[1-256] as your key."
      end
    end

    def self.create(name)
      Nagios.instance.find(Nagios::Resource.new(name))
    end

    def import(hash)
      update_options(hash)
    end

    def to_s
      key
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
cloud-mu-2.0.4 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.1.0beta cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.3 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.2 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.1 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.beta3 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.beta2 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.beta1 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha9 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha8 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha7 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha6 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha5 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha4 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha3 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha2 cookbooks/nagios/libraries/resource.rb
cloud-mu-2.0.0.pre.alpha cookbooks/nagios/libraries/resource.rb
cloud-mu-1.9.0.pre.beta cookbooks/nagios/libraries/resource.rb