Monday, June 23, 2025

Zabbix 7 - Formula to count number of CDP Neighbors

 Formula to count number of CDP Neighbors.

 count(last_foreach(//net.if.cdp.neighbor.name[*],5m))

 

Saturday, June 21, 2025

Zabbix 7 - Searching on Zabbix

You can search using multiple keys in Zabbix API.

 
KEY1 = 'net.if.cdp.neighbor'
KEY2 = 'net.if.discovery' 
key_items_info = zapi.item.get(
groupids=group_id,
output=["hostid", "name", "lastvalue"],
search={"key_": [KEY1, KEY2]},
searchByAny=True,
selectHosts=['name']
)
 

By default, elements specified in "search" are "AND-ed". In order to "OR" them add searchByAny.

This will also search with wildcards.

"search": {"key_": "net.if.cdp.neighbor.*"},
"searchWildcardsEnabled": True