oui 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7463e3796f9ab02ec63573ea6ca8927d38eef923
4
- data.tar.gz: d7597f11cf943b25bf50b401c2e78d6e69328de2
3
+ metadata.gz: 2615ddef89daccfce7848cd820e7099698d2a543
4
+ data.tar.gz: eabfb4df35310bd79aa3310ae5cb2f867c035231
5
5
  SHA512:
6
- metadata.gz: 4085cd5cd8d38de2fc8ff203b4051d6bccbfc61beaae41767226c324ef14b15da4d9dbcc9a869bf8e11c178074d60ef8744ac7e03710ad9857330b54f7b9b783
7
- data.tar.gz: 8b85aef2a26df22103fa10392e9a903f0d7017fc0d976f170db3d9c1f362d5cebbde938194a1d53d20226bd3d41cc4a2b1a82d6c9ab0fc7c2d3b4ca04826cb4d
6
+ metadata.gz: 477f020c7cbcad34419f717b5565090f44e9066d1fa3658959f5cdea8d8777343559519b08eaf89f796f49cd7b0a58722211a45620f006377951beec74143831
7
+ data.tar.gz: f4cfd5bf693de11ceb9673d39f6dbf338b433f2238a7826655ec090dba7779d5ab0545e28ba589f104213e08e21fa1d0f5d2261c34dc8fc773476cfa04cc6f03
data/.gitignore CHANGED
@@ -14,3 +14,4 @@ spec/reports
14
14
  test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
+ records.txt
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rspec
data/Gemfile CHANGED
@@ -3,3 +3,8 @@ source 'https://rubygems.org'
3
3
  ruby '2.0.0'
4
4
 
5
5
  gemspec
6
+
7
+ gem 'newrelic_rpm'
8
+
9
+ gem 'unicorn'
10
+ gem 'thin'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oui (0.0.2)
4
+ oui (0.0.3)
5
5
  sinatra
6
6
  sinatra-contrib
7
7
 
@@ -10,18 +10,23 @@ GEM
10
10
  specs:
11
11
  backports (3.6.0)
12
12
  coderay (1.1.0)
13
+ daemons (1.1.9)
13
14
  diff-lcs (1.2.5)
15
+ eventmachine (1.0.3)
16
+ kgio (2.8.0)
14
17
  method_source (0.8.2)
15
18
  multi_json (1.10.1)
19
+ newrelic_rpm (3.9.0.229)
16
20
  pry (0.9.12.4)
17
21
  coderay (~> 1.0)
18
22
  method_source (~> 0.8)
19
23
  slop (~> 3.4)
20
24
  rack (1.5.2)
21
- rack-protection (1.5.0)
25
+ rack-protection (1.5.3)
22
26
  rack
23
27
  rack-test (0.6.2)
24
28
  rack (>= 1.0)
29
+ raindrops (0.11.0)
25
30
  rake (10.3.2)
26
31
  rspec (3.0.0)
27
32
  rspec-core (~> 3.0.0)
@@ -37,8 +42,8 @@ GEM
37
42
  rspec-support (3.0.2)
38
43
  shotgun (0.9)
39
44
  rack (>= 1.0)
40
- sinatra (1.4.2)
41
- rack (~> 1.5, >= 1.5.2)
45
+ sinatra (1.4.5)
46
+ rack (~> 1.4)
42
47
  rack-protection (~> 1.4)
43
48
  tilt (~> 1.3, >= 1.3.4)
44
49
  sinatra-contrib (1.4.2)
@@ -49,15 +54,26 @@ GEM
49
54
  sinatra (~> 1.4.0)
50
55
  tilt (~> 1.3)
51
56
  slop (3.4.7)
57
+ thin (1.5.1)
58
+ daemons (>= 1.0.9)
59
+ eventmachine (>= 0.12.6)
60
+ rack (>= 1.0.0)
52
61
  tilt (1.4.1)
62
+ unicorn (4.6.2)
63
+ kgio (~> 2.6)
64
+ rack
65
+ raindrops (~> 0.7)
53
66
 
54
67
  PLATFORMS
55
68
  ruby
56
69
 
57
70
  DEPENDENCIES
