le 1.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/LE.gemspec +4 -4
- data/{lib1.2backup → lib}/le.rb +9 -1
- data/{lib1.2backup → lib}/le/host.rb +9 -1
- data/{lib1.2backup → lib}/le/host/https.rb +9 -0
- data/lib/le/host/https/tcp.rb +75 -0
- metadata +9 -8
- data/lib1.2backup/le/host/https/tcp.rb +0 -41
data/LE.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
dir = File.dirname(__FILE__)
|
2
|
-
require File.expand_path(File.join(dir, '
|
2
|
+
require File.expand_path(File.join(dir, 'lib', 'le'))
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "le"
|
6
|
-
s.version = "1.4"
|
6
|
+
s.version = "1.4.5"
|
7
7
|
s.date = Time.now
|
8
8
|
s.summary = "Logentries plugin"
|
9
9
|
s.description =<<EOD
|
@@ -13,7 +13,7 @@ EOD
|
|
13
13
|
s.authors = ["Mark Lacomber (Logentries)"]
|
14
14
|
s.email = "marklacomber@gmail.com"
|
15
15
|
|
16
|
-
s.files = %w{ LE.gemspec } + Dir["#{dir}/
|
17
|
-
s.require_paths = ["
|
16
|
+
s.files = %w{ LE.gemspec } + Dir["#{dir}/lib/**/*.rb"]
|
17
|
+
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
end
|
data/{lib1.2backup → lib}/le.rb
RENAMED
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
#
|
5
|
+
# Logentries Ruby monitoring agent
|
6
|
+
# Copyright 2010,2011 Logentries, Jlizard
|
7
|
+
# Mark Lacomber <marklacomber@gmail.com>
|
8
|
+
#
|
9
|
+
|
2
10
|
require File.join(File.dirname(__FILE__), 'le', 'host')
|
3
11
|
|
4
12
|
require 'logger'
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
#
|
5
|
+
# Logentries Ruby monitoring agent
|
6
|
+
# Copyright 2010,2011 Logentries, Jlizard
|
7
|
+
# Mark Lacomber <marklacomber@gmail.com>
|
8
|
+
#
|
9
|
+
|
10
|
+
module Le
|
11
|
+
module Host
|
12
|
+
class HTTPS
|
13
|
+
|
14
|
+
class TCPSOCKET
|
15
|
+
|
16
|
+
attr_accessor :sock, :conn, :key, :location
|
17
|
+
def initialize(key, location)
|
18
|
+
|
19
|
+
@key = key
|
20
|
+
@location = location
|
21
|
+
begin
|
22
|
+
createSocket(key, location)
|
23
|
+
rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
24
|
+
$stderr.puts "WARNING: #{e.class} creating the connection to Logentries. #{e.message}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def createSocket(key, location)
|
29
|
+
|
30
|
+
addr = sprintf('/%s/hosts/%s/?realtime=1', key, location)
|
31
|
+
|
32
|
+
# Open the TCP connection to the Logentries Server
|
33
|
+
@sock = TCPSocket.new('api.logentries.com', 443)
|
34
|
+
|
35
|
+
@conn = OpenSSL::SSL::SSLSocket.new(@sock, OpenSSL::SSL::SSLContext.new())
|
36
|
+
@conn.sync_close = true
|
37
|
+
@conn.connect
|
38
|
+
|
39
|
+
# Set up connection with Logentries API to receive messages in chunks, i.e, logs
|
40
|
+
request = sprintf("PUT %s HTTP/1.1\r\n", addr)
|
41
|
+
@conn.print(request)
|
42
|
+
@conn.print("Accept-Encoding: identity\r\n")
|
43
|
+
@conn.print("Transfer_Encoding: chunked\r\n\r\n")
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def deliver(message)
|
48
|
+
|
49
|
+
if @conn == nil
|
50
|
+
begin
|
51
|
+
createSocket(@key, @location)
|
52
|
+
rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
53
|
+
$stderr.puts "WARNING: #{e.class} Could not write log. No connection to Logentries #{e.message}"
|
54
|
+
return
|
55
|
+
end
|
56
|
+
end
|
57
|
+
# Sends the log to the Logentries Server
|
58
|
+
begin
|
59
|
+
@conn.print(message + "\r\n")
|
60
|
+
rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ENOTCONN, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
61
|
+
|
62
|
+
$stderr.puts "WARNING: #{e.class} sending log #{e.message}"
|
63
|
+
begin
|
64
|
+
createSocket(@key, @location)
|
65
|
+
rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
66
|
+
$stderr.puts "WARNING: #{e.class} creating the connection to Logentries. #{e.message}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: le
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
|
9
|
+
- 5
|
10
|
+
version: 1.4.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Mark Lacomber (Logentries)
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-08-09 00:00:00 Z
|
18
19
|
dependencies: []
|
19
20
|
|
20
21
|
description: |
|
@@ -29,10 +30,10 @@ extra_rdoc_files: []
|
|
29
30
|
|
30
31
|
files:
|
31
32
|
- LE.gemspec
|
32
|
-
- ./
|
33
|
-
- ./
|
34
|
-
- ./
|
35
|
-
- ./
|
33
|
+
- ./lib/le.rb
|
34
|
+
- ./lib/le/host.rb
|
35
|
+
- ./lib/le/host/https.rb
|
36
|
+
- ./lib/le/host/https/tcp.rb
|
36
37
|
homepage:
|
37
38
|
licenses: []
|
38
39
|
|
@@ -40,7 +41,7 @@ post_install_message:
|
|
40
41
|
rdoc_options: []
|
41
42
|
|
42
43
|
require_paths:
|
43
|
-
-
|
44
|
+
- lib
|
44
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
46
|
none: false
|
46
47
|
requirements:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Le
|
2
|
-
module Host
|
3
|
-
class HTTPS
|
4
|
-
|
5
|
-
class TCPSOCKET
|
6
|
-
|
7
|
-
attr_accessor :sock, :conn
|
8
|
-
def initialize(key, location)
|
9
|
-
|
10
|
-
# Create the unique address comprising of user-key and location of file on logentries server
|
11
|
-
addr = sprintf('/%s/hosts/%s/?realtime=1', key, location)
|
12
|
-
|
13
|
-
# Open the TCP connection to the Logentries Server
|
14
|
-
@sock = TCPSocket.new('api.logentries.com', 443)
|
15
|
-
|
16
|
-
@conn = OpenSSL::SSL::SSLSocket.new(@sock, OpenSSL::SSL::SSLContext.new())
|
17
|
-
@conn.sync_close = true
|
18
|
-
@conn.connect
|
19
|
-
|
20
|
-
# Set up connection with Logentries API to receive messages in chunks, i.e, logs
|
21
|
-
request = sprintf("PUT %s HTTP/1.1\r\n", addr)
|
22
|
-
@conn.print(request)
|
23
|
-
@conn.print("Accept-Encoding: identity\r\n")
|
24
|
-
@conn.print("Transfer_Encoding: chunked\r\n\r\n")
|
25
|
-
end
|
26
|
-
|
27
|
-
def deliver(message)
|
28
|
-
|
29
|
-
# Sends the log to the Logentries Server
|
30
|
-
begin
|
31
|
-
@conn.print(message + "\r\n")
|
32
|
-
rescue OpenSSL::SSL::SSLError, TimeoutError, Errno::ECONNRESET, EOFError => e
|
33
|
-
$stderr.puts "WARNING: #{e.class} sending log #{message}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|