Alright, trying to get this working for a while now I figured it might be time to ask for some help. Zabbix 7.4.1, Zabbix Agent 7.4.1, CentOS 8, no proxies.
I have a folder structure which contains backups. It's fed by a number of scripts and I'd like to avoid changing the input here if possible. It's rather dynamic, new services can be added, removed, it felt like nested LLD might do the trick. This is what the directory structure looks like,
Code:
/backups/<SERVICENAME>/<DATE>/<SERVICENAME>.<DATE>.tar.gz
The idea was to use a discovery rule that maps services which exist in the directory structure out using
Code:
vfs.dir.get[/backups/,,,dir,,0,,,,,]
Based on this, I wanted to list backup files within the service directory with the help of a macro defined in the previous discovery rule which looks like this,
Code:
vfs.dir.get[{#SERVICEPATH},,,file,,2,,,,7d,]
And based on that, I wanted to get details on each file using a macro defined above,
Code:
vfs.file.get[{#SERVICEBACKUPPATH}]
I can create the first discovery rule no problem,
Name: Discover Services With Backups
Type: Zabbix agent
Key: vfs.dir.get[/backups/,,,dir,,0,,,,,]
LLD macros (2):
{#SERVICE}=$.basename
{#SERVICEPATH=$.pathname}
Type: Zabbix agent
Key: vfs.dir.get[/backups/,,,dir,,0,,,,,]
LLD macros (2):
{#SERVICE}=$.basename
{#SERVICEPATH=$.pathname}
Name: Discover {#SERVICE}'s Backups
Type: Nested
Key: vfs.dir.get[{#SERVICEPATH},,,file,,2,,,,7d,]
LLD macros (2):
{#BACKUPNAME}=$.basename
{#BACKUPPATH}=$.pathname
Type: Nested
Key: vfs.dir.get[{#SERVICEPATH},,,file,,2,,,,7d,]
LLD macros (2):
{#BACKUPNAME}=$.basename
{#BACKUPPATH}=$.pathname
Code:
hostname.local - Service Backups Template: Discover FTP (ed note ie from {#SERVICE}) Backups - Item prototypes - trigger prototypes - host prototypes - discovery prototypes - key: vfs.dir.get[/backups/FTP,,,file,,2,,,,7d,] - NESTED - Status Not Supported
I've tried adding the {#BACKUPNAME} macro to the title of the discovery prototype rule named "Discover {#SERVICE}, since the #SERVICE macro is being resolved, but it doesn't look like the 1st nested item is actually inheriting any json at all even though the item key is being generated properly. So the first LLD is not passing on any json to its first nested discovery prototype? If I create the item key as a standalone item and manually define it to iterate the files for a particular service then I can get a list of backup files to be generated. It's using essentially the same key that's being generated for the nested discovery prototype.
I even tried shoving the entirity of the JSON that could be passed on from the first LLD using a wildcard into a macro for the nested discovery prototype but it doesn't look like anything at all is being defined to that macro.
I feel like I'm missing something very obvious and I've tried all sorts of combinations, using a normal item and then creating a discovery rule dependent on that item, and a bunch of similar permuatations like using Item prototypes dependent on other items, etc. In the above example I did create an Item Prototype for the initial discovery rule and it works, it produces the json right output listing the backup files within the discovered service directory but I don't know how to use that in the subsequent nested rules since I can't define macros in an item prototype, and I can't use them as master items for subsequent dependent rules further in the nested chain and that doesn't feel like the right way to go about it either.
Anyway, I've tried a bunch of ways and didn't document everything and I've also I've deleted and restarted a bunch of times. There really aren't many guides on Nested LLD, or I would have done more digging. The documentation did not seem to help for my particular case, I did try applying what I saw there even though the above example might not reflect it, but I was not successful. That's probably a me problem. Anyway, if anyone could help me work through this, I would be appreciative. I was hoping to manage doing this without resorting to custom UserParameters and local scripts but if I have to go that route, I suppose I could. I realize I could also manually define items that look specifically at predefined services but I was hoping to automate the whole thing.
I'll be back at this tomorrow and I'll be more than happy to documents additional trials and thanks for making it this far!