konverge 1.0.0
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 +7 -0
- data/LICENSE +165 -0
- data/README.rdoc +62 -0
- data/lib/cacert.pem +3554 -0
- data/lib/konverge.rb +118 -0
- metadata +61 -0
data/lib/konverge.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'net/https'
|
5
|
+
|
6
|
+
def loadable?(name) begin gem name; return true; rescue Exception => e; return false; end end
|
7
|
+
class Object
|
8
|
+
def empty?() return self.nil? || self == false || self == 0 || self == ''; end
|
9
|
+
end
|
10
|
+
|
11
|
+
if loadable?('json')
|
12
|
+
require 'json/ext'
|
13
|
+
elsif loadable?('json_pure')
|
14
|
+
require 'json/pure'
|
15
|
+
else
|
16
|
+
puts '***Konverge*** JSON is required'
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
class Konverge
|
21
|
+
private_class_method :new
|
22
|
+
|
23
|
+
def self.assert(message) internal('Assert',message,caller(1)) unless yield end
|
24
|
+
def self.capture(type,message) internal(type,message,caller(1)) end
|
25
|
+
def self.critical(message) internal('Critical',message,caller(1)) end
|
26
|
+
def self.database(message) internal('Database',message,caller(1)) end
|
27
|
+
def self.debug(message) internal('Debug',message,caller(1)) end
|
28
|
+
def self.error(message) internal('Error',message,caller(1)) end
|
29
|
+
def self.exception(e) internal('Exception',e.class.name + ': ' + e.message,e.backtrace) end
|
30
|
+
def self.info(message) internal('Info',message,caller(1)) end
|
31
|
+
def self.initialize(server,apiKey,version = nil,useSSL = true)
|
32
|
+
begin
|
33
|
+
return if server.empty? || apiKey.empty?
|
34
|
+
version = '1.0' if version==nil
|
35
|
+
useSSL = true if useSSL!=false
|
36
|
+
Signal.trap("EXIT") { unless $!.class.name == "SystemExit" || $!.nil?; Konverge::exception($!); exit!; end }
|
37
|
+
at_exit { unless $!.class.name == "SystemExit" || $!.nil?; Konverge::exception($!); exit!; end }
|
38
|
+
@@variables['Host'] = server.split('/',2)[0]
|
39
|
+
@@variables['Path'] = server.sub(@@variables['Host'],'')
|
40
|
+
@@variables['APIKey'] = apiKey
|
41
|
+
@@variables['Version'] = version
|
42
|
+
@@variables['UseSSL'] = useSSL
|
43
|
+
@@variables['Enabled'] = true
|
44
|
+
rescue Exception => ignore
|
45
|
+
end
|
46
|
+
end
|
47
|
+
def self.isEnabled?() !@@variables['Enabled'].empty? end
|
48
|
+
def self.isInitialized?() !@@variables['Host'].empty? && !@@variables['APIKey'].empty? end
|
49
|
+
def self.warning(message) internal('Warning',message,caller(1)) end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def self.build_query(parameters)
|
54
|
+
string = ''
|
55
|
+
parameters.each do |pair|
|
56
|
+
string << '&' if string.length > 0
|
57
|
+
string << pair[0].to_s << '=' << URI.escape(pair[1].to_s,Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
58
|
+
end
|
59
|
+
return string
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.internal(type,message,context = nil)
|
63
|
+
return if !isInitialized?
|
64
|
+
return if !isEnabled?
|
65
|
+
begin
|
66
|
+
message << "\n " << context.join("\n ") if !context.empty?;
|
67
|
+
|
68
|
+
environment = Hash.new
|
69
|
+
ENV.each_pair do |k,v| environment[k] = v; end
|
70
|
+
|
71
|
+
platform = Hash.new
|
72
|
+
platform['Gem Directory'] = Gem::dir
|
73
|
+
platform['Bin Directory'] = Gem::default_bindir
|
74
|
+
platform['Marshal Version'] = Gem::marshal_version
|
75
|
+
platform['Binary Mode'] = Gem::binary_mode
|
76
|
+
platform['Config File'] = Gem::config_file
|
77
|
+
#platform['Configurtion'] = Gem::configuration
|
78
|
+
platform['Executable'] = Gem::ruby
|
79
|
+
platform['Engine'] = Gem::ruby_engine
|
80
|
+
platform['Platform'] = Gem::platforms[1].to_s if Gem::platforms.length > 1
|
81
|
+
platform['Version'] = Gem::ruby_version.to_s
|
82
|
+
platform['Gems'] = []
|
83
|
+
Gem::Specification.each { |x| platform['Gems'].push(x.name + '-' + x.version.to_s) }
|
84
|
+
|
85
|
+
extra = Hash.new
|
86
|
+
extra['Environment'] = environment;
|
87
|
+
extra['Platform'] = platform;
|
88
|
+
|
89
|
+
request = Hash.new;
|
90
|
+
request['APIKey'] = @@variables['APIKey'];
|
91
|
+
request['Event'] = message;
|
92
|
+
request['Extra'] = JSON.generate(extra)
|
93
|
+
request['Platform'] = 8;
|
94
|
+
request['Time'] = Time.now.to_i;
|
95
|
+
request['Type'] = type;
|
96
|
+
request['Version'] = @@variables['Version'];
|
97
|
+
|
98
|
+
http = nil
|
99
|
+
if @@variables['UseSSL'] == true
|
100
|
+
http = Net::HTTP.new(@@variables['Host'],443)
|
101
|
+
http.use_ssl = true
|
102
|
+
#http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
103
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
104
|
+
http.ca_file = File.dirname(__FILE__) + '/cacert.pem'
|
105
|
+
else
|
106
|
+
http = Net::HTTP.new(@@variables['Host'],80)
|
107
|
+
end
|
108
|
+
http.post(@@variables['Path'] + '/rest/event-add.jsp',build_query(request))
|
109
|
+
|
110
|
+
rescue Exception => ignore
|
111
|
+
@@variables['Enabled'] = false
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
@@variables = Hash.new
|
116
|
+
end
|
117
|
+
|
118
|
+
Konverge::initialize(ENV['KONVERGE_SERVER'],ENV['KONVERGE_API_KEY'],ENV['KONVERGE_APP_VERSION']) if !ENV['KONVERGE_API_KEY'].empty?;
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: konverge
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konverge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.7.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.7.3
|
27
|
+
description: Konverge
|
28
|
+
email: support@konverge.io
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/konverge.rb
|
34
|
+
- lib/cacert.pem
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
homepage: https://www.konverge.io/
|
38
|
+
licenses:
|
39
|
+
- LGPLv3
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.8.7
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project: konverge
|
57
|
+
rubygems_version: 2.0.3
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Monitor exceptions, errors, and custom logging events.
|
61
|
+
test_files: []
|