diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:44:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:44:55 +0000 |
commit | 5068d34c08f951a7ea6257d305a1627b09a95817 (patch) | |
tree | 08213e2be853396a3b07ce15dbe222644dcd9a89 /src/scripts/dhclient-summary.lnav | |
parent | Initial commit. (diff) | |
download | lnav-5068d34c08f951a7ea6257d305a1627b09a95817.tar.xz lnav-5068d34c08f951a7ea6257d305a1627b09a95817.zip |
Adding upstream version 0.11.1.upstream/0.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/scripts/dhclient-summary.lnav | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/scripts/dhclient-summary.lnav b/src/scripts/dhclient-summary.lnav new file mode 100644 index 0000000..87d0c1a --- /dev/null +++ b/src/scripts/dhclient-summary.lnav @@ -0,0 +1,23 @@ +# +# @synopsis: dhclient-summary +# @description: Generate a summary of DHCP addresses bound in this log +# + +:echo DHCP leases over time: +:echo +;SELECT ip AS IP, start_time AS "Start Time", + printf("% 24s", CASE + WHEN end_time IS NULL THEN printf("%s%s%s", $ansi_green, 'Active', $ansi_norm) + ELSE + printf("%s%.02f%s hours", $ansi_bold, (julianday(end_time) - julianday(start_time)) * 24, $ansi_norm) + END) AS Duration + FROM + (WITH lease_times AS + (SELECT min(log_time) AS start_time, ip FROM + (SELECT log_time, regexp_match('bound to (\S+) --', log_text) AS ip FROM syslog_log WHERE ip IS NOT NULL) + GROUP BY ip ORDER BY start_time ASC) + SELECT start_time, + (SELECT lt2.start_time AS end_time FROM lease_times AS lt2 WHERE lt1.start_time < lt2.start_time LIMIT 1) AS end_time, + ip + FROM lease_times AS lt1) +:write-table-to - |