MassimilianoPasquini97 / zbx_unifi_network

Zabbix Template for Unifi Network
MIT License
48 stars 10 forks source link

[BUG] Clients showing as {#NAME} #16

Closed longhornwhistler closed 6 months ago

longhornwhistler commented 6 months ago

Checklist

Describe the Bug

Clients are showing as {#NAME} instead of the actual client name.

Screenshot 2024-03-12 at 10 47 36 AM

MACROS

Screenshot 2024-03-12 at 10 49 13 AM Screenshot 2024-03-12 at 10 49 02 AM Screenshot 2024-03-12 at 10 49 32 AM Screenshot 2024-03-12 at 10 49 22 AM

Context

cawhite6 commented 6 months ago

Issue lies with the JSON returned with current Network App 8.0+ - if you have NOT manually set a connected client name in the UI Network App, then that field is never returned. Update the LLD MARCO #NAME in the template for Wired and Wireless clients discovery to 'hostname' field. Now issue is if you do manually set a name in clients then hostname is returned as "" (blank/empty) and name field is generated. I'm trying to work on a way to basically do an IF/THEN with LLD to fix this but don't know if it's possible. IF hostname ="" then parse 'name' field for LLD MACRO #NAME.

Hope this helps the 99% it did for me...... excellent work on this template btw!

MassimilianoPasquini97 commented 6 months ago

Hi @cawhite6, thanks for your report, any help is appreciated. One way to solve this issue could be adding a simple custom JavaScript at preprocessing stage on the discovery rule. The script need to check if name is defined and in case it isn't it define name with hostname value.

ketomagasaki commented 6 months ago

Hello,

I've just set up the template, and I'm facing the same issue, with the following specifications:

But I also have another issue that might be related. I'm missing 2 switches in the discovery, and I found these errors:

image

MassimilianoPasquini97 commented 6 months ago

I have fixed the issue with empty {#NAME} LDD macron on c8f653f8e65a536b93f59331645733bdc4e6e406. I have solved that with a Custom JavaScript that define 'name' value with 'hostname' if undefined.

MassimilianoPasquini97 commented 6 months ago

@ketomagasaki Is your USW device containing '{' character?

ketomagasaki commented 6 months ago

Thank you for the correction c8f653f, I no longer have the client value with {#NAME} 😊

No, the names of the 2 missing USWs are:

I posted here because the error message is Cannot create host "Unifi USW {#NAME}": name contains invalid character '{. So, since there's also an issue with {#NAME}, I thought it might be the same problem.

ketomagasaki commented 6 months ago

I analyzed the API call and indeed for these 2 USWs, there is no name returned.

image

I simply changed their names and then put back the original ones, now their names appear in the JSON. A bug in the API apparently 🤔

It's good for me, thank you for your help 👍

MassimilianoPasquini97 commented 6 months ago

Released version c8f653f containing the fix.