cloudfoundry-graylog2 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +27 -0
- data/Rakefile +6 -0
- data/bin/cf-graylog2-control +6 -0
- data/cloudfoundry-graylog2.gemspec +20 -0
- data/lib/cloudfoundry-graylog2.rb +55 -0
- metadata +94 -0
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
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.
|
data/README.md
ADDED
@@ -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.
|
data/Rakefile
ADDED
@@ -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: []
|