net-snmp 1.2.4 → 1.2.5
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 +1296 -1296
- package/example/cisco-device-inventory.js +140 -140
- package/example/snmp-get-bulk.js +53 -53
- package/example/snmp-get-next.js +30 -30
- package/example/snmp-get.js +30 -30
- package/example/snmp-inform.js +32 -32
- package/example/snmp-set.js +31 -31
- package/example/snmp-subtree.js +37 -37
- package/example/snmp-table-columns.js +61 -61
- package/example/snmp-table.js +56 -56
- package/example/snmp-tail.js +34 -34
- package/example/snmp-trap.js +32 -32
- package/example/snmp-walk.js +37 -37
- package/example/specify-source-address-and-port.js +41 -41
- package/example/specify-sysuptime-to-inform.js +34 -34
- package/example/specify-sysuptime-to-trap.js +35 -35
- package/index.js +1464 -1464
- package/package.json +43 -39
- package/ref/rfc/v1/rfc1065.txt +1178 -1178
- package/ref/rfc/v1/rfc1066.txt +5042 -5042
- package/ref/rfc/v1/rfc1067.txt +1850 -1850
- package/ref/rfc/v1/rfc1098.txt +1906 -1906
- package/ref/rfc/v1/rfc1155.txt +1234 -1234
- package/ref/rfc/v2c/rfc1908.txt +563 -563
- package/ref/rfc/v2c/rfc2578.txt +2541 -2541
- package/ref/rfc/v2c/rfc3416.txt +1739 -1739
- package/test/varbinds.js +42 -42
package/example/snmp-subtree.js
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var snmp = require ("../");
|
5
|
-
|
6
|
-
if (process.argv.length < 6) {
|
7
|
-
console.log ("usage: snmp-subtree <target> <community> <version> <oid>");
|
8
|
-
process.exit (1);
|
9
|
-
}
|
10
|
-
|
11
|
-
var target = process.argv[2];
|
12
|
-
var community = process.argv[3];
|
13
|
-
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
-
|
15
|
-
var oid = process.argv[5];
|
16
|
-
|
17
|
-
var session = snmp.createSession (target, community, {version: version});
|
18
|
-
|
19
|
-
function doneCb (error) {
|
20
|
-
if (error)
|
21
|
-
console.error (error.toString ());
|
22
|
-
}
|
23
|
-
|
24
|
-
function feedCb (varbinds) {
|
25
|
-
for (var i = 0; i < varbinds.length; i++) {
|
26
|
-
if (snmp.isVarbindError (varbinds[i]))
|
27
|
-
console.error (snmp.varbindError (varbinds[i]));
|
28
|
-
else
|
29
|
-
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
var maxRepetitions = 20;
|
34
|
-
|
35
|
-
// The maxRepetitions argument is optional, and will be ignored unless using
|
36
|
-
// SNMP verison 2c
|
37
|
-
session.subtree (oid, maxRepetitions, feedCb, doneCb);
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var snmp = require ("../");
|
5
|
+
|
6
|
+
if (process.argv.length < 6) {
|
7
|
+
console.log ("usage: snmp-subtree <target> <community> <version> <oid>");
|
8
|
+
process.exit (1);
|
9
|
+
}
|
10
|
+
|
11
|
+
var target = process.argv[2];
|
12
|
+
var community = process.argv[3];
|
13
|
+
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
+
|
15
|
+
var oid = process.argv[5];
|
16
|
+
|
17
|
+
var session = snmp.createSession (target, community, {version: version});
|
18
|
+
|
19
|
+
function doneCb (error) {
|
20
|
+
if (error)
|
21
|
+
console.error (error.toString ());
|
22
|
+
}
|
23
|
+
|
24
|
+
function feedCb (varbinds) {
|
25
|
+
for (var i = 0; i < varbinds.length; i++) {
|
26
|
+
if (snmp.isVarbindError (varbinds[i]))
|
27
|
+
console.error (snmp.varbindError (varbinds[i]));
|
28
|
+
else
|
29
|
+
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
var maxRepetitions = 20;
|
34
|
+
|
35
|
+
// The maxRepetitions argument is optional, and will be ignored unless using
|
36
|
+
// SNMP verison 2c
|
37
|
+
session.subtree (oid, maxRepetitions, feedCb, doneCb);
|
@@ -1,61 +1,61 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var snmp = require ("../");
|
5
|
-
|
6
|
-
if (process.argv.length < 7) {
|
7
|
-
console.log ("usage: snmp-table-columns <target> <community> <version> "
|
8
|
-
+ "<oid> <col> [<col> ...]");
|
9
|
-
process.exit (1);
|
10
|
-
}
|
11
|
-
|
12
|
-
var target = process.argv[2];
|
13
|
-
var community = process.argv[3];
|
14
|
-
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
15
|
-
|
16
|
-
var oid = process.argv[5];
|
17
|
-
var columns = [];
|
18
|
-
|
19
|
-
for (var i = 6; i < process.argv.length; i++)
|
20
|
-
columns.push (process.argv[i]);
|
21
|
-
|
22
|
-
var session = snmp.createSession (target, community, {version: version});
|
23
|
-
|
24
|
-
function sortInt (a, b) {
|
25
|
-
if (a > b)
|
26
|
-
return 1;
|
27
|
-
else if (b > a)
|
28
|
-
return -1;
|
29
|
-
else
|
30
|
-
return 0;
|
31
|
-
}
|
32
|
-
|
33
|
-
function responseCb (error, table) {
|
34
|
-
if (error) {
|
35
|
-
console.error (error.toString ());
|
36
|
-
} else {
|
37
|
-
var indexes = [];
|
38
|
-
for (index in table)
|
39
|
-
indexes.push (index);
|
40
|
-
indexes.sort ();
|
41
|
-
|
42
|
-
for (var i = 0; i < indexes.length; i++) {
|
43
|
-
var columns = [];
|
44
|
-
for (column in table[indexes[i]])
|
45
|
-
columns.push (parseInt (column));
|
46
|
-
columns.sort (sortInt);
|
47
|
-
|
48
|
-
console.log ("row for index = " + indexes[i]);
|
49
|
-
for (var j = 0; j < columns.length; j++) {
|
50
|
-
console.log (" column " + columns[j] + " = "
|
51
|
-
+ table[indexes[i]][columns[j]]);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
var maxRepetitions = 20;
|
58
|
-
|
59
|
-
// The maxRepetitions argument is optional, and will be ignored unless using
|
60
|
-
// SNMP verison 2c
|
61
|
-
session.tableColumns (oid, columns, maxRepetitions, responseCb);
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var snmp = require ("../");
|
5
|
+
|
6
|
+
if (process.argv.length < 7) {
|
7
|
+
console.log ("usage: snmp-table-columns <target> <community> <version> "
|
8
|
+
+ "<oid> <col> [<col> ...]");
|
9
|
+
process.exit (1);
|
10
|
+
}
|
11
|
+
|
12
|
+
var target = process.argv[2];
|
13
|
+
var community = process.argv[3];
|
14
|
+
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
15
|
+
|
16
|
+
var oid = process.argv[5];
|
17
|
+
var columns = [];
|
18
|
+
|
19
|
+
for (var i = 6; i < process.argv.length; i++)
|
20
|
+
columns.push (process.argv[i]);
|
21
|
+
|
22
|
+
var session = snmp.createSession (target, community, {version: version});
|
23
|
+
|
24
|
+
function sortInt (a, b) {
|
25
|
+
if (a > b)
|
26
|
+
return 1;
|
27
|
+
else if (b > a)
|
28
|
+
return -1;
|
29
|
+
else
|
30
|
+
return 0;
|
31
|
+
}
|
32
|
+
|
33
|
+
function responseCb (error, table) {
|
34
|
+
if (error) {
|
35
|
+
console.error (error.toString ());
|
36
|
+
} else {
|
37
|
+
var indexes = [];
|
38
|
+
for (index in table)
|
39
|
+
indexes.push (index);
|
40
|
+
indexes.sort ();
|
41
|
+
|
42
|
+
for (var i = 0; i < indexes.length; i++) {
|
43
|
+
var columns = [];
|
44
|
+
for (column in table[indexes[i]])
|
45
|
+
columns.push (parseInt (column));
|
46
|
+
columns.sort (sortInt);
|
47
|
+
|
48
|
+
console.log ("row for index = " + indexes[i]);
|
49
|
+
for (var j = 0; j < columns.length; j++) {
|
50
|
+
console.log (" column " + columns[j] + " = "
|
51
|
+
+ table[indexes[i]][columns[j]]);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
var maxRepetitions = 20;
|
58
|
+
|
59
|
+
// The maxRepetitions argument is optional, and will be ignored unless using
|
60
|
+
// SNMP verison 2c
|
61
|
+
session.tableColumns (oid, columns, maxRepetitions, responseCb);
|
package/example/snmp-table.js
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var snmp = require ("../");
|
5
|
-
|
6
|
-
if (process.argv.length < 6) {
|
7
|
-
console.log ("usage: snmp-table <target> <community> <version> <oid>");
|
8
|
-
process.exit (1);
|
9
|
-
}
|
10
|
-
|
11
|
-
var target = process.argv[2];
|
12
|
-
var community = process.argv[3];
|
13
|
-
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
-
|
15
|
-
var oid = process.argv[5];
|
16
|
-
|
17
|
-
var session = snmp.createSession (target, community, {version: version});
|
18
|
-
|
19
|
-
function sortInt (a, b) {
|
20
|
-
if (a > b)
|
21
|
-
return 1;
|
22
|
-
else if (b > a)
|
23
|
-
return -1;
|
24
|
-
else
|
25
|
-
return 0;
|
26
|
-
}
|
27
|
-
|
28
|
-
function responseCb (error, table) {
|
29
|
-
if (error) {
|
30
|
-
console.error (error.toString ());
|
31
|
-
} else {
|
32
|
-
var indexes = [];
|
33
|
-
for (index in table)
|
34
|
-
indexes.push (index);
|
35
|
-
indexes.sort ();
|
36
|
-
|
37
|
-
for (var i = 0; i < indexes.length; i++) {
|
38
|
-
var columns = [];
|
39
|
-
for (column in table[indexes[i]])
|
40
|
-
columns.push (parseInt (column));
|
41
|
-
columns.sort (sortInt);
|
42
|
-
|
43
|
-
console.log ("row for index = " + indexes[i]);
|
44
|
-
for (var j = 0; j < columns.length; j++) {
|
45
|
-
console.log (" column " + columns[j] + " = "
|
46
|
-
+ table[indexes[i]][columns[j]]);
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
var maxRepetitions = 20;
|
53
|
-
|
54
|
-
// The maxRepetitions argument is optional, and will be ignored unless using
|
55
|
-
// SNMP verison 2c
|
56
|
-
session.table (oid, maxRepetitions, responseCb);
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var snmp = require ("../");
|
5
|
+
|
6
|
+
if (process.argv.length < 6) {
|
7
|
+
console.log ("usage: snmp-table <target> <community> <version> <oid>");
|
8
|
+
process.exit (1);
|
9
|
+
}
|
10
|
+
|
11
|
+
var target = process.argv[2];
|
12
|
+
var community = process.argv[3];
|
13
|
+
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
+
|
15
|
+
var oid = process.argv[5];
|
16
|
+
|
17
|
+
var session = snmp.createSession (target, community, {version: version});
|
18
|
+
|
19
|
+
function sortInt (a, b) {
|
20
|
+
if (a > b)
|
21
|
+
return 1;
|
22
|
+
else if (b > a)
|
23
|
+
return -1;
|
24
|
+
else
|
25
|
+
return 0;
|
26
|
+
}
|
27
|
+
|
28
|
+
function responseCb (error, table) {
|
29
|
+
if (error) {
|
30
|
+
console.error (error.toString ());
|
31
|
+
} else {
|
32
|
+
var indexes = [];
|
33
|
+
for (index in table)
|
34
|
+
indexes.push (index);
|
35
|
+
indexes.sort ();
|
36
|
+
|
37
|
+
for (var i = 0; i < indexes.length; i++) {
|
38
|
+
var columns = [];
|
39
|
+
for (column in table[indexes[i]])
|
40
|
+
columns.push (parseInt (column));
|
41
|
+
columns.sort (sortInt);
|
42
|
+
|
43
|
+
console.log ("row for index = " + indexes[i]);
|
44
|
+
for (var j = 0; j < columns.length; j++) {
|
45
|
+
console.log (" column " + columns[j] + " = "
|
46
|
+
+ table[indexes[i]][columns[j]]);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
var maxRepetitions = 20;
|
53
|
+
|
54
|
+
// The maxRepetitions argument is optional, and will be ignored unless using
|
55
|
+
// SNMP verison 2c
|
56
|
+
session.table (oid, maxRepetitions, responseCb);
|
package/example/snmp-tail.js
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var snmp = require ("../");
|
5
|
-
|
6
|
-
if (process.argv.length < 6) {
|
7
|
-
console.log ("usage: snmp-tail <target> <community> <version> <oid>");
|
8
|
-
process.exit (1);
|
9
|
-
}
|
10
|
-
|
11
|
-
var target = process.argv[2];
|
12
|
-
var community = process.argv[3];
|
13
|
-
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
-
|
15
|
-
var oid = process.argv[5];
|
16
|
-
|
17
|
-
var session = snmp.createSession (target, community, {version: version});
|
18
|
-
|
19
|
-
function poll () {
|
20
|
-
session.get ([oid], function (error, varbinds) {
|
21
|
-
if (error) {
|
22
|
-
console.error (error.toString ());
|
23
|
-
} else {
|
24
|
-
if (snmp.isVarbindError (varbinds[0]))
|
25
|
-
console.error (snmp.varbindError (varbinds[0]));
|
26
|
-
else
|
27
|
-
console.log (varbinds[0].value);
|
28
|
-
}
|
29
|
-
});
|
30
|
-
}
|
31
|
-
|
32
|
-
poll ();
|
33
|
-
|
34
|
-
setInterval (poll, 1000);
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var snmp = require ("../");
|
5
|
+
|
6
|
+
if (process.argv.length < 6) {
|
7
|
+
console.log ("usage: snmp-tail <target> <community> <version> <oid>");
|
8
|
+
process.exit (1);
|
9
|
+
}
|
10
|
+
|
11
|
+
var target = process.argv[2];
|
12
|
+
var community = process.argv[3];
|
13
|
+
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
+
|
15
|
+
var oid = process.argv[5];
|
16
|
+
|
17
|
+
var session = snmp.createSession (target, community, {version: version});
|
18
|
+
|
19
|
+
function poll () {
|
20
|
+
session.get ([oid], function (error, varbinds) {
|
21
|
+
if (error) {
|
22
|
+
console.error (error.toString ());
|
23
|
+
} else {
|
24
|
+
if (snmp.isVarbindError (varbinds[0]))
|
25
|
+
console.error (snmp.varbindError (varbinds[0]));
|
26
|
+
else
|
27
|
+
console.log (varbinds[0].value);
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
poll ();
|
33
|
+
|
34
|
+
setInterval (poll, 1000);
|
package/example/snmp-trap.js
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var dns = require ("dns");
|
5
|
-
var os = require ("os");
|
6
|
-
var snmp = require ("../");
|
7
|
-
|
8
|
-
if (process.argv.length < 6) {
|
9
|
-
console.log ("usage: node snmp-trap <target> <community> <version> <typeOrOid>");
|
10
|
-
process.exit (1);
|
11
|
-
}
|
12
|
-
|
13
|
-
var target = process.argv[2];
|
14
|
-
var community = process.argv[3];
|
15
|
-
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
16
|
-
|
17
|
-
var typeOrOid = process.argv[5];
|
18
|
-
|
19
|
-
var session = snmp.createSession (target, community, {version: version});
|
20
|
-
|
21
|
-
dns.lookup (os.hostname (), function (error, address) {
|
22
|
-
if (error) {
|
23
|
-
console.trace (error);
|
24
|
-
} else {
|
25
|
-
// address will be ignored for version 2c
|
26
|
-
session.trap (snmp.TrapType[typeOrOid] || typeOrOid,
|
27
|
-
address, function (error) {
|
28
|
-
if (error)
|
29
|
-
console.trace ("Trap failed: " + error);
|
30
|
-
});
|
31
|
-
}
|
32
|
-
});
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var dns = require ("dns");
|
5
|
+
var os = require ("os");
|
6
|
+
var snmp = require ("../");
|
7
|
+
|
8
|
+
if (process.argv.length < 6) {
|
9
|
+
console.log ("usage: node snmp-trap <target> <community> <version> <typeOrOid>");
|
10
|
+
process.exit (1);
|
11
|
+
}
|
12
|
+
|
13
|
+
var target = process.argv[2];
|
14
|
+
var community = process.argv[3];
|
15
|
+
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
16
|
+
|
17
|
+
var typeOrOid = process.argv[5];
|
18
|
+
|
19
|
+
var session = snmp.createSession (target, community, {version: version});
|
20
|
+
|
21
|
+
dns.lookup (os.hostname (), function (error, address) {
|
22
|
+
if (error) {
|
23
|
+
console.trace (error);
|
24
|
+
} else {
|
25
|
+
// address will be ignored for version 2c
|
26
|
+
session.trap (snmp.TrapType[typeOrOid] || typeOrOid,
|
27
|
+
address, function (error) {
|
28
|
+
if (error)
|
29
|
+
console.trace ("Trap failed: " + error);
|
30
|
+
});
|
31
|
+
}
|
32
|
+
});
|
package/example/snmp-walk.js
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var snmp = require ("../");
|
5
|
-
|
6
|
-
if (process.argv.length < 6) {
|
7
|
-
console.log ("usage: snmp-walk <target> <community> <version> <oid>");
|
8
|
-
process.exit (1);
|
9
|
-
}
|
10
|
-
|
11
|
-
var target = process.argv[2];
|
12
|
-
var community = process.argv[3];
|
13
|
-
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
-
|
15
|
-
var oid = process.argv[5];
|
16
|
-
|
17
|
-
var session = snmp.createSession (target, community, {version: version});
|
18
|
-
|
19
|
-
function doneCb (error) {
|
20
|
-
if (error)
|
21
|
-
console.error (error.toString ());
|
22
|
-
}
|
23
|
-
|
24
|
-
function feedCb (varbinds) {
|
25
|
-
for (var i = 0; i < varbinds.length; i++) {
|
26
|
-
if (snmp.isVarbindError (varbinds[i]))
|
27
|
-
console.error (snmp.varbindError (varbinds[i]));
|
28
|
-
else
|
29
|
-
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
var maxRepetitions = 20;
|
34
|
-
|
35
|
-
// The maxRepetitions argument is optional, and will be ignored unless using
|
36
|
-
// SNMP verison 2c
|
37
|
-
session.walk (oid, maxRepetitions, feedCb, doneCb);
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var snmp = require ("../");
|
5
|
+
|
6
|
+
if (process.argv.length < 6) {
|
7
|
+
console.log ("usage: snmp-walk <target> <community> <version> <oid>");
|
8
|
+
process.exit (1);
|
9
|
+
}
|
10
|
+
|
11
|
+
var target = process.argv[2];
|
12
|
+
var community = process.argv[3];
|
13
|
+
var version = (process.argv[4] == "2c") ? snmp.Version2c : snmp.Version1;
|
14
|
+
|
15
|
+
var oid = process.argv[5];
|
16
|
+
|
17
|
+
var session = snmp.createSession (target, community, {version: version});
|
18
|
+
|
19
|
+
function doneCb (error) {
|
20
|
+
if (error)
|
21
|
+
console.error (error.toString ());
|
22
|
+
}
|
23
|
+
|
24
|
+
function feedCb (varbinds) {
|
25
|
+
for (var i = 0; i < varbinds.length; i++) {
|
26
|
+
if (snmp.isVarbindError (varbinds[i]))
|
27
|
+
console.error (snmp.varbindError (varbinds[i]));
|
28
|
+
else
|
29
|
+
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
var maxRepetitions = 20;
|
34
|
+
|
35
|
+
// The maxRepetitions argument is optional, and will be ignored unless using
|
36
|
+
// SNMP verison 2c
|
37
|
+
session.walk (oid, maxRepetitions, feedCb, doneCb);
|
@@ -1,41 +1,41 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var snmp = require ("../");
|
5
|
-
|
6
|
-
if (process.argv.length < 8) {
|
7
|
-
console.log ("usage: specify-source-address-and-port <source-address> "
|
8
|
-
+ "<source-port>\n <target> <community> <version> "
|
9
|
-
+ "<oid>");
|
10
|
-
process.exit (1);
|
11
|
-
}
|
12
|
-
|
13
|
-
var sourceAddress = process.argv[2];
|
14
|
-
var sourcePort = process.argv[3];
|
15
|
-
|
16
|
-
var target = process.argv[4];
|
17
|
-
var community = process.argv[5];
|
18
|
-
var version = (process.argv[6] == "2c") ? snmp.Version2c : snmp.Version1;
|
19
|
-
|
20
|
-
var oids = [process.argv[7]];
|
21
|
-
|
22
|
-
var sessionOptions = {
|
23
|
-
version: version,
|
24
|
-
sourceAddress: sourceAddress,
|
25
|
-
sourcePort: sourcePort
|
26
|
-
};
|
27
|
-
|
28
|
-
var session = snmp.createSession (target, community, sessionOptions);
|
29
|
-
|
30
|
-
session.get (oids, function (error, varbinds) {
|
31
|
-
if (error) {
|
32
|
-
console.error (error.toString ());
|
33
|
-
} else {
|
34
|
-
for (var i = 0; i < varbinds.length; i++) {
|
35
|
-
if (snmp.isVarbindError (varbinds[i]))
|
36
|
-
console.error (snmp.varbindError (varbinds[i]));
|
37
|
-
else
|
38
|
-
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
});
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var snmp = require ("../");
|
5
|
+
|
6
|
+
if (process.argv.length < 8) {
|
7
|
+
console.log ("usage: specify-source-address-and-port <source-address> "
|
8
|
+
+ "<source-port>\n <target> <community> <version> "
|
9
|
+
+ "<oid>");
|
10
|
+
process.exit (1);
|
11
|
+
}
|
12
|
+
|
13
|
+
var sourceAddress = process.argv[2];
|
14
|
+
var sourcePort = process.argv[3];
|
15
|
+
|
16
|
+
var target = process.argv[4];
|
17
|
+
var community = process.argv[5];
|
18
|
+
var version = (process.argv[6] == "2c") ? snmp.Version2c : snmp.Version1;
|
19
|
+
|
20
|
+
var oids = [process.argv[7]];
|
21
|
+
|
22
|
+
var sessionOptions = {
|
23
|
+
version: version,
|
24
|
+
sourceAddress: sourceAddress,
|
25
|
+
sourcePort: sourcePort
|
26
|
+
};
|
27
|
+
|
28
|
+
var session = snmp.createSession (target, community, sessionOptions);
|
29
|
+
|
30
|
+
session.get (oids, function (error, varbinds) {
|
31
|
+
if (error) {
|
32
|
+
console.error (error.toString ());
|
33
|
+
} else {
|
34
|
+
for (var i = 0; i < varbinds.length; i++) {
|
35
|
+
if (snmp.isVarbindError (varbinds[i]))
|
36
|
+
console.error (snmp.varbindError (varbinds[i]));
|
37
|
+
else
|
38
|
+
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
});
|
@@ -1,34 +1,34 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
3
|
-
|
4
|
-
var snmp = require ("../");
|
5
|
-
|
6
|
-
if (process.argv.length < 6) {
|
7
|
-
console.log ("usage: specify-sysuptime-to-inform <target> <community> <oid> <sysuptime>");
|
8
|
-
process.exit (1);
|
9
|
-
}
|
10
|
-
|
11
|
-
var target = process.argv[2];
|
12
|
-
var community = process.argv[3];
|
13
|
-
|
14
|
-
var typeOrOid = process.argv[4];
|
15
|
-
|
16
|
-
var upTime = parseInt(process.argv[5]);
|
17
|
-
|
18
|
-
var options = {version: snmp.Version2c};
|
19
|
-
|
20
|
-
var session = snmp.createSession (target, community, options);
|
21
|
-
|
22
|
-
session.inform (snmp.TrapType[typeOrOid] || typeOrOid, {upTime: upTime},
|
23
|
-
function (error, varbinds) {
|
24
|
-
if (error) {
|
25
|
-
console.error (error.toString ());
|
26
|
-
} else {
|
27
|
-
for (var i = 0; i < varbinds.length; i++) {
|
28
|
-
if (snmp.isVarbindError (varbinds[i]))
|
29
|
-
console.error (snmp.varbindError (varbinds[i]));
|
30
|
-
else
|
31
|
-
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
});
|
1
|
+
|
2
|
+
// Copyright 2013 Stephen Vickers
|
3
|
+
|
4
|
+
var snmp = require ("../");
|
5
|
+
|
6
|
+
if (process.argv.length < 6) {
|
7
|
+
console.log ("usage: specify-sysuptime-to-inform <target> <community> <oid> <sysuptime>");
|
8
|
+
process.exit (1);
|
9
|
+
}
|
10
|
+
|
11
|
+
var target = process.argv[2];
|
12
|
+
var community = process.argv[3];
|
13
|
+
|
14
|
+
var typeOrOid = process.argv[4];
|
15
|
+
|
16
|
+
var upTime = parseInt(process.argv[5]);
|
17
|
+
|
18
|
+
var options = {version: snmp.Version2c};
|
19
|
+
|
20
|
+
var session = snmp.createSession (target, community, options);
|
21
|
+
|
22
|
+
session.inform (snmp.TrapType[typeOrOid] || typeOrOid, {upTime: upTime},
|
23
|
+
function (error, varbinds) {
|
24
|
+
if (error) {
|
25
|
+
console.error (error.toString ());
|
26
|
+
} else {
|
27
|
+
for (var i = 0; i < varbinds.length; i++) {
|
28
|
+
if (snmp.isVarbindError (varbinds[i]))
|
29
|
+
console.error (snmp.varbindError (varbinds[i]));
|
30
|
+
else
|
31
|
+
console.log (varbinds[i].oid + "|" + varbinds[i].value);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
});
|