summaryrefslogtreecommitdiffstats
path: root/lib/puppet/external/nagios.rb
blob: d7f64d59b72f994ba4eb45ee898ea3cf2e614757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env ruby -w

#--------------------
# A script to retrieve hosts from ldap and create an importable
# cfservd file from them
#
# $Id: nagios.rb,v 1.3 2004/06/09 20:32:46 luke Exp $

require 'digest/md5'
#require 'ldap'
require 'puppet/external/nagios/parser.rb'
require 'puppet/external/nagios/base.rb'

module Nagios
    NAGIOSVERSION = '1.1'
    # yay colors
    PINK = ""
    GREEN = ""
    YELLOW = ""
    SLATE = ""
    ORANGE = ""
    BLUE = ""
    NOCOLOR = ""
    RESET = ""

    def self.version
        NAGIOSVERSION
    end

    class Config
        def Config.import(config)

            text = String.new

            File.open(config) { |file|
                file.each { |line|
                    text += line
                }
            }
            parser = Nagios::Parser.new
            return parser.parse(text)
        end

        def Config.each
            Nagios::Object.objects.each { |object|
                yield object
            }
        end
    end
end