cloudfoundry-graylog2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg/
@@ -0,0 +1,3 @@
1
+ ## 0.0.1
2
+
3
+ * Throws logs over to Graylog2.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (C) 2012 by Colin Humphreys
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ # CloudFoundry-Graylog2
2
+
3
+ A simple gem to throw the logs from 'vcap tail' into Graylog2 for ease of search and access.
4
+
5
+ ## Setup
6
+
7
+ Set up a Graylog2 server somewhere accepting GELF messages on port 12201 UDP.
8
+
9
+ Install this gem on your Cloud Foundry servers.
10
+
11
+ gem install cloudfoundry-graylog2 # or add to your bundle
12
+
13
+ Create a file on your Cloud Foundry servers to tell them where about vcap and where your Graylog2 server is;
14
+
15
+ #/etc/cf-graylog2.conf
16
+ CF_HOME = '/home/colin/cloudfoundry/vcap'
17
+ GRAYLOG2_HOST = '192.168.0.43'
18
+
19
+ ## Starting/Stopping
20
+
21
+ cf-graylog2-control {start|stop|status}
22
+
23
+ I'll do the decent thing and create debs and rpms (including init scripts) once anyone apart from me starts using this.
24
+
25
+ ## Contributing
26
+
27
+ Please, please, please fork this, improve it, and issue a pull request. You know you want to.
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ task :default => :install
4
+
5
+ Bundler.setup
6
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'daemons'
5
+
6
+ Daemons.run(File.join(File.dirname(__FILE__),'../lib/cloudfoundry-graylog2.rb'), :dir_mode => :normal, :dir => "/tmp")
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "cloudfoundry-graylog2"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Colin Humphreys"]
8
+ s.homepage = "https://github.com/hatofmonkeys/cloudfoundry-graylog2"
9
+ s.summary = "#{s.name}-#{s.version}"
10
+ s.description = "Send Cloud Foundry logs to Graylog2"
11
+ s.license = 'MIT'
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ s.require_path = "lib"
16
+
17
+ s.add_dependency "gelf"
18
+ s.add_dependency "daemons"
19
+ s.add_development_dependency "rake"
20
+ end
@@ -0,0 +1,55 @@
1
+ require 'gelf'
2
+
3
+ CONF_FILE = '/etc/cf-graylog2.conf'
4
+
5
+ FileTest.exists?(CONF_FILE) && load(CONF_FILE)
6
+
7
+ CF_HOME ||= '/home/cloudfoundry/vcap'
8
+ GRAYLOG2_HOST ||= 'localhost'
9
+
10
+ def stfu
11
+ begin
12
+ orig_stderr = $stderr.clone
13
+ $stderr.reopen File.new('/dev/null', 'w')
14
+ retval = yield
15
+ rescue Exception => e
16
+ $stderr.reopen orig_stderr
17
+ raise e
18
+ ensure
19
+ $stderr.reopen orig_stderr
20
+ end
21
+ retval
22
+ end
23
+
24
+ stfu do
25
+ load "#{CF_HOME}/bin/vcap"
26
+ end
27
+
28
+ module Run
29
+ module Tail
30
+ def initialize(component)
31
+ @component = component
32
+ @notifier = GELF::Notifier.new(GRAYLOG2_HOST)
33
+ end
34
+ def receive_line(line)
35
+ # puts prefix + line
36
+ @notifier.notify!(prefix + line)
37
+ if line.start_with?('F') # FATAL
38
+ @notifier.notify!(prefix + "fatal error, closing tail")
39
+ close_connection_after_writing
40
+ end
41
+ end
42
+ end
43
+ end
44
+ args = [ "tail" ]
45
+ opts_parser = OptionParser.new do |opts|
46
+ opts.on('--port PORT') { |port| $port = port.to_i }
47
+ opts.on('--configdir CONFIGDIR', '-c CONFIGDIR') { |dir| $configdir = File.expand_path(dir.to_s) }
48
+ opts.on('--config CONFIGDIR') { |dir| $configdir = File.expand_path(dir.to_s) }
49
+ opts.on('--no-color', '--nocolor', '--nc') { $nocolor = true }
50
+ opts.on('--noprompt', '-n') { $noprompt = true }
51
+ end
52
+ args = opts_parser.parse!(args)
53
+ $nocolor = true
54
+ command = args.shift.downcase
55
+ Run.send(command, args)
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloudfoundry-graylog2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Colin Humphreys
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gelf
16
+ requirement: &85238310 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *85238310
25
+ - !ruby/object:Gem::Dependency
26
+ name: daemons
27
+ requirement: &85238080 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *85238080
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &85237870 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *85237870
47
+ description: Send Cloud Foundry logs to Graylog2
48
+ email:
49
+ executables:
50
+ - cf-graylog2-control
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - CHANGELOG.md
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - bin/cf-graylog2-control
61
+ - cloudfoundry-graylog2.gemspec
62
+ - lib/cloudfoundry-graylog2.rb
63
+ homepage: https://github.com/hatofmonkeys/cloudfoundry-graylog2
64
+ licenses:
65
+ - MIT
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ segments:
77
+ - 0
78
+ hash: 229132115
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ segments:
86
+ - 0
87
+ hash: 229132115
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 1.8.10
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: cloudfoundry-graylog2-0.0.1
94
+ test_files: []