lognotify 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6dfcb7af64eb44ded509098ca04f6def5d1c2fca
4
+ data.tar.gz: 6bfd5d1d56e2b608ba27fc866d6b714839b0644d
5
+ SHA512:
6
+ metadata.gz: 92c40ae9eeb45838e8ee31e9d2919f16e0108051380fab04bb301d6555370dc44f2b08d45bf53049a194c086ddd767922f221d9af1c2ec9cc76b8aceb3e8632a
7
+ data.tar.gz: 4542fccf0d1ea09e5a155bd6fd70877e8895a47346e80be64dae7348ab23536cfefc27af815c70e557488653390967739f500dea8360b97d0e9750ab58366724
Binary file
Binary file
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: lognotify.rb
4
+
5
+ require 'sps-pub'
6
+
7
+
8
+ class LogNotify
9
+
10
+ def initialize(logfile, sps_address: nil, sps_port: 59000, sps_topic: 'lognotify')
11
+
12
+ @sps = sps_address ? SPSPub.new(address: sps_address, port: sps_port) : nil
13
+ @sps_topic = sps_topic
14
+
15
+ @command = 'tail -n 1 -f ' + logfile
16
+
17
+ end
18
+
19
+ def on_update(entry)
20
+
21
+ # custom defined
22
+
23
+ end
24
+
25
+ def start()
26
+
27
+ t = Time.now # using the time we can ignore existing entries
28
+
29
+ IO.popen(@command).each_line do |x|
30
+
31
+ # anything after 5 seconds from start is new
32
+ if Time.now > t + 5 then
33
+
34
+ raw_log_entry = x.lines.last
35
+
36
+ #@sps.notice(@sps_topic + ': ' + json) if @sps
37
+ on_update(raw_log_entry)
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ if __FILE__ == $0 then
46
+
47
+ ln = LogNotify.new('/var/log/messages')
48
+
49
+ def ln.on_update(entry)
50
+
51
+ puts 'entry: ' + entry.inspect
52
+
53
+ end
54
+
55
+ ln.start
56
+
57
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lognotify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE1MTAwNDA5NDUxN1oXDTE2MTAwMzA5NDUxN1owSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAKQEp+VQBEPU87HOP59a6qJn2YnBr+Z1ytKyn2kMSAxDMoYF8C/jRumKEJwy
19
+ ZZLUWkWkJTcnxZAe0Ag4zmS0ij+5PNRbxL53oewtfCEmDpzzhOoyFAZYpgYI4Dj1
20
+ 78XXaP7bqoAvWkip1/IoVLonzaIdPvFVxTUPiiMP7XB2FmovEOq5rWsJA90UKZpa
21
+ I1hDLBlMPeo8QSGuA+HUzrwRJ9t5Z8+hugQE/EXPQADSKdox5RAbvCSBKfduPByp
22
+ tICq+73VQXHr4iUTpgL+CrGu7MGKbFW0nvZxrJH36Ee817gSSFT4b0rzBB0f7qQd
23
+ qo4FvJ118dqnY07tG5Lh2CilLJsCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQU8IzYHGUkhlZ2U/MbRur9oQQTkJowJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEADdkwS96s
27
+ dcfxXLK+J9dgjx7GPmFdxzavMkb9fMtFxZUcNuaorCBCX4+TuCEI5QFpHJp3PNBV
28
+ je9mx10vhYpkXzqagEQYJ3sL8AzPmwnb6r2Qtovmner0QOD5WH51yl41mx+3lvVv
29
+ /8hW4VihzTBUSQAdAzlwM7u5oUrRG1OZu5Br/JNUENuqyIbpFoqgQr3EQ3MhpAsu
30
+ uQvInsjAwdw+K3NmGCD5MM+IZH0kKRGScGCqyZpVWBsOMnPJU4+Vm3slTaaBhBPm
31
+ jQarmH/mSu2199AGM47NcPurKNtbKiJmdgP2BRlxr+xfBVMx/kxtWTyGpUEVnySM
32
+ 8emjzy61C0eJ9Q==
33
+ -----END CERTIFICATE-----
34
+ date: 2015-10-04 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: sps-pub
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.4'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.4.0
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.4'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.4.0
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/lognotify.rb
63
+ homepage: https://github.com/jrobertson/lognotify
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Actively monitors a log file for new entries and can trigger an event using
87
+ a regular expression
88
+ test_files: []
@@ -0,0 +1 @@
1
+