SNMP/en: различия между версиями

м
FuzzyBot переименовал страницу Драйвер SNMP/en в SNMP/en без оставления перенаправления: Часть переводимой страницы Драйвер SNMP.
(Новая страница: «*''' debug''' - flag to enable debug mode. If true, then in the process of the daemon in the log file will be put debug information (default is false); *'''num_wo…»)
м (FuzzyBot переименовал страницу Драйвер SNMP/en в SNMP/en без оставления перенаправления: Часть переводимой страницы Драйвер SNMP.)
 
(не показано 26 промежуточных версий 1 участника)
Строка 70: Строка 70:
*'''devices''' - list of devices to be polled.
*'''devices''' - list of devices to be polled.


==== Описание устройства ====
==== Device description ====


{| class="wikitable"
{| class="wikitable"
|-
|-
! Имя параметра !! Тип !! Описание !! Обязательный !! Значение по умолчанию
! Parameter name !! Type !! Description !! Required !! Default
 
|-
|-
| '''name ''' || string || Имя устройства || Нет || SNMP [address]_[community]
| '''name ''' || string || device name || No || SNMP [address]_[community]
|-
|-
| '''id''' || string || ID устройства в MQTT || Нет || snmp_[address]_[community]
| '''id''' || string || device ID in MQTT || No || snmp_[address]_[community]
|-
|-
| '''address''' || string || Сетевой адрес устройства || style="background: #22EE44;" | Да || -
| '''address''' || string || Network address of the device || style="background: #22EE44;" | Yes || -
|-
|-
| '''device_type''' || string || Тип устройства (нужен для загрузки шаблона) || Нет || -
| '''device_type''' || string || Type of device (required for downloading the template) || No || -
|-
|-
| '''enabled''' || bool || Включить устройство в опрос? || Нет || true
| '''enabled''' || bool || do you want to include the device in the poll? || No || true
|-
|-
| '''community''' || string || Имя сообщества SNMP || style="background: #22EE44;" | Да || -
| '''community''' || string || community name SNMP || style="background: #22EE44;" | Yes || -
|-
|-
| '''oid_prefix''' || string || Префикс (имя MIB) для текстовых OID каналов, где оный не указан явно || Нет || -
| '''oid_prefix''' || string || Prefix (MIB name) for text OID channels where the prefix is explicitly specified  || No || -
|-
|-
| '''snmp_version''' || string || Версия SNMP (на сегодняшний день поддерживается только 2с) || Нет || 2c
| '''snmp_version''' || string || SNMP version (currently only 2C is supported ) || No|| 2c
|-
|-
| '''snmp_timeout''' || integer || Время ожидания ответа (в секундах) || Нет || 5
| '''snmp_timeout''' || integer || response timeout (in seconds) || No || 5
|-
|-
| '''poll_interval''' || integer || Минимальное время опроса для каждого канала по умолчанию || Нет || -
| '''poll_interval''' || integer || Minimum polling time for each channel by default || No || -
|-
|-
| '''channels''' || array || Описание каналов устройства (переменных SNMP) || Нет || -
| '''channels''' || array || channels description (SNMP variables) || No || -
|-
|-
|}
|}


==== Описание каналов ====
==== Channel description ====


{| class="wikitable"
{| class="wikitable"
|-
|-
! Имя параметра !! Тип !! Описание !! Обязательный !! Значение по умолчанию
! Parameter name !! Type  !! Description !! Required !! Default
|-
|-
| '''name''' || string || Имя канала || style="background: #22EE44;" | Да || -
| '''name''' || string || channel name || style="background: #22EE44;" | Yes || -
|-
|-
| '''oid''' || string || OID в числовом или текстовом виде || style="background: #22EE44;" | Да || -
| '''oid''' || string || OID in numeric or text form || style="background: #22EE44;" | Yes || -
|-
|-
| '''enabled''' || boolean || Включить канал в опрос? || Нет || true
| '''enabled''' || boolean || Include the channel in poll? || No || true
|-
|-
| '''control_type''' || string || Тип данных (согласно [https://github.com/contactless/homeui/blob/contactless/conventions.md Conventions]) || Нет || text
| '''control_type''' || string || data type(according to [https://github.com/contactless/homeui/blob/contactless/conventions.md Conventions]) || No || text
|-
|-
| '''units''' || string || Обозначение единиц измерения (для control_type == value) || Нет || -
| '''units''' || string || the string name of the units(for control_type == value) || No || -
|-
|-
| '''scale''' || float || Множитель (для числовых значений) || Нет || 1.0
| '''scale''' || float || Multiplier (for numeric values) || No || 1.0
|-
|-
| '''poll_interval''' || int || Минимальный интервал опроса канала (в мс) || Нет || poll_interval из описания устройства, либо 1000
| '''poll_interval''' || int || the polling interval of the channel (in ms) || No || poll_interval from the description of the device, or  1000
|-
|-
|}
|}


== Преобразование OID ==
== OID conversion ==


При запуске демона происходит попытка преобразовать записанные в конфигурации текстовые OID в числовые.
When the daemon is started, an attempt is made to convert the text OIDs recorded in the configuration into numeric ones.


Если OID представлен в числовом виде (начинается с точки: .1.2.3.4), никакого преобразования не происходит.
If the OID is represented in numeric form (starts with the dot: .1.2.3.4), no conversion occurs.


Если OID представлен в текстовом виде (например, SNMPv2-MIB::sysName.0), необходимо, чтобы в системе был установлен соответствующий MIB, содержащий описание этой переменной.
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
Преобразование имён происходит с помощью вызова утилиты snmptranslate, так что можно проверить наличие MIB вручную с помощью команды


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Строка 135: Строка 135:
</syntaxhighlight>
</syntaxhighlight>


Параметр '''oid_prefix''' в описании устройства позволяет опустить имя MIB (префикс; '''SNMPv2-MIB'''::sysName.0). В этом случае, префикс из '''oid_prefix''' будет автоматически
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:
присоединён ко всем OID каналов устройства, где явно не указан префикс. Например, при '''oid_prefix''' = SNMPv2-MIB:


* sysName.0 -> '''SNMPv2-MIB::'''sysName.0
* sysName.0 -> '''SNMPv2-MIB::'''sysName.0
Строка 143: Строка 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 ====
==== MIB installation ====


Если у Вас есть требуемый MIB-файл, то достаточно скопировать его в директорию /root/.snmp/mibs, предварительно создав её:
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
Строка 151: Строка 150:
</syntaxhighlight>
</syntaxhighlight>


После этого проверьте правильность работы snmptranslate с каким-либо известным OID:
After that, verify that snmptranslate works correctly with any known OID:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Строка 157: Строка 156:
</syntaxhighlight>
</syntaxhighlight>


== Шаблоны ==
== Templates ==


Для описания устройств удобно (хотя и не обязательно) использовать ''шаблоны''. ''Шаблон (тип устройства)'' - это внешний конфигурационный файл (располагается в /usr/share/wb-mqtt-snmp/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.
и имеет имя config-[device-type-name].json, например, config-test-snmp.json), в котором содержится базовое описание устройства (например, имя сообщества SNMP) и базовое описание всех его каналов.


Для использования шаблона в описании устройства в конфигурационном файле укажите поле "''device_type''". Среди всех представленных шаблонов будет выбран шаблон с таким же значением ''device_type'', при этом
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.
все поля, которые не были определены в конфигурационном файле, примут значения из шаблона.


Точно так же это работает с каналами. Сравнение каналов происходит по обязательному полю ''name''; если имя канала из конфигурационного файла совпадёт с именем канала в шаблоне, из шаблона будут взяты
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:
Config-my-device.json template:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
Строка 190: Строка 186:
</syntaxhighlight>
</syntaxhighlight>


Конфигурационный файл:
Configuration file:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
Строка 216: Строка 212:
</syntaxhighlight>
</syntaxhighlight>


В данном случае мы описали один шаблон my-device, по которому определили два разных устройства ''Device 1'' и ''Device 2'' с одинаковым набором каналов.
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.


Поскольку ''Device 1'' находится в локальной сети, логично выставить ему небольшое значение таймаута, чтобы быстрее определить неисправность устройства. Все остальные настройки берутся из шаблона.
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.


''Device 2'' - удалённый сервер, потому для него стоит увеличить таймаут, чтобы не считать устройство неисправным при задержке пакета. Более того, для канала ''Channel 2'' здесь мы переопределяем
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.


В поставке wb-mqtt-snmp прилагается набор шаблонов для типовых устройств (список будет расширяться):
= 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
|-
|-
| Тестовый сервер Net-SNMP || test-snmp || style="background: #22EE44;" | Да || адрес тестового сервера test.net-snmp.org
| 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 || Нет ||  
* Требуется локально установленный PowerNet-MIB
* Requires locally installed PowerNet-MIB
* Описание устройства такое же, как в wb-mqtt-apcsnmp
*   The device description is the same as in wb-mqtt-apcsnmp
|-
|-
|}
|}
wb_editors
14 355

правок