I'm trying to patch a check for my LSI RAID controllers, that uses a hardcoded JSON path, as described in this bug report: https://github.com/mykolq/zabbix_lsi_template/issues/4
So after looking into how the template works, I figured out that it creates an item with the entire json blob, and then has dependent items that make queries off of that blob.
The json blob is also scoped down to just the "Response Data" tree.
So after playing around with trying to work out a JSONPath string to get the correct value I need, rather than using the hardcoded first value it finds, I ran into a weird problem, in that the value returned is bracketed, and double quoted.
Here is the raw data for the value I'm trying to extract.
{ "Property" : "Replacement required", "Value" : "No" },
Originally the pre-processing step was doing this: $['Firmware_Status'][0]['Value']
And then I changed it to do this: $.Firmware_Status[?(@.Property == "Replacement required")].Value
No is the value I'm looking to pull out, but ["No"] is the value returned to that configured item.
This was enough to satiate the trigger giving me a false positive, but I'd like to figure out how to do this correctly, as well as be able to make a pull request to update the check for the original author.
So hopefully someone can point me in the correct direction to help me figure out why the formatting got hosed when I changed the JSONPath preprocessing.
This was my first time messing with the JSONPath stuff, so feel free to tell me if there is a better way to
Cheers
So after looking into how the template works, I figured out that it creates an item with the entire json blob, and then has dependent items that make queries off of that blob.
The json blob is also scoped down to just the "Response Data" tree.
So after playing around with trying to work out a JSONPath string to get the correct value I need, rather than using the hardcoded first value it finds, I ran into a weird problem, in that the value returned is bracketed, and double quoted.
Here is the raw data for the value I'm trying to extract.
{ "Property" : "Replacement required", "Value" : "No" },
Originally the pre-processing step was doing this: $['Firmware_Status'][0]['Value']
And then I changed it to do this: $.Firmware_Status[?(@.Property == "Replacement required")].Value
No is the value I'm looking to pull out, but ["No"] is the value returned to that configured item.
This was enough to satiate the trigger giving me a false positive, but I'd like to figure out how to do this correctly, as well as be able to make a pull request to update the check for the original author.
So hopefully someone can point me in the correct direction to help me figure out why the formatting got hosed when I changed the JSONPath preprocessing.
This was my first time messing with the JSONPath stuff, so feel free to tell me if there is a better way to
Cheers