Hi all,
I’d like to extract the version numbers from a daemon’s log file, for use in tracking versions and upgrades. In unix I’d do this with awk and regex matching. Some simple relevance pulls just the applicable lines:
Q: ((lines containing "nessusd" of file "/Library/NessusAgent/run/var/nessus/logs/nessusd.messages") whose (it contains "build"))
A: [Wed May 26 13:10:49 2021][2466.1] nessusd 6.11.1 (build M20101) started
A: [Wed May 26 21:33:09 2021][258.1] nessusd 6.11.1 (build M20101) started
A: [Wed Jun 2 14:59:29 2021][298.1] nessusd 6.11.1 (build M20101) started
A: [Tue Jun 8 11:21:22 2021][274.1] nessusd 6.11.1 (build M20101) started
A: [Thu Jun 10 19:01:47 2021][272.1] nessusd 6.11.1 (build M20101) started
A: [Wed Jun 16 21:08:08 2021][278.1] nessusd 6.11.1 (build M20101) started
A: [Fri Jul 2 19:57:55 2021][287.1] nessusd 6.11.1 (build M20101) started
A: [Wed Jul 21 12:03:02 2021][269.1] nessusd 6.11.1 (build M20101) started
A: [Wed Jul 21 12:33:47 2021][317.1] nessusd 6.11.1 (build M20101) started
A: [Mon Jul 26 11:59:34 2021][301.1] nessusd 6.11.1 (build M20101) started
A: [Mon Jul 26 12:07:18 2021][351.1] nessusd 6.11.1 (build M20101) started
A: [Fri Jul 30 03:54:22 2021][276.1] nessusd 6.11.1 (build M20101) started
A: [Mon Aug 9 11:47:09 2021][272.1] nessusd 6.11.1 (build M20101) started
A: [Fri Aug 20 14:37:49 2021][293.1] nessusd 6.11.1 (build M20101) started
A: [Tue Sep 7 13:52:10 2021][295.1] nessusd 6.11.1 (build M20101) started
A: [Mon Sep 13 12:21:49 2021][308.1] nessusd 6.11.1 (build M20101) started
A: [Fri Sep 17 14:30:06 2021][288.1] nessusd 6.11.1 (build M20101) started
A: [Tue Sep 21 13:16:04 2021][277.1] nessusd 6.11.1 (build M20101) started
A: [Mon Sep 27 14:51:14 2021][277.1] nessusd 6.11.1 (build M20101) started
A: [Thu Sep 30 10:52:46 2021][257.1] nessusd 6.11.1 (build M20101) started
A: [Sat Oct 2 11:28:59 2021][274.1] nessusd 6.11.1 (build M20101) started
T: 1187
I’m unsure about how in relevance to extract just the version strings?
Seeking to get further, I resorted to relevance for matches regex
:
Q: (matches (regex("[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}")) of ((lines containing "nessusd" of file "/Library/NessusAgent/run/var/nessus/logs/nessusd.messages") whose (it contains "build")))
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
A: 6.11.1
T: 1704
From there it’s pretty simple to convert to versions and get the maximum:
Q: maximum of ((matches (regex("[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,2}")) of ((lines containing "nessusd" of file "/Library/NessusAgent/run/var/nessus/logs/nessusd.messages") whose (it contains "build"))) as version)
A: 6.11.1
T: 1512
How might you have solved this?
Thanks,
Andrew