hotwired 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7dab1b10129f03eea7cac6f1a20c2d1b08505ba75e59b378f85899b8cc81d087
4
- data.tar.gz: 65be9085ccd1af47bb8ed42c76de9a1845c7d4f2f01ad04e549d8fd29fa466a8
3
+ metadata.gz: e7c0ed8b826f908dd301c5bcde4924f1ec2f2b0746cae8c39d18b925e6ee4ca7
4
+ data.tar.gz: 5fb5a32780d389d3c21e1c6b4bf409e15d7ba5722b26a568e325239de63f33cb
5
5
  SHA512:
6
- metadata.gz: 17ce5565e6b88d24aca47ccaeb550b15492b6b24a4051d2131907ce9cd865901f7fbba99c9909cec5c9069d8e4ea197c89b6fdeb3899840496b9ac4f7b9b4657
7
- data.tar.gz: 7c942ae65c15eb0a28cd4f617f3d7b514a6fe8e302bed9cd46d490a40230f6235ac6119e21a2fae4ea464e2a6504196dae0ec9d1c4a5e9bf52b6b61f66daf4d7
6
+ metadata.gz: 15e383a92cd27f1df70542cb65c069ded139cdad64579558a9ebc53e640e0d3218b2faec60bab6a56a7d7b76c0a999943726af31bf5f66569be4de8f4dc4039f
7
+ data.tar.gz: b41dda4c8a8cf94fb382c62d401fdd7e721d004f34c7e82279f95b6bb6dfce7e189d563bfec65d6d96ec2956bf0b6f4b8af86cd2b76bb77daea7d9721e637883
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # 默认忽略的文件
2
+ /shelf/
3
+ /workspace.xml
4
+ # 基于编辑器的 HTTP 客户端请求
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectDictionaryState">
4
+ <dictionary name="careline" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="inheritedJdk" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.2.3, RVM: ruby-3.1.0) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-3.1.0) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.7, RVM: ruby-3.1.0) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, RVM: ruby-3.1.0) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-3.1.0) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-3.1.0) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-3.1.0) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.0, RVM: ruby-3.1.0) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, RVM: ruby-3.1.0) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-3.1.0) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-3.1.0) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.3.0, RVM: ruby-3.1.0) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-3.1.0) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.27.0, RVM: ruby-3.1.0) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.17.0, RVM: ruby-3.1.0) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-minitest (v0.19.1, RVM: ruby-3.1.0) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-packaging (v0.5.1, RVM: ruby-3.1.0) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.13.3, RVM: ruby-3.1.0) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-rails (v2.14.2, RVM: ruby-3.1.0) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-3.1.0) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="sequel (v5.55.0, RVM: ruby-3.1.0) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="slop (v4.9.2, RVM: ruby-3.1.0) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="snmp (v1.3.2, RVM: ruby-3.1.0) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="sqlite3 (v1.4.2, RVM: ruby-3.1.0) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="strada (v0.0.3, RVM: ruby-3.1.0) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-3.1.0) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-3.1.0) [gem]" level="application" />
41
+ </component>
42
+ <component name="RakeTasksCache">
43
+ <option name="myRootTask">
44
+ <RakeTaskImpl id="rake" />
45
+ </option>
46
+ </component>
47
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="MarkdownSettingsMigration">
4
+ <option name="stateVersion" value="1" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-3.1.0" project-jdk-type="RUBY_SDK" />
7
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/hotwired.iml" filepath="$PROJECT_DIR$/.idea/hotwired.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vagrant.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VagrantProjectSettings">
4
+ <option name="instanceFolder" value="" />
5
+ <option name="provider" value="" />
6
+ </component>
7
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hotwired (0.0.2)
5
+ sequel (~> 5.0)
6
+ slop (~> 4.0)
7
+ snmp (~> 1.3)
8
+ sqlite3 (~> 1.4)
9
+ strada (>= 0.0.3)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (7.0.2.3)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ ast (2.4.2)
20
+ concurrent-ruby (1.1.10)
21
+ i18n (1.10.0)
22
+ concurrent-ruby (~> 1.0)
23
+ minitest (5.15.0)
24
+ parallel (1.22.1)
25
+ parser (3.1.2.0)
26
+ ast (~> 2.4.1)
27
+ rack (2.2.3)
28
+ rainbow (3.1.1)
29
+ rake (13.0.6)
30
+ regexp_parser (2.3.0)
31
+ rexml (3.2.5)
32
+ rubocop (1.27.0)
33
+ parallel (~> 1.10)
34
+ parser (>= 3.1.0.0)
35
+ rainbow (>= 2.2.2, < 4.0)
36
+ regexp_parser (>= 1.8, < 3.0)
37
+ rexml
38
+ rubocop-ast (>= 1.16.0, < 2.0)
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (>= 1.4.0, < 3.0)
41
+ rubocop-ast (1.17.0)
42
+ parser (>= 3.1.1.0)
43
+ rubocop-minitest (0.19.1)
44
+ rubocop (>= 0.90, < 2.0)
45
+ rubocop-packaging (0.5.1)
46
+ rubocop (>= 0.89, < 2.0)
47
+ rubocop-performance (1.13.3)
48
+ rubocop (>= 1.7.0, < 2.0)
49
+ rubocop-ast (>= 0.4.0)
50
+ rubocop-rails (2.14.2)
51
+ activesupport (>= 4.2.0)
52
+ rack (>= 1.1)
53
+ rubocop (>= 1.7.0, < 2.0)
54
+ ruby-progressbar (1.11.0)
55
+ sequel (5.55.0)
56
+ slop (4.9.2)
57
+ snmp (1.3.2)
58
+ sqlite3 (1.4.2)
59
+ strada (0.0.3)
60
+ tzinfo (2.0.4)
61
+ concurrent-ruby (~> 1.0)
62
+ unicode-display_width (2.1.0)
63
+
64
+ PLATFORMS
65
+ x86_64-linux
66
+
67
+ DEPENDENCIES
68
+ hotwired!
69
+ rake (~> 13.0)
70
+ rubocop
71
+ rubocop-minitest
72
+ rubocop-packaging
73
+ rubocop-performance
74
+ rubocop-rails
75
+
76
+ BUNDLED WITH
77
+ 2.3.7
data/README.md CHANGED
@@ -41,7 +41,7 @@ Or install it yourself as:
41
41
  # CLI execute sample
