mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
doc update
This commit is contained in:
@ -2,6 +2,7 @@ jc changelog
|
|||||||
|
|
||||||
20221118 v1.22.3
|
20221118 v1.22.3
|
||||||
- Add Common Log Format and Combined Log Format file parser (standard and streaming)
|
- Add Common Log Format and Combined Log Format file parser (standard and streaming)
|
||||||
|
- Add PostgreSQL password file parser
|
||||||
- Enhance `ifconfig` parser with interface lane information on BSD
|
- Enhance `ifconfig` parser with interface lane information on BSD
|
||||||
- Enhance `ifconfig` parser with additional IPv6 `scope_id` info for BSD
|
- Enhance `ifconfig` parser with additional IPv6 `scope_id` info for BSD
|
||||||
- Fix `ifconfig` parser to capture some IPv6 addresses missed on BSD
|
- Fix `ifconfig` parser to capture some IPv6 addresses missed on BSD
|
||||||
|
@ -228,6 +228,7 @@ option.
|
|||||||
| ` --os-prober` | `os-prober` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_prober) |
|
| ` --os-prober` | `os-prober` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_prober) |
|
||||||
| ` --passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
|
| ` --passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
|
||||||
| ` --pci-ids` | `pci.ids` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pci_ids) |
|
| ` --pci-ids` | `pci.ids` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pci_ids) |
|
||||||
|
| ` --pgpass` | PostgreSQL password file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pgpass) |
|
||||||
| ` --pidstat` | `pidstat -H` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
|
| ` --pidstat` | `pidstat -H` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
|
||||||
| ` --pidstat-s` | `pidstat -H` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat_s) |
|
| ` --pidstat-s` | `pidstat -H` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat_s) |
|
||||||
| ` --ping` | `ping` and `ping6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ping) |
|
| ` --ping` | `ping` and `ping6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ping) |
|
||||||
|
@ -4,7 +4,7 @@ _jc()
|
|||||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||||
|
|
||||||
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
||||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --os-prober --passwd --pci-ids --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --os-prober --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||||
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
||||||
jc_about_options=(--about -a)
|
jc_about_options=(--about -a)
|
||||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||||
|
@ -100,7 +100,7 @@ _jc() {
|
|||||||
'xrandr:run "xrandr" command with magic syntax.'
|
'xrandr:run "xrandr" command with magic syntax.'
|
||||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||||
)
|
)
|
||||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --os-prober --passwd --pci-ids --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --os-prober --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||||
jc_parsers_describe=(
|
jc_parsers_describe=(
|
||||||
'--acpi:`acpi` command parser'
|
'--acpi:`acpi` command parser'
|
||||||
'--airport:`airport -I` command parser'
|
'--airport:`airport -I` command parser'
|
||||||
@ -176,6 +176,7 @@ _jc() {
|
|||||||
'--os-prober:`os-prober` command parser'
|
'--os-prober:`os-prober` command parser'
|
||||||
'--passwd:`/etc/passwd` file parser'
|
'--passwd:`/etc/passwd` file parser'
|
||||||
'--pci-ids:`pci.ids` file parser'
|
'--pci-ids:`pci.ids` file parser'
|
||||||
|
'--pgpass:PostgreSQL password file parser'
|
||||||
'--pidstat:`pidstat -H` command parser'
|
'--pidstat:`pidstat -H` command parser'
|
||||||
'--pidstat-s:`pidstat -H` command streaming parser'
|
'--pidstat-s:`pidstat -H` command streaming parser'
|
||||||
'--ping:`ping` and `ping6` command parser'
|
'--ping:`ping` and `ping6` command parser'
|
||||||
|
75
docs/parsers/pgpass.md
Normal file
75
docs/parsers/pgpass.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.pgpass"></a>
|
||||||
|
|
||||||
|
# jc.parsers.pgpass
|
||||||
|
|
||||||
|
jc - JSON Convert PostgreSQL password file parser
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ cat /var/lib/postgresql/.pgpass | jc --pgpass
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('pgpass', postgres_password_file)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"hostname": string,
|
||||||
|
"port": string,
|
||||||
|
"database": string,
|
||||||
|
"username": string,
|
||||||
|
"password": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ cat /var/lib/postgresql/.pgpass | jc --pgpass -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"hostname": "dbserver",
|
||||||
|
"port": "*",
|
||||||
|
"database": "db1",
|
||||||
|
"username": "dbuser",
|
||||||
|
"password": "pwd123"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname": "dbserver2",
|
||||||
|
"port": "8888",
|
||||||
|
"database": "inventory",
|
||||||
|
"username": "joe:user",
|
||||||
|
"password": "abc123"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.pgpass.parse"></a>
|
||||||
|
|
||||||
|
### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False) -> List[JSONDictType]
|
||||||
|
```
|
||||||
|
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
|
### Parser Information
|
||||||
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
|
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
@ -1,7 +1,5 @@
|
|||||||
"""jc - JSON Convert PostgreSQL password file parser
|
"""jc - JSON Convert PostgreSQL password file parser
|
||||||
|
|
||||||
<<Short pgpass description and caveats>>
|
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat /var/lib/postgresql/.pgpass | jc --pgpass
|
$ cat /var/lib/postgresql/.pgpass | jc --pgpass
|
||||||
@ -15,16 +13,34 @@ Schema:
|
|||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"pgpass": string,
|
"hostname": string,
|
||||||
"bar": boolean,
|
"port": string,
|
||||||
"baz": integer
|
"database": string,
|
||||||
|
"username": string,
|
||||||
|
"password": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ cat /var/lib/postgresql/.pgpass | jc --pgpass -p
|
$ cat /var/lib/postgresql/.pgpass | jc --pgpass -p
|
||||||
[]
|
[
|
||||||
|
{
|
||||||
|
"hostname": "dbserver",
|
||||||
|
"port": "*",
|
||||||
|
"database": "db1",
|
||||||
|
"username": "dbuser",
|
||||||
|
"password": "pwd123"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname": "dbserver2",
|
||||||
|
"port": "8888",
|
||||||
|
"database": "inventory",
|
||||||
|
"username": "joe:user",
|
||||||
|
"password": "abc123"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
"""
|
"""
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
from jc.jc_types import JSONDictType
|
from jc.jc_types import JSONDictType
|
||||||
@ -94,7 +110,6 @@ def parse(
|
|||||||
line = line.replace('\\\\', '\\')
|
line = line.replace('\\\\', '\\')
|
||||||
line = line.replace('\\\u2063', ':')
|
line = line.replace('\\\u2063', ':')
|
||||||
|
|
||||||
# split on \u2063
|
|
||||||
hostname, port, database, username, password = line.split('\u2063')
|
hostname, port, database, username, password = line.split('\u2063')
|
||||||
|
|
||||||
raw_output.append(
|
raw_output.append(
|
||||||
|
5
man/jc.1
5
man/jc.1
@ -405,6 +405,11 @@ M3U and M3U8 file parser
|
|||||||
\fB--pci-ids\fP
|
\fB--pci-ids\fP
|
||||||
`pci.ids` file parser
|
`pci.ids` file parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--pgpass\fP
|
||||||
|
PostgreSQL password file parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--pidstat\fP
|
\fB--pidstat\fP
|
||||||
|
3
tests/fixtures/generic/pgpass.txt
vendored
3
tests/fixtures/generic/pgpass.txt
vendored
@ -6,4 +6,5 @@ dbserver3:8888:inventory:joeuser:abc123
|
|||||||
# comment
|
# comment
|
||||||
|
|
||||||
localhost:5555:table\\1:user\:w\:colon:password123
|
localhost:5555:table\\1:user\:w\:colon:password123
|
||||||
hostname:port:database:username:password
|
# anther comment
|
||||||
|
hostname:*:database:username:password
|
||||||
|
Reference in New Issue
Block a user