hotwired 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +27 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +306 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/hotwired +11 -0
- data/bin/setup +8 -0
- data/hotwired.gemspec +34 -0
- data/lib/hotwired/cli.rb +92 -0
- data/lib/hotwired/config.rb +33 -0
- data/lib/hotwired/core.rb +237 -0
- data/lib/hotwired/db/db.rb +61 -0
- data/lib/hotwired/db/model.rb +8 -0
- data/lib/hotwired/log.rb +18 -0
- data/lib/hotwired/model.rb +103 -0
- data/lib/hotwired/snmp.rb +119 -0
- data/lib/hotwired/version.rb +5 -0
- data/lib/hotwired.rb +7 -0
- data/sig/hotwired.rbs +4 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7dab1b10129f03eea7cac6f1a20c2d1b08505ba75e59b378f85899b8cc81d087
|
4
|
+
data.tar.gz: 65be9085ccd1af47bb8ed42c76de9a1845c7d4f2f01ad04e549d8fd29fa466a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 17ce5565e6b88d24aca47ccaeb550b15492b6b24a4051d2131907ce9cd865901f7fbba99c9909cec5c9069d8e4ea197c89b6fdeb3899840496b9ac4f7b9b4657
|
7
|
+
data.tar.gz: 7c942ae65c15eb0a28cd4f617f3d7b514a6fe8e302bed9cd46d490a40230f6235ac6119e21a2fae4ea464e2a6504196dae0ec9d1c4a5e9bf52b6b61f66daf4d7
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby:
|
17
|
+
- '3.1.0'
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Run the default task
|
27
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,306 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-minitest
|
3
|
+
- rubocop-packaging
|
4
|
+
- rubocop-performance
|
5
|
+
- rubocop-rails
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.7
|
9
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
10
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
11
|
+
DisabledByDefault: true
|
12
|
+
SuggestExtensions: false
|
13
|
+
Exclude:
|
14
|
+
- '**/tmp/**/*'
|
15
|
+
- '**/templates/**/*'
|
16
|
+
- '**/vendor/**/*'
|
17
|
+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
|
18
|
+
- 'actionmailbox/test/dummy/**/*'
|
19
|
+
- 'actiontext/test/dummy/**/*'
|
20
|
+
- '**/node_modules/**/*'
|
21
|
+
|
22
|
+
Performance:
|
23
|
+
Exclude:
|
24
|
+
- '**/test/**/*'
|
25
|
+
|
26
|
+
# Prefer assert_not over assert !
|
27
|
+
Rails/AssertNot:
|
28
|
+
Include:
|
29
|
+
- '**/test/**/*'
|
30
|
+
|
31
|
+
# Prefer assert_not_x over refute_x
|
32
|
+
Rails/RefuteMethods:
|
33
|
+
Include:
|
34
|
+
- '**/test/**/*'
|
35
|
+
|
36
|
+
Rails/IndexBy:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Rails/IndexWith:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
# Prefer &&/|| over and/or.
|
43
|
+
Style/AndOr:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
# Align `when` with `case`.
|
47
|
+
Layout/CaseIndentation:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
Layout/ClosingHeredocIndentation:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
Layout/ClosingParenthesisIndentation:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
# Align comments with method definitions.
|
57
|
+
Layout/CommentIndentation:
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
Layout/ElseAlignment:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
# Align `end` with the matching keyword or starting expression except for
|
64
|
+
# assignments, where it should be aligned with the LHS.
|
65
|
+
Layout/EndAlignment:
|
66
|
+
Enabled: true
|
67
|
+
EnforcedStyleAlignWith: variable
|
68
|
+
AutoCorrect: true
|
69
|
+
|
70
|
+
Layout/EndOfLine:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
Layout/EmptyLineAfterMagicComment:
|
74
|
+
Enabled: true
|
75
|
+
|
76
|
+
Layout/EmptyLinesAroundAccessModifier:
|
77
|
+
Enabled: true
|
78
|
+
EnforcedStyle: only_before
|
79
|
+
|
80
|
+
Layout/EmptyLinesAroundBlockBody:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
# In a regular class definition, no empty lines around the body.
|
84
|
+
Layout/EmptyLinesAroundClassBody:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
# In a regular method definition, no empty lines around the body.
|
88
|
+
Layout/EmptyLinesAroundMethodBody:
|
89
|
+
Enabled: true
|
90
|
+
|
91
|
+
# In a regular module definition, no empty lines around the body.
|
92
|
+
Layout/EmptyLinesAroundModuleBody:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
96
|
+
Style/HashSyntax:
|
97
|
+
Enabled: true
|
98
|
+
|
99
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
100
|
+
# extra level of indentation.
|
101
|
+
Layout/IndentationConsistency:
|
102
|
+
Enabled: true
|
103
|
+
EnforcedStyle: indented_internal_methods
|
104
|
+
|
105
|
+
# Two spaces, no tabs (for indentation).
|
106
|
+
Layout/IndentationWidth:
|
107
|
+
Enabled: true
|
108
|
+
|
109
|
+
Layout/LeadingCommentSpace:
|
110
|
+
Enabled: true
|
111
|
+
|
112
|
+
Layout/SpaceAfterColon:
|
113
|
+
Enabled: true
|
114
|
+
|
115
|
+
Layout/SpaceAfterComma:
|
116
|
+
Enabled: true
|
117
|
+
|
118
|
+
Layout/SpaceAfterSemicolon:
|
119
|
+
Enabled: true
|
120
|
+
|
121
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
122
|
+
Enabled: true
|
123
|
+
|
124
|
+
Layout/SpaceAroundKeyword:
|
125
|
+
Enabled: true
|
126
|
+
|
127
|
+
Layout/SpaceAroundOperators:
|
128
|
+
Enabled: true
|
129
|
+
|
130
|
+
Layout/SpaceBeforeComma:
|
131
|
+
Enabled: true
|
132
|
+
|
133
|
+
Layout/SpaceBeforeComment:
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
Layout/SpaceBeforeFirstArg:
|
137
|
+
Enabled: true
|
138
|
+
|
139
|
+
Style/DefWithParentheses:
|
140
|
+
Enabled: true
|
141
|
+
|
142
|
+
# Defining a method with parameters needs parentheses.
|
143
|
+
Style/MethodDefParentheses:
|
144
|
+
Enabled: true
|
145
|
+
|
146
|
+
Style/ExplicitBlockArgument:
|
147
|
+
Enabled: true
|
148
|
+
|
149
|
+
Style/FrozenStringLiteralComment:
|
150
|
+
Enabled: true
|
151
|
+
EnforcedStyle: always
|
152
|
+
Exclude:
|
153
|
+
- 'actionview/test/**/*.builder'
|
154
|
+
- 'actionview/test/**/*.ruby'
|
155
|
+
- 'actionpack/test/**/*.builder'
|
156
|
+
- 'actionpack/test/**/*.ruby'
|
157
|
+
- 'activestorage/db/migrate/**/*.rb'
|
158
|
+
- 'activestorage/db/update_migrate/**/*.rb'
|
159
|
+
- 'actionmailbox/db/migrate/**/*.rb'
|
160
|
+
- 'actiontext/db/migrate/**/*.rb'
|
161
|
+
|
162
|
+
Style/RedundantFreeze:
|
163
|
+
Enabled: true
|
164
|
+
|
165
|
+
# Use `foo {}` not `foo{}`.
|
166
|
+
Layout/SpaceBeforeBlockBraces:
|
167
|
+
Enabled: true
|
168
|
+
|
169
|
+
# Use `foo { bar }` not `foo {bar}`.
|
170
|
+
Layout/SpaceInsideBlockBraces:
|
171
|
+
Enabled: true
|
172
|
+
EnforcedStyleForEmptyBraces: space
|
173
|
+
|
174
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
175
|
+
Layout/SpaceInsideHashLiteralBraces:
|
176
|
+
Enabled: true
|
177
|
+
|
178
|
+
Layout/SpaceInsideParens:
|
179
|
+
Enabled: true
|
180
|
+
|
181
|
+
# Check quotes usage according to lint rule below.
|
182
|
+
Style/StringLiterals:
|
183
|
+
Enabled: true
|
184
|
+
EnforcedStyle: double_quotes
|
185
|
+
|
186
|
+
# Detect hard tabs, no hard tabs.
|
187
|
+
Layout/IndentationStyle:
|
188
|
+
Enabled: true
|
189
|
+
|
190
|
+
# Empty lines should not have any spaces.
|
191
|
+
Layout/TrailingEmptyLines:
|
192
|
+
Enabled: true
|
193
|
+
|
194
|
+
# No trailing whitespace.
|
195
|
+
Layout/TrailingWhitespace:
|
196
|
+
Enabled: true
|
197
|
+
|
198
|
+
# Use quotes for string literals when they are enough.
|
199
|
+
Style/RedundantPercentQ:
|
200
|
+
Enabled: true
|
201
|
+
|
202
|
+
Lint/AmbiguousOperator:
|
203
|
+
Enabled: true
|
204
|
+
|
205
|
+
Lint/AmbiguousRegexpLiteral:
|
206
|
+
Enabled: true
|
207
|
+
|
208
|
+
Lint/DuplicateRequire:
|
209
|
+
Enabled: true
|
210
|
+
|
211
|
+
Lint/DuplicateMethods:
|
212
|
+
Enabled: true
|
213
|
+
|
214
|
+
Lint/ErbNewArguments:
|
215
|
+
Enabled: true
|
216
|
+
|
217
|
+
Lint/EnsureReturn:
|
218
|
+
Enabled: true
|
219
|
+
|
220
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
221
|
+
Lint/RequireParentheses:
|
222
|
+
Enabled: true
|
223
|
+
|
224
|
+
Lint/RedundantStringCoercion:
|
225
|
+
Enabled: true
|
226
|
+
|
227
|
+
Lint/UriEscapeUnescape:
|
228
|
+
Enabled: true
|
229
|
+
|
230
|
+
Lint/UselessAssignment:
|
231
|
+
Enabled: true
|
232
|
+
|
233
|
+
Lint/DeprecatedClassMethods:
|
234
|
+
Enabled: true
|
235
|
+
|
236
|
+
Style/ParenthesesAroundCondition:
|
237
|
+
Enabled: true
|
238
|
+
|
239
|
+
Style/HashTransformKeys:
|
240
|
+
Enabled: true
|
241
|
+
|
242
|
+
Style/HashTransformValues:
|
243
|
+
Enabled: true
|
244
|
+
|
245
|
+
Style/RedundantBegin:
|
246
|
+
Enabled: true
|
247
|
+
|
248
|
+
Style/RedundantReturn:
|
249
|
+
Enabled: true
|
250
|
+
AllowMultipleReturnValues: true
|
251
|
+
|
252
|
+
Style/RedundantRegexpEscape:
|
253
|
+
Enabled: true
|
254
|
+
|
255
|
+
Style/Semicolon:
|
256
|
+
Enabled: true
|
257
|
+
AllowAsExpressionSeparator: true
|
258
|
+
|
259
|
+
# Prefer Foo.method over Foo::method
|
260
|
+
Style/ColonMethodCall:
|
261
|
+
Enabled: true
|
262
|
+
|
263
|
+
Style/TrivialAccessors:
|
264
|
+
Enabled: true
|
265
|
+
|
266
|
+
Performance/BindCall:
|
267
|
+
Enabled: true
|
268
|
+
|
269
|
+
Performance/FlatMap:
|
270
|
+
Enabled: true
|
271
|
+
|
272
|
+
Performance/MapCompact:
|
273
|
+
Enabled: true
|
274
|
+
|
275
|
+
Performance/SelectMap:
|
276
|
+
Enabled: true
|
277
|
+
|
278
|
+
Performance/RedundantMerge:
|
279
|
+
Enabled: true
|
280
|
+
|
281
|
+
Performance/StartWith:
|
282
|
+
Enabled: true
|
283
|
+
|
284
|
+
Performance/EndWith:
|
285
|
+
Enabled: true
|
286
|
+
|
287
|
+
Performance/RegexpMatch:
|
288
|
+
Enabled: true
|
289
|
+
|
290
|
+
Performance/ReverseEach:
|
291
|
+
Enabled: true
|
292
|
+
|
293
|
+
Performance/StringReplacement:
|
294
|
+
Enabled: true
|
295
|
+
|
296
|
+
Performance/UnfreezeString:
|
297
|
+
Enabled: true
|
298
|
+
|
299
|
+
Performance/DeletePrefix:
|
300
|
+
Enabled: true
|
301
|
+
|
302
|
+
Performance/DeleteSuffix:
|
303
|
+
Enabled: true
|
304
|
+
|
305
|
+
Minitest/UnreachableAssertion:
|
306
|
+
Enabled: true
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at careline@foxmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in hotwired.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :rubocop do
|
9
|
+
gem "rubocop", require: false
|
10
|
+
gem "rubocop-minitest", require: false
|
11
|
+
gem "rubocop-packaging", require: false
|
12
|
+
gem "rubocop-performance", require: false
|
13
|
+
gem "rubocop-rails", require: false
|
14
|
+
end
|
15
|
+
|
16
|
+
gem "rake", "~> 13.0"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 WENWU.YAN
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Hotwired
|
2
|
+
|
3
|
+
hotwired sends SNMP queries to defined CIDR ranges and populates SQL database based on nodes found. Some particular
|
4
|
+
problems it tries to deal with:
|
5
|
+
|
6
|
+
* Only discover one node once
|
7
|
+
* To that effect it has priority list of idDescr lo0.0, loopback0, vlan2 etc. Higher priority will always replace lower
|
8
|
+
priority interface (say you have MGMT in loop0 but giga0/2.42 has valid MGMT address towards L2 metro)
|
9
|
+
* Tries to handle gracefully renumbering, renaming, etc
|
10
|
+
|
11
|
+
# Install
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'hotwired'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install hotwired
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
1. gem install hotwired
|
30
|
+
2. hotwired
|
31
|
+
3. ^C (break it)
|
32
|
+
4. edit ~/.config/hotwired/config
|
33
|
+
5. put hotwired in crontab as hotwired|mail -E -s 'new nodes found' foo@example.com_
|
34
|
+
|
35
|
+
# Config
|
36
|
+
|
37
|
+
* You need to configure SNMP community
|
38
|
+
* You need to define CIDR to poll and CIDRs to ignore (subset of those you poll)
|
39
|
+
* CIDR in example config is list, but can be replaced with 'string' which points to file, where CIDRs are listed
|
40
|
+
|
41
|
+
# CLI execute sample
|
42
|
+
|
43
|
+
```shell
|
44
|
+
[hotwired@nodes ~/hotwired]% hotwired --help
|
45
|
+
Usage: hotwired [options] [argument]
|
46
|
+
-d, --debug Debugging on
|
47
|
+
-p, --poll Poll CIDR [argument]
|
48
|
+
-r, --remove Remove [argument] from DB
|
49
|
+
-m, --max-delete Maximum number to delete, default 1
|
50
|
+
-o, --purge-old Remove records order than [argument] days
|
51
|
+
-s, --simulate Simulate, do not change DB
|
52
|
+
-h, --help Display this help message.
|
53
|
+
|
54
|
+
% hotwired -p 192.0.2.0/28 # poll specific CIDR
|
55
|
+
% hotwired -r core-sw1 # remove specific record
|
56
|
+
% hotwired -o 7 # remore records older than 7 days
|
57
|
+
```
|
58
|
+
|
59
|
+
## Development
|
60
|
+
|
61
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive
|
62
|
+
prompt that will allow you to experiment.
|
63
|
+
|
64
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
65
|
+
version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
|
66
|
+
push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ciscolive/hotwired. This project is intended
|
71
|
+
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).
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
77
|
+
|
78
|
+
## Code of Conduct
|
79
|
+
|
80
|
+
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).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "hotwired"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/hotwired
ADDED
data/bin/setup
ADDED
data/hotwired.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/hotwired/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "hotwired"
|
7
|
+
spec.version = Hotwired::VERSION
|
8
|
+
spec.authors = ["WENWU.YAN"]
|
9
|
+
spec.email = ["careline@foxmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Device discovery via snmp polls"
|
12
|
+
spec.description = "Threaded SNMP poll based network discovery. Devices are stored in SQL"
|
13
|
+
spec.homepage = "https://github.com/ciscolive/hotwired"
|
14
|
+
spec.licenses = "MIT"
|
15
|
+
|
16
|
+
# spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
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"
|
21
|
+
|
22
|
+
spec.files = `git ls-files`.split("\n")
|
23
|
+
spec.executables = %w( hotwired )
|
24
|
+
|
25
|
+
spec.require_paths = "lib"
|
26
|
+
spec.required_ruby_version = ">= 2.6.0"
|
27
|
+
|
28
|
+
# 项目依赖
|
29
|
+
spec.add_runtime_dependency "strada", "~> 0.0.2"
|
30
|
+
spec.add_runtime_dependency "sequel", "~> 5.0"
|
31
|
+
spec.add_runtime_dependency "slop", "~> 4.0"
|
32
|
+
spec.add_runtime_dependency "snmp", "~> 1.3"
|
33
|
+
spec.add_runtime_dependency "sqlite3", "~> 1.4"
|
34
|
+
end
|