Closed zbx-sadman closed 1 year ago
I would say that right now the method that you are using is valid. I haven't created a more elegant solution and the filter will provide the functionallity you need.
Although i do agree that there might be a more elegant solution like a seperate options.py file which could be provided to manipulate the filtering instead of modifying the main script.
I've seen this use case and request before so i made a simple config.py file which you can modify. This is a lot cleaner instead of modifying the source code :) Feel free to pull the latest "main" and try it out! :)
Thanks for impetuous improvement. I try to finish testing on this week.
I have one more question, because do not programming on python: i can use more that one item for filter dictionary (i guess right name of this hash array?) like that:
nb_device_filter = {"tag": "zabbix", "site": "HQ-AMS"}
Yes, you can use multiple keys. This will become a logical AND :) Your example (Device must have the tag zabbix and be part of site HQ-AMS) is valid.
-------- Oorspronkelijk bericht -------- Op 29 nov. 2022 18:35, schreef Grigory Prigodin :
Thanks for impetuous improvement. I try to finish testing on this week.
I have one more question, because do not program on python: i can use more that one item for filter dictionary (i guess right name of this hash array?) like that:
nb_device_filter = {"tag": "zabbix", "site": "HQ-AMS"}
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.Message ID: @.***>
Seems all OK
NetBox:
Utility log:
cat sync.log
2022-11-30 09:40:17,520 - Netbox-Zabbix-sync - DEBUG - Found group XXXXXXXXXX for host AnyplaceUSB.
2022-11-30 09:40:17,522 - Netbox-Zabbix-sync - DEBUG - Found template ID 10186 for host AnyplaceUSB.
2022-11-30 09:40:18,340 - Netbox-Zabbix-sync - INFO - Created host AnyplaceUSB in Zabbix.
Zabbix v6
And i was make one more change in the config/source to ignore SSL cert if it not valid (i'm so lazy to generate valid cert on test NetBox instance). You can add it to src, if you think it's necessary.
config.py
nb_enable_ssl_verify = False
netbox_zabbix_sync.py
# Set Netbox API
netbox = api(netbox_host, token=netbox_token, threading=True)
netbox.http_session.verify = nb_enable_ssl_verify
Thanks again.
Good day,
I will create the variable in the config.py file later this evening.
As for your other question with Zabbix interfaces which i got on the mail, isn't this something that will help you or is your use case something else (like 2 interfaces on 1 host object?): https://github.com/TheNetworkGuy/netbox-zabbix-sync#set-interface-parameters-within-netbox
Yes, you right - custom context is more flexible.
May be I had overengineering.
I looked at NetBox hosts and thinked: what if device has a Service (Z.Agent or IPMI), which binds not to primary IP (or non-standart port). We must create custom context for every device and sync context with Service record data for correct IP address transfer. But, if Service record already contain IP/Port/Proto fieds - can use they for autocreating Zabbix Interface items, and do not worry about copypaste errors.
What you think about it?
There is a use case where there are 2 interfaces on one Zabbix host. However this is currently not in scope of this project since it would take a tremendous amount of time for a very niche problem.
If you encounter a situation where you must configure 2 interfaces on one host, let the script sync a host to a Zabbix server and manually modify it with an extra IP address. The script will continue to function properly. For example, set the interface type in Netbox to Agent and manually create an interface as IPMI. After that you can change the item types which need to point to the IPMI to that interface.
Okay, thanks for answer. I'll try to make it for myself.
Hello Twan.
Thanks for your work.
I have in the Netbox many devices, but not all of they must be transferred to Zabbix. Currently i try to use dirty hack for filter:
And running script with
export NETBOX_TAG="zabbix"
This is ok or another method exist?