net-snmp 3.26.3 → 3.28.0
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.
- package/README.md +26 -2
- package/index.js +142 -12
- package/package.json +10 -1
- package/.claude/skills/git-commit/SKILL.md +0 -54
- package/.claude/skills/prepare-release/SKILL.md +0 -97
- package/.claude/skills/propose-action/SKILL.md +0 -111
- package/.claude/skills/publish-release/SKILL.md +0 -68
- package/.github/FUNDING.yml +0 -1
- package/.travis.yml +0 -13
- package/.vscode/launch.json +0 -249
- package/eslint.config.js +0 -98
- package/example/test.js +0 -70
- package/test/README-test-coverage.md +0 -76
- package/test/TEST-MIB.mib +0 -210
- package/test/cast-set-value.test.js +0 -200
- package/test/crypto.test.js +0 -384
- package/test/dgram-module.test.js +0 -71
- package/test/mib.test.js +0 -139
- package/test/object-types.test.js +0 -269
- package/test/oid-in-subtree.test.js +0 -36
- package/test/receiver-test.sh +0 -83
- package/test/snmp-test.sh +0 -122
- package/test/snmpv3-auth-failures.test.js +0 -331
- package/test/strict-int-range-checks.test.js +0 -337
- package/test/subagent.test.js +0 -477
- package/test/transport-option.test.js +0 -53
- package/test/varbinds.test.js +0 -53
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
const assert = require('assert');
|
|
2
|
-
const snmp = require('..');
|
|
3
|
-
|
|
4
|
-
describe('Object Types', function() {
|
|
5
|
-
|
|
6
|
-
describe('isValid() - Boolean', function() {
|
|
7
|
-
describe('JS true is a Boolean type', function() {
|
|
8
|
-
it('returns true', function() {
|
|
9
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Boolean, true), true);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
describe('JS false is a Boolean type', function() {
|
|
13
|
-
it('returns true', function() {
|
|
14
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Boolean, false), true);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('isValid() - Integer', function() {
|
|
20
|
-
describe('Zero is an Integer type', function() {
|
|
21
|
-
it('returns true', function() {
|
|
22
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 0), true);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe('An positive integer number is an Integer type', function() {
|
|
26
|
-
it('returns true', function() {
|
|
27
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 44), true);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe('An positive integer string is an Integer type', function() {
|
|
31
|
-
it('returns true', function() {
|
|
32
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "44"), true);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('An negative integer number is an Integer type', function() {
|
|
36
|
-
it('returns true', function() {
|
|
37
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -24), true);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('A negative integer string is an Integer type', function() {
|
|
41
|
-
it('returns true', function() {
|
|
42
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "-24"), true);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('A non-integer decimal number is not an Integer type', function() {
|
|
46
|
-
it('returns false', function() {
|
|
47
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 45.2), false);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe('A non-integer decimal string is not an Integer type', function() {
|
|
51
|
-
it('returns false', function() {
|
|
52
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "45.2"), false);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
describe('An integer at the bottom of the valid range is an Integer type', function() {
|
|
56
|
-
it('returns true', function() {
|
|
57
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -2147483648), true);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('An integer just lower than the valid range is not an Integer type', function() {
|
|
61
|
-
it('returns false', function() {
|
|
62
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -2147483649), false);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe('An integer at the top of the valid range is an Integer type', function() {
|
|
66
|
-
it('returns true', function() {
|
|
67
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483647), true);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('An integer just higher than the valid range is not an Integer type', function() {
|
|
71
|
-
it('returns false', function() {
|
|
72
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483648), false);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
// Tests for constraints
|
|
76
|
-
describe('An integer at the bottom of the valid range is a valid Integer type', function() {
|
|
77
|
-
it('returns true', function() {
|
|
78
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 0, { ranges: [{ min: 0, max: 10 }] }), true);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe('An integer outside the valid range is not an valid Integer type', function() {
|
|
82
|
-
it('returns false', function() {
|
|
83
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 11, { ranges: [{ min: 0, max: 10 }] }), false);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('isValid() - OctetString', function() {
|
|
89
|
-
describe('A string is an OctetString type', function() {
|
|
90
|
-
it('returns true', function() {
|
|
91
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'Better late than never'), true);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe('A buffer is an OctetString type', function() {
|
|
95
|
-
it('returns true', function() {
|
|
96
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, Buffer.from('1.3.6.1.2.3.4.5')), true);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
describe('A string with a length of 6 is valid for a size range of 2 - 7', function() {
|
|
100
|
-
it('returns true', function() {
|
|
101
|
-
const sizes = [
|
|
102
|
-
{ min: 2, max: 7 },
|
|
103
|
-
];
|
|
104
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'sixlet', { sizes }), true);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
describe('A string with a length of 6 is not valid for a size range of 2 - 5', function() {
|
|
108
|
-
it('returns true', function() {
|
|
109
|
-
const sizes = [
|
|
110
|
-
{ min: 2, max: 5 },
|
|
111
|
-
];
|
|
112
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'sixlet', { sizes }), false);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe('isValid() - OID', function() {
|
|
118
|
-
describe('A string OID is an OID type', function() {
|
|
119
|
-
it('returns true', function() {
|
|
120
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1.2.33.4.5'), true);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
describe('A string non-OID is not an OID type', function() {
|
|
124
|
-
it('returns true', function() {
|
|
125
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'dog'), true);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
describe('An OID string with a double-dot is not an OID type', function() {
|
|
129
|
-
it('returns true', function() {
|
|
130
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1..2.33.4.5'), true);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
describe('An OID string with a leading dot is not an OID type', function() {
|
|
134
|
-
it('returns true', function() {
|
|
135
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '.1.3.6.1..2.33.4.5'), true);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
describe('An OID string with a trailing dot is not an OID type', function() {
|
|
139
|
-
it('returns true', function() {
|
|
140
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1.2.33.4.5.'), true);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe('isValid() - Counter', function() {
|
|
146
|
-
describe('Zero is a Counter type', function() {
|
|
147
|
-
it('returns true', function() {
|
|
148
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 0), true);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
describe('An positive integer number is a Counter type', function() {
|
|
152
|
-
it('returns true', function() {
|
|
153
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 44), true);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
describe('An positive integer string is a Counter type', function() {
|
|
157
|
-
it('returns true', function() {
|
|
158
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "44"), true);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
describe('An negative integer number is not a Counter type', function() {
|
|
162
|
-
it('returns false', function() {
|
|
163
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, -24), false);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
describe('A negative integer string is not a Counter type', function() {
|
|
167
|
-
it('returns false', function() {
|
|
168
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "-24"), false);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
describe('A non-integer decimal number is not a Counter type', function() {
|
|
172
|
-
it('returns false', function() {
|
|
173
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 45.2), false);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
describe('A non-integer decimal string is not a Counter type', function() {
|
|
177
|
-
it('returns false', function() {
|
|
178
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "45.2"), false);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
describe('An integer at the bottom of the valid range is a Counter type', function() {
|
|
182
|
-
it('returns true', function() {
|
|
183
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 0), true);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
describe('An integer just lower than the valid range is not a Counter type', function() {
|
|
187
|
-
it('returns false', function() {
|
|
188
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, -1), false);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
describe('An integer at the top of the valid range is a Counter type', function() {
|
|
192
|
-
it('returns true', function() {
|
|
193
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 4294967295), true);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
describe('An integer just higher than the valid range is not a Counter type', function() {
|
|
197
|
-
it('returns false', function() {
|
|
198
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 4294967296), false);
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
describe('isValid() - Counter64', function() {
|
|
204
|
-
describe('Zero is a Counter64 type', function() {
|
|
205
|
-
it('returns true', function() {
|
|
206
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 0), true);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
describe('An positive integer number is a Counter64 type', function() {
|
|
210
|
-
it('returns true', function() {
|
|
211
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 44), true);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
describe('An positive integer string is a Counter64 type', function() {
|
|
215
|
-
it('returns true', function() {
|
|
216
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "44"), true);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
describe('An negative integer number is not a Counter64 type', function() {
|
|
220
|
-
it('returns false', function() {
|
|
221
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, -24), false);
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
describe('A negative integer string is not a Counter64 type', function() {
|
|
225
|
-
it('returns false', function() {
|
|
226
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "-24"), false);
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
describe('A non-integer decimal number is not a Counter64 type', function() {
|
|
230
|
-
it('returns false', function() {
|
|
231
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 45.2), false);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
describe('A non-integer decimal string is not a Counter64 type', function() {
|
|
235
|
-
it('returns false', function() {
|
|
236
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "45.2"), false);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
describe('An integer at the bottom of the valid range is a Counter64 type', function() {
|
|
240
|
-
it('returns true', function() {
|
|
241
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 0), true);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
describe('An integer just lower than the valid range is not a Counter64 type', function() {
|
|
245
|
-
it('returns false', function() {
|
|
246
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, -1), false);
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
describe('isValid() - IPAddress', function() {
|
|
252
|
-
describe('Dotted quad of numbers is an IpAddress type', function() {
|
|
253
|
-
it('returns true', function() {
|
|
254
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.3.147.4'), true);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
describe('Dotted quin of numbers is not an IpAddress type', function() {
|
|
258
|
-
it('returns false', function() {
|
|
259
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.3.147.22.4'), false);
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
describe('Dotted quad containing non-numbers is not an IpAddress type', function() {
|
|
263
|
-
it('returns false', function() {
|
|
264
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.word.147.4'), false);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const assert = require('assert');
|
|
2
|
-
const snmp = require('..');
|
|
3
|
-
|
|
4
|
-
const oidInSubtree = snmp.OidUtil.oidInSubtree;
|
|
5
|
-
|
|
6
|
-
describe('oidInSubtree()', function () {
|
|
7
|
-
|
|
8
|
-
it('returns true when nextString is in the subtree', function () {
|
|
9
|
-
assert.strictEqual(oidInSubtree('1.3.6.1.2.1', '1.3.6.1.2.1.1.1.0'), true);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('returns true when oidString equals nextString', function () {
|
|
13
|
-
assert.strictEqual(oidInSubtree('1.3.6.1.2.1', '1.3.6.1.2.1'), true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('returns false when nextString is outside the subtree', function () {
|
|
17
|
-
assert.strictEqual(oidInSubtree('1.3.6.1.2.1', '1.3.6.1.4.1.9'), false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false when nextString is shorter than oidString', function () {
|
|
21
|
-
assert.strictEqual(oidInSubtree('1.3.6.1.2.1', '1.3.6.1'), false);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('returns false when nextString is null (issue #298)', function () {
|
|
25
|
-
assert.strictEqual(oidInSubtree('1.3.6.1.2.1', null), false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('returns false when nextString is undefined', function () {
|
|
29
|
-
assert.strictEqual(oidInSubtree('1.3.6.1.2.1', undefined), false);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('returns false when nextString is an empty string', function () {
|
|
33
|
-
assert.strictEqual(oidInSubtree('1.3.6.1.2.1', ''), false);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
});
|
package/test/receiver-test.sh
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# receiver-test.sh - run tests for the net-snmp Receiver
|
|
4
|
-
|
|
5
|
-
# Usage: receiver-test.sh [ -6 ] [ -e <engine-id> ] [ -h ] [ -p ] [ -t target ]
|
|
6
|
-
|
|
7
|
-
HOME_DIR=.
|
|
8
|
-
HOST=localhost
|
|
9
|
-
PRINT_ONLY=0
|
|
10
|
-
CMDS=/var/tmp/receiver-test.$$
|
|
11
|
-
TRAP_OID="1.3.6.1.6.3.1.1.5.2"
|
|
12
|
-
unset ENGINE_ID
|
|
13
|
-
IPV6=0
|
|
14
|
-
|
|
15
|
-
# Auth parameters - change as necessary
|
|
16
|
-
COMMUNITY=public
|
|
17
|
-
USER_NONE=fred
|
|
18
|
-
USER_AUTH=betty
|
|
19
|
-
USER_PRIV=barney
|
|
20
|
-
AUTH_PROTOCOL=sha
|
|
21
|
-
AUTH_KEY=illhavesomeauth
|
|
22
|
-
PRIV_PROTOCOL=aes
|
|
23
|
-
PRIV_KEY=andsomepriv
|
|
24
|
-
|
|
25
|
-
usage() {
|
|
26
|
-
echo "Usage: $0 [ -6 ] [ -e <engine-id> ] [ -h ] [ -p ] [ -t target ]"
|
|
27
|
-
echo
|
|
28
|
-
echo "Options:"
|
|
29
|
-
echo " -6 use IPv6"
|
|
30
|
-
echo " -e <engine-id> engine ID - used for SNMPv3 traps only"
|
|
31
|
-
echo " -h print usage message and exit"
|
|
32
|
-
echo " -p print commands but do not run them"
|
|
33
|
-
echo " -t <host> target host"
|
|
34
|
-
exit 1
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
while getopts "6e:hl:pt:" OPT ; do
|
|
38
|
-
case ${OPT} in
|
|
39
|
-
6) IPV6=1 ;;
|
|
40
|
-
e) ENGINE_ID=${OPTARG} ;;
|
|
41
|
-
h) usage ;;
|
|
42
|
-
p) PRINT_ONLY=1 ;;
|
|
43
|
-
t) HOST=${OPTARG} ;;
|
|
44
|
-
esac
|
|
45
|
-
done
|
|
46
|
-
shift $((OPTIND - 1))
|
|
47
|
-
|
|
48
|
-
PARAMS=""
|
|
49
|
-
if [[ -n ${ENGINE_ID} ]] ; then
|
|
50
|
-
PARAMS="${PARAMS} -e \"${ENGINE_ID}\""
|
|
51
|
-
fi
|
|
52
|
-
if (( IPV6 )) ; then
|
|
53
|
-
PARAMS="${PARAMS} -t udp6"
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
cat >>${CMDS} <<ENDOFCMDS
|
|
57
|
-
node ${HOME_DIR}/example/snmp-trap.js -v 1 -c ${COMMUNITY} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
58
|
-
node ${HOME_DIR}/example/snmp-trap.js -v 2c -c ${COMMUNITY} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
59
|
-
node ${HOME_DIR}/example/snmp-trap.js -v 3 -l noAuthNoPriv -u ${USER_NONE} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
60
|
-
node ${HOME_DIR}/example/snmp-trap.js -v 3 -l authNoPriv -u ${USER_AUTH} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
61
|
-
node ${HOME_DIR}/example/snmp-trap.js -v 3 -l authPriv -u ${USER_PRIV} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
62
|
-
node ${HOME_DIR}/example/snmp-inform.js -v 2c -c ${COMMUNITY} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
63
|
-
node ${HOME_DIR}/example/snmp-inform.js -v 3 -l noAuthNoPriv -u ${USER_NONE} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
64
|
-
node ${HOME_DIR}/example/snmp-inform.js -v 3 -l authNoPriv -u ${USER_AUTH} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
65
|
-
node ${HOME_DIR}/example/snmp-inform.js -v 3 -l authPriv -u ${USER_PRIV} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
|
66
|
-
ENDOFCMDS
|
|
67
|
-
|
|
68
|
-
COUNT=1
|
|
69
|
-
|
|
70
|
-
while read CMD ; do
|
|
71
|
-
if (( PRINT_ONLY )) ; then
|
|
72
|
-
echo ${CMD}
|
|
73
|
-
else
|
|
74
|
-
CMD_NAME=$(echo ${CMD} | awk '{print $2}' | xargs basename)
|
|
75
|
-
echo "${COUNT}. ${CMD_NAME}"
|
|
76
|
-
echo ${CMD}
|
|
77
|
-
eval ${CMD}
|
|
78
|
-
echo
|
|
79
|
-
fi
|
|
80
|
-
COUNT=$((COUNT+1))
|
|
81
|
-
done <${CMDS}
|
|
82
|
-
|
|
83
|
-
rm -f ${CMDS}
|
package/test/snmp-test.sh
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# snmp-test.sh - run snmp tests
|
|
4
|
-
|
|
5
|
-
# Usage: snmp-test.sh [ -6 ] [ -e <engineId> ] [ -h host ] [ -l v1 | v2c | noauthnopriv | authnopriv | authpriv ] [ -p ]
|
|
6
|
-
|
|
7
|
-
HOME_DIR=.
|
|
8
|
-
HOST=localhost
|
|
9
|
-
LEVEL=authpriv
|
|
10
|
-
PRINT_ONLY=0
|
|
11
|
-
TRAP_ENGINEID="010203040a"
|
|
12
|
-
IPV6=0
|
|
13
|
-
CMDS=/var/tmp/snmp-test.$$
|
|
14
|
-
|
|
15
|
-
# Auth parameters - change as necessary
|
|
16
|
-
RO_COMMUNITY=public
|
|
17
|
-
RW_COMMUNITY=private
|
|
18
|
-
USER_NONE=fred
|
|
19
|
-
USER_AUTH=betty
|
|
20
|
-
USER_PRIV=barney
|
|
21
|
-
USER_TRAP_NONE=fred
|
|
22
|
-
USER_TRAP_AUTH=betty
|
|
23
|
-
USER_TRAP_PRIV=wilma
|
|
24
|
-
USER_SET_NONE=trapnone
|
|
25
|
-
USER_SET_AUTH=trapshaonly
|
|
26
|
-
USER_SET_PRIV=trapshades
|
|
27
|
-
AUTH_PROTOCOL=sha
|
|
28
|
-
AUTH_KEY=illhavesomeauth
|
|
29
|
-
PRIV_PROTOCOL=aes
|
|
30
|
-
PRIV_KEY=andsomepriv
|
|
31
|
-
|
|
32
|
-
usage() {
|
|
33
|
-
echo "Usage: $0 [ -6 ] [ -e <engineId> ] [ -h <host> ] [ -l v1 | v2c | noauthnopriv | authnopriv | authpriv ] [ -p ]"
|
|
34
|
-
echo
|
|
35
|
-
echo "Options:"
|
|
36
|
-
echo " -6 use IPv6"
|
|
37
|
-
echo " -e <engineId> local snmpEngineID - used for traps only"
|
|
38
|
-
echo " -h print usage message"
|
|
39
|
-
echo " -l <level> v1 | v2c | noauthnopriv | authnopriv | authpriv"
|
|
40
|
-
echo " -p print commands but do not run them"
|
|
41
|
-
echo " -t <host> target host"
|
|
42
|
-
exit 1
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get_auth_parameters() {
|
|
46
|
-
LEVEL=$1
|
|
47
|
-
|
|
48
|
-
if [[ ${LEVEL} == "v1" ]] ; then
|
|
49
|
-
PARAMS="-v 1 -c ${RO_COMMUNITY}"
|
|
50
|
-
TRAP_PARAMS="-v 1 -c ${RO_COMMUNITY}"
|
|
51
|
-
SET_PARAMS="-v 1 -c ${RW_COMMUNITY}"
|
|
52
|
-
elif [[ ${LEVEL} == "v2c" ]] ; then
|
|
53
|
-
PARAMS="-v 2c -c ${RO_COMMUNITY}"
|
|
54
|
-
TRAP_PARAMS="-v 2c -c ${RO_COMMUNITY}"
|
|
55
|
-
SET_PARAMS="-v 2c -c ${RW_COMMUNITY}"
|
|
56
|
-
elif [[ ${LEVEL} == "noauthnopriv" ]] ; then
|
|
57
|
-
PARAMS="-v 3 -u ${USER_NONE} -l noAuthNoPriv"
|
|
58
|
-
TRAP_PARAMS="-v 3 -u ${USER_TRAP_NONE} -l noAuthNoPriv"
|
|
59
|
-
SET_PARAMS="-v 3 -u ${USER_NONE} -l noAuthNoPriv"
|
|
60
|
-
elif [[ ${LEVEL} == "authnopriv" ]] ; then
|
|
61
|
-
PARAMS="-v 3 -u ${USER_AUTH} -l authNoPriv -a ${AUTH_PROTOCOL} -A ${AUTH_KEY}"
|
|
62
|
-
TRAP_PARAMS="-v 3 -u ${USER_TRAP_AUTH} -l authNoPriv -a ${AUTH_PROTOCOL} -A ${AUTH_KEY}"
|
|
63
|
-
SET_PARAMS="-v 3 -u ${USER_AUTH} -l authNoPriv -a ${AUTH_PROTOCOL} -A ${AUTH_KEY}"
|
|
64
|
-
elif [[ ${LEVEL} == "authpriv" ]] ; then
|
|
65
|
-
PARAMS="-v 3 -u ${USER_PRIV} -l authPriv -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY}"
|
|
66
|
-
TRAP_PARAMS="-v 3 -u ${USER_TRAP_PRIV} -l authPriv -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY}"
|
|
67
|
-
SET_PARAMS="-v 3 -u ${USER_PRIV} -l authPriv -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY}"
|
|
68
|
-
else
|
|
69
|
-
echo "$0: Unsupported level: $1"
|
|
70
|
-
fi
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
while getopts "6e:hl:pt:" OPT ; do
|
|
74
|
-
case ${OPT} in
|
|
75
|
-
6) IPV6=1 ;;
|
|
76
|
-
e) TRAP_ENGINEID=${OPTARG} ;;
|
|
77
|
-
h) usage ;;
|
|
78
|
-
l) LEVEL=${OPTARG} ;;
|
|
79
|
-
p) PRINT_ONLY=1 ;;
|
|
80
|
-
t) HOST=${OPTARG} ;;
|
|
81
|
-
esac
|
|
82
|
-
done
|
|
83
|
-
shift $((OPTIND - 1))
|
|
84
|
-
|
|
85
|
-
get_auth_parameters ${LEVEL}
|
|
86
|
-
|
|
87
|
-
if (( IPV6 )) ; then
|
|
88
|
-
PARAMS="${PARAMS} -t udp6"
|
|
89
|
-
TRAP_PARAMS="${TRAP_PARAMS} -t udp6"
|
|
90
|
-
SET_PARAMS="${SET_PARAMS} -t udp6"
|
|
91
|
-
fi
|
|
92
|
-
|
|
93
|
-
cat >>${CMDS} <<ENDOFCMDS
|
|
94
|
-
node ${HOME_DIR}/example/snmp-get.js ${PARAMS} ${HOST} 1.3.6.1.2.1.1.1.0
|
|
95
|
-
node ${HOME_DIR}/example/snmp-get-next.js ${PARAMS} ${HOST} 1.3.6.1.2.1.1.1.0
|
|
96
|
-
node ${HOME_DIR}/example/snmp-get-bulk.js ${PARAMS} -n 0 -r 5 ${HOST} 1.3.6.1.2.1.1.2.0
|
|
97
|
-
node ${HOME_DIR}/example/snmp-walk.js ${PARAMS} ${HOST} 1.3.6.1.6.3.16.1.5.2.1.6.9
|
|
98
|
-
node ${HOME_DIR}/example/snmp-subtree.js ${PARAMS} ${HOST} 1.3.6.1.6.3.16.1.5.2.1.4.5
|
|
99
|
-
node ${HOME_DIR}/example/snmp-table.js ${PARAMS} ${HOST} 1.3.6.1.2.1.1.9
|
|
100
|
-
node ${HOME_DIR}/example/snmp-table-columns.js ${PARAMS} ${HOST} 1.3.6.1.2.1.2.2 2
|
|
101
|
-
node ${HOME_DIR}/example/snmp-set.js ${SET_PARAMS} ${HOST} 1.3.6.1.2.1.1.6.0 OctetString Auckland
|
|
102
|
-
node ${HOME_DIR}/example/snmp-trap.js -e ${TRAP_ENGINEID} ${TRAP_PARAMS} ${HOST} 1.3.6.1.6.3.1.1.5.2
|
|
103
|
-
node ${HOME_DIR}/example/snmp-inform.js ${PARAMS} ${HOST} 1.3.6.1.6.3.1.1.5.2
|
|
104
|
-
ENDOFCMDS
|
|
105
|
-
|
|
106
|
-
COUNT=1
|
|
107
|
-
|
|
108
|
-
while read CMD ; do
|
|
109
|
-
if (( PRINT_ONLY )) ; then
|
|
110
|
-
echo ${CMD}
|
|
111
|
-
else
|
|
112
|
-
CMD_NAME=$(echo ${CMD} | awk '{print $2}' | xargs basename)
|
|
113
|
-
echo "${COUNT}. ${CMD_NAME}"
|
|
114
|
-
echo ${CMD}
|
|
115
|
-
eval ${CMD}
|
|
116
|
-
echo
|
|
117
|
-
fi
|
|
118
|
-
COUNT=$((COUNT+1))
|
|
119
|
-
done <${CMDS}
|
|
120
|
-
|
|
121
|
-
rm -f ${CMDS}
|
|
122
|
-
|