Fixed problem with SNMP version change and added log message when changing interface type.

This commit is contained in:
Twan Kamans
2021-04-19 21:26:41 +02:00
parent fb2c64cbb8
commit 1b84f2c2eb
3 changed files with 101 additions and 473 deletions

View File

@@ -21,7 +21,7 @@ A script to sync the Netbox device inventory to Zabbix.
#### Logging
Logs are generated under sync.log, set the script for debugging / info options etc.
Logs are generated under sync.log, use -v for debugging.
#### Hostgroups: manual mode
@@ -52,6 +52,63 @@ And this field for the Zabbix template
* Default: null
* Object: dcim > device_type
#### Set interface parameters within Netbox
When adding a new device, you can set the interface type with custom context.
Due to Zabbix limitations of changing interface type with a linked template, changing the interface type from within Netbox is not supported and the script will generate an error.
For example when changing a SNMP interface to an Agent interface:
```
Netbox-Zabbix-sync - WARNING - Device: Interface OUT of sync.
Netbox-Zabbix-sync - ERROR - Device: changing interface type to 1 is not supported.
```
To configure the interface parameters you'll need to use custom context. Custom context was used to make this script as customizable as posible for each environment. For example, you could:
* Set the custom context directly on a device
* Set the custom context on a label, which you would add to a device (for instance, SNMPv3)
* Set the custom context on a device role
* Set the custom context on a site or region
##### Agent interface configuration example
```json
{
"zabbix": {
"interface_port": 1500,
"interface_type": 1
}
}
```
##### SNMPv2 interface configuration example
```json
{
"zabbix": {
"interface_port": 161,
"interface_type": 2,
"snmp": {
"bulk": 1,
"community": "SecretCommunity",
"version": 2
}
}
}
```
##### SNMPv3 interface configuration example
```json
{
"zabbix": {
"interface_port": 1610,
"interface_type": 2,
"snmp": {
"authpassphrase": "SecretAuth",
"bulk": 1,
"securitylevel": 1,
"securityname": "MySecurityName",
"version": 3
}
}
}
```
Note: Not all SNMP data is required for a working configuration. [The following parameters are allowed ](https://www.zabbix.com/documentation/current/manual/api/reference/hostinterface/object#details_tag "The following parameters are allowed ")but are not all required, depending on your environment.
#### Permissions
Make sure that the user has proper permissions for device read and modify (modify to set the Zabbix HostID custom field) operations.