/[adm]/puppet/modules/report-irc_ii/lib/puppet/reports/socket.rb
ViewVC logotype

Contents of /puppet/modules/report-irc_ii/lib/puppet/reports/socket.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2254 - (show annotations) (download)
Sun Jan 15 10:11:56 2012 UTC (12 years, 9 months ago) by misc
File size: 924 byte(s)
rename the file and the module to socket
1 require 'puppet'
2 require 'yaml'
3
4 unless Puppet.version >= '2.6.5'
5 fail "This report processor requires Puppet version 2.6.5 or later"
6 end
7
8 Puppet::Reports.register_report(:socket) do
9 configfile = File.join([File.dirname(Puppet.settings[:config]), "socket.yaml"])
10 raise(Puppet::ParseError, "Socket report config file #{configfile} not readable") unless File.exist?(configfile)
11
12 config = YAML.load_file(configfile)
13 SOCKET_PATH = config[:socket_path]
14 # TODO add support for using another user ?
15
16 desc <<-DESC
17 Send notification of failed reports to a socket.
18 DESC
19
20 def process
21 if self.status == 'failed'
22 message = "Puppet run for #{self.host} #{self.status} at #{Time.now.asctime}."
23 if File.exist?(SOCKET_PATH)
24 Puppet::Util.execute("echo #{message} > #{SOCKET_PATH}" , "nobody", "nogroup")
25 end
26 end
27 end
28 end

Properties

Name Value
svn:keywords "ID Date Rev"

  ViewVC Help
Powered by ViewVC 1.1.30