42
42
 
43
43
  ```shell
44
- [hotwired@nodes ~/hotwired]% hotwired --help
44
+ careline@careline:~/.config/hotwired -h
45
45
  Usage: hotwired [options] [argument]
46
46
  -d, --debug Debugging on
47
47
  -p, --poll Poll CIDR [argument]
@@ -54,6 +54,28 @@ Usage: hotwired [options] [argument]
54
54
  % hotwired -p 192.0.2.0/28 # poll specific CIDR
55
55
  % hotwired -r core-sw1 # remove specific record
56
56
  % hotwired -o 7 # remore records older than 7 days
57
+
58
+ careline@careline:~/.config/hotwired
59
+ % ll 22-04-17 - 16:42:14
60
+ 总用量 20K
61
+ -rw-r--r-- 1 careline careline 245 4月 17 16:39 config
62
+ -rw-r--r-- 1 careline careline 12K 4月 17 16:42 hotwired.db
63
+ -rw-r--r-- 1 careline careline 67 4月 17 16:09 log
64
+
65
+ careline@careline:~/.config/hotwired
66
+ % rm -rf hotwired.db 22-04-17 - 16:43:10
67
+
68
+ careline@careline:~/.config/hotwired
69
+ % hotwired -d 22-04-17 - 16:43:12
70
+ I, [2022-04-17T16:43:18.909105 #599481] INFO -- : ptr [R1.cisco.com] sysName [RUBY_R1.cisco.com] ip [192.168.8.80]
71
+ I, [2022-04-17T16:43:18.918306 #599481] INFO -- : ptr [R4.cisco.com] sysName [R4.cisco.com] ip [192.168.8.83]
72
+ I, [2022-04-17T16:43:18.925623 #599481] INFO -- : ptr [R10.cisco.com] sysName [R10.cisco.com] ip [192.168.8.89]
73
+ I, [2022-04-17T16:43:18.930507 #599481] INFO -- : ptr [R5.cisco.com] sysName [R5.cisco.com] ip [192.168.8.84]
74
+ I, [2022-04-17T16:43:18.936821 #599481] INFO -- : ptr [R2.cisco.com] sysName [R2.cisco.com] ip [192.168.8.81]
75
+ I, [2022-04-17T16:43:18.942099 #599481] INFO -- : ptr [R8.cisco.com] sysName [R8.cisco.com] ip [192.168.8.87]
76
+ I, [2022-04-17T16:43:18.947214 #599481] INFO -- : ptr [R3.cisco.com] sysName [R3.cisco.com] ip [192.168.8.82]
77
+ I, [2022-04-17T16:43:18.953543 #599481] INFO -- : ptr [R7.cisco.com] sysName [R7.cisco.com] ip [192.168.8.86]
78
+ I, [2022-04-17T16:43:18.969960 #599481] INFO -- : ptr [R9.cisco.com] sysName [R9.cisco.com] ip [192.168.8.88]
57
79
  ```
