TheNetworkGuy / netbox-zabbix-sync

Python script to synchronise Netbox devices to Zabbix.
MIT License
123 stars 29 forks source link

Using custom device fields with other types (e.g. Boolean) #28

Closed mwllgr closed 1 year ago

mwllgr commented 1 year ago

Hello,

this project currently does not allow the usage of custom field types other than text:

device_cfs = netbox.extras.custom_fields.filter(type="text", content_type_id=23)

Why exactly are you filtering for only text-type fields? Are there any disadvantages in removing the type filter?

device_cfs = netbox.extras.custom_fields.filter(content_type_id=23)
TheNetworkGuy commented 1 year ago

This filter is used to gather custom field names and content. This data is used to generate Zabbix hostgroup names if the user chooses to do so.

Since the data ends up in the Hostgroup name (which usually is some form of human readable text) it seems logical to filter the initial data and limit the user to only using text / string type fields.

Do you have an use case to gather data types other than text / string for the Zabbix hostgroup names?

mwllgr commented 1 year ago

Thanks for your quick reply - we have some Boolean custom fields which we'd have to include too. Let's call the field "monitor" and we'd only want to include all the items that have the monitor field set to true.

TheNetworkGuy commented 1 year ago

I think that we are talking about 2 different things. The custom field construction that you mention is only used for the hostgroup name generation.

Corrent me if i'm wrong but you want to filter your devices with a custom field 0 / 1 value. You can easily do this as follows in the config file:

nb_device_filter = {"cf_monitor": True}

Is this correct?

mwllgr commented 1 year ago

It was a configuration issue on our side. Everything works as expected - but thanks for the heads-up!