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.
@@ -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);
@@ -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);
@@ -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);
@@ -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
+ });
@@ -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
+ });