logflume 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/logflume/flume.rb +42 -10
- data/lib/logflume/syslog_constants.rb +35 -0
- data/lib/logflume/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1574262c08ea7ea7ed4397ac75d87a56dea416d6
|
4
|
+
data.tar.gz: c9b2fcfc55a57092d2377e248aea47d59a2345c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 262bf57233ce2b814740182339e6f964372fe05fc257c3fece571aea4952c7a70bdf8a4ed957c7b64b232ca0a2e17dac5d6ed30c80b8b227e8fe27906e8884f9
|
7
|
+
data.tar.gz: aedf52b24820a3bc04eddf8f85e36085a203edbdee6c61e96fda9ece1ec36e03d9f7f351c201e6eec16b36e25d21940340b4500678293270149b1f9d440be620
|
data/lib/logflume/flume.rb
CHANGED
@@ -9,6 +9,12 @@ module Logflume
|
|
9
9
|
@interval = opts[:interval] || 5.0
|
10
10
|
@pre_load = opts[:pre_load] || false
|
11
11
|
@blocking = opts[:blocking] || false
|
12
|
+
@prefix_syslog = opts[:prefix_syslog] || false
|
13
|
+
@syslog_sourceip = opts[:syslog_sourceip] || "127.0.0.1"
|
14
|
+
@syslog_facility = opts[:syslog_facility] || "local7"
|
15
|
+
@syslog_level = opts[:syslog_level] || "info"
|
16
|
+
@syslog_priority = opts[:syslog_priority] || "info"
|
17
|
+
@syslog_progname = opts[:syslog_progname] || "logflume"
|
12
18
|
@pipe = opts[:pipe] || "/tmp/logflume.pipe.#{$$}"
|
13
19
|
@configured = false
|
14
20
|
end
|
@@ -65,29 +71,45 @@ module Logflume
|
|
65
71
|
end
|
66
72
|
|
67
73
|
def create_pipe
|
68
|
-
if @blocking
|
74
|
+
if @blocking
|
69
75
|
@pipe_handler = Fifo.new(@pipe, :w, :wait)
|
70
|
-
else
|
76
|
+
else
|
71
77
|
@pipe_handler = Fifo.new(@pipe)
|
72
78
|
end
|
73
79
|
end
|
74
80
|
|
75
81
|
def hookup_pipe
|
76
|
-
@dw.add_observer do |*args|
|
77
|
-
args.each do |event|
|
78
|
-
|
82
|
+
@dw.add_observer do |*args|
|
83
|
+
args.each do |event|
|
84
|
+
|
79
85
|
if event.type == :added
|
80
86
|
#root = File.dirname(__FILE__)
|
81
87
|
#infile = File.join(root, event.path)
|
82
88
|
#@logger.info "new File found => #{infile}"
|
83
89
|
@logger.info "new File found => #{event.path}"
|
84
|
-
|
85
|
-
|
90
|
+
if @prefix_syslog
|
91
|
+
File.open(event.path).each_line do |line|
|
92
|
+
@pipe_handler.puts prefix + line
|
93
|
+
end
|
94
|
+
else
|
95
|
+
File.open(event.path).each_line do |line|
|
96
|
+
@pipe_handler.puts line
|
97
|
+
end
|
86
98
|
end
|
87
99
|
end
|
88
100
|
|
89
101
|
end
|
90
|
-
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def prefix
|
106
|
+
mytime = Time.now
|
107
|
+
#template("$SOURCEIP|$FACILITY|$PRIORITY|$LEVEL|$TAG|$YEAR-$MONTH-$DAY|$HOUR:$MIN:$SEC|$PROGRAM| $MSG\n")
|
108
|
+
#@syslog_priority = @syslog_facility * 8 + @syslog_severity
|
109
|
+
ymd = a.strftime("%Y-%M-%d")
|
110
|
+
hms = a.strftime("%H:%m:%S")
|
111
|
+
@tag = "logflume"
|
112
|
+
return "#{@syslog_sourceip}|#{@syslog_facility}|#{@syslog_priority}|#{@syslog_level}|#{@tag}|#{ymd}|#{hms}|#{@syslog_progname}| "
|
91
113
|
end
|
92
114
|
|
93
115
|
def directory_exists?(directory)
|
@@ -95,8 +117,18 @@ module Logflume
|
|
95
117
|
end
|
96
118
|
|
97
119
|
def destroy_pipe
|
98
|
-
::FileUtils.rm @pipe, :force => true
|
120
|
+
::FileUtils.rm @pipe, :force => true
|
121
|
+
end
|
122
|
+
|
123
|
+
# Borrowed from SyslogLogger.
|
124
|
+
def clean(message)
|
125
|
+
message = message.to_s.dup
|
126
|
+
message.strip! # remove whitespace
|
127
|
+
message.gsub!(/\n/, '\\n') # escape newlines
|
128
|
+
message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)
|
129
|
+
message.gsub!(/\e\[[^m]*m/, '') # remove useless ansi color codes
|
130
|
+
message
|
99
131
|
end
|
100
132
|
|
101
133
|
end
|
102
|
-
end
|
134
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
=begin
|
2
|
+
0 kern kernel messages
|
3
|
+
1 user user-level messages
|
4
|
+
2 mail mail system
|
5
|
+
3 daemon system daemons
|
6
|
+
4 auth security/authorization messages
|
7
|
+
5 syslog messages generated internally by syslogd
|
8
|
+
6 lpr line printer subsystem
|
9
|
+
7 news network news subsystem
|
10
|
+
8 uucp UUCP subsystem
|
11
|
+
9 clock daemon
|
12
|
+
10 authpriv security/authorization messages
|
13
|
+
11 ftp FTP daemon
|
14
|
+
12 - NTP subsystem
|
15
|
+
13 - log audit
|
16
|
+
14 - log alert
|
17
|
+
15 cron clock daemon
|
18
|
+
16 local0 local use 0 (local0)
|
19
|
+
17 local1 local use 1 (local1)
|
20
|
+
18 local2 local use 2 (local2)
|
21
|
+
19 local3 local use 3 (local3)
|
22
|
+
20 local4 local use 4 (local4)
|
23
|
+
21 local5 local use 5 (local5)
|
24
|
+
22 local6 local use 6 (local6)
|
25
|
+
23 local7 local use 7 (local7)
|
26
|
+
|
27
|
+
"code" => 0, "severity" => "Emergency", "keyword"emerg (panic) System is unusable. A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
28
|
+
1 Alert alert Action must be taken immediately. Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
29
|
+
2 Critical crit Critical conditions. Should be corrected immediately, but indicates failure in a secondary system, an example is a loss of a backup ISP connection.
|
30
|
+
3 Error err (error) Error conditions. Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time.
|
31
|
+
4 Warning warning (warn) Warning conditions. Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time.
|
32
|
+
5 Notice notice Normal but significant condition. Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
|
33
|
+
6 Informational info Informational messages. Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required.
|
34
|
+
7 Debug debug Debug-level messages. Info useful to developers for debugging the application, not useful during operations.
|
35
|
+
=end
|
data/lib/logflume/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logflume
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shadowbq
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: directory_watcher
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/logflume.rb
|
150
150
|
- lib/logflume/exceptions.rb
|
151
151
|
- lib/logflume/flume.rb
|
152
|
+
- lib/logflume/syslog_constants.rb
|
152
153
|
- lib/logflume/version.rb
|
153
154
|
- spec/data/flume/dpkg.log
|
154
155
|
- spec/data/flume/test.log
|