snoopit 0.0.1

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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +39 -0
  4. data/.idea/.name +1 -0
  5. data/.idea/.rakeTasks +7 -0
  6. data/.idea/dictionaries/rbirch.xml +9 -0
  7. data/.idea/encodings.xml +5 -0
  8. data/.idea/misc.xml +5 -0
  9. data/.idea/modules.xml +9 -0
  10. data/.idea/scopes/scope_settings.xml +5 -0
  11. data/.idea/snoopit.iml +233 -0
  12. data/.idea/vcs.xml +7 -0
  13. data/.rspec +2 -0
  14. data/.travis.yml +7 -0
  15. data/Gemfile +15 -0
  16. data/LICENSE.txt +22 -0
  17. data/README.md +411 -0
  18. data/Rakefile +1 -0
  19. data/bin/snoopit +173 -0
  20. data/lib/snoopit.rb +22 -0
  21. data/lib/snoopit/detected.rb +50 -0
  22. data/lib/snoopit/file_info.rb +104 -0
  23. data/lib/snoopit/file_tracker.rb +83 -0
  24. data/lib/snoopit/logger.rb +30 -0
  25. data/lib/snoopit/notification_manager.rb +123 -0
  26. data/lib/snoopit/notifier.rb +25 -0
  27. data/lib/snoopit/notifiers/email.rb +61 -0
  28. data/lib/snoopit/notifiers/http.rb +85 -0
  29. data/lib/snoopit/notifiers/https.rb +21 -0
  30. data/lib/snoopit/notifiers/stomp.rb +59 -0
  31. data/lib/snoopit/register.rb +69 -0
  32. data/lib/snoopit/sniffer.rb +51 -0
  33. data/lib/snoopit/snooper.rb +149 -0
  34. data/lib/snoopit/snoopy.rb +67 -0
  35. data/lib/snoopit/version.rb +3 -0
  36. data/snoopit.gemspec +27 -0
  37. data/spec/bin/snoopit_spec.rb +258 -0
  38. data/spec/file_info_spec.rb +131 -0
  39. data/spec/file_tracker_spec.rb +172 -0
  40. data/spec/notification_manager_spec.rb +103 -0
  41. data/spec/notifiers/email_spec.rb +36 -0
  42. data/spec/notifiers/http_spec.rb +37 -0
  43. data/spec/notifiers/https_spec.rb +38 -0
  44. data/spec/notifiers/stomp_spec.rb +34 -0
  45. data/spec/register_spec.rb +105 -0
  46. data/spec/snooper_spec.rb +538 -0
  47. data/spec/spec_helper.rb +24 -0
  48. data/spec/support/log/snoop_log.test +593 -0
  49. data/spec/support/log/snoop_log_2.test +593 -0
  50. data/spec/support/multiple_snoopies.json +82 -0
  51. data/spec/support/regexp_tester.rb +10 -0
  52. data/spec/support/snoopies.json +93 -0
  53. data/spec/support/snoopies_notifiers.json +66 -0
  54. data/spec/support/test_notifier.rb +18 -0
  55. data/spec/support/test_notifier_load.rb +18 -0
  56. data/support/snoopies.json +110 -0
  57. metadata +190 -0
