core_to_rollbar 0.2.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/bin/core_to_rollbar +5 -0
- data/lib/core_to_rollbar.rb +70 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8807ec0ce23b02d84f5516a3deea373cfeb86cf8
|
4
|
+
data.tar.gz: f57cdb34230d5e3f2d0f5e5b1e31b29314fbfe6b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 87c87f5092577510d78f1a3084268406416b613b79f62fb10f156a667cb34d9fa58594db0749b470481a7978fb4fb78900d31b8ac54919aa55640b96a5ec9eab
|
7
|
+
data.tar.gz: 2c052ce7f719e809370acc154ed9de1b58562e158ac4a02ec77686b8316fa127a482fb4e1d441765a51f7930b163fd838ff2e40c34a9c6fb0d64a490c8ba4bc0
|
data/bin/core_to_rollbar
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'etc'
|
5
|
+
require 'rollbar'
|
6
|
+
require 'syslog'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
APPORT_LOCATION = '/usr/share/apport/apport'.freeze
|
10
|
+
CONFIG_FILE = '/etc/core_to_rollbar.yaml'.freeze
|
11
|
+
|
12
|
+
class CoreToRollbar
|
13
|
+
def run(args)
|
14
|
+
# arguments assumed in core_pattern:
|
15
|
+
# %p %u %h %s %t %E %c %P
|
16
|
+
@pid, @uid, @host, @signal, @time, @executable, @soft_limit, @initial_pid = args
|
17
|
+
|
18
|
+
Syslog.open('core_to_rollbar', Syslog::LOG_CONS)
|
19
|
+
Syslog.log(Syslog::LOG_ERR, "Reporting a crash of #{@executable} [#{@pid}] to rollbar")
|
20
|
+
|
21
|
+
failed = false
|
22
|
+
begin
|
23
|
+
forward_to_rollbar
|
24
|
+
rescue => e
|
25
|
+
Syslog.log(Syslog::LOG_CRIT, "Could not report the crash to rollbar: #{e}")
|
26
|
+
failed = true
|
27
|
+
end
|
28
|
+
begin
|
29
|
+
forward_to_apport
|
30
|
+
rescue => e
|
31
|
+
Syslog.log(Syslog::LOG_CRIT, "Could not report the crash to apport: #{e}")
|
32
|
+
failed = true
|
33
|
+
end
|
34
|
+
|
35
|
+
!failed
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def forward_to_rollbar
|
41
|
+
read_config
|
42
|
+
|
43
|
+
executable_fixed = @executable.tr('!', '/')
|
44
|
+
time_fixed = DateTime.strptime(@time, '%s')
|
45
|
+
|
46
|
+
message = "Process #{executable_fixed} [#{@pid}] running as uid #{@uid} on #{@host} crashed on signal #{@signal} at #{time_fixed}"
|
47
|
+
|
48
|
+
report_crash(message)
|
49
|
+
end
|
50
|
+
|
51
|
+
def forward_to_apport
|
52
|
+
exec(APPORT_LOCATION, @pid, @time, @soft_limit, @initial_pid)
|
53
|
+
end
|
54
|
+
|
55
|
+
def read_config
|
56
|
+
File.open(CONFIG_FILE) do |file|
|
57
|
+
@config = YAML.safe_load(file.read)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def report_crash(message)
|
62
|
+
Rollbar.configure do |config|
|
63
|
+
config.access_token = @config['access_token']
|
64
|
+
config.host = @host
|
65
|
+
config.environment = @config['environment'] || 'production'
|
66
|
+
end
|
67
|
+
|
68
|
+
Rollbar.error(message)
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: core_to_rollbar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stan Pitucha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rollbar
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email: stan.pitucha@envato.com
|
29
|
+
executables:
|
30
|
+
- core_to_rollbar
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/core_to_rollbar
|
35
|
+
- lib/core_to_rollbar.rb
|
36
|
+
homepage:
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.6.8
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Submits the crash report to rollbar and forwards it to apport
|
60
|
+
test_files: []
|