58
80
 
59
81
  ## Development
@@ -67,9 +89,9 @@ push git commits and the created tag, and push the `.gem` file to [rubygems.org]
67
89
 
68
90
  ## Contributing
69
91
 
70
- Bug reports and pull requests are welcome on GitHub at https://github.com/ciscolive/hotwired. This project is intended
92
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ciscolive/hotwired-ruby. This project is intended
71
93
  to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
72
- the [code of conduct](https://github.com/ciscolive/hotwired/blob/main/CODE_OF_CONDUCT.md).
94
+ the [code of conduct](https://github.com/ciscolive/hotwired-ruby/blob/main/CODE_OF_CONDUCT.md).
73
95
 
74
96
  ## License
75
97
 
@@ -78,4 +100,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
78
100
  ## Code of Conduct
79
101
 
80
102
  Everyone interacting in the Hotwired project's codebases, issue trackers, chat rooms and mailing lists is expected to
81
- follow the [code of conduct](https://github.com/ciscolive/hotwired/blob/main/CODE_OF_CONDUCT.md).
103
+ follow the [code of conduct](https://github.com/ciscolive/hotwired-ruby/blob/main/CODE_OF_CONDUCT.md).
data/bin/hotwired CHANGED
@@ -3,9 +3,8 @@
3
3
 
4
4
  begin
5
5
  require_relative "../lib/hotwired/cli"
6
-
7
6
  Hotwired::CLI.new.run
8
- rescue StoreError => error
9
- warn "#{error}"
7
+ rescue StandardError => e
8
+ warn e.to_s
10
9
  raise if Hotwired::CFG.debug
11
10
  end
data/hotwired.gemspec CHANGED
@@ -10,14 +10,14 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "Device discovery via snmp polls"
12
12
  spec.description = "Threaded SNMP poll based network discovery. Devices are stored in SQL"
13
- spec.homepage = "https://github.com/ciscolive/hotwired"
13
+ spec.homepage = "https://github.com/ciscolive/hotwired-ruby"
14
14
  spec.licenses = "MIT"
15
15
 
16
16
  # spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = "https://github.com/ciscolive/hotwired"
20
- spec.metadata["changelog_uri"] = "https://github.com/ciscolive/hotwired"
19
+ spec.metadata["source_code_uri"] = "https://github.com/ciscolive/hotwired-ruby"
20
+ spec.metadata["changelog_uri"] = "https://github.com/ciscolive/hotwired-ruby"
21
21
 
22
22
  spec.files = `git ls-files`.split("\n")
23
23
  spec.executables = %w( hotwired )
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.required_ruby_version = ">= 2.6.0"
27
27
 
28
28
  # 项目依赖
29
- spec.add_runtime_dependency "strada", "~> 0.0.2"
29
+ spec.add_runtime_dependency "strada", ">= 0.0.3"
30
30
  spec.add_runtime_dependency "sequel", "~> 5.0"
31
31
  spec.add_runtime_dependency "slop", "~> 4.0"
32
32
  spec.add_runtime_dependency "snmp", "~> 1.3"
data/lib/hotwired/cli.rb CHANGED
@@ -5,6 +5,8 @@ module Hotwired
5
5
  require "slop"
6
6
  require_relative "../hotwired"
7
7
 
8
+ class HotwiredError < StandardError; end
9
+
8
10
  class NoConfig < HotwiredError; end
9
11
 
10
12
  MAX_DELETE = 1
@@ -10,18 +10,18 @@ module Hotwired
10
10
  end
11
11
 
12
12
  FileUtils.mkdir_p Config::ROOT
13
- CONFIG = Strada.new name: "hotwired", load: "false", key_to_s: true
13
+ CONFIG = Strada.new name: "hotwired", load: "false"
14
14
 
15
15
  CONFIG.default.community = "cisco"
16
16
  CONFIG.default.db = File.join Config::ROOT, "hotwired.db"
17
- CONFIG.default.poll = %w( 192.168.8.0/24 )
17
+ CONFIG.default.poll = %w( 192.168.8.0/24 10.250.8.0/24 )
18
18
  CONFIG.default.ignore = %w( 192.168.8.100 )
19
19
  CONFIG.default.mgmt = %w( lo0.0 loopback0 vlan2 )
20
20
  CONFIG.default.threads = 50
21
21
  CONFIG.default.timeout = 0.25
22
22
  CONFIG.default.retries = 2
23
23
  CONFIG.default.log = File.join Config::ROOT, "log"
24
- CONFIG.default.debug = true
24
+ CONFIG.default.debug = false
25
25
 
26
26
  # 加载初始化配置
27
27
  CONFIG.load
@@ -29,5 +29,6 @@ module Hotwired
29
29
 
30
30
  # 初始化项目日志参数
31
31
  Log.file = CFG.log if CFG.log
32
- Log.level = CFG.debug ? Logger::INFO : Logger::DEBUG
32
+ Log.level = Logger::INFO
33
+ Log.level = Logger::DEBUG if CFG.debug
33
34
  end
data/lib/hotwired/core.rb CHANGED
@@ -139,8 +139,8 @@ module Hotwired
139
139
  # 查无记录则需要新增
140
140
  if (not old_by_sysname) && (not old_by_ip)
141
141
  # all new device
142
- @output.info "ptr [%s] sysName [%s] ip [%s]" % [record[:ptr], record[:oid_sysName], record[:ip]]
143
- Log.info "#{record[:ip]} added"
142
+ Log.info "ptr [%s] sysName [%s] ip [%s]" % [record[:ptr], record[:oid_sysName], record[:ip]]
143
+ # Log.info "#{record[:ip]} added"
144
144
  @db.add record
145
145
  # 根据 IP 可以查询到数据,但设备名称发生变化
146
146
  elsif (not old_by_sysname) && old_by_ip
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hotwired
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwired
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - WENWU.YAN
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: strada
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.2
19
+ version: 0.0.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.2
26
+ version: 0.0.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sequel
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,10 +90,18 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - ".github/workflows/main.yml"
92
92
  - ".gitignore"
93
+ - ".idea/.gitignore"
94
+ - ".idea/dictionaries"
95
+ - ".idea/hotwired.iml"
96
+ - ".idea/misc.xml"
97
+ - ".idea/modules.xml"
98
+ - ".idea/vagrant.xml"
99
+ - ".idea/vcs.xml"
93
100
  - ".rubocop.yml"
94
101
  - CHANGELOG.md
95
102
  - CODE_OF_CONDUCT.md
96
103
  - Gemfile
104
+ - Gemfile.lock
97
105
  - LICENSE.txt
98
106
  - README.md
99
107
  - Rakefile
@@ -112,13 +120,13 @@ files:
112
120
  - lib/hotwired/snmp.rb
113
121
  - lib/hotwired/version.rb
114
122
  - sig/hotwired.rbs
115
- homepage: https://github.com/ciscolive/hotwired
123
+ homepage: https://github.com/ciscolive/hotwired-ruby
116
124
  licenses:
117
125
  - MIT
118
126
  metadata:
119
- homepage_uri: https://github.com/ciscolive/hotwired
120
- source_code_uri: https://github.com/ciscolive/hotwired
121
- changelog_uri: https://github.com/ciscolive/hotwired
127
+ homepage_uri: https://github.com/ciscolive/hotwired-ruby
128
+ source_code_uri: https://github.com/ciscolive/hotwired-ruby
129
+ changelog_uri: https://github.com/ciscolive/hotwired-ruby
122
130
  post_install_message:
123
131
  rdoc_options: []
124
132
  require_paths: