I'm trying to parse through dpkg versions with the "system.sw.packages.get" key.
Dpkg prepends and appends various data that I want to trim off so it can be consistent accross different package managers.
For example I would like to get rid of the ":1" and the "+deb11u1" values in this example: "1:8.4p1-5+deb11u1
But the problem is, these values are not always present in the return version value.
And there is no way for Zabbix to fail safely and still return some value (the Custom On Fail: discard value doesn't work as it doesn't give a value back, it just fails outright).
So I am trying to use regex to work on a lot of different strings and trim off the uneeded material.
Here are my preprocessing steps so far:
Despite adding the "?" after match group, it fails when the value is present. But if I remove it, it fails when the value is not present.
Here is some examples for the various input data:
Can someone help me with this regex? I am not sure how to work with all these different input values and have the preprocessing steps not fail.
Dpkg prepends and appends various data that I want to trim off so it can be consistent accross different package managers.
For example I would like to get rid of the ":1" and the "+deb11u1" values in this example: "1:8.4p1-5+deb11u1
But the problem is, these values are not always present in the return version value.
And there is no way for Zabbix to fail safely and still return some value (the Custom On Fail: discard value doesn't work as it doesn't give a value back, it just fails outright).
So I am trying to use regex to work on a lot of different strings and trim off the uneeded material.
Here are my preprocessing steps so far:
Code:
JSONPath $.*.version Regex (?<=").*(?=") \0 Regex .*(?=\+)? \0 Regex (?<=:)?.* \0
Here is some examples for the various input data:
Code:
[{"name":"archivebox","manager":"dpkg","version":"0.6.2-1","size":1763328,"arch":"all","buildtime":{"times tamp":0,"value":""},"installtime":{"timestamp":0," value":""}}]
[{"name":"chrony","manager":"dpkg","version":"4.0-8+deb11u2","size":644096,"arch":"amd64","buildtime ":{"timestamp":0,"value":""},"installtime":{"times tamp":0,"value":""}}]
[{"name":"openssh-server","manager":"dpkg","version":"1:8.4p1-5+deb11u1","size":1604608,"arch":"amd64","buildtim e":{"timestamp":0,"value":""},"installtime":{"time stamp":0,"value":""}}]
[{"name":"qemu-guest-agent","manager":"dpkg","version":"1:5.2+dfsg-11+deb11u2","size":765952,"arch":"amd64","buildtim e":{"timestamp":0,"value":""},"installtime":{"time stamp":0,"value":""}}]
Comment