@@ -0,0 +1,82 @@
1
+ { "snoopers" :
2
+ {
3
+ "SnoopTest":
4
+ {
5
+ "snoop": "./spec/support/log/snoop_log.test",
6
+ "dir": {
7
+ "path": "./spec/support/log",
8
+ "glob": "*.test"
9
+ },
10
+ "sniffers": [
11
+ {
12
+ "comment": "Bad status from lisp server",
13
+ "regexp": "Non OK Status",
14
+ "lines": {
15
+ "before": 2,
16
+ "after": 2
17
+ },
18
+ "notify": [
19
+ {
20
+ "Test Notifier": null
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "comment": "Failed Bulk load, typically one or more bad records. Need to use manual loader",
26
+ "regexp": "Failed to bulk load",
27
+ "lines": {
28
+ "before": 2,
29
+ "after": 2
30
+ },
31
+ "notify": [
32
+ {
33
+ "Test Notifier": null
34
+ }
35
+ ]
36
+
37
+ }
38
+ ]
39
+ },
40
+ "SnoopTest2":
41
+ {
42
+ "snoop": "./spec/support/log/snoop_log_2.test",
43
+ "dir": {
44
+ "path": "./spec/support/log",
45
+ "glob": "*.test"
46
+ },
47
+ "sniffers": [
48
+ {
49
+ "comment": "Bad status from lisp server",
50
+ "regexp": "Non OK Status",
51
+ "lines": {
52
+ "before": 2,
53
+ "after": 2
54
+ },
55
+ "notify": [
56
+ {
57
+ "Test Notifier": null
58
+ }
59
+ ]
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ "notifiers" :
65
+ {
66
+ "load" : {
67
+ "Test Notifier Load" : {
68
+ "file" : "./spec/support/test_notifier_load",
69
+ "class" : "TestNotifierLoad",
70
+ "config" : { }
71
+ }
72
+ },
73
+ "email" : {
74
+ "smtp-server" : "smtp.gmail.com",
75
+ "port" : 587,
76
+ "tls" : true,
77
+ "user" : "",
78
+ "password" : "",
79
+ "authentication" : "login"
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ #regexp = Regexp.new 'Total Number of records loaded'
5
+ regexp = Regexp.new 'Total Number of records:'
6
+ File.foreach 'snoop.log' do |line|
7
+ regexp.match line do |m|
8
+ puts "Match: #{m}"
9
+ end
10
+ end
@@ -0,0 +1,93 @@
1
+ { "snoopers" :
2
+ {
3
+ "SnoopTest": {
4
+ "snoop": "./spec/support/log/snoop_log.test",
5
+ "dir": {
6
+ "path": "./spec/support/log",
7
+ "glob": "*.test"
8
+ },
9
+ "sniffers": [
10
+ {
11
+ "comment": "Bad status from lisp server",
12
+ "regexp": "Non OK Status",
13
+ "lines": {
14
+ "before": 2,
15
+ "after": 2
16
+ },
17
+ "notify": {
18
+ "Test Notifier": {
19
+ "param1": "value1",
20
+ "param2": "value2"
21
+ }
22
+ }
23
+ },
24
+ {
25
+ "comment": "Failed Bulk load, typically one or more bad records. Need to use manual loader",
26
+ "regexp": "Failed to bulk load",
27
+ "lines": {
28
+ "before": 2,
29
+ "after": 2
30
+ },
31
+ "notify": {
32
+ "Test Notifier": {
33
+ "param1": "value1",
34
+ "param2": "value2"
35
+ }
36
+ }
37
+ },
38
+ {
39
+ "comment": "Data gathered to generate a statistics report",
40
+ "regexp": "Total Number of records:",
41
+ "lines": {
42
+ "before": 1,
43
+ "after": 1
44
+ },
45
+ "notify": {
46
+ "Test Notifier Load": {
47
+ "param1": "value1",
48
+ "param2": "value2"
49
+ }
50
+ }
51
+ }
52
+ ]
53
+ },
54
+ "AppServer2" : {
55
+ "snoop": "./spec/support/log/snoop_log.test",
56
+ "dir": {
57
+ "path": "./spec/support/log",
58
+ "glob": "*.test"
59
+ },
60
+ "sniffers" : [
61
+ {
62
+ "comment": "Bad status from app server",
63
+ "regexp": "Non OK Status",
64
+ "lines": {
65
+ "before": 2,
66
+ "after": 2
67
+ }
68
+ }
69
+ ]
70
+ }
71
+ },
72
+ "notifiers" :
73
+ {
74
+ "load" : {
75
+ "Test Notifier Load" : {
76
+ "file" : "./spec/support/test_notifier_load",
77
+ "class" : "TestNotifierLoad",
78
+ "config" : {
79
+ "c_param1" : "value1",
80
+ "c_param2" : "value2"
81
+ }
82
+ }
83
+ },
84
+ "email" : {
85
+ "smtp-server" : "smtp.gmail.com",
86
+ "port" : 587,
87
+ "tls" : true,
88
+ "user" : "",
89
+ "password" : "",
90
+ "authentication" : "login"
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,66 @@
1
+ { "snoopers" :
2
+ {
3
+ "SnooperTest": {
4
+ "snoop": "./spec/support/log/snoop_log.test",
5
+ "dir": {
6
+ "path": "./spec/support/log",
7
+ "glob": "*.test"
8
+ },
9
+ "sniffers": [
10
+ {
11
+ "comment": "Failed Bulk load, typically one or more bad records. Need to use manual loader",
12
+ "regexp": "Failed to bulk load",
13
+ "lines": {
14
+ "before": 2,
15
+ "after": 2
16
+ },
17
+ "notify": {
18
+ "email": {
19
+ "to": [ "admin@noxaos.com", "robert.birch@noxaos.com" ],
20
+ "from": "snooper@noxaos.com"
21
+ },
22
+ "http" : {
23
+ "url" : "http://localhost:3000/snoops/snooped"
24
+ },
25
+ "https" : {
26
+ "url" : "https://localhost:3000/snoops/snooped"
27
+ },
28
+ "stomp" : {
29
+ "queue" : "/queue/snooped",
30
+ "headers" : {
31
+ "key-a": "a",
32
+ "key-b": "b"
33
+ }
34
+ }
35
+ }
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ "notifiers" : {
41
+ "email": {
42
+ "smtp-server": "smtp.gmail.com",
43
+ "port": 587,
44
+ "tls": true,
45
+ "user": "",
46
+ "password": "",
47
+ "authentication": "login"
48
+ },
49
+ "http": {
50
+ "api-key": "BR549"
51
+ },
52
+ "https": {
53
+ "api-key": "BR549"
54
+ },
55
+ "stomp": {
56
+ "host": "localhost",
57
+ "port": "61613",
58
+ "login": "admin",
59
+ "passcode": "flintstone",
60
+ "headers": {
61
+ "accept-version": "1.1",
62
+ "host": "chatterlens"
63
+ }
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,18 @@
1
+ require 'snoopit'
2
+
3
+ class TestNotifier < Snoopit::Notifier
4
+
5
+ attr :found, :params, :config
6
+
7
+ def initialize(config=nil)
8
+ super config, 'Test Notifier'
9
+ @found = []
10
+ @params = nil
11
+ end
12
+
13
+ def notify(found, notify_params=nil)
14
+ @params = notify_params
15
+ @found << found
16
+ end
17
+
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'snoopit'
2
+
3
+ class TestNotifierLoad < Snoopit::Notifier
4
+
5
+ attr :found, :config, :params
6
+
7
+ def initialize(config=nil)
8
+ super config, 'Test Notifier Load'
9
+ @found = []
10
+ @params = nil
11
+ end
12
+
13
+ def notify(found, notify_params=nil)
14
+ @found << found
15
+ @params = notify_params
16
+ end
17
+
18
+ end
@@ -0,0 +1,110 @@
1
+ {
2
+ "snoopers" : {
3
+ "AppServer" : {
4
+ "snoop" : "/Users/snoopers/log/app_server.log",
5
+ "dir" : {
6
+ "path" : "/Users/snoopers/log",
7
+ "glob" : "*.log"
8
+ },
9
+ "sniffers" : [
10
+ {
11
+ "comment" : "Bad status from app server",
12
+ "regexp" : "Non OK Status",
13
+ "lines" : {
14
+ "before" : 2,
15
+ "after" : 2
16
+ },
17
+ "notify" : {
18
+ "email" : {
19
+ "to" : "somebody@somemail.com",
20
+ "from" : "snooper@noxaos.com"
21
+ },
22
+ "http" : {
23
+ "url" : "http://localhost:3000/snoopers/snooped"
24
+ },
25
+ "stomp" : {
26
+ "queue" : "/queue/snooped",
27
+ "headers" : {
28
+ "persistent" : true
29
+ }
30
+ }
31
+ }
32
+ },
33
+ {
34
+ "comment" : "Failed Bulk load failure!",
35
+ "regexp" : "Failed to bulk load",
36
+ "lines" : {
37
+ "before" : 2,
38
+ "after" : 2
39
+ },
40
+ "notify" :
41
+ {
42
+ "email" : {
43
+ "to" : [
44
+ "someone@somemail.com",
45
+ "somebody@somemail.com"
46
+ ],
47
+ "from" : "snooper@noxaos.com"
48
+ }
49
+ }
50
+ }
51
+ ]
52
+ },
53
+ "AppServer2" : {
54
+ "snoop" : "/Users/snoopers/log/app_server.log",
55
+ "dir" : {
56
+ "path" : "/Users/snoopers/log",
57
+ "glob" : "*.log"
58
+ },
59
+ "sniffers" : [
60
+ {
61
+ "comment": "Bad status from app server",
62
+ "regexp": "Non OK Status",
63
+ "lines": {
64
+ "before": 2,
65
+ "after": 2
66
+ }
67
+ }
68
+ ]
69
+ }
70
+ },
71
+ "notifiers" : {
72
+ "load" : {
73
+ "Notifier Identifier" : {
74
+ "file" : "/path/to/mynotifier",
75
+ "class" : "MyNotifierClassName",
76
+ "config" : {
77
+ "configParms" : "PassedAfterCreated"
78
+ }
79
+ }
80
+ },
81
+ "email" : {
82
+ "smtp-server" : "smtp.gmail.com",
83
+ "port" : 587,
84
+ "tls" : true,
85
+ "user" : "admin@foomail.com",
86
+ "password" : "",
87
+ "authentication" : "login"
88
+ },
89
+ "http" : {
90
+ "api-key" : "BR549",
91
+ "user" : "fred",
92
+ "password" : "flintstone"
93
+ },
94
+ "https" : {
95
+ "api-key" : "BR549",
96
+ "user" : "fred",
97
+ "password" : "flintstone"
98
+ },
99
+ "stomp" : {
100
+ "host" : "localhost",
101
+ "port" : "61613",
102
+ "login" : "fred",
103
+ "passcode" : "flintstone",
104
+ "headers" : {
105
+ "accept-version" : "1.1",
106
+ "host" : "vhost"
107
+ }
108
+ }
109
+ }
110
+ }
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snoopit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Robert Birch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: stomp
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: '10.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: '10.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: '2.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: '2.14'
83
+ description: Snoops files for specified information via a simple configuration file
84
+ email:
85
+ - robdbirch@gmail.com
86
+ executables:
87
+ - snoopit
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".coveralls.yml"
92
+ - ".gitignore"
93
+ - ".idea/.name"
94
+ - ".idea/.rakeTasks"
95
+ - ".idea/dictionaries/rbirch.xml"
96
+ - ".idea/encodings.xml"
97
+ - ".idea/misc.xml"
98
+ - ".idea/modules.xml"
99
+ - ".idea/scopes/scope_settings.xml"
100
+ - ".idea/snoopit.iml"
101
+ - ".idea/vcs.xml"
102
+ - ".rspec"
103
+ - ".travis.yml"
104
+ - Gemfile
105
+ - LICENSE.txt
106
+ - README.md
107
+ - Rakefile
108
+ - bin/snoopit
109
+ - lib/snoopit.rb
110
+ - lib/snoopit/detected.rb
111
+ - lib/snoopit/file_info.rb
112
+ - lib/snoopit/file_tracker.rb
113
+ - lib/snoopit/logger.rb
114
+ - lib/snoopit/notification_manager.rb
115
+ - lib/snoopit/notifier.rb
116
+ - lib/snoopit/notifiers/email.rb
117
+ - lib/snoopit/notifiers/http.rb
118
+ - lib/snoopit/notifiers/https.rb
119
+ - lib/snoopit/notifiers/stomp.rb
120
+ - lib/snoopit/register.rb
121
+ - lib/snoopit/sniffer.rb
122
+ - lib/snoopit/snooper.rb
123
+ - lib/snoopit/snoopy.rb
124
+ - lib/snoopit/version.rb
125
+ - snoopit.gemspec
126
+ - spec/bin/snoopit_spec.rb
127
+ - spec/file_info_spec.rb
128
+ - spec/file_tracker_spec.rb
129
+ - spec/notification_manager_spec.rb
130
+ - spec/notifiers/email_spec.rb
131
+ - spec/notifiers/http_spec.rb
132
+ - spec/notifiers/https_spec.rb
133
+ - spec/notifiers/stomp_spec.rb
134
+ - spec/register_spec.rb
135
+ - spec/snooper_spec.rb
136
+ - spec/spec_helper.rb
137
+ - spec/support/log/snoop_log.test
138
+ - spec/support/log/snoop_log_2.test
139
+ - spec/support/multiple_snoopies.json
140
+ - spec/support/regexp_tester.rb
141
+ - spec/support/snoopies.json
142
+ - spec/support/snoopies_notifiers.json
143
+ - spec/support/test_notifier.rb
144
+ - spec/support/test_notifier_load.rb
145
+ - support/snoopies.json
146
+ homepage: https://github.com/robdbirch/snoopit/blob/master/README.md
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.2.2
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Using regular expressions snoops files or directories for specific information.
170
+ Sends events and tracks repeated invocations as not to send repeat events
171
+ test_files:
172
+ - spec/bin/snoopit_spec.rb
173
+ - spec/file_info_spec.rb
174
+ - spec/file_tracker_spec.rb
175
+ - spec/notification_manager_spec.rb
176
+ - spec/notifiers/email_spec.rb
177
+ - spec/notifiers/http_spec.rb
178
+ - spec/notifiers/https_spec.rb
179
+ - spec/notifiers/stomp_spec.rb
180
+ - spec/register_spec.rb
181
+ - spec/snooper_spec.rb
182
+ - spec/spec_helper.rb
183
+ - spec/support/log/snoop_log.test
184
+ - spec/support/log/snoop_log_2.test
185
+ - spec/support/multiple_snoopies.json
186
+ - spec/support/regexp_tester.rb
187
+ - spec/support/snoopies.json
188
+ - spec/support/snoopies_notifiers.json
189
+ - spec/support/test_notifier.rb
190
+ - spec/support/test_notifier_load.rb