remote_syslog_sender 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/remote_syslog_sender/sender.rb +13 -3
- data/remote_syslog_sender.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 860ccfa2eb6457c816ad1461a9c6f2e1ab26827f
|
4
|
+
data.tar.gz: c0e4d13e4d178258ebc63e5096e845ad4f8447f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bba3380a97df8bdeb452580f2a16192c50d7a94598c2968ab3174781068e26aa5a82f5cdeb2218f15648c31cb4c8c8046a78ed8ee4ef9b0aedb89b1bbce3611
|
7
|
+
data.tar.gz: 4d265b126e5f4173c18ff685b57b52362ae69a519c89b7d47363595a4b73db064839344586071eb2a357810efb013c329272bb9cff5cf7f9497d159d560e6076
|
@@ -11,6 +11,9 @@ module RemoteSyslogSender
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
attr_reader :socket
|
15
|
+
attr_accessor :packet
|
16
|
+
|
14
17
|
def initialize(remote_hostname, remote_port, options = {})
|
15
18
|
@remote_hostname = remote_hostname
|
16
19
|
@remote_port = remote_port
|
@@ -19,22 +22,29 @@ module RemoteSyslogSender
|
|
19
22
|
|
20
23
|
@packet = Packet.new
|
21
24
|
|
22
|
-
local_hostname = options[:local_hostname] || (Socket.gethostname rescue `hostname`.chomp)
|
25
|
+
local_hostname = options[:hostname] || options[:local_hostname] || (Socket.gethostname rescue `hostname`.chomp)
|
23
26
|
local_hostname = 'localhost' if local_hostname.nil? || local_hostname.empty?
|
24
27
|
@packet.hostname = local_hostname
|
25
28
|
|
26
29
|
@packet.facility = options[:facility] || 'user'
|
27
30
|
@packet.severity = options[:severity] || 'notice'
|
28
|
-
@packet.tag = options[:program] || "#{File.basename($0)}[#{$$}]"
|
31
|
+
@packet.tag = options[:tag] || options[:program] || "#{File.basename($0)}[#{$$}]"
|
29
32
|
|
30
33
|
@socket = nil
|
31
34
|
end
|
32
35
|
|
33
|
-
def transmit(message)
|
36
|
+
def transmit(message, packet_options = nil)
|
34
37
|
message.split(/\r?\n/).each do |line|
|
35
38
|
begin
|
36
39
|
next if line =~ /^\s*$/
|
37
40
|
packet = @packet.dup
|
41
|
+
if packet_options
|
42
|
+
packet.tag = packet_options[:program] if packet_options[:program]
|
43
|
+
packet.hostname = packet_options[:local_hostname] if packet_options[:local_hostname]
|
44
|
+
%i(hostname facility severity tag).each do |key|
|
45
|
+
packet.send("#{key}=", packet_options[key]) if packet_options[key]
|
46
|
+
end
|
47
|
+
end
|
38
48
|
packet.content = line
|
39
49
|
send_msg(packet.assemble(@packet_size))
|
40
50
|
rescue
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'remote_syslog_sender'
|
3
|
-
s.version = '1.1.
|
3
|
+
s.version = '1.1.1'
|
4
4
|
s.summary = "Message sender that sends directly to a remote syslog endpoint"
|
5
5
|
s.description = "Message sender that sends directly to a remote syslog endpoint (Support UDP, TCP, TCP+TLS)"
|
6
6
|
|