wb_editors
14 457
правок
(Новая страница: «== OID conversion ==») |
FuzzyBot (обсуждение | вклад) м (FuzzyBot переименовал страницу Драйвер SNMP/en в SNMP/en без оставления перенаправления: Часть переводимой страницы Драйвер SNMP.) |
||
(не показана 21 промежуточная версия 1 участника) | |||
Строка 125: | Строка 125: | ||
== OID conversion == | == OID conversion == | ||
When the daemon is started, an attempt is made to convert the text OIDs recorded in the configuration into numeric ones. | |||
If the OID is represented in numeric form (starts with the dot: .1.2.3.4), no conversion occurs. | |||
If the OID is in text form (for example, SNMPv2-MIB::sysName.0), it is necessary that the appropriate MIB containing the description of this variable is installed on the system. The name conversion is done by calling the snmptranslate utility, so you can check for a MIB manually by using the command | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Строка 136: | Строка 135: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Oid_prefix parameter in the device description allows you to omit the name of the MIB (prefix; SNMPv2-MIB::sysName.0). In this case, the prefix from '''oid_prefix''' will be automatically attached to all OID channels of the device where the prefix is not explicitly specified. For example, if oid_prefix = SNMPv2-MIB: | |||
* sysName.0 -> '''SNMPv2-MIB::'''sysName.0 | * sysName.0 -> '''SNMPv2-MIB::'''sysName.0 | ||
Строка 144: | Строка 142: | ||
* .1.3.6.1.2.1.1.6.0 -> .1.3.6.1.2.1.1.6.0 | * .1.3.6.1.2.1.1.6.0 -> .1.3.6.1.2.1.1.6.0 | ||
==== | ==== MIB installation ==== | ||
If You have the required MIB file, just copy it to the /root/.snmp/mibs, by pre-creating it: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# mkdir -p /root/.snmp/mibs | # mkdir -p /root/.snmp/mibs | ||
Строка 152: | Строка 150: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
After that, verify that snmptranslate works correctly with any known OID: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Строка 158: | Строка 156: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == Templates == | ||
It is convenient (though not necessary) to use templates to describe devices. The template (device type) is an external configuration file (located in /usr/share/wb-mqtt-snmp/templates and named config-[device-type-name].json, for example, config-test-snmp.json), which contains a basic description of the device (such as the SNMP community name) and a basic description of all its channels. | |||
To use the template in the device description in the configuration file, specify the field ''''device_type''''. Among all presented templates, a template with the same ''device_type'' value will be selected, and all fields that were not defined in the configuration file will take values from the template. | |||
It works the same way with channels. The channels are compared by the mandatory field name; if the channel name from the configuration file matches the channel name in the template, all unspecified values will be taken from the template. | |||
=== | === Example === | ||
Config-my-device.json template: | |||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
Строка 191: | Строка 186: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Configuration file: | |||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
{ | { | ||
Строка 217: | Строка 212: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
In this case, we have described one my-device template, by which we have defined two different devices Device 1 and Device 2 with the same set of channels. | |||
In this case, we have described one my-device template, by which we have defined two different devices Device 1 and Device 2 with the same set of channels. | |||
Since Device 1 is on the local network, it is logical to set it a small timeout value to quickly determine the malfunction of the device. All other settings are taken from the template. | |||
Device 2 and the remote server, because for him, it is necessary to increase the timeout to not think the device is faulty if the delay of the package. What's more, for channel 2 here, we are redefining the polling interval to a larger one to reduce the load on the network. | |||
So, it is very convenient to use templates to describe a group of similar devices. | |||
= Template list = | |||
The WB-mqtt-snmp package includes a set of templates for typical devices (the list will be expanded): | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! Device !! Template !! Tested !! Comments | ||
|- | |- | ||
| | | Test server Net-SNMP || test-snmp || style="background: #22EE44;" | Yes || Test server address test.net-snmp.org | ||
|- | |- | ||
| APC UPS || apc-ups || Нет || | | APC UPS || apc-ups || Нет || | ||
* | * Requires locally installed PowerNet-MIB | ||
* | * The device description is the same as in wb-mqtt-apcsnmp | ||
|- | |- | ||
|} | |} |