58
71
  bundler (~> 1.3)
72
+ newrelic_rpm
59
73
  oui!
60
74
  pry
61
75
  rake
62
76
  rspec
63
77
  shotgun
78
+ thin
79
+ unicorn
@@ -0,0 +1 @@
1
+ web: bundle exec rackup -p $PORT
data/README.md CHANGED
@@ -2,6 +2,57 @@
2
2
 
3
3
  look up OUI information /w Chinese translation using MAC addresses
4
4
 
5
+ OUI info from [IEEE OUI text file](https://standards.ieee.org/develop/regauth/oui/oui.txt)
6
+
7
+ [![Build Status](https://travis-ci.org/modouwifi/oui-gem.svg?branch=master)](https://travis-ci.org/modouwifi/oui-gem)
8
+
9
+ Currently hosted on [heroku.com](https://heroku.com), live at [http://oui.ly.md](http://oui.ly.md), try URLs like this: [http://oui.ly.md/lookup?mac=14:10:9f:ea:49:11](http://oui.ly.md/lookup?mac=14:10:9f:ea:49:11)
10
+
11
+ ## Service Benchmark
12
+
13
+ Roughly 320 requests per second, or 20000 requests per minute.
14
+
15
+ with `ab -n 20000 -c 100 http://oui.ly.md/lookup?mac=14:10:9f:ea:49:11`
16
+
17
+ ```
18
+ Server Software: thin
19
+ Server Hostname: oui.ly.md
20
+ Server Port: 80
21
+
22
+ Document Path: /lookup?mac=14:10:9f:ea:49:11
23
+ Document Length: 74 bytes
24
+
25
+ Concurrency Level: 100
26
+ Time taken for tests: 61.629 seconds
27
+ Complete requests: 20000
28
+ Failed requests: 0
29
+ Write errors: 0
30
+ Total transferred: 6160000 bytes
31
+ HTML transferred: 1480000 bytes
32
+ Requests per second: 324.52 [#/sec] (mean)
33
+ Time per request: 308.143 [ms] (mean)
34
+ Time per request: 3.081 [ms] (mean, across all concurrent requests)
35
+ Transfer rate: 97.61 [Kbytes/sec] received
36
+
37
+ Connection Times (ms)
38
+ min mean[+/-sd] median max
39
+ Connect: 72 74 24.0 73 846
40
+ Processing: 86 233 78.3 233 2377
41
+ Waiting: 85 231 78.0 231 2375
42
+ Total: 161 307 80.9 306 2450
43
+
44
+ Percentage of the requests served within a certain time (ms)
45
+ 50% 306
46
+ 66% 327
47
+ 75% 334
48
+ 80% 340
49
+ 90% 355
50
+ 95% 369
51
+ 98% 393
52
+ 99% 432
53
+ 100% 2450 (longest request)
54
+ ```
55
+
5
56
  ## Installation
6
57
 
7
58
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -7,3 +7,64 @@ require 'rake'
7
7
  # RSpec::Core::RakeTask.new(:spec)
8
8
  #
9
9
  # task :default => :spec
10
+
11
+ def download_logs
12
+ `mkdir -p tmp`
13
+ `heroku logs -n 100000 > tmp/logs.txt`
14
+ end
15
+
16
+ def show_report
17
+ require "oui"
18
+
19
+ logs = File.read('tmp/logs.txt')
20
+
21
+ mac_addresses = []
22
+
23
+ logs.each_line do |line|
24
+ if line =~ /(#{OUI::MACAddress.mac_regex_string})/
25
+ puts $1
26
+ mac_addresses << $1
27
+ end
28
+ end
29
+
30
+ mac_addresses.uniq!
31
+
32
+ File.open("records.txt", "a") do |file|
33
+ mac_addresses.each do |mac|
34
+ org = OUI::MACAddress.parse(mac).organization
35
+ if org.chinese_name.nil? || org.chinese_name.length > 10
36
+ if org.name
37
+ p org
38
+ file.puts org.inspect
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ def show_feeds
46
+ logs = File.read('tmp/logs.txt')
47
+
48
+ logs.each_line do |line|
49
+ if line =~ /path="\/feed/
50
+ puts line
51
+ end
52
+ end
53
+ end
54
+
55
+ task :report_local do
56
+ show_report
57
+ end
58
+
59
+ task :report do
60
+ download_logs
61
+ show_report
62
+ end
63
+
64
+ task :feeds do
65
+ show_feeds
66
+ end
67
+
68
+ task :download_logs do
69
+ download_logs
70
+ end
data/TODO.md ADDED
@@ -0,0 +1,10 @@
1
+ ## library
2
+ - js call lookup MAC on index page
3
+ - support vendor override: need to analyze logs
4
+ - support locally administered addresses (e.g. 0A:72:2C:1E:8B:0A)
5
+ - support Individual Address Block (addresses start with 40-D8-55)
6
+
7
+ ## server
8
+ - utilize `.profile` and capture `SIGTERM` as described in [https://devcenter.heroku.com/articles/dynos#the-dyno-manager](https://devcenter.heroku.com/articles/dynos#the-dyno-manager)
9
+ - handle deployment downtime gracefully
10
+ - separate `oui.txt` lookup to a database
data/bin/oui CHANGED
@@ -25,6 +25,23 @@ def generate_yml
25
25
  end
26
26
  end
27
27
 
28
- mac = ARGV.first
28
+ if ARGV.empty?
29
+ puts
30
+ puts "usage:"
31
+ puts "oui MAC_ADDR_1 MAC_ADDR_2 # lookup MAC addresses"
32
+ puts "oui local # lookup vendor info of all local MAC addresses (via ifconfig)"
33
+ exit
34
+ end
29
35
 
30
- p OUI::MACAddress.parse(mac).organization
36
+ if ARGV.first == 'local'
37
+ `ifconfig`.each_line do |line|
38
+ match = /[\d|[a-f]][\d|[a-f]]:[\d|[a-f]][\d|[a-f]]:[\d|[a-f]][\d|[a-f]]:[\d|[a-f]][\d|[a-f]]:[\d|[a-f]][\d|[a-f]]:[\d|[a-f]][\d|[a-f]]/.match(line)
39
+ if match
40
+ puts "#{match[0]} => #{OUI::MACAddress.parse(match[0]).organization.inspect}"
41
+ end
42
+ end
43
+ else
44
+ ARGV.each do |mac|
45
+ puts "#{mac} => #{OUI::MACAddress.parse(mac).organization.inspect}"
46
+ end
47
+ end
data/config.ru CHANGED
@@ -2,4 +2,10 @@
2
2
  require "oui"
3
3
  require 'oui/server'
4
4
 
5
+ # realtime logging
6
+ # https://devcenter.heroku.com/articles/logging
7
+ $stdout.sync = true
8
+
9
+ use Rack::Static, :urls => ["/assets"], :root => "public"
10
+
5
11
  run OUI::Server
@@ -0,0 +1,227 @@
1
+ #
2
+ # This file configures the New Relic Agent. New Relic monitors
3
+ # Ruby, Java, .NET, PHP, and Python applications with deep visibility and low overhead.
4
+ # For more information, visit www.newrelic.com.
5
+ #
6
+ # Generated June 03, 2013
7
+ #
8
+ # This configuration file is custom generated for Barsoom
9
+
10
+
11
+ # Here are the settings that are common to all environments
12
+ common: &default_settings
13
+ # ============================== LICENSE KEY ===============================
14
+
15
+ # You must specify the license key associated with your New Relic
16
+ # account. This key binds your Agent's data to your account in the
17
+ # New Relic service.
18
+ license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
19
+
20
+ # Agent Enabled (Ruby/Rails Only)
21
+ # Use this setting to force the agent to run or not run.
22
+ # Default is 'auto' which means the agent will install and run only
23
+ # if a valid dispatcher such as Mongrel is running. This prevents
24
+ # it from running with Rake or the console. Set to false to
25
+ # completely turn the agent off regardless of the other settings.
26
+ # Valid values are true, false and auto.
27
+ #
28
+ # agent_enabled: auto
29
+
30
+ # Application Name Set this to be the name of your application as
31
+ # you'd like it show up in New Relic. The service will then auto-map
32
+ # instances of your application into an "application" on your
33
+ # dashboard page. If you want to map this instance into multiple
34
+ # apps, like "AJAX Requests" and "All UI" then specify a semicolon
35
+ # separated list of up to three distinct names, or a yaml list.
36
+ # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
37
+ # Production, Staging, etc)
38
+ #
39
+ # Example:
40
+ #
41
+ # app_name:
42
+ # - Ajax Service
43
+ # - All Services
44
+ #
45
+ app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
46
+
47
+ # When "true", the agent collects performance data about your
48
+ # application and reports this data to the New Relic service at
49
+ # newrelic.com. This global switch is normally overridden for each
50
+ # environment below. (formerly called 'enabled')
51
+ monitor_mode: true
52
+
53
+ # Developer mode should be off in every environment but
54
+ # development as it has very high overhead in memory.
55
+ developer_mode: false
56
+
57
+ # The newrelic agent generates its own log file to keep its logging
58
+ # information separate from that of your application. Specify its
59
+ # log level here.
60
+ log_level: info
61
+
62
+ # Optionally set the path to the log file This is expanded from the
63
+ # root directory (may be relative or absolute, e.g. 'log/' or
64
+ # '/var/log/') The agent will attempt to create this directory if it
65
+ # does not exist.
66
+ # log_file_path: 'log'
67
+
68
+ # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
69
+ # log_file_name: 'newrelic_agent.log'
70
+
71
+ # The newrelic agent communicates with the service via https by default. This
72
+ # prevents eavesdropping on the performance metrics transmitted by the agent.
73
+ # The encryption required by SSL introduces a nominal amount of CPU overhead,
74
+ # which is performed asynchronously in a background thread. If you'd prefer
75
+ # to send your metrics over http uncomment the following line.
76
+ # ssl: false
77
+
78
+ #============================== Browser Monitoring ===============================
79
+ # New Relic Real User Monitoring gives you insight into the performance real users are
80
+ # experiencing with your website. This is accomplished by measuring the time it takes for
81
+ # your users' browsers to download and render your web pages by injecting a small amount
82
+ # of JavaScript code into the header and footer of each page.
83
+ browser_monitoring:
84
+ # By default the agent automatically injects the monitoring JavaScript
85
+ # into web pages. Set this attribute to false to turn off this behavior.
86
+ auto_instrument: true
87
+
88
+ # Proxy settings for connecting to the New Relic server.
89
+ #
90
+ # If a proxy is used, the host setting is required. Other settings
91
+ # are optional. Default port is 8080.
92
+ #
93
+ # proxy_host: hostname
94
+ # proxy_port: 8080
95
+ # proxy_user:
96
+ # proxy_pass:
97
+
98
+ # The agent can optionally log all data it sends to New Relic servers to a
99
+ # separate log file for human inspection and auditing purposes. To enable this
100
+ # feature, change 'enabled' below to true.
101
+ # See: https://newrelic.com/docs/ruby/audit-log
102
+ audit_log:
103
+ enabled: false
104
+
105
+ # Tells transaction tracer and error collector (when enabled)
106
+ # whether or not to capture HTTP params. When true, frameworks can
107
+ # exclude HTTP parameters from being captured.
108
+ # Rails: the RoR filter_parameter_logging excludes parameters
109
+ # Java: create a config setting called "ignored_params" and set it to
110
+ # a comma separated list of HTTP parameter names.
111
+ # ex: ignored_params: credit_card, ssn, password
112
+ capture_params: false
113
+
114
+ # Transaction tracer captures deep information about slow
115
+ # transactions and sends this to the New Relic service once a
116
+ # minute. Included in the transaction is the exact call sequence of
117
+ # the transactions including any SQL statements issued.
118
+ transaction_tracer:
119
+
120
+ # Transaction tracer is enabled by default. Set this to false to
121
+ # turn it off. This feature is only available at the Professional
122
+ # and above product levels.
123
+ enabled: true
124
+
125
+ # Threshold in seconds for when to collect a transaction
126
+ # trace. When the response time of a controller action exceeds
127
+ # this threshold, a transaction trace will be recorded and sent to
128
+ # New Relic. Valid values are any float value, or (default) "apdex_f",
129
+ # which will use the threshold for an dissatisfying Apdex
130
+ # controller action - four times the Apdex T value.
131
+ transaction_threshold: apdex_f
132
+
133
+ # When transaction tracer is on, SQL statements can optionally be
134
+ # recorded. The recorder has three modes, "off" which sends no
135
+ # SQL, "raw" which sends the SQL statement in its original form,
136
+ # and "obfuscated", which strips out numeric and string literals.
137
+ record_sql: obfuscated
138
+
139
+ # Threshold in seconds for when to collect stack trace for a SQL
140
+ # call. In other words, when SQL statements exceed this threshold,
141
+ # then capture and send to New Relic the current stack trace. This is
142
+ # helpful for pinpointing where long SQL calls originate from.
143
+ stack_trace_threshold: 0.500
144
+
145
+ # Determines whether the agent will capture query plans for slow
146
+ # SQL queries. Only supported in mysql and postgres. Should be
147
+ # set to false when using other adapters.
148
+ # explain_enabled: true
149
+
150
+ # Threshold for query execution time below which query plans will
151
+ # not be captured. Relevant only when `explain_enabled` is true.
152
+ # explain_threshold: 0.5
153
+
154
+ # Error collector captures information about uncaught exceptions and
155
+ # sends them to New Relic for viewing
156
+ error_collector:
157
+
158
+ # Error collector is enabled by default. Set this to false to turn
159
+ # it off. This feature is only available at the Professional and above
160
+ # product levels.
161
+ enabled: true
162
+
163
+ # Rails Only - tells error collector whether or not to capture a
164
+ # source snippet around the place of the error when errors are View
165
+ # related.
166
+ capture_source: true
167
+
168
+ # To stop specific errors from reporting to New Relic, set this property
169
+ # to comma-separated values. Default is to ignore routing errors,
170
+ # which are how 404's get triggered.
171
+ ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
172
+
173
+ # If you're interested in capturing memcache keys as though they
174
+ # were SQL uncomment this flag. Note that this does increase
175
+ # overhead slightly on every memcached call, and can have security
176
+ # implications if your memcached keys are sensitive
177
+ # capture_memcache_keys: true
178
+
179
+ # Application Environments
180
+ # ------------------------------------------
181
+ # Environment-specific settings are in this section.
182
+ # For Rails applications, RAILS_ENV is used to determine the environment.
183
+ # For Java applications, pass -Dnewrelic.environment <environment> to set
184
+ # the environment.
185
+
186
+ # NOTE if your application has other named environments, you should
187
+ # provide newrelic configuration settings for these environments here.
188
+
189
+ development:
190
+ <<: *default_settings
191
+ # Turn off communication to New Relic service in development mode (also
192
+ # 'enabled').
193
+ # NOTE: for initial evaluation purposes, you may want to temporarily
194
+ # turn the agent on in development mode.
195
+ monitor_mode: false
196
+
197
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
198
+ # present performance information on the last 100 transactions you have
199
+ # executed since starting the mongrel.
200
+ # NOTE: There is substantial overhead when running in developer mode.
201
+ # Do not use for production or load testing.
202
+ developer_mode: true
203
+
204
+ # Enable textmate links
205
+ # textmate: true
206
+
207
+ test:
208
+ <<: *default_settings
209
+ # It almost never makes sense to turn on the agent when running
210
+ # unit, functional or integration tests or the like.
211
+ monitor_mode: false
212
+
213
+ # Turn on the agent in production for 24x7 monitoring. NewRelic
214
+ # testing shows an average performance impact of < 5 ms per
215
+ # transaction, you can leave this on all the time without
216
+ # incurring any user-visible performance degradation.
217
+ production:
218
+ <<: *default_settings
219
+ monitor_mode: true
220
+
221
+ # Many applications have a staging environment which behaves
222
+ # identically to production. Support for that environment is provided
223
+ # here. By default, the staging environment has the agent turned on.
224
+ staging:
225
+ <<: *default_settings
226
+ monitor_mode: true
227
+ app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging)