From a92e318319ec00d4b2ddfa0f29d0bd83394346e2 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 7 Jun 2024 17:42:30 -0700 Subject: [PATCH] doc update --- CHANGELOG | 3 ++- docs/parsers/ss.md | 9 ++++++++- jc/parsers/ss.py | 20 +++++++++++++++++--- man/jc.1 | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 207a9e206..54cceeea3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,10 +1,11 @@ jc changelog -20240510 v1.25.3 +20240607 v1.25.3 - Enhance `bluetoothctl` parser with added `battery_percentage` field - Enhance `git-log` standard and streaming parsers with added `lines_changed` field under `file_stats` - Fix `pci-ids` parser to correctly handle multiple subdevices - Fix `pip-show` parser to handle multi-line fields with a beginning blank line +- Fix `ss` parser to correctly handle the `Recv-Q` field being too close to the `Status` field - Fix `top` parsers to quiet uptime info parsing - Fix `traceroute` parser to correctly handle hops with multiple IPs - Fix `zpool-status` parser for config items lacking data values diff --git a/docs/parsers/ss.md b/docs/parsers/ss.md index 834fd6d3c..8dcc7e3b7 100644 --- a/docs/parsers/ss.md +++ b/docs/parsers/ss.md @@ -47,6 +47,13 @@ field names "file_descriptor": string } } + "inode_number": string, + "cookie": string, + "cgroup": string, + "v6only": string, + "timer_name": string, + "expire_time": string, + "retrans": string } } ] @@ -310,4 +317,4 @@ Compatibility: linux Source: [`jc/parsers/ss.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ss.py) -Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) +Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/jc/parsers/ss.py b/jc/parsers/ss.py index 7c11d870e..f105cc21f 100644 --- a/jc/parsers/ss.py +++ b/jc/parsers/ss.py @@ -42,6 +42,13 @@ "file_descriptor": string } } + "inode_number": string, + "cookie": string, + "cgroup": string, + "v6only": string, + "timer_name": string, + "expire_time": string, + "retrans": string } } ] @@ -344,13 +351,16 @@ def _parse_opts(proc_data): """ o_field = proc_data.split(' ') opts = {} + for item in o_field: # -e option: item = re.sub( 'uid', 'uid_number', re.sub('sk', 'cookie', re.sub('ino', 'inode_number', item))) + if ":" in item: key, val = item.split(':') + # -o option if key == "timer": val = val.replace('(', '[').replace(')', ']') @@ -361,6 +371,7 @@ def _parse_opts(proc_data): 'retrans': val[2] } opts[key] = val + # -p option if key == "users": key = 'process_id' @@ -380,7 +391,9 @@ def _parse_opts(proc_data): } }) val = data + opts[key] = val + return opts def parse(data, raw=False, quiet=False): @@ -432,10 +445,10 @@ def parse(data, raw=False, quiet=False): # fix weird ss bug where first two columns have no space between them sometimes entry = entry[:5] + ' ' + entry[5:] - entry_list = re.split(r'[ ]{1,}',entry.strip()) + entry_list = re.split(r'[ ]{1,}', entry.strip()) if len(entry_list) > len(header_list) or extra_opts == True: - entry_list = re.split(r'[ ]{2,}',entry.strip()) + entry_list = re.split(r'[ ]{2,}', entry.strip()) extra_opts = True if entry_list[0] in contains_colon and ':' in entry_list[4]: @@ -453,7 +466,8 @@ def parse(data, raw=False, quiet=False): entry_list.insert(7, p_port) if re.search(r'ino:|uid:|sk:|users:|timer:|cgroup:|v6only:', entry_list[-1]): - header_list.append('opts') + if header_list[-1] != 'opts': + header_list.append('opts') entry_list[-1] = _parse_opts(entry_list[-1]) output_line = dict(zip(header_list, entry_list)) diff --git a/man/jc.1 b/man/jc.1 index 43fd2efa6..a179db0f3 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2024-05-14 1.25.3 "JSON Convert" +.TH jc 1 2024-06-07 1.25.3 "JSON Convert" .SH NAME \fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings