Skip to content

Commit

Permalink
doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjonbrazil committed Jun 8, 2024
1 parent 7d81663 commit a92e318
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 8 additions & 1 deletion docs/parsers/ss.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
]
Expand Down Expand Up @@ -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 ([email protected])
Version 1.8 by Kelly Brazil ([email protected])
20 changes: 17 additions & 3 deletions jc/parsers/ss.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
"file_descriptor": string
}
}
"inode_number": string,
"cookie": string,
"cgroup": string,
"v6only": string,
"timer_name": string,
"expire_time": string,
"retrans": string
}
}
]
Expand Down Expand Up @@ -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(')', ']')
Expand All @@ -361,6 +371,7 @@ def _parse_opts(proc_data):
'retrans': val[2]
}
opts[key] = val

# -p option
if key == "users":
key = 'process_id'
Expand All @@ -380,7 +391,9 @@ def _parse_opts(proc_data):
}
})
val = data

opts[key] = val

return opts

def parse(data, raw=False, quiet=False):
Expand Down Expand Up @@ -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]:
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion man/jc.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit a92e318

Please sign in to comment.