diff options
Diffstat (limited to '')
-rw-r--r-- | collectors/node.d.plugin/snmp/Makefile.inc | 13 | ||||
-rw-r--r-- | collectors/node.d.plugin/snmp/README.md (renamed from conf.d/node.d/snmp.conf.md) | 12 | ||||
-rw-r--r-- | collectors/node.d.plugin/snmp/snmp.node.js (renamed from node.d/snmp.node.js) | 17 |
3 files changed, 28 insertions, 14 deletions
diff --git a/collectors/node.d.plugin/snmp/Makefile.inc b/collectors/node.d.plugin/snmp/Makefile.inc new file mode 100644 index 000000000..26448a1ce --- /dev/null +++ b/collectors/node.d.plugin/snmp/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_node_DATA += snmp/snmp.node.js +# dist_nodeconfig_DATA += snmp/snmp.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += snmp/README.md snmp/Makefile.inc + diff --git a/conf.d/node.d/snmp.conf.md b/collectors/node.d.plugin/snmp/README.md index 6b496f7a8..a307a3642 100644 --- a/conf.d/node.d/snmp.conf.md +++ b/collectors/node.d.plugin/snmp/README.md @@ -10,8 +10,6 @@ This collector supports: - each SNMP device may have a different update frequency - each SNMP device will accept one or more batches to report values (you can set `max_request_size` per SNMP server, to control the size of batches). -The source code of the plugin is [here](https://github.com/firehol/netdata/blob/master/node.d/snmp.node.js). - ## Configuration You will need to create the file `/etc/netdata/node.d/snmp.conf` with data like the following. @@ -23,7 +21,7 @@ In this example: - we will update the values every 10 seconds (`update_every: 10` under the server `10.11.12.8`). - we define 2 charts `snmp_switch.bandwidth_port1` and `snmp_switch.bandwidth_port2`, each having 2 dimensions: `in` and `out`. -```js +```json { "enable_autodetect": false, "update_every": 5, @@ -105,7 +103,7 @@ Each of the 24 new charts will have its id (1-24) appended at: 3. its `oid` (for all dimensions), i.e. dimension `in` will be `1.3.6.1.2.1.2.2.1.10.1` to `1.3.6.1.2.1.2.2.1.10.24` 3. its priority (which will be incremented for each chart so that the charts will appear on the dashboard in this order) -```js +```json { "enable_autodetect": false, "update_every": 10, @@ -154,7 +152,7 @@ The `options` given for each server, are: - `port`, the port of the SNMP device to connect to. The default is `161`. - `retries`, the number of attempts to make to fetch the data. The default is `1`. -## Retreiving names from snmp +## Retrieving names from snmp You can append a value retrieved from SNMP to the title, by adding `titleoid` to the chart. @@ -177,7 +175,7 @@ If it works, restart netdata to activate the snmp collector and refresh the dash ## Data collection speed -Keep in mind that many SNMP switches are routers are very slow. They may not be able to report values per second. If you run `node.d.plugin` in `debug` mode, it will report the time it took for the SNMP device to respond. My switch, for example, needs 7-8 seconds to respond for the traffic on 24 ports (48 OIDs, in/out). +Keep in mind that many SNMP switches and routers are very slow. They may not be able to report values per second. If you run `node.d.plugin` in `debug` mode, it will report the time it took for the SNMP device to respond. My switch, for example, needs 7-8 seconds to respond for the traffic on 24 ports (48 OIDs, in/out). Also, if you use many SNMP clients on the same SNMP device at the same time, values may be skipped. This is a problem of the SNMP device, not this collector. @@ -210,7 +208,7 @@ This switch also reports various other metrics, like snmp, packets per port, etc This switch has a very slow SNMP processors. To respond, it needs about 8 seconds, so I have set the refresh frequency (`update_every`) to 15 seconds. -```js +```json { "enable_autodetect": false, "update_every": 5, diff --git a/node.d/snmp.node.js b/collectors/node.d.plugin/snmp/snmp.node.js index 3e7027958..a051d3d3a 100644 --- a/node.d/snmp.node.js +++ b/collectors/node.d.plugin/snmp/snmp.node.js @@ -1,4 +1,5 @@ 'use strict'; +// SPDX-License-Identifier: GPL-3.0-or-later // netdata snmp module // This program will connect to one or more SNMP Agents // @@ -170,7 +171,7 @@ netdata.processors.snmp = { var oid = this.fixoid(dim.oid); var oidname = this.fixoid(dim.oidname); - + if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': indexing ' + this.name + ' chart: ' + c + ', dimension: ' + d + ', OID: ' + oid + ", OID name: " + oidname); @@ -275,14 +276,16 @@ netdata.processors.snmp = { switch(varbinds[i].type) { case net_snmp.ObjectType.OctetString: - if(service.snmp_oids_index[varbinds[i].oid].type !== 'title') + if (service.snmp_oids_index[varbinds[i].oid].type !== 'title' && service.snmp_oids_index[varbinds[i].oid].type !== 'name') { // parse floating point values, exposed as strings value = parseFloat(varbinds[i].value) * 1000; - if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as float in string)"); - else + if (__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as float in string)"); + } + else { // just use the string value = varbinds[i].value; - if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as string)"); + if (__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as string)"); + } break; case net_snmp.ObjectType.Counter64: @@ -306,7 +309,7 @@ netdata.processors.snmp = { if(value !== null) { switch(service.snmp_oids_index[varbinds[i].oid].type) { case 'title': service.snmp_oids_index[varbinds[i].oid].link.title += ' ' + value; break; - case 'name' : service.snmp_oids_index[varbinds[i].oid].link.name = value; break; + case 'name' : service.snmp_oids_index[varbinds[i].oid].link.name = value.toString().replace(/\W/g, '_'); break; case 'value': service.snmp_oids_index[varbinds[i].oid].link.value = value; break; } } @@ -445,7 +448,7 @@ var snmp = { var id = c + from.toString(); var chart = extend(true, {}, service_request_chart); chart.title += from.toString(); - + if(typeof chart.titleoid !== 'undefined') chart.titleoid += from.toString(); |