chef-deployment-monitor 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/Rakefile +11 -1
- data/bin/chef-logmon +19 -20
- data/chef-deployment-monitor.gemspec +27 -0
- data/lib/{chef_monitor → chef_deployment_monitor}/config.rb +16 -9
- data/lib/{chef_monitor → chef_deployment_monitor}/log.rb +18 -16
- data/lib/chef_deployment_monitor/logmon.rb +77 -0
- data/lib/chef_deployment_monitor/sinks.rb +37 -0
- data/lib/{chef_monitor → chef_deployment_monitor}/version.rb +7 -3
- data/lib/chef_logmon.rb +4 -4
- metadata +45 -15
- data/chef-monitor.gemspec +0 -24
- data/lib/chef_monitor/logmon.rb +0 -71
- data/lib/chef_monitor/sinks.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWM1YmNlNWJhNjc3NGNmYWVmNDVmZDBmZDgyZDgwOWQ2MmIxNTI2Nw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Y2FlNDY2ZTQ2YTJmNzZhMDNhYWNjYzAxM2JmZmY3ZTY2MGJmNGUyYg==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTEzM2E2YzRlNzQwZjJiMjNiYWIzNjRkOTVkOTI0ZWFjOTMzOGI5OTZhNTYy
|
10
|
+
Mjk1ZWU0MGY4YzJkMTNjZDhjNDI2NzkyZDQ1OGRmNjMyNzdiYWMyNTJlMDUw
|
11
|
+
MDRkN2IyMDNhZGRkYmFmN2FhNWE2NzFhNTZjZDVlZDdlZDRmYzc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDE0NTAwNGExZjk4NzY2YmM3NTJmN2Q1NWQ1MDQwMmU3ZDM5MTBmODg2NzEz
|
14
|
+
MGM2NDE2N2QxN2I1M2UxYjU3NTJjMDg1ZDczNmViMDBlNzcxNDA1YzhjZmVi
|
15
|
+
MjQ3MjZjZDRhNDYzNmFmMDgzYTE4YjgwZTA4ZGU5ZDZlZjYzNTk=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.2.0
|
5
|
+
deploy:
|
6
|
+
provider: rubygems
|
7
|
+
api_key:
|
8
|
+
secure: mqUOkyrmNz2gB58ejdwW25+7XWDm9e2GdiuogdmJ/RcfhyPOjhUqf7DtJIeeNt8MZ21JGZNr079sR7wLHHBFhPAVLI0jxUwyWe9Z20p2OJydqS/gYaAiZykWp8sPbfbwKvmdMNiVPTMmscz/27NALROjpQvKS7t/yhCirBrOVPNsh/8YS94bQbOK6NsxN0l9Xig2Ltq68nDjezCR0fgpGaNnu6XMAz8+uw9H9T20ZeTUhLBKYxx7zgDg56v/GwUW5LD9b/4h/YBF9kqCKiTxZ1xx1sPU+cGXqpKZxGzOzXwCr2OFPD/6d12aMfcQaCIML1AWIrgIR0pYZnzf7Qz4ZkMJv27ZF0RSqG0Asyg41z+pf5EMxHTw43ARnk9f7+TX/LXEIP7LexevGPq6dAOcGYjQtutq5V6iMyU7V2uSDsHX2fAPOI/75IiXDw8l4EedXraFcf0NpfBV0vf0pdePMThjF8dy0BbBbNPZ+ioq6RiMyppJdFtTyViZylOSbNvl6GXBRj9SEYje5cvjTzuXE7YmpCUtPiA46HqEEXqBerlkxHRAZLWZxMKnVD6STCZxkwgH9agJyD0dOaWqnUAkQ23YUa3hjePpp7Fd7PUjK58uxy0C+usZK6GhDa0IfX/Yi3XoWbQOO9jK1bwv2uAGSG0tqFZKcnhBgiFa4b3t1Hc=
|
9
|
+
gem: chef-deployment-monitor
|
10
|
+
on:
|
11
|
+
tags: true
|
12
|
+
repo: kamaradclimber/chef-deployment-monitor
|
data/Rakefile
CHANGED
data/bin/chef-logmon
CHANGED
@@ -17,47 +17,46 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require 'chef_logmon'
|
21
21
|
require 'rubygems'
|
22
22
|
require 'file-tail'
|
23
23
|
require 'json'
|
24
24
|
require 'daemons'
|
25
25
|
|
26
|
-
config=nil
|
27
|
-
debug=false
|
26
|
+
config = nil
|
27
|
+
debug = false
|
28
28
|
|
29
|
-
opt=0
|
29
|
+
opt = 0
|
30
30
|
ARGV.each do |arg|
|
31
|
-
config = ARGV[opt+1] if arg ==
|
32
|
-
debug = true if arg ==
|
33
|
-
opt+=1
|
31
|
+
config = ARGV[opt + 1] if arg == '-C' || arg == '--config'
|
32
|
+
debug = true if arg == '--debug'
|
33
|
+
opt += 1
|
34
34
|
end
|
35
35
|
|
36
36
|
if config.nil?
|
37
|
-
puts
|
37
|
+
puts 'Please enter the configuration file with the option -C or --config'
|
38
38
|
exit 1
|
39
39
|
else
|
40
|
-
Monitor::Config.from_file(config)
|
41
|
-
|
42
|
-
if Monitor::Config[item.to_sym].empty?
|
40
|
+
Chef::Deployment::Monitor::Config.from_file(config)
|
41
|
+
%w(mon_file pid_dir log_dir).each do |item|
|
42
|
+
if (Chef::Deployment::Monitor::Config[item.to_sym] || '').empty?
|
43
43
|
puts "Missing item: #{item} within the configuration file!"
|
44
44
|
exit 1
|
45
45
|
end
|
46
46
|
end
|
47
|
-
end
|
47
|
+
end
|
48
48
|
|
49
|
-
LOGMONNAME =
|
49
|
+
LOGMONNAME = `hostname`
|
50
50
|
DEBUG = debug
|
51
51
|
|
52
52
|
@options = {
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
53
|
+
log_output: true,
|
54
|
+
dir_mode: :normal,
|
55
|
+
dir: Chef::Deployment::Monitor::Config[:pid_dir],
|
56
|
+
log_dir: Chef::Deployment::Monitor::Config[:log_dir]
|
57
57
|
}
|
58
58
|
|
59
59
|
Daemons.run_proc('chef-logmon', @options) do
|
60
|
-
logmon = Monitor::Logmon.new
|
61
|
-
logmon.run
|
60
|
+
logmon = Chef::Deployment::Monitor::Logmon.new
|
61
|
+
logmon.run
|
62
62
|
end
|
63
|
-
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'chef_deployment_monitor/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'chef-deployment-monitor'
|
7
|
+
s.version = Chef::Deployment::Monitor::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.has_rdoc = false
|
10
|
+
s.extra_rdoc_files = ['LICENSE']
|
11
|
+
s.authors = ['Sander Botman', 'Grégoire Seux']
|
12
|
+
s.email = ['g.seux@criteo.com']
|
13
|
+
s.homepage = 'https://github.com/kamaradclimber/chef-deployment-monitor'
|
14
|
+
s.summary = 'Chef Monitoring tool to monitor all changes made'
|
15
|
+
s.description = s.summary
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.license = 'Apache 2.0'
|
21
|
+
s.add_dependency 'file-tail', '>= 1.0.12'
|
22
|
+
s.add_dependency 'daemons', '>= 1.1.9'
|
23
|
+
s.add_dependency 'mixlib-config'
|
24
|
+
|
25
|
+
s.add_development_dependency 'rake'
|
26
|
+
s.add_development_dependency 'rubocop'
|
27
|
+
end
|
@@ -17,15 +17,22 @@
|
|
17
17
|
|
18
18
|
require 'mixlib/config'
|
19
19
|
|
20
|
-
class
|
21
|
-
class
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
default :marker_file, '/tmp/last_chef_deployment'
|
27
|
-
%w(user_blacklist mon_file log_dir pid_dir).each { |o| configurable o.to_sym }
|
20
|
+
class Chef
|
21
|
+
class Deployment
|
22
|
+
class Monitor
|
23
|
+
class Config
|
24
|
+
extend Mixlib::Config
|
25
|
+
config_strict_mode true
|
28
26
|
|
27
|
+
default :marker_file, '/tmp/last_chef_deployment'
|
28
|
+
default :action_blacklist, /GET/
|
29
|
+
%w(
|
30
|
+
user_blacklist
|
31
|
+
mon_file
|
32
|
+
log_dir
|
33
|
+
pid_dir
|
34
|
+
).each { |o| configurable o.to_sym }
|
35
|
+
end
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
|
-
|
@@ -15,23 +15,25 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
class
|
19
|
-
class
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
18
|
+
class Chef
|
19
|
+
class Deployment
|
20
|
+
class Monitor
|
21
|
+
class Log
|
22
|
+
def initialize(text, type = 'INFO')
|
23
|
+
case type.downcase
|
24
|
+
when 'INFO'.downcase
|
25
|
+
puts '[' + Time.now.iso8601 + '] INFO: ' + text
|
26
|
+
when 'WARN'.downcase
|
27
|
+
puts '[' + Time.now.iso8601 + '] WARN: ' + text
|
28
|
+
when 'ERROR'.downcase
|
29
|
+
puts '[' + Time.now.iso8601 + '] ERROR: ' + text
|
30
|
+
when 'DEBUG'.downcase
|
31
|
+
puts '[' + Time.now.iso8601 + '] DEBUG: ' + text if DEBUG
|
32
|
+
else
|
33
|
+
puts '[' + Time.now.iso8601 + '] UNKNOWN: ' + text
|
34
|
+
end
|
35
|
+
end
|
33
36
|
end
|
34
37
|
end
|
35
|
-
|
36
38
|
end
|
37
39
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman (<sander.botman@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Sander Botman.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
class Chef
|
19
|
+
class Deployment
|
20
|
+
class Monitor
|
21
|
+
class Logmon
|
22
|
+
def run
|
23
|
+
sink = MarkerFileSink.new
|
24
|
+
|
25
|
+
begin
|
26
|
+
File.open(Monitor::Config[:mon_file]) do |mon|
|
27
|
+
mon.extend(File::Tail)
|
28
|
+
mon.interval = 5
|
29
|
+
mon.backward(1)
|
30
|
+
mon.tail do |line|
|
31
|
+
data = scan(line)
|
32
|
+
# skipping the objects 'checksum-.*' and 'reports'
|
33
|
+
unless data.nil? || data['org'].nil? || data['object'] =~ /(^checksum-.*$|^reports$)/
|
34
|
+
unless filter(data)
|
35
|
+
Monitor::Log.new(data.to_json, 'INFO')
|
36
|
+
sink.receive(data)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def filter(data)
|
45
|
+
filter_user(data) || filter_action(data)
|
46
|
+
end
|
47
|
+
|
48
|
+
def filter_user(data)
|
49
|
+
user_blacklist = Monitor::Config[:user_blacklist]
|
50
|
+
user_blacklist && (data['user'] =~ user_blacklist)
|
51
|
+
end
|
52
|
+
|
53
|
+
def filter_action(data)
|
54
|
+
action_blacklist = Monitor::Config[:action_blacklist]
|
55
|
+
action_blacklist && (data['action'] =~ action_blacklist)
|
56
|
+
end
|
57
|
+
|
58
|
+
def scan(line)
|
59
|
+
@regex = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - (.{0})- \[([^\]]+?)\] "(\w+) ([^\s]+?) (HTTP\/1\.1)" (\d+) "(.*)" (\d+) "-" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)"/
|
60
|
+
if line =~ @regex
|
61
|
+
data = {}
|
62
|
+
data['time'] = Regexp.last_match(3)
|
63
|
+
data['user'] = Regexp.last_match(16)
|
64
|
+
data['server'] = LOGMONNAME
|
65
|
+
data['org'] = Regexp.last_match(5).split('/')[2] unless Regexp.last_match(5).split('/')[2].nil?
|
66
|
+
data['object'] = Regexp.last_match(5).split('/')[3] unless Regexp.last_match(5).split('/')[3].nil?
|
67
|
+
data['name'] = Regexp.last_match(5).split('/')[4] unless Regexp.last_match(5).split('/')[4].nil?
|
68
|
+
data['version'] = Regexp.last_match(5).split('/')[5] unless Regexp.last_match(5).split('/')[5].nil?
|
69
|
+
data['action'] = Regexp.last_match(4)
|
70
|
+
return data
|
71
|
+
end
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
class Chef
|
3
|
+
class Deployment
|
4
|
+
class Monitor
|
5
|
+
class Sink
|
6
|
+
def receive(_data)
|
7
|
+
fail 'must be implemented by subclass'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class RmqSink < Sink
|
12
|
+
def initialize
|
13
|
+
@conn = Bunny.new(hostname: Monitor::Config[:mq_server])
|
14
|
+
@conn.start
|
15
|
+
|
16
|
+
@ch = @conn.create_channel
|
17
|
+
@q = @ch.queue(Monitor::Config[:mq_queue], durable: true)
|
18
|
+
end
|
19
|
+
|
20
|
+
def receive(data)
|
21
|
+
@q.publish(data, persistent: true, content_type: 'application/json')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class MarkerFileSink < Sink
|
26
|
+
# will modify the marker file
|
27
|
+
# last write data of marker file will be within 5 seconds
|
28
|
+
# of last deployement
|
29
|
+
def receive(data)
|
30
|
+
File.open(Monitor::Config[:marker_file], 'w+') do |f|
|
31
|
+
f.write(data['user'])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -15,7 +15,11 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
class
|
19
|
-
|
20
|
-
|
18
|
+
class Chef
|
19
|
+
class Deployment
|
20
|
+
class Monitor
|
21
|
+
VERSION = '0.2.0'
|
22
|
+
MAJOR, MINOR, TINY = VERSION.split('.')
|
23
|
+
end
|
24
|
+
end
|
21
25
|
end
|
data/lib/chef_logmon.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
18
|
+
require 'chef_deployment_monitor/log'
|
19
|
+
require 'chef_deployment_monitor/config'
|
20
|
+
require 'chef_deployment_monitor/sinks'
|
21
|
+
require 'chef_deployment_monitor/logmon'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-deployment-monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sander Botman
|
@@ -15,42 +15,70 @@ dependencies:
|
|
15
15
|
name: file-tail
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ! '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.0.12
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ! '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.0.12
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: daemons
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ! '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.1.9
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ! '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.1.9
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: mixlib-config
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ! '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
54
82
|
- !ruby/object:Gem::Version
|
55
83
|
version: '0'
|
56
84
|
description: Chef Monitoring tool to monitor all changes made
|
@@ -62,18 +90,20 @@ extensions: []
|
|
62
90
|
extra_rdoc_files:
|
63
91
|
- LICENSE
|
64
92
|
files:
|
93
|
+
- .gitignore
|
94
|
+
- .travis.yml
|
65
95
|
- Gemfile
|
66
96
|
- LICENSE
|
67
97
|
- README.md
|
68
98
|
- Rakefile
|
69
99
|
- bin/chef-logmon
|
70
|
-
- chef-monitor.gemspec
|
100
|
+
- chef-deployment-monitor.gemspec
|
101
|
+
- lib/chef_deployment_monitor/config.rb
|
102
|
+
- lib/chef_deployment_monitor/log.rb
|
103
|
+
- lib/chef_deployment_monitor/logmon.rb
|
104
|
+
- lib/chef_deployment_monitor/sinks.rb
|
105
|
+
- lib/chef_deployment_monitor/version.rb
|
71
106
|
- lib/chef_logmon.rb
|
72
|
-
- lib/chef_monitor/config.rb
|
73
|
-
- lib/chef_monitor/log.rb
|
74
|
-
- lib/chef_monitor/logmon.rb
|
75
|
-
- lib/chef_monitor/sinks.rb
|
76
|
-
- lib/chef_monitor/version.rb
|
77
107
|
homepage: https://github.com/kamaradclimber/chef-deployment-monitor
|
78
108
|
licenses:
|
79
109
|
- Apache 2.0
|
@@ -84,12 +114,12 @@ require_paths:
|
|
84
114
|
- lib
|
85
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
116
|
requirements:
|
87
|
-
- -
|
117
|
+
- - ! '>='
|
88
118
|
- !ruby/object:Gem::Version
|
89
119
|
version: '0'
|
90
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
121
|
requirements:
|
92
|
-
- -
|
122
|
+
- - ! '>='
|
93
123
|
- !ruby/object:Gem::Version
|
94
124
|
version: '0'
|
95
125
|
requirements: []
|
data/chef-monitor.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "chef_monitor/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "chef-deployment-monitor"
|
7
|
-
s.version = Monitor::VERSION
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.has_rdoc = false
|
10
|
-
s.extra_rdoc_files = ["LICENSE"]
|
11
|
-
s.authors = ["Sander Botman", 'Grégoire Seux']
|
12
|
-
s.email = ["g.seux@criteo.com"]
|
13
|
-
s.homepage = "https://github.com/kamaradclimber/chef-deployment-monitor"
|
14
|
-
s.summary = %q{Chef Monitoring tool to monitor all changes made}
|
15
|
-
s.description = s.summary
|
16
|
-
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = ["lib"]
|
20
|
-
s.license = 'Apache 2.0'
|
21
|
-
s.add_dependency "file-tail", ">= 1.0.12"
|
22
|
-
s.add_dependency "daemons", ">= 1.1.9"
|
23
|
-
s.add_dependency 'mixlib-config'
|
24
|
-
end
|
data/lib/chef_monitor/logmon.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Sander Botman (<sander.botman@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c) 2014 Sander Botman.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
class Monitor
|
19
|
-
class Logmon
|
20
|
-
|
21
|
-
def initialize(config)
|
22
|
-
@config = config
|
23
|
-
end
|
24
|
-
|
25
|
-
def run
|
26
|
-
|
27
|
-
sink = MarkerFileSink.new
|
28
|
-
|
29
|
-
begin
|
30
|
-
File.open(Monitor::Config[:mon_file]) do |mon|
|
31
|
-
mon.extend(File::Tail)
|
32
|
-
mon.interval = 5
|
33
|
-
mon.backward(1)
|
34
|
-
mon.tail { |line|
|
35
|
-
data = scan(line)
|
36
|
-
# skipping the objects 'checksum-.*' and 'reports'
|
37
|
-
unless data.nil? || data['org'].nil? || data['object'] =~ /(^checksum-.*$|^reports$)/
|
38
|
-
unless filter(data)
|
39
|
-
Monitor::Log.new(data.to_json, "INFO")
|
40
|
-
sink.receive(data)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def filter(data)
|
49
|
-
user_blacklist = Monitor::Config[:user_blacklist]
|
50
|
-
user_blacklist && (data['user'] =~ user_blacklist)
|
51
|
-
end
|
52
|
-
|
53
|
-
def scan(line)
|
54
|
-
@regex = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - (.{0})- \[([^\]]+?)\] "(PUT|DELETE|POST) ([^\s]+?) (HTTP\/1\.1)" (\d+) "(.*)" (\d+) "-" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)" "(.*)"/
|
55
|
-
if line =~ @regex
|
56
|
-
data = {}
|
57
|
-
data['time'] = $3
|
58
|
-
data['user'] = $16
|
59
|
-
data['server'] = LOGMONNAME
|
60
|
-
data['org'] = $5.split('/')[2] unless $5.split('/')[2].nil?
|
61
|
-
data['object'] = $5.split('/')[3] unless $5.split('/')[3].nil?
|
62
|
-
data['name'] = $5.split('/')[4] unless $5.split('/')[4].nil?
|
63
|
-
data['version'] = $5.split('/')[5] unless $5.split('/')[5].nil?
|
64
|
-
data['action'] = $4
|
65
|
-
return data
|
66
|
-
end
|
67
|
-
return nil
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
data/lib/chef_monitor/sinks.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
|
2
|
-
class Monitor
|
3
|
-
class Sink
|
4
|
-
def receive(data)
|
5
|
-
raise "must be implemented by subclass"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class RmqSink < Sink
|
10
|
-
def initialize
|
11
|
-
@conn = Bunny.new(:hostname => Monitor::Config[:mq_server])
|
12
|
-
@conn.start
|
13
|
-
|
14
|
-
@ch = @conn.create_channel
|
15
|
-
@q = @ch.queue(Monitor::Config[:mq_queue], :durable => true)
|
16
|
-
end
|
17
|
-
|
18
|
-
def receive(data)
|
19
|
-
@q.publish(data, :persistent => true, :content_type => "application/json")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class MarkerFileSink < Sink
|
24
|
-
# will modify the marker file
|
25
|
-
# last write data of marker file will be within 5 seconds
|
26
|
-
# of last deployement
|
27
|
-
def receive(data)
|
28
|
-
File.open(Monitor::Config[:marker_file], 'w+') do |f|
|
29
|
-
f.write(data['user'])
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|