mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-03 17:44:07 +02:00
Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d298e101e9 | ||
|
|
cea975d7f1 | ||
|
|
1ed69f9e6a | ||
|
|
ab0e05ec82 | ||
|
|
c16cce4bf0 | ||
|
|
d3489536a1 | ||
|
|
041050ce28 | ||
|
|
7de1a8a5d6 | ||
|
|
d4604743d1 | ||
|
|
0b8fb31298 | ||
|
|
dcdd79e28c | ||
|
|
5291baeb8e | ||
|
|
6867102c66 | ||
|
|
36ed2c7e2e | ||
|
|
4ab0aba9d3 | ||
|
|
e643badaf7 | ||
|
|
d96e96219e | ||
|
|
e42af3353e | ||
|
|
4ec2b16f42 | ||
|
|
0a028456bf | ||
|
|
a1f10928e1 | ||
|
|
eae1d4b89a | ||
|
|
d3c7cec333 | ||
|
|
36fa08d711 | ||
|
|
a9958841e4 | ||
|
|
504ad81a01 | ||
|
|
8bf2f4f4d0 | ||
|
|
805397ea18 | ||
|
|
1b3985c2d7 | ||
|
|
f602043642 | ||
|
|
1a1aa8fda3 | ||
|
|
3249a017ae | ||
|
|
84f0246b2d | ||
|
|
1c795982b0 | ||
|
|
c5164b4108 | ||
|
|
dc3716ecb3 | ||
|
|
c5165ccc21 | ||
|
|
5b2035e0e6 | ||
|
|
5205154aaf | ||
|
|
f500de3af6 | ||
|
|
4b028b5080 | ||
|
|
4cd721be85 | ||
|
|
d58ca402a7 | ||
|
|
5386879040 | ||
|
|
f19a1f23a9 | ||
|
|
5023e5be4c |
38
CHANGELOG
38
CHANGELOG
@@ -1,5 +1,43 @@
|
||||
jc changelog
|
||||
|
||||
20231021 v1.23.5
|
||||
- Add `host` command parser
|
||||
- Add `nsd-control` command parser
|
||||
- Add `lsb_release` command parser
|
||||
- Add `/etc/os-release` file parser
|
||||
- Enhance `env` command parser to support multi-line values
|
||||
- Enhance `ping` and `ping-s` parsers to add error and corrupted support
|
||||
- Enhance `xml` parser to include comments in the JSON output
|
||||
- Fix `pidstat` command parser when using `-T ALL`
|
||||
- Fix `x509-cert` parser to allow negative serial numbers
|
||||
- Fix `x509-cert` parser for cases when bitstrings are larger than standard
|
||||
- Fix `xrandr` command parser for associated device issues
|
||||
- Fix error when pygments library is not installed
|
||||
|
||||
20230730 v1.23.4
|
||||
- Add `/etc/resolve.conf` file parser
|
||||
- Add `/proc/net/tcp` and `/proc/net/tcp6` file parser
|
||||
- Add `find` command parser
|
||||
- Add `ip route` command parser
|
||||
- Fix `certbot` command parser to be more robust with different line endings
|
||||
|
||||
20230621 v1.23.3
|
||||
- Add `lsattr` command parser
|
||||
- Add `srt` file parser
|
||||
- Add `veracrypt` command parser
|
||||
- Add X509 Certificate Request file parser
|
||||
- Enhance X509 Certificate parser to allow non-compliant email addresses with a warning
|
||||
- Enhance `dig` command parser to support the `+nsid` option
|
||||
- Enhance `last` and `lastb` command parser to support the `-x` option
|
||||
- Enhance `route` command parser to add Windows support
|
||||
- Enhnace `netstat` command parser to add Windows support
|
||||
- Enhance `ss` command parser to support extended options
|
||||
- Enhance the compatibility warning message
|
||||
- Fix `bluetoothctl` command parser for some mouse devices
|
||||
- Fix `ping` command parsers for output with missing hostname
|
||||
- Fix `stat` command parser for older versions that may not contain all fields
|
||||
- Fix deprecated option in `setup.cfg`
|
||||
|
||||
20230429 v1.23.2
|
||||
- Add `bluetoothctl` command parser
|
||||
- Add `certbot` command parser for `certificates` and `show_account` options
|
||||
|
||||
51
EXAMPLES.md
51
EXAMPLES.md
@@ -4551,6 +4551,57 @@ cat entrust.pem | jc --x509-cert -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### X.509 PEM and DER certificate request files
|
||||
```bash
|
||||
cat myserver.csr | jc --x509-csr -p
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"certification_request_info": {
|
||||
"version": "v1",
|
||||
"subject": {
|
||||
"common_name": "myserver.for.example"
|
||||
},
|
||||
"subject_pk_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp256r1"
|
||||
},
|
||||
"public_key": "04:40:33:c0:91:8f:e9:46:ea:d0:dc:d0:f9:63:2c:a4:35:1f:0f:54:c8:a9:9b:e3:9e:d4:f3:64:b8:60:cc:7f:39:75:dd:a7:61:31:02:7c:9e:89:c6:db:45:15:f2:5f:b0:65:29:0b:42:d2:6e:c2:ea:a6:23:bd:fc:65:e5:7d:4e"
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "extension_request",
|
||||
"values": [
|
||||
[
|
||||
{
|
||||
"extn_id": "extended_key_usage",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"server_auth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"myserver.for.example"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature": "30:45:02:20:77:ac:5b:51:bf:c5:f5:43:02:52:ae:66:8a:fe:95:98:98:98:a9:45:34:31:08:ff:2c:cc:92:d9:1c:70:28:74:02:21:00:97:79:7b:e7:45:18:76:cf:d7:3b:79:34:56:d2:69:b5:73:41:9b:8a:b7:ad:ec:80:23:c1:2f:64:da:e5:28:19"
|
||||
}
|
||||
]
|
||||
```
|
||||
### XML files
|
||||
```bash
|
||||
cat cd_catalog.xml
|
||||
|
||||
15
README.md
15
README.md
@@ -5,11 +5,13 @@
|
||||
|
||||
> Try the `jc` [web demo](https://jc-web.onrender.com/) and [REST API](https://github.com/kellyjonbrazil/jc-restapi)
|
||||
|
||||
> JC is [now available](https://galaxy.ansible.com/community/general) as an
|
||||
> `jc` is [now available](https://galaxy.ansible.com/community/general) as an
|
||||
Ansible filter plugin in the `community.general` collection. See this
|
||||
[blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
|
||||
for an example.
|
||||
|
||||
> Looking for something like `jc` but lower-level? Check out [regex2json](https://gitlab.com/tozd/regex2json).
|
||||
|
||||
# JC
|
||||
JSON Convert
|
||||
|
||||
@@ -185,6 +187,7 @@ option.
|
||||
| `--email-address` | Email Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/email_address) |
|
||||
| `--env` | `env` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
|
||||
| `--file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
|
||||
| `--find` | `find` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/find) |
|
||||
| `--findmnt` | `findmnt` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/findmnt) |
|
||||
| `--finger` | `finger` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
|
||||
| `--free` | `free` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/free) |
|
||||
@@ -199,6 +202,7 @@ option.
|
||||
| `--hashsum` | hashsum command parser (`md5sum`, `shasum`, etc.) | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum) |
|
||||
| `--hciconfig` | `hciconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig) |
|
||||
| `--history` | `history` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/history) |
|
||||
| `--host` | `host` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/host) |
|
||||
| `--hosts` | `/etc/hosts` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts) |
|
||||
| `--id` | `id` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/id) |
|
||||
| `--ifconfig` | `ifconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig) |
|
||||
@@ -208,6 +212,7 @@ option.
|
||||
| `--iostat-s` | `iostat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) |
|
||||
| `--ip-address` | IPv4 and IPv6 Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_address) |
|
||||
| `--iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
|
||||
| `--ip-route` | `ip route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_route) |
|
||||
| `--iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |
|
||||
| `--iwconfig` | `iwconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iwconfig) |
|
||||
| `--jar-manifest` | Java MANIFEST.MF file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest) |
|
||||
@@ -217,6 +222,8 @@ option.
|
||||
| `--last` | `last` and `lastb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/last) |
|
||||
| `--ls` | `ls` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls) |
|
||||
| `--ls-s` | `ls` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s) |
|
||||
| `--lsattr` | `lsattr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsattr) |
|
||||
| `--lsb-release` | `lsb_release` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsb_release) |
|
||||
| `--lsblk` | `lsblk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk) |
|
||||
| `--lsmod` | `lsmod` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod) |
|
||||
| `--lsof` | `lsof` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof) |
|
||||
@@ -229,9 +236,11 @@ option.
|
||||
| `--mpstat-s` | `mpstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s) |
|
||||
| `--netstat` | `netstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
|
||||
| `--nmcli` | `nmcli` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
|
||||
| `--nsd-control` | `nsd-control` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nsd_control) |
|
||||
| `--ntpq` | `ntpq -p` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
|
||||
| `--openvpn` | openvpn-status.log file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/openvpn) |
|
||||
| `--os-prober` | `os-prober` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_prober) |
|
||||
| `--os-release` | `/etc/os-release` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_release) |
|
||||
| `--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) |
|
||||
| `--pgpass` | PostgreSQL password file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pgpass) |
|
||||
@@ -245,6 +254,7 @@ option.
|
||||
| `--postconf` | `postconf -M` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/postconf) |
|
||||
| `--proc` | `/proc/` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/proc) |
|
||||
| `--ps` | `ps` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ps) |
|
||||
| `--resolve-conf` | `/etc/resolve.conf` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/resolve_conf) |
|
||||
| `--route` | `route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/route) |
|
||||
| `--rpm-qi` | `rpm -qi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi) |
|
||||
| `--rsync` | `rsync` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync) |
|
||||
@@ -252,6 +262,7 @@ option.
|
||||
| `--semver` | Semantic Version string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/semver) |
|
||||
| `--sfdisk` | `sfdisk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk) |
|
||||
| `--shadow` | `/etc/shadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow) |
|
||||
| `--srt` | SRT file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/srt) |
|
||||
| `--ss` | `ss` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ss) |
|
||||
| `--ssh-conf` | `ssh` config file and `ssh -G` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ssh_conf) |
|
||||
| `--sshd-conf` | `sshd` config file and `sshd -T` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sshd_conf) |
|
||||
@@ -285,12 +296,14 @@ option.
|
||||
| `--uptime` | `uptime` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime) |
|
||||
| `--url` | URL string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/url) |
|
||||
| `--ver` | Version string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ver) |
|
||||
| `--veracrypt` | `veracrypt` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/veracrypt) |
|
||||
| `--vmstat` | `vmstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat) |
|
||||
| `--vmstat-s` | `vmstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s) |
|
||||
| `--w` | `w` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/w) |
|
||||
| `--wc` | `wc` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/wc) |
|
||||
| `--who` | `who` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/who) |
|
||||
| `--x509-cert` | X.509 PEM and DER certificate file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_cert) |
|
||||
| `--x509-csr` | X.509 PEM and DER certificate request file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_csr) |
|
||||
| `--xml` | XML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xml) |
|
||||
| `--xrandr` | `xrandr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xrandr) |
|
||||
| `--yaml` | YAML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml) |
|
||||
|
||||
@@ -3,8 +3,8 @@ _jc()
|
||||
local cur prev words cword jc_commands jc_parsers jc_options \
|
||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||
|
||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw iwconfig 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 ssh 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 zpool)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --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 --ini-dup --iostat --iostat-s --ip-address --iptables --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --openvpn --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 --ssh-conf --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 --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --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 --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --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-tcp --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 --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --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 --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
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_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||
|
||||
@@ -9,7 +9,7 @@ _jc() {
|
||||
jc_help_options jc_help_options_describe \
|
||||
jc_special_options jc_special_options_describe
|
||||
|
||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw iwconfig 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 ssh 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 zpool)
|
||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||
jc_commands_describe=(
|
||||
'acpi:run "acpi" command with magic syntax.'
|
||||
'airport:run "airport" command with magic syntax.'
|
||||
@@ -35,9 +35,11 @@ _jc() {
|
||||
'git:run "git" command with magic syntax.'
|
||||
'gpg:run "gpg" command with magic syntax.'
|
||||
'hciconfig:run "hciconfig" command with magic syntax.'
|
||||
'host:run "host" command with magic syntax.'
|
||||
'id:run "id" command with magic syntax.'
|
||||
'ifconfig:run "ifconfig" command with magic syntax.'
|
||||
'iostat:run "iostat" command with magic syntax.'
|
||||
'ip:run "ip" command with magic syntax.'
|
||||
'iptables:run "iptables" command with magic syntax.'
|
||||
'iw:run "iw" command with magic syntax.'
|
||||
'iwconfig:run "iwconfig" command with magic syntax.'
|
||||
@@ -45,6 +47,8 @@ _jc() {
|
||||
'last:run "last" command with magic syntax.'
|
||||
'lastb:run "lastb" command with magic syntax.'
|
||||
'ls:run "ls" command with magic syntax.'
|
||||
'lsattr:run "lsattr" command with magic syntax.'
|
||||
'lsb_release:run "lsb_release" command with magic syntax.'
|
||||
'lsblk:run "lsblk" command with magic syntax.'
|
||||
'lsmod:run "lsmod" command with magic syntax.'
|
||||
'lsof:run "lsof" command with magic syntax.'
|
||||
@@ -57,6 +61,7 @@ _jc() {
|
||||
'mpstat:run "mpstat" command with magic syntax.'
|
||||
'netstat:run "netstat" command with magic syntax.'
|
||||
'nmcli:run "nmcli" command with magic syntax.'
|
||||
'nsd-control:run "nsd-control" command with magic syntax.'
|
||||
'ntpq:run "ntpq" command with magic syntax.'
|
||||
'os-prober:run "os-prober" command with magic syntax.'
|
||||
'pidstat:run "pidstat" command with magic syntax.'
|
||||
@@ -98,6 +103,7 @@ _jc() {
|
||||
'upower:run "upower" command with magic syntax.'
|
||||
'uptime:run "uptime" command with magic syntax.'
|
||||
'vdir:run "vdir" command with magic syntax.'
|
||||
'veracrypt:run "veracrypt" command with magic syntax.'
|
||||
'vmstat:run "vmstat" command with magic syntax.'
|
||||
'w:run "w" command with magic syntax.'
|
||||
'wc:run "wc" command with magic syntax.'
|
||||
@@ -106,7 +112,7 @@ _jc() {
|
||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||
'zpool:run "zpool" command with magic syntax.'
|
||||
)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --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 --ini-dup --iostat --iostat-s --ip-address --iptables --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --openvpn --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 --ssh-conf --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 --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --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 --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --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-tcp --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 --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --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 --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_parsers_describe=(
|
||||
'--acpi:`acpi` command parser'
|
||||
'--airport:`airport -I` command parser'
|
||||
@@ -139,6 +145,7 @@ _jc() {
|
||||
'--email-address:Email Address string parser'
|
||||
'--env:`env` command parser'
|
||||
'--file:`file` command parser'
|
||||
'--find:`find` command parser'
|
||||
'--findmnt:`findmnt` command parser'
|
||||
'--finger:`finger` command parser'
|
||||
'--free:`free` command parser'
|
||||
@@ -153,6 +160,7 @@ _jc() {
|
||||
'--hashsum:hashsum command parser (`md5sum`, `shasum`, etc.)'
|
||||
'--hciconfig:`hciconfig` command parser'
|
||||
'--history:`history` command parser'
|
||||
'--host:`host` command parser'
|
||||
'--hosts:`/etc/hosts` file parser'
|
||||
'--id:`id` command parser'
|
||||
'--ifconfig:`ifconfig` command parser'
|
||||
@@ -162,6 +170,7 @@ _jc() {
|
||||
'--iostat-s:`iostat` command streaming parser'
|
||||
'--ip-address:IPv4 and IPv6 Address string parser'
|
||||
'--iptables:`iptables` command parser'
|
||||
'--ip-route:`ip route` command parser'
|
||||
'--iw-scan:`iw dev [device] scan` command parser'
|
||||
'--iwconfig:`iwconfig` command parser'
|
||||
'--jar-manifest:Java MANIFEST.MF file parser'
|
||||
@@ -171,6 +180,8 @@ _jc() {
|
||||
'--last:`last` and `lastb` command parser'
|
||||
'--ls:`ls` command parser'
|
||||
'--ls-s:`ls` command streaming parser'
|
||||
'--lsattr:`lsattr` command parser'
|
||||
'--lsb-release:`lsb_release` command parser'
|
||||
'--lsblk:`lsblk` command parser'
|
||||
'--lsmod:`lsmod` command parser'
|
||||
'--lsof:`lsof` command parser'
|
||||
@@ -183,9 +194,11 @@ _jc() {
|
||||
'--mpstat-s:`mpstat` command streaming parser'
|
||||
'--netstat:`netstat` command parser'
|
||||
'--nmcli:`nmcli` command parser'
|
||||
'--nsd-control:`nsd-control` command parser'
|
||||
'--ntpq:`ntpq -p` command parser'
|
||||
'--openvpn:openvpn-status.log file parser'
|
||||
'--os-prober:`os-prober` command parser'
|
||||
'--os-release:`/etc/os-release` file parser'
|
||||
'--passwd:`/etc/passwd` file parser'
|
||||
'--pci-ids:`pci.ids` file parser'
|
||||
'--pgpass:PostgreSQL password file parser'
|
||||
@@ -237,6 +250,7 @@ _jc() {
|
||||
'--proc-net-packet:`/proc/net/packet` file parser'
|
||||
'--proc-net-protocols:`/proc/net/protocols` file parser'
|
||||
'--proc-net-route:`/proc/net/route` file parser'
|
||||
'--proc-net-tcp:`/proc/net/tcp` and `/proc/net/tcp6` file parser'
|
||||
'--proc-net-unix:`/proc/net/unix` file parser'
|
||||
'--proc-pid-fdinfo:`/proc/<pid>/fdinfo/<fd>` file parser'
|
||||
'--proc-pid-io:`/proc/<pid>/io` file parser'
|
||||
@@ -248,6 +262,7 @@ _jc() {
|
||||
'--proc-pid-statm:`/proc/<pid>/statm` file parser'
|
||||
'--proc-pid-status:`/proc/<pid>/status` file parser'
|
||||
'--ps:`ps` command parser'
|
||||
'--resolve-conf:`/etc/resolve.conf` file parser'
|
||||
'--route:`route` command parser'
|
||||
'--rpm-qi:`rpm -qi` command parser'
|
||||
'--rsync:`rsync` command parser'
|
||||
@@ -255,6 +270,7 @@ _jc() {
|
||||
'--semver:Semantic Version string parser'
|
||||
'--sfdisk:`sfdisk` command parser'
|
||||
'--shadow:`/etc/shadow` file parser'
|
||||
'--srt:SRT file parser'
|
||||
'--ss:`ss` command parser'
|
||||
'--ssh-conf:`ssh` config file and `ssh -G` command parser'
|
||||
'--sshd-conf:`sshd` config file and `sshd -T` command parser'
|
||||
@@ -288,12 +304,14 @@ _jc() {
|
||||
'--uptime:`uptime` command parser'
|
||||
'--url:URL string parser'
|
||||
'--ver:Version string parser'
|
||||
'--veracrypt:`veracrypt` command parser'
|
||||
'--vmstat:`vmstat` command parser'
|
||||
'--vmstat-s:`vmstat` command streaming parser'
|
||||
'--w:`w` command parser'
|
||||
'--wc:`wc` command parser'
|
||||
'--who:`who` command parser'
|
||||
'--x509-cert:X.509 PEM and DER certificate file parser'
|
||||
'--x509-csr:X.509 PEM and DER certificate request file parser'
|
||||
'--xml:XML file parser'
|
||||
'--xrandr:`xrandr` command parser'
|
||||
'--yaml:YAML file parser'
|
||||
|
||||
@@ -36,6 +36,7 @@ a controller and a device but there might be fields corresponding to one entity.
|
||||
"name": string,
|
||||
"is_default": boolean,
|
||||
"is_public": boolean,
|
||||
"is_random": boolean,
|
||||
"address": string,
|
||||
"alias": string,
|
||||
"class": string,
|
||||
@@ -54,8 +55,10 @@ a controller and a device but there might be fields corresponding to one entity.
|
||||
{
|
||||
"name": string,
|
||||
"is_public": boolean,
|
||||
"is_random": boolean,
|
||||
"address": string,
|
||||
"alias": string,
|
||||
"appearance": string,
|
||||
"class": string,
|
||||
"icon": string,
|
||||
"paired": string,
|
||||
@@ -66,7 +69,8 @@ a controller and a device but there might be fields corresponding to one entity.
|
||||
"legacy_pairing": string,
|
||||
"rssi": int,
|
||||
"txpower": int,
|
||||
"uuids": array
|
||||
"uuids": array,
|
||||
"modalias": string
|
||||
}
|
||||
]
|
||||
|
||||
@@ -126,4 +130,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Jake Ob (iakopap at gmail.com)
|
||||
Version 1.1 by Jake Ob (iakopap at gmail.com)
|
||||
|
||||
@@ -158,4 +158,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -9,6 +9,7 @@ Options supported:
|
||||
- `+noall +answer` options are supported in cases where only the answer
|
||||
information is desired.
|
||||
- `+axfr` option is supported on its own
|
||||
- `+nsid` option is supported
|
||||
|
||||
The `when_epoch` calculated timestamp field is naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
@@ -345,4 +346,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -90,10 +90,10 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
Dictionary of raw structured data or (default)
|
||||
List of Dictionaries of processed structured data (raw)
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
82
docs/parsers/find.md
Normal file
82
docs/parsers/find.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.find"></a>
|
||||
|
||||
# jc.parsers.find
|
||||
|
||||
jc - JSON Convert `find` command output parser
|
||||
|
||||
This parser returns a list of objects by default and a list of strings if
|
||||
the `--raw` option is used.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ find | jc --find
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('find', find_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"path": string,
|
||||
"node": string,
|
||||
"error": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ find | jc --find -p
|
||||
[
|
||||
{
|
||||
"path": "./directory"
|
||||
"node": "filename"
|
||||
},
|
||||
{
|
||||
"path": "./anotherdirectory"
|
||||
"node": "anotherfile"
|
||||
},
|
||||
{
|
||||
"path": null
|
||||
"node": null
|
||||
"error": "find: './inaccessible': Permission denied"
|
||||
}
|
||||
...
|
||||
]
|
||||
|
||||
$ find | jc --find -p -r
|
||||
[
|
||||
"./templates/readme_template",
|
||||
"./templates/manpage_template",
|
||||
"./.github/workflows/pythonapp.yml",
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.find.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
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 raw strings or
|
||||
List of Dictionaries of processed structured data
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Solomon Leang (solomonleang@gmail.com)
|
||||
113
docs/parsers/host.md
Normal file
113
docs/parsers/host.md
Normal file
@@ -0,0 +1,113 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.host"></a>
|
||||
|
||||
# jc.parsers.host
|
||||
|
||||
jc - JSON Convert `host` command output parser
|
||||
|
||||
Supports parsing of the most commonly used RR types (A, AAAA, MX, TXT)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ host google.com | jc --host
|
||||
|
||||
or
|
||||
|
||||
$ jc host google.com
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('host', host_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"hostname": string,
|
||||
"address": [
|
||||
string
|
||||
],
|
||||
"v6-address": [
|
||||
string
|
||||
],
|
||||
"mail": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
[
|
||||
{
|
||||
"nameserver": string,
|
||||
"zone": string,
|
||||
"mname": string,
|
||||
"rname": string,
|
||||
"serial": integer,
|
||||
"refresh": integer,
|
||||
"retry": integer,
|
||||
"expire": integer,
|
||||
"minimum": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ host google.com | jc --host
|
||||
[
|
||||
{
|
||||
"hostname": "google.com",
|
||||
"address": [
|
||||
"142.251.39.110"
|
||||
],
|
||||
"v6-address": [
|
||||
"2a00:1450:400e:811::200e"
|
||||
],
|
||||
"mail": [
|
||||
"smtp.google.com."
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ jc host -C sunet.se
|
||||
[
|
||||
{
|
||||
"nameserver": "2001:6b0:7::2",
|
||||
"zone": "sunet.se",
|
||||
"mname": "sunic.sunet.se.",
|
||||
"rname": "hostmaster.sunet.se.",
|
||||
"serial": "2023090401",
|
||||
"refresh": "28800",
|
||||
"retry": "7200",
|
||||
"expire": "604800",
|
||||
"minimum": "300"
|
||||
},
|
||||
{
|
||||
...
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.host.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False)
|
||||
```
|
||||
|
||||
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 Pettai (pettai@sunet.se)
|
||||
@@ -22,12 +22,12 @@ contained in lists/arrays.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.ini | jc --ini
|
||||
$ cat foo.ini | jc --ini-dup
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('ini', ini_file_output)
|
||||
result = jc.parse('ini_dup', ini_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -67,7 +67,7 @@ Examples:
|
||||
fruit = peach
|
||||
color = green
|
||||
|
||||
$ cat example.ini | jc --ini -p
|
||||
$ cat example.ini | jc --ini-dup -p
|
||||
{
|
||||
"foo": [
|
||||
"fiz"
|
||||
@@ -118,4 +118,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
74
docs/parsers/ip_route.md
Normal file
74
docs/parsers/ip_route.md
Normal file
@@ -0,0 +1,74 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ip_route"></a>
|
||||
|
||||
# jc.parsers.ip\_route
|
||||
|
||||
jc - JSON Convert `ip route` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ip route | jc --ip-route
|
||||
|
||||
or
|
||||
|
||||
$ jc ip-route
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('ip_route', ip_route_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"ip": string,
|
||||
"via": string,
|
||||
"dev": string,
|
||||
"metric": integer,
|
||||
"proto": string,
|
||||
"scope": string,
|
||||
"src": string,
|
||||
"via": string,
|
||||
"status": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ ip route | jc --ip-route -p
|
||||
[
|
||||
{
|
||||
"ip": "10.0.2.0/24",
|
||||
"dev": "enp0s3",
|
||||
"proto": "kernel",
|
||||
"scope": "link",
|
||||
"src": "10.0.2.15",
|
||||
"metric": 100
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.ip_route.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
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 Json objects if data is processed and Raw data if raw = true.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Julian Jackson (jackson.julian55@yahoo.com)
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
jc - JSON Convert `last` and `lastb` command output parser
|
||||
|
||||
Supports `-w` and `-F` options.
|
||||
Supports `-w`, `-F`, and `-x` options.
|
||||
|
||||
Calculated epoch time fields are naive (i.e. based on the local time of the
|
||||
system the parser is run on) since there is no timezone information in the
|
||||
@@ -127,4 +127,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
89
docs/parsers/lsattr.md
Normal file
89
docs/parsers/lsattr.md
Normal file
@@ -0,0 +1,89 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.lsattr"></a>
|
||||
|
||||
# jc.parsers.lsattr
|
||||
|
||||
jc - JSON Convert `lsattr` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsattr | jc --lsattr
|
||||
|
||||
or
|
||||
|
||||
$ jc lsattr
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('lsattr', lsattr_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Information from https://github.com/mirror/busybox/blob/2d4a3d9e6c1493a9520b907e07a41aca90cdfd94/e2fsprogs/e2fs_lib.c#L40
|
||||
used to define field names
|
||||
|
||||
[
|
||||
{
|
||||
"file": string,
|
||||
"compressed_file": Optional[boolean],
|
||||
"compressed_dirty_file": Optional[boolean],
|
||||
"compression_raw_access": Optional[boolean],
|
||||
"secure_deletion": Optional[boolean],
|
||||
"undelete": Optional[boolean],
|
||||
"synchronous_updates": Optional[boolean],
|
||||
"synchronous_directory_updates": Optional[boolean],
|
||||
"immutable": Optional[boolean],
|
||||
"append_only": Optional[boolean],
|
||||
"no_dump": Optional[boolean],
|
||||
"no_atime": Optional[boolean],
|
||||
"compression_requested": Optional[boolean],
|
||||
"encrypted": Optional[boolean],
|
||||
"journaled_data": Optional[boolean],
|
||||
"indexed_directory": Optional[boolean],
|
||||
"no_tailmerging": Optional[boolean],
|
||||
"top_of_directory_hierarchies": Optional[boolean],
|
||||
"extents": Optional[boolean],
|
||||
"no_cow": Optional[boolean],
|
||||
"casefold": Optional[boolean],
|
||||
"inline_data": Optional[boolean],
|
||||
"project_hierarchy": Optional[boolean],
|
||||
"verity": Optional[boolean],
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo lsattr /etc/passwd | jc --lsattr
|
||||
[
|
||||
{
|
||||
"file": "/etc/passwd",
|
||||
"extents": true
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.lsattr.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
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Mark Rotner (rotner.mr@gmail.com)
|
||||
61
docs/parsers/lsb_release.md
Normal file
61
docs/parsers/lsb_release.md
Normal file
@@ -0,0 +1,61 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.lsb_release"></a>
|
||||
|
||||
# jc.parsers.lsb\_release
|
||||
|
||||
jc - JSON Convert `lsb_release` command parser
|
||||
|
||||
This parser is an alias to the Key/Value parser (`--kv`).
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsb_release -a | jc --lsb-release
|
||||
|
||||
or
|
||||
$ jc lsb_release -a
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('lsb_release', lsb_release_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"<key>": string
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsb_release -a | jc --lsb-release -p
|
||||
{
|
||||
"Distributor ID": "Ubuntu",
|
||||
"Description": "Ubuntu 16.04.6 LTS",
|
||||
"Release": "16.04",
|
||||
"Codename": "xenial"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.lsb_release.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> 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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -376,6 +376,6 @@ Returns:
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
Compatibility: linux, darwin, freebsd, win32
|
||||
|
||||
Version 1.13 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.15 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
90
docs/parsers/nsd_control.md
Normal file
90
docs/parsers/nsd_control.md
Normal file
@@ -0,0 +1,90 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.nsd_control"></a>
|
||||
|
||||
# jc.parsers.nsd\_control
|
||||
|
||||
jc - JSON Convert `nsd-control` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ nsd-control | jc --nsd-control
|
||||
|
||||
or
|
||||
|
||||
$ jc nsd-control
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('nsd_control', nsd_control_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"version": string,
|
||||
"verbosity": integer,
|
||||
"ratelimit": integer
|
||||
}
|
||||
]
|
||||
|
||||
[
|
||||
{
|
||||
"zone": string
|
||||
"status": {
|
||||
"state": string,
|
||||
"served-serial": string,
|
||||
"commit-serial": string,
|
||||
"wait": string
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ nsd-control | jc --nsd-control status
|
||||
[
|
||||
{
|
||||
"version": "4.6.2",
|
||||
"verbosity": "2",
|
||||
"ratelimit": "0"
|
||||
}
|
||||
]
|
||||
|
||||
$ nsd-control | jc --nsd-control zonestatus sunet.se
|
||||
[
|
||||
{
|
||||
"zone": "sunet.se",
|
||||
"status": {
|
||||
"state": "ok",
|
||||
"served-serial": "2023090704 since 2023-09-07T16:34:27",
|
||||
"commit-serial": "2023090704 since 2023-09-07T16:34:27",
|
||||
"wait": "28684 sec between attempts"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.nsd_control.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False)
|
||||
```
|
||||
|
||||
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 Pettai (pettai@sunet.se)
|
||||
86
docs/parsers/os_release.md
Normal file
86
docs/parsers/os_release.md
Normal file
@@ -0,0 +1,86 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.os_release"></a>
|
||||
|
||||
# jc.parsers.os\_release
|
||||
|
||||
jc - JSON Convert `/etc/os-release` file parser
|
||||
|
||||
This parser is an alias to the Key/Value parser (`--kv`).
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/os-release | jc --os-release
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('os_release', os_release_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"<key>": string
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/os-release | jc --os-release -p
|
||||
{
|
||||
"NAME": "CentOS Linux",
|
||||
"VERSION": "7 (Core)",
|
||||
"ID": "centos",
|
||||
"ID_LIKE": "rhel fedora",
|
||||
"VERSION_ID": "7",
|
||||
"PRETTY_NAME": "CentOS Linux 7 (Core)",
|
||||
"ANSI_COLOR": "0;31",
|
||||
"CPE_NAME": "cpe:/o:centos:centos:7",
|
||||
"HOME_URL": "https://www.centos.org/",
|
||||
"BUG_REPORT_URL": "https://bugs.centos.org/",
|
||||
"CENTOS_MANTISBT_PROJECT": "CentOS-7",
|
||||
"CENTOS_MANTISBT_PROJECT_VERSION": "7",
|
||||
"REDHAT_SUPPORT_PRODUCT": "centos",
|
||||
"REDHAT_SUPPORT_PRODUCT_VERSION": "7"
|
||||
}
|
||||
|
||||
$ cat /etc/os-release | jc --os-release -p -r
|
||||
{
|
||||
"NAME": "\\"CentOS Linux\\"",
|
||||
"VERSION": "\\"7 (Core)\\"",
|
||||
"ID": "\\"centos\\"",
|
||||
"ID_LIKE": "\\"rhel fedora\\"",
|
||||
"VERSION_ID": "\\"7\\"",
|
||||
"PRETTY_NAME": "\\"CentOS Linux 7 (Core)\\"",
|
||||
"ANSI_COLOR": "\\"0;31\\"",
|
||||
"CPE_NAME": "\\"cpe:/o:centos:centos:7\\"",
|
||||
"HOME_URL": "\\"https://www.centos.org/\\"",
|
||||
"BUG_REPORT_URL": "\\"https://bugs.centos.org/\\"",
|
||||
"CENTOS_MANTISBT_PROJECT": "\\"CentOS-7\\"",
|
||||
"CENTOS_MANTISBT_PROJECT_VERSION": "\\"7\\"",
|
||||
"REDHAT_SUPPORT_PRODUCT": "\\"centos\\"",
|
||||
"REDHAT_SUPPORT_PRODUCT_VERSION": "\\"7\\""
|
||||
}
|
||||
|
||||
<a id="jc.parsers.os_release.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> 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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -45,6 +45,9 @@ Schema:
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"usr_ms": integer,
|
||||
"system_ms": integer,
|
||||
"guest_ms": integer,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
@@ -148,4 +151,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -39,6 +39,7 @@ Schema:
|
||||
"percent_usr": float,
|
||||
"percent_system": float,
|
||||
"percent_guest": float,
|
||||
"percent_wait": float,
|
||||
"percent_cpu": float,
|
||||
"cpu": integer,
|
||||
"minflt_s": float,
|
||||
@@ -53,6 +54,9 @@ Schema:
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"usr_ms": integer,
|
||||
"system_ms": integer,
|
||||
"guest_ms": integer,
|
||||
"command": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
@@ -107,4 +111,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -35,6 +35,8 @@ Schema:
|
||||
"packets_received": integer,
|
||||
"packet_loss_percent": float,
|
||||
"duplicates": integer,
|
||||
"errors": integer,
|
||||
"corrupted": integer,
|
||||
"round_trip_ms_min": float,
|
||||
"round_trip_ms_avg": float,
|
||||
"round_trip_ms_max": float,
|
||||
@@ -185,4 +187,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -36,7 +36,7 @@ Schema:
|
||||
"source_ip": string,
|
||||
"destination_ip": string,
|
||||
"sent_bytes": integer,
|
||||
"pattern": string, # (null if not set)
|
||||
"pattern": string, # null if not set
|
||||
"destination": string,
|
||||
"timestamp": float,
|
||||
"response_bytes": integer,
|
||||
@@ -49,10 +49,12 @@ Schema:
|
||||
"packets_received": integer,
|
||||
"packet_loss_percent": float,
|
||||
"duplicates": integer,
|
||||
"round_trip_ms_min": float,
|
||||
"round_trip_ms_avg": float,
|
||||
"round_trip_ms_max": float,
|
||||
"round_trip_ms_stddev": float,
|
||||
"errors": integer, # null if not set
|
||||
"corrupted": integer, # null if not set
|
||||
"round_trip_ms_min": float, # null if not set
|
||||
"round_trip_ms_avg": float, # null if not set
|
||||
"round_trip_ms_max": float, # null if not set
|
||||
"round_trip_ms_stddev": float, # null if not set
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
@@ -106,4 +108,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
186
docs/parsers/proc_net_tcp.md
Normal file
186
docs/parsers/proc_net_tcp.md
Normal file
@@ -0,0 +1,186 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.proc_net_tcp"></a>
|
||||
|
||||
# jc.parsers.proc\_net\_tcp
|
||||
|
||||
jc - JSON Convert `/proc/net/tcp` and `proc/net/tcp6` file parser
|
||||
|
||||
IPv4 and IPv6 addresses are converted to standard notation unless the raw
|
||||
(--raw) option is used.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/net/tcp
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc-net-tcp
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('proc', proc_net_tcp_file)
|
||||
|
||||
or
|
||||
|
||||
import jc
|
||||
result = jc.parse('proc_net_tcp', proc_net_tcp_file)
|
||||
|
||||
Schema:
|
||||
|
||||
Field names and types gathered from the following:
|
||||
|
||||
https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt
|
||||
|
||||
https://github.com/torvalds/linux/blob/master/net/ipv4/tcp_ipv4.c
|
||||
|
||||
https://github.com/torvalds/linux/blob/master/net/ipv6/tcp_ipv6.c
|
||||
|
||||
[
|
||||
{
|
||||
"entry": integer,
|
||||
"local_address": string,
|
||||
"local_port": integer,
|
||||
"remote_address": string,
|
||||
"remote_port": integer,
|
||||
"state": string,
|
||||
"tx_queue": string,
|
||||
"rx_queue": string,
|
||||
"timer_active": integer,
|
||||
"jiffies_until_timer_expires": string,
|
||||
"unrecovered_rto_timeouts": string,
|
||||
"uid": integer,
|
||||
"unanswered_0_window_probes": integer,
|
||||
"inode": integer,
|
||||
"sock_ref_count": integer,
|
||||
"sock_mem_loc": string,
|
||||
"retransmit_timeout": integer,
|
||||
"soft_clock_tick": integer,
|
||||
"ack_quick_pingpong": integer,
|
||||
"sending_congestion_window": integer,
|
||||
"slow_start_size_threshold": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc -p
|
||||
[
|
||||
{
|
||||
"entry": "0",
|
||||
"local_address": "10.0.0.28",
|
||||
"local_port": 42082,
|
||||
"remote_address": "64.12.0.108",
|
||||
"remote_port": 80,
|
||||
"state": "04",
|
||||
"tx_queue": "00000001",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": 1,
|
||||
"jiffies_until_timer_expires": "00000015",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": 0,
|
||||
"unanswered_0_window_probes": 0,
|
||||
"inode": 0,
|
||||
"sock_ref_count": 3,
|
||||
"sock_mem_loc": "ffff8c7a0de930c0",
|
||||
"retransmit_timeout": 21,
|
||||
"soft_clock_tick": 4,
|
||||
"ack_quick_pingpong": 30,
|
||||
"sending_congestion_window": 10,
|
||||
"slow_start_size_threshold": -1
|
||||
},
|
||||
{
|
||||
"entry": "1",
|
||||
"local_address": "10.0.0.28",
|
||||
"local_port": 38864,
|
||||
"remote_address": "104.244.42.65",
|
||||
"remote_port": 80,
|
||||
"state": "06",
|
||||
"tx_queue": "00000000",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": 3,
|
||||
"jiffies_until_timer_expires": "000007C5",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": 0,
|
||||
"unanswered_0_window_probes": 0,
|
||||
"inode": 0,
|
||||
"sock_ref_count": 3,
|
||||
"sock_mem_loc": "ffff8c7a12d31aa0"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc -p -r
|
||||
[
|
||||
{
|
||||
"entry": "1",
|
||||
"local_address": "1C00000A",
|
||||
"local_port": "A462",
|
||||
"remote_address": "6C000C40",
|
||||
"remote_port": "0050",
|
||||
"state": "04",
|
||||
"tx_queue": "00000001",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": "01",
|
||||
"jiffies_until_timer_expires": "00000015",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": "0",
|
||||
"unanswered_0_window_probes": "0",
|
||||
"inode": "0",
|
||||
"sock_ref_count": "3",
|
||||
"sock_mem_loc": "ffff8c7a0de930c0",
|
||||
"retransmit_timeout": "21",
|
||||
"soft_clock_tick": "4",
|
||||
"ack_quick_pingpong": "30",
|
||||
"sending_congestion_window": "10",
|
||||
"slow_start_size_threshold": "-1"
|
||||
},
|
||||
{
|
||||
"entry": "2",
|
||||
"local_address": "1C00000A",
|
||||
"local_port": "97D0",
|
||||
"remote_address": "412AF468",
|
||||
"remote_port": "0050",
|
||||
"state": "06",
|
||||
"tx_queue": "00000000",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": "03",
|
||||
"jiffies_until_timer_expires": "000007C5",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": "0",
|
||||
"unanswered_0_window_probes": "0",
|
||||
"inode": "0",
|
||||
"sock_ref_count": "3",
|
||||
"sock_mem_loc": "ffff8c7a12d31aa0"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.proc_net_tcp.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
Version 1.0 by Alvin Solomon (alvinms01@gmail.com)
|
||||
83
docs/parsers/resolve_conf.md
Normal file
83
docs/parsers/resolve_conf.md
Normal file
@@ -0,0 +1,83 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.resolve_conf"></a>
|
||||
|
||||
# jc.parsers.resolve\_conf
|
||||
|
||||
jc - JSON Convert `/etc/resolve.conf` file parser
|
||||
|
||||
This parser may be more forgiving than the system parser. For example, if
|
||||
multiple `search` lists are defined, this parser will append all entries to
|
||||
the `search` field, while the system parser may only use the list from the
|
||||
last defined instance.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/resolve.conf | jc --resolve-conf
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('resolve_conf', resolve_conf_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"domain": string,
|
||||
"search": [
|
||||
string
|
||||
],
|
||||
"nameservers": [
|
||||
string
|
||||
],
|
||||
"options": [
|
||||
string
|
||||
],
|
||||
"sortlist": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/resolve.conf | jc --resolve-conf -p
|
||||
{
|
||||
"search": [
|
||||
"eng.myprime.com",
|
||||
"dev.eng.myprime.com",
|
||||
"labs.myprime.com",
|
||||
"qa.myprime.com"
|
||||
],
|
||||
"nameservers": [
|
||||
"10.136.17.15"
|
||||
],
|
||||
"options": [
|
||||
"rotate",
|
||||
"ndots:1"
|
||||
]
|
||||
}
|
||||
|
||||
<a id="jc.parsers.resolve_conf.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> 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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -22,6 +22,13 @@ Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"interfaces": [
|
||||
{
|
||||
"id": string,
|
||||
"mac": string,
|
||||
"name": string,
|
||||
}
|
||||
]
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"genmask": string,
|
||||
@@ -129,6 +136,6 @@ Returns:
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
Compatibility: linux, win32
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
136
docs/parsers/srt.md
Normal file
136
docs/parsers/srt.md
Normal file
@@ -0,0 +1,136 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.srt"></a>
|
||||
|
||||
# jc.parsers.srt
|
||||
|
||||
jc - JSON Convert `SRT` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.srt | jc --srt
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('srt', srt_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"index": int,
|
||||
"start": {
|
||||
"hours": int,
|
||||
"minutes": int,
|
||||
"seconds": int,
|
||||
"milliseconds": int,
|
||||
"timestamp": string
|
||||
},
|
||||
"end": {
|
||||
"hours": int,
|
||||
"minutes": int,
|
||||
"seconds": int,
|
||||
"milliseconds": int,
|
||||
"timestamp": string
|
||||
},
|
||||
"content": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat attack_of_the_clones.srt
|
||||
1
|
||||
00:02:16,612 --> 00:02:19,376
|
||||
Senator, we're making
|
||||
our final approach into Coruscant.
|
||||
|
||||
2
|
||||
00:02:19,482 --> 00:02:21,609
|
||||
Very good, Lieutenant.
|
||||
...
|
||||
|
||||
$ cat attack_of_the_clones.srt | jc --srt
|
||||
[
|
||||
{
|
||||
"index": 1,
|
||||
"start": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 16,
|
||||
"milliseconds": 612,
|
||||
"timestamp": "00:02:16,612"
|
||||
},
|
||||
"end": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 19,
|
||||
"milliseconds": 376,
|
||||
"timestamp": "00:02:19,376"
|
||||
},
|
||||
"content": "Senator, we're making\nour final approach into Coruscant."
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"start": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 19,
|
||||
"milliseconds": 482,
|
||||
"timestamp": "00:02:19,482"
|
||||
},
|
||||
"end": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 21,
|
||||
"milliseconds": 609,
|
||||
"timestamp": "00:02:21,609"
|
||||
},
|
||||
"content": "Very good, Lieutenant."
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.srt.parse_timestamp"></a>
|
||||
|
||||
### parse\_timestamp
|
||||
|
||||
```python
|
||||
def parse_timestamp(timestamp: str) -> Dict
|
||||
```
|
||||
|
||||
timestamp: "hours:minutes:seconds,milliseconds" --->
|
||||
{
|
||||
"hours": "hours",
|
||||
"minutes": "minutes",
|
||||
"seconds": "seconds",
|
||||
"milliseconds": "milliseconds",
|
||||
"timestamp": "hours:minutes:seconds,milliseconds"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.srt.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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Mark Rotner (rotner.mr@gmail.com)
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
jc - JSON Convert `ss` command output parser
|
||||
|
||||
Extended information options like `-e` and `-p` are not supported and may
|
||||
cause parsing irregularities.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ss | jc --ss
|
||||
@@ -28,21 +25,29 @@ field names
|
||||
|
||||
[
|
||||
{
|
||||
"netid": string,
|
||||
"state": string,
|
||||
"recv_q": integer,
|
||||
"send_q": integer,
|
||||
"local_address": string,
|
||||
"local_port": string,
|
||||
"local_port_num": integer,
|
||||
"peer_address": string,
|
||||
"peer_port": string,
|
||||
"peer_port_num": integer,
|
||||
"interface": string,
|
||||
"link_layer" string,
|
||||
"channel": string,
|
||||
"path": string,
|
||||
"pid": integer
|
||||
"netid": string,
|
||||
"state": string,
|
||||
"recv_q": integer,
|
||||
"send_q": integer,
|
||||
"local_address": string,
|
||||
"local_port": string,
|
||||
"local_port_num": integer,
|
||||
"peer_address": string,
|
||||
"peer_port": string,
|
||||
"peer_port_num": integer,
|
||||
"interface": string,
|
||||
"link_layer" string,
|
||||
"channel": string,
|
||||
"path": string,
|
||||
"pid": integer,
|
||||
"opts": {
|
||||
"process_id": {
|
||||
"<process_id>": {
|
||||
"user": string,
|
||||
"file_descriptor": string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -303,4 +308,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -193,4 +193,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.13 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -7,7 +7,7 @@ jc - JSON Convert Version string output parser
|
||||
|
||||
Best-effort attempt to parse various styles of version numbers. This parser
|
||||
is based off of the version parser included in the CPython distutils
|
||||
libary.
|
||||
library.
|
||||
|
||||
If the version string conforms to some de facto-standard versioning rules
|
||||
followed by many developers a `strict` key will be present in the output
|
||||
|
||||
108
docs/parsers/veracrypt.md
Normal file
108
docs/parsers/veracrypt.md
Normal file
@@ -0,0 +1,108 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.veracrypt"></a>
|
||||
|
||||
# jc.parsers.veracrypt
|
||||
|
||||
jc - JSON Convert `veracrypt` command output parser
|
||||
|
||||
Supports the following `veracrypt` subcommands:
|
||||
- `veracrypt --text --list`
|
||||
- `veracrypt --text --list --verbose`
|
||||
- `veracrypt --text --volume-properties <volume>`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ veracrypt --text --list | jc --veracrypt
|
||||
or
|
||||
|
||||
$ jc veracrypt --text --list
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('veracrypt', veracrypt_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Volume:
|
||||
[
|
||||
{
|
||||
"slot": integer,
|
||||
"path": string,
|
||||
"device": string,
|
||||
"mountpoint": string,
|
||||
"size": string,
|
||||
"type": string,
|
||||
"readonly": string,
|
||||
"hidden_protected": string,
|
||||
"encryption_algo": string,
|
||||
"pk_size": string,
|
||||
"sk_size": string,
|
||||
"block_size": string,
|
||||
"mode": string,
|
||||
"prf": string,
|
||||
"format_version": integer,
|
||||
"backup_header": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ veracrypt --text --list | jc --veracrypt -p
|
||||
[
|
||||
{
|
||||
"slot": 1,
|
||||
"path": "/dev/sdb1",
|
||||
"device": "/dev/mapper/veracrypt1",
|
||||
"mountpoint": "/home/bob/mount/encrypt/sdb1"
|
||||
}
|
||||
]
|
||||
|
||||
$ veracrypt --text --list --verbose | jc --veracrypt -p
|
||||
[
|
||||
{
|
||||
"slot": 1,
|
||||
"path": "/dev/sdb1",
|
||||
"device": "/dev/mapper/veracrypt1",
|
||||
"mountpoint": "/home/bob/mount/encrypt/sdb1",
|
||||
"size": "522 MiB",
|
||||
"type": "Normal",
|
||||
"readonly": "No",
|
||||
"hidden_protected": "No",
|
||||
"encryption_algo": "AES",
|
||||
"pk_size": "256 bits",
|
||||
"sk_size": "256 bits",
|
||||
"block_size": "128 bits",
|
||||
"mode": "XTS",
|
||||
"prf": "HMAC-SHA-512",
|
||||
"format_version": 2,
|
||||
"backup_header": "Yes"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.veracrypt.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
|
||||
|
||||
Version 1.0 by Jake Ob (iakopap at gmail.com)
|
||||
@@ -433,4 +433,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
282
docs/parsers/x509_csr.md
Normal file
282
docs/parsers/x509_csr.md
Normal file
@@ -0,0 +1,282 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.x509_csr"></a>
|
||||
|
||||
# jc.parsers.x509\_csr
|
||||
|
||||
jc - JSON Convert X.509 Certificate Request format file parser
|
||||
|
||||
This parser will convert DER and PEM encoded X.509 certificate request files.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat certificateRequest.pem | jc --x509-csr
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('x509_csr', x509_csr_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"certification_request_info": {
|
||||
"version": string,
|
||||
"serial_number": string, # [0]
|
||||
"serial_number_str": string,
|
||||
"signature": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null,
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": string,
|
||||
"state_or_province_name" string,
|
||||
"locality_name": string,
|
||||
"organization_name": array/string,
|
||||
"organizational_unit_name": array/string,
|
||||
"common_name": string,
|
||||
"email_address": string,
|
||||
"serial_number": string, # [0]
|
||||
"serial_number_str": string
|
||||
},
|
||||
"validity": {
|
||||
"not_before": integer, # [1]
|
||||
"not_after": integer, # [1]
|
||||
"not_before_iso": string,
|
||||
"not_after_iso": string
|
||||
},
|
||||
"subject": {
|
||||
"country_name": string,
|
||||
"state_or_province_name": string,
|
||||
"locality_name": string,
|
||||
"organization_name": array/string,
|
||||
"organizational_unit_name": array/string,
|
||||
"common_name": string,
|
||||
"email_address": string,
|
||||
"serial_number": string, # [0]
|
||||
"serial_number_str": string
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null,
|
||||
},
|
||||
"public_key": {
|
||||
"modulus": string, # [0]
|
||||
"public_exponent": integer
|
||||
}
|
||||
},
|
||||
"issuer_unique_id": string/null,
|
||||
"subject_unique_id": string/null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": string,
|
||||
"critical": boolean,
|
||||
"extn_value": array/object/string/integer # [2]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null
|
||||
},
|
||||
"signature_value": string # [0]
|
||||
}
|
||||
]
|
||||
|
||||
[0] in colon-delimited hex notation
|
||||
[1] time-zone-aware (UTC) epoch timestamp
|
||||
[2] See below for well-known Extension schemas:
|
||||
|
||||
Basic Constraints:
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": boolean,
|
||||
"extn_value": {
|
||||
"ca": boolean,
|
||||
"path_len_constraint": string/null
|
||||
}
|
||||
}
|
||||
|
||||
Key Usage:
|
||||
{
|
||||
"extn_id": "key_usage",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
Key Identifier:
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": boolean,
|
||||
"extn_value": string # [0]
|
||||
}
|
||||
|
||||
Authority Key Identifier:
|
||||
{
|
||||
"extn_id": "authority_key_identifier",
|
||||
"critical": boolean,
|
||||
"extn_value": {
|
||||
"key_identifier": string, # [0]
|
||||
"authority_cert_issuer": string/null,
|
||||
"authority_cert_serial_number": string/null
|
||||
}
|
||||
}
|
||||
|
||||
Subject Alternative Name:
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
Certificate Policies:
|
||||
{
|
||||
"extn_id": "certificate_policies",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
{
|
||||
"policy_identifier": string,
|
||||
"policy_qualifiers": [ array or null
|
||||
{
|
||||
"policy_qualifier_id": string,
|
||||
"qualifier": string
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Signed Certificate Timestamp List:
|
||||
{
|
||||
"extn_id": "signed_certificate_timestamp_list",
|
||||
"critical": boolean,
|
||||
"extn_value": string # [0]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat server.csr| jc --x509-csr -p
|
||||
[
|
||||
{
|
||||
"certification_request_info": {
|
||||
"version": "v1",
|
||||
"subject": {
|
||||
"common_name": "myserver.for.example"
|
||||
},
|
||||
"subject_pk_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp256r1"
|
||||
},
|
||||
"public_key": "04:40:33:c0:91:8f:e9:46:ea:d0:dc:d0:f9:63:2..."
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "extension_request",
|
||||
"values": [
|
||||
[
|
||||
{
|
||||
"extn_id": "extended_key_usage",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"server_auth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"myserver.for.example"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature": "30:45:02:20:77:ac:5b:51:bf:c5:f5:43:02:52:ae:66:..."
|
||||
}
|
||||
]
|
||||
|
||||
$ openssl req -in server.csr | jc --x509-csr -p
|
||||
[
|
||||
{
|
||||
"certification_request_info": {
|
||||
"version": "v1",
|
||||
"subject": {
|
||||
"common_name": "myserver.for.example"
|
||||
},
|
||||
"subject_pk_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp256r1"
|
||||
},
|
||||
"public_key": "04:40:33:c0:91:8f:e9:46:ea:d0:dc:d0:f9:63:2..."
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "extension_request",
|
||||
"values": [
|
||||
[
|
||||
{
|
||||
"extn_id": "extended_key_usage",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"server_auth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"myserver.for.example"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature": "30:45:02:20:77:ac:5b:51:bf:c5:f5:43:02:52:ae:66:..."
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.x509_csr.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string or bytes) text or binary 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)
|
||||
@@ -98,4 +98,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -31,8 +31,8 @@ Schema:
|
||||
"current_height": integer,
|
||||
"maximum_width": integer,
|
||||
"maximum_height": integer,
|
||||
"associated_device": {
|
||||
"associated_modes": [
|
||||
"devices": {
|
||||
"modes": [
|
||||
{
|
||||
"resolution_width": integer,
|
||||
"resolution_height": integer,
|
||||
@@ -63,24 +63,6 @@ Schema:
|
||||
"reflection": string
|
||||
}
|
||||
],
|
||||
"unassociated_devices": [
|
||||
{
|
||||
"associated_modes": [
|
||||
{
|
||||
"resolution_width": integer,
|
||||
"resolution_height": integer,
|
||||
"is_high_resolution": boolean,
|
||||
"frequencies": [
|
||||
{
|
||||
"frequency": float,
|
||||
"is_current": boolean,
|
||||
"is_preferred": boolean
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
@@ -96,8 +78,8 @@ Examples:
|
||||
"current_height": 1080,
|
||||
"maximum_width": 32767,
|
||||
"maximum_height": 32767,
|
||||
"associated_device": {
|
||||
"associated_modes": [
|
||||
"devices": {
|
||||
"modes": [
|
||||
{
|
||||
"resolution_width": 1920,
|
||||
"resolution_height": 1080,
|
||||
@@ -141,8 +123,7 @@ Examples:
|
||||
"reflection": "normal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"unassociated_devices": []
|
||||
]
|
||||
}
|
||||
|
||||
$ xrandr --properties | jc --xrandr -p
|
||||
@@ -156,8 +137,8 @@ Examples:
|
||||
"current_height": 1080,
|
||||
"maximum_width": 32767,
|
||||
"maximum_height": 32767,
|
||||
"associated_device": {
|
||||
"associated_modes": [
|
||||
"devices": {
|
||||
"modes": [
|
||||
{
|
||||
"resolution_width": 1920,
|
||||
"resolution_height": 1080,
|
||||
@@ -204,8 +185,7 @@ Examples:
|
||||
"reflection": "normal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"unassociated_devices": []
|
||||
]
|
||||
}
|
||||
|
||||
<a id="jc.parsers.xrandr.parse"></a>
|
||||
@@ -231,4 +211,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.2 by Kevin Lyter (lyter_git at sent.com)
|
||||
Version 1.3 by Kevin Lyter (code (at) lyterk.com)
|
||||
|
||||
45
jc/cli.py
45
jc/cli.py
@@ -145,33 +145,34 @@ class JcCli():
|
||||
JC_COLORS=blue,brightblack,magenta,green
|
||||
JC_COLORS=default,default,default,default
|
||||
"""
|
||||
input_error = False
|
||||
env_colors = os.getenv('JC_COLORS')
|
||||
if PYGMENTS_INSTALLED:
|
||||
input_error = False
|
||||
env_colors = os.getenv('JC_COLORS')
|
||||
|
||||
if env_colors:
|
||||
color_list = env_colors.split(',')
|
||||
else:
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
if env_colors:
|
||||
color_list = env_colors.split(',')
|
||||
else:
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
|
||||
if len(color_list) != 4:
|
||||
input_error = True
|
||||
|
||||
for color in color_list:
|
||||
if color != 'default' and color not in PYGMENT_COLOR:
|
||||
if len(color_list) != 4:
|
||||
input_error = True
|
||||
|
||||
# if there is an issue with the env variable, just set all colors to default and move on
|
||||
if input_error:
|
||||
utils.warning_message(['Could not parse JC_COLORS environment variable'])
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
for color in color_list:
|
||||
if color != 'default' and color not in PYGMENT_COLOR:
|
||||
input_error = True
|
||||
|
||||
# Try the color set in the JC_COLORS env variable first. If it is set to default, then fall back to default colors
|
||||
self.custom_colors = {
|
||||
Name.Tag: f'bold {PYGMENT_COLOR[color_list[0]]}' if color_list[0] != 'default' else f"bold {PYGMENT_COLOR['blue']}", # key names
|
||||
Keyword: PYGMENT_COLOR[color_list[1]] if color_list[1] != 'default' else PYGMENT_COLOR['brightblack'], # true, false, null
|
||||
Number: PYGMENT_COLOR[color_list[2]] if color_list[2] != 'default' else PYGMENT_COLOR['magenta'], # numbers
|
||||
String: PYGMENT_COLOR[color_list[3]] if color_list[3] != 'default' else PYGMENT_COLOR['green'] # strings
|
||||
}
|
||||
# if there is an issue with the env variable, just set all colors to default and move on
|
||||
if input_error:
|
||||
utils.warning_message(['Could not parse JC_COLORS environment variable'])
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
|
||||
# Try the color set in the JC_COLORS env variable first. If it is set to default, then fall back to default colors
|
||||
self.custom_colors = {
|
||||
Name.Tag: f'bold {PYGMENT_COLOR[color_list[0]]}' if color_list[0] != 'default' else f"bold {PYGMENT_COLOR['blue']}", # key names
|
||||
Keyword: PYGMENT_COLOR[color_list[1]] if color_list[1] != 'default' else PYGMENT_COLOR['brightblack'], # true, false, null
|
||||
Number: PYGMENT_COLOR[color_list[2]] if color_list[2] != 'default' else PYGMENT_COLOR['magenta'], # numbers
|
||||
String: PYGMENT_COLOR[color_list[3]] if color_list[3] != 'default' else PYGMENT_COLOR['green'] # strings
|
||||
}
|
||||
|
||||
def set_mono(self) -> None:
|
||||
"""
|
||||
|
||||
14
jc/lib.py
14
jc/lib.py
@@ -9,7 +9,7 @@ from .jc_types import ParserInfoType, JSONDictType
|
||||
from jc import appdirs
|
||||
|
||||
|
||||
__version__ = '1.23.2'
|
||||
__version__ = '1.23.5'
|
||||
|
||||
parsers: List[str] = [
|
||||
'acpi',
|
||||
@@ -43,6 +43,7 @@ parsers: List[str] = [
|
||||
'email-address',
|
||||
'env',
|
||||
'file',
|
||||
'find',
|
||||
'findmnt',
|
||||
'finger',
|
||||
'free',
|
||||
@@ -57,6 +58,7 @@ parsers: List[str] = [
|
||||
'hashsum',
|
||||
'hciconfig',
|
||||
'history',
|
||||
'host',
|
||||
'hosts',
|
||||
'id',
|
||||
'ifconfig',
|
||||
@@ -66,6 +68,7 @@ parsers: List[str] = [
|
||||
'iostat-s',
|
||||
'ip-address',
|
||||
'iptables',
|
||||
'ip-route',
|
||||
'iso-datetime',
|
||||
'iw-scan',
|
||||
'iwconfig',
|
||||
@@ -76,6 +79,8 @@ parsers: List[str] = [
|
||||
'last',
|
||||
'ls',
|
||||
'ls-s',
|
||||
'lsattr',
|
||||
'lsb-release',
|
||||
'lsblk',
|
||||
'lsmod',
|
||||
'lsof',
|
||||
@@ -88,9 +93,11 @@ parsers: List[str] = [
|
||||
'mpstat-s',
|
||||
'netstat',
|
||||
'nmcli',
|
||||
'nsd-control',
|
||||
'ntpq',
|
||||
'openvpn',
|
||||
'os-prober',
|
||||
'os-release',
|
||||
'passwd',
|
||||
'pci-ids',
|
||||
'pgpass',
|
||||
@@ -142,6 +149,7 @@ parsers: List[str] = [
|
||||
'proc-net-packet',
|
||||
'proc-net-protocols',
|
||||
'proc-net-route',
|
||||
'proc-net-tcp',
|
||||
'proc-net-unix',
|
||||
'proc-pid-fdinfo',
|
||||
'proc-pid-io',
|
||||
@@ -153,6 +161,7 @@ parsers: List[str] = [
|
||||
'proc-pid-statm',
|
||||
'proc-pid-status',
|
||||
'ps',
|
||||
'resolve-conf',
|
||||
'route',
|
||||
'rpm-qi',
|
||||
'rsync',
|
||||
@@ -160,6 +169,7 @@ parsers: List[str] = [
|
||||
'semver',
|
||||
'sfdisk',
|
||||
'shadow',
|
||||
'srt',
|
||||
'ss',
|
||||
'ssh-conf',
|
||||
'sshd-conf',
|
||||
@@ -193,12 +203,14 @@ parsers: List[str] = [
|
||||
'uptime',
|
||||
'url',
|
||||
'ver',
|
||||
'veracrypt',
|
||||
'vmstat',
|
||||
'vmstat-s',
|
||||
'w',
|
||||
'wc',
|
||||
'who',
|
||||
'x509-cert',
|
||||
'x509-csr',
|
||||
'xml',
|
||||
'xrandr',
|
||||
'yaml',
|
||||
|
||||
@@ -2333,8 +2333,8 @@ class BitString(_IntegerBitString, Constructable, Castable, Primitive, ValueMap)
|
||||
if self._map:
|
||||
self._native = set()
|
||||
for index, bit in enumerate(bits):
|
||||
if bit:
|
||||
name = self._map.get(index, index)
|
||||
if bit and index in self._map:
|
||||
name = self._map.get(index)
|
||||
self._native.add(name)
|
||||
else:
|
||||
self._native = bits
|
||||
|
||||
1
jc/parsers/asn1crypto/jc_global.py
Normal file
1
jc/parsers/asn1crypto/jc_global.py
Normal file
@@ -0,0 +1 @@
|
||||
quiet = False
|
||||
@@ -251,7 +251,18 @@ class EmailAddress(IA5String):
|
||||
self._unicode = contents.decode('cp1252')
|
||||
else:
|
||||
mailbox, hostname = contents.rsplit(b'@', 1)
|
||||
self._unicode = mailbox.decode('cp1252') + '@' + hostname.decode('idna')
|
||||
|
||||
# fix to allow incorrectly encoded email addresses to succeed with warning
|
||||
try:
|
||||
self._unicode = mailbox.decode('cp1252') + '@' + hostname.decode('idna')
|
||||
except UnicodeDecodeError:
|
||||
ascii_mailbox = mailbox.decode('ascii', errors='backslashreplace')
|
||||
ascii_hostname = hostname.decode('ascii', errors='backslashreplace')
|
||||
from jc.utils import warning_message
|
||||
import jc.parsers.asn1crypto.jc_global as jc_global
|
||||
if not jc_global.quiet:
|
||||
warning_message([f'Invalid email address found: {ascii_mailbox}@{ascii_hostname}'])
|
||||
self._unicode = ascii_mailbox + '@' + ascii_hostname
|
||||
return self._unicode
|
||||
|
||||
def __ne__(self, other):
|
||||
|
||||
@@ -31,6 +31,7 @@ a controller and a device but there might be fields corresponding to one entity.
|
||||
"name": string,
|
||||
"is_default": boolean,
|
||||
"is_public": boolean,
|
||||
"is_random": boolean,
|
||||
"address": string,
|
||||
"alias": string,
|
||||
"class": string,
|
||||
@@ -49,8 +50,10 @@ a controller and a device but there might be fields corresponding to one entity.
|
||||
{
|
||||
"name": string,
|
||||
"is_public": boolean,
|
||||
"is_random": boolean,
|
||||
"address": string,
|
||||
"alias": string,
|
||||
"appearance": string,
|
||||
"class": string,
|
||||
"icon": string,
|
||||
"paired": string,
|
||||
@@ -61,7 +64,8 @@ a controller and a device but there might be fields corresponding to one entity.
|
||||
"legacy_pairing": string,
|
||||
"rssi": int,
|
||||
"txpower": int,
|
||||
"uuids": array
|
||||
"uuids": array,
|
||||
"modalias": string
|
||||
}
|
||||
]
|
||||
|
||||
@@ -104,12 +108,12 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = '`bluetoothctl` command parser'
|
||||
author = 'Jake Ob'
|
||||
author_email = 'iakopap at gmail.com'
|
||||
compatible = ["linux"]
|
||||
magic_commands = ["bluetoothctl"]
|
||||
compatible = ['linux']
|
||||
magic_commands = ['bluetoothctl']
|
||||
tags = ['command']
|
||||
|
||||
|
||||
@@ -124,6 +128,7 @@ try:
|
||||
"name": str,
|
||||
"is_default": bool,
|
||||
"is_public": bool,
|
||||
"is_random": bool,
|
||||
"address": str,
|
||||
"alias": str,
|
||||
"class": str,
|
||||
@@ -141,8 +146,10 @@ try:
|
||||
{
|
||||
"name": str,
|
||||
"is_public": bool,
|
||||
"is_random": bool,
|
||||
"address": str,
|
||||
"alias": str,
|
||||
"appearance": str,
|
||||
"class": str,
|
||||
"icon": str,
|
||||
"paired": str,
|
||||
@@ -154,6 +161,7 @@ try:
|
||||
"rssi": int,
|
||||
"txpower": int,
|
||||
"uuids": List[str],
|
||||
"modalias": str
|
||||
},
|
||||
)
|
||||
except ImportError:
|
||||
@@ -195,6 +203,7 @@ def _parse_controller(next_lines: List[str]) -> Optional[Controller]:
|
||||
"name": '',
|
||||
"is_default": False,
|
||||
"is_public": False,
|
||||
"is_random": False,
|
||||
"address": matches["address"],
|
||||
"alias": '',
|
||||
"class": '',
|
||||
@@ -210,10 +219,12 @@ def _parse_controller(next_lines: List[str]) -> Optional[Controller]:
|
||||
if name.endswith("[default]"):
|
||||
controller["is_default"] = True
|
||||
name = name.replace("[default]", "")
|
||||
|
||||
if name.endswith("(public)"):
|
||||
elif name.endswith("(public)"):
|
||||
controller["is_public"] = True
|
||||
name = name.replace("(public)", "")
|
||||
elif name.endswith("(random)"):
|
||||
controller["is_random"] = True
|
||||
name = name.replace("(random)", "")
|
||||
|
||||
controller["name"] = name.strip()
|
||||
|
||||
@@ -257,6 +268,7 @@ _device_head_pattern = r"Device (?P<address>([0-9A-F]{2}:){5}[0-9A-F]{2}) (?P<na
|
||||
_device_line_pattern = (
|
||||
r"(\s*Name:\s*(?P<name>.+)"
|
||||
+ r"|\s*Alias:\s*(?P<alias>.+)"
|
||||
+ r"|\s*Appearance:\s*(?P<appearance>.+)"
|
||||
+ r"|\s*Class:\s*(?P<class>.+)"
|
||||
+ r"|\s*Icon:\s*(?P<icon>.+)"
|
||||
+ r"|\s*Paired:\s*(?P<paired>.+)"
|
||||
@@ -290,8 +302,10 @@ def _parse_device(next_lines: List[str], quiet: bool) -> Optional[Device]:
|
||||
device: Device = {
|
||||
"name": '',
|
||||
"is_public": False,
|
||||
"is_random": False,
|
||||
"address": matches["address"],
|
||||
"alias": '',
|
||||
"appearance": '',
|
||||
"class": '',
|
||||
"icon": '',
|
||||
"paired": '',
|
||||
@@ -303,11 +317,15 @@ def _parse_device(next_lines: List[str], quiet: bool) -> Optional[Device]:
|
||||
"rssi": 0,
|
||||
"txpower": 0,
|
||||
"uuids": [],
|
||||
"modalias": ''
|
||||
}
|
||||
|
||||
if name.endswith("(public)"):
|
||||
device["is_public"] = True
|
||||
name = name.replace("(public)", "")
|
||||
elif name.endswith("(random)"):
|
||||
device["is_random"] = True
|
||||
name = name.replace("(random)", "")
|
||||
|
||||
device["name"] = name.strip()
|
||||
|
||||
@@ -325,6 +343,8 @@ def _parse_device(next_lines: List[str], quiet: bool) -> Optional[Device]:
|
||||
device["name"] = matches["name"]
|
||||
elif matches["alias"]:
|
||||
device["alias"] = matches["alias"]
|
||||
elif matches["appearance"]:
|
||||
device["appearance"] = matches["appearance"]
|
||||
elif matches["class"]:
|
||||
device["class"] = matches["class"]
|
||||
elif matches["icon"]:
|
||||
@@ -359,6 +379,8 @@ def _parse_device(next_lines: List[str], quiet: bool) -> Optional[Device]:
|
||||
if not "uuids" in device:
|
||||
device["uuids"] = []
|
||||
device["uuids"].append(matches["uuid"])
|
||||
elif matches["modalias"]:
|
||||
device["modalias"] = matches["modalias"]
|
||||
|
||||
return device
|
||||
|
||||
@@ -376,12 +398,11 @@ def parse(data: str, raw: bool = False, quiet: bool = False) -> List[JSONDictTyp
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
result: List = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
linedata = data.splitlines()
|
||||
linedata.reverse()
|
||||
|
||||
|
||||
@@ -130,6 +130,7 @@ Examples:
|
||||
}
|
||||
}
|
||||
"""
|
||||
import re
|
||||
from typing import List, Dict
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.utils
|
||||
@@ -137,7 +138,7 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
version = '1.2'
|
||||
description = '`certbot` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -200,7 +201,9 @@ def parse(
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if 'Found the following certs:\n' in data:
|
||||
cert_pattern = re.compile(r'^Found the following certs:\r?$', re.MULTILINE)
|
||||
|
||||
if re.search(cert_pattern, data):
|
||||
cmd_option = 'certificates'
|
||||
else:
|
||||
cmd_option = 'account'
|
||||
|
||||
@@ -198,7 +198,7 @@ def _process(proc_data):
|
||||
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
# put itmes in lists
|
||||
# put items in lists
|
||||
try:
|
||||
for entry in proc_data['schedule']:
|
||||
entry['minute'] = entry['minute'].split(',')
|
||||
|
||||
@@ -194,7 +194,7 @@ def _process(proc_data):
|
||||
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
# put itmes in lists
|
||||
# put items in lists
|
||||
try:
|
||||
for entry in proc_data['schedule']:
|
||||
entry['minute'] = entry['minute'].split(',')
|
||||
|
||||
@@ -4,6 +4,7 @@ Options supported:
|
||||
- `+noall +answer` options are supported in cases where only the answer
|
||||
information is desired.
|
||||
- `+axfr` option is supported on its own
|
||||
- `+nsid` option is supported
|
||||
|
||||
The `when_epoch` calculated timestamp field is naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
@@ -322,7 +323,7 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '2.4'
|
||||
version = '2.5'
|
||||
description = '`dig` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -427,6 +428,7 @@ def _parse_flags_line(flagsline):
|
||||
def _parse_opt_pseudosection(optline):
|
||||
# ;; OPT PSEUDOSECTION:
|
||||
# ; EDNS: version: 0, flags:; udp: 4096
|
||||
# ; NSID: 67 70 64 6e 73 2d 73 66 6f ("gpdns-sfo")
|
||||
# ; COOKIE: 1cbc06703eaef210
|
||||
if optline.startswith('; EDNS:'):
|
||||
optline_list = optline.replace(',', ' ').split(';')
|
||||
@@ -443,11 +445,18 @@ def _parse_opt_pseudosection(optline):
|
||||
}
|
||||
}
|
||||
|
||||
elif optline.startswith('; COOKIE:'):
|
||||
if optline.startswith('; COOKIE:'):
|
||||
return {
|
||||
'cookie': optline.split()[2]
|
||||
}
|
||||
|
||||
if optline.startswith('; NSID:'):
|
||||
return {
|
||||
'nsid': optline.split('("')[-1].rstrip('")')
|
||||
}
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
def _parse_question(question):
|
||||
# ;www.cnn.com. IN A
|
||||
|
||||
@@ -67,12 +67,13 @@ Examples:
|
||||
"_": "/usr/bin/env"
|
||||
}
|
||||
"""
|
||||
import re
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
version = '1.5'
|
||||
description = '`env` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -83,6 +84,7 @@ class info():
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
VAR_DEF_PATTERN = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*=\S*.*$')
|
||||
|
||||
def _process(proc_data):
|
||||
"""
|
||||
@@ -96,8 +98,6 @@ def _process(proc_data):
|
||||
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
|
||||
# rebuild output for added semantic information
|
||||
processed = []
|
||||
for k, v in proc_data.items():
|
||||
proc_line = {}
|
||||
@@ -120,24 +120,29 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
Dictionary of raw structured data or (default)
|
||||
List of Dictionaries of processed structured data (raw)
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
key = ''
|
||||
value = None
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
for line in data.splitlines():
|
||||
if VAR_DEF_PATTERN.match(line):
|
||||
if not value is None:
|
||||
raw_output[key] = value
|
||||
key, value = line.split('=', maxsplit=1)
|
||||
continue
|
||||
|
||||
for entry in cleandata:
|
||||
parsed_line = entry.split('=', maxsplit=1)
|
||||
raw_output[parsed_line[0]] = parsed_line[1]
|
||||
if not value is None:
|
||||
value = value + '\n' + line
|
||||
|
||||
if not value is None:
|
||||
raw_output[key] = value
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return _process(raw_output)
|
||||
|
||||
137
jc/parsers/find.py
Normal file
137
jc/parsers/find.py
Normal file
@@ -0,0 +1,137 @@
|
||||
"""jc - JSON Convert `find` command output parser
|
||||
|
||||
This parser returns a list of objects by default and a list of strings if
|
||||
the `--raw` option is used.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ find | jc --find
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('find', find_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"path": string,
|
||||
"node": string,
|
||||
"error": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ find | jc --find -p
|
||||
[
|
||||
{
|
||||
"path": "./directory"
|
||||
"node": "filename"
|
||||
},
|
||||
{
|
||||
"path": "./anotherdirectory"
|
||||
"node": "anotherfile"
|
||||
},
|
||||
{
|
||||
"path": null
|
||||
"node": null
|
||||
"error": "find: './inaccessible': Permission denied"
|
||||
}
|
||||
...
|
||||
]
|
||||
|
||||
$ find | jc --find -p -r
|
||||
[
|
||||
"./templates/readme_template",
|
||||
"./templates/manpage_template",
|
||||
"./.github/workflows/pythonapp.yml",
|
||||
...
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`find` command parser'
|
||||
author = 'Solomon Leang'
|
||||
author_email = 'solomonleang@gmail.com'
|
||||
compatible = ['linux']
|
||||
tags = ['command']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (List of Strings) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
processed = []
|
||||
|
||||
for index in proc_data:
|
||||
path, node, error = "", "", ""
|
||||
|
||||
if index == ".":
|
||||
node = "."
|
||||
elif index.startswith('find: '):
|
||||
error = index
|
||||
else:
|
||||
try:
|
||||
path, node = index.rsplit('/', maxsplit=1)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
proc_line = {
|
||||
'path': path if path else None,
|
||||
'node': node if node else None
|
||||
}
|
||||
|
||||
if error:
|
||||
proc_line.update(
|
||||
{'error': error}
|
||||
)
|
||||
|
||||
processed.append(proc_line)
|
||||
|
||||
return processed
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
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 raw strings or
|
||||
List of Dictionaries of processed structured data
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
raw_output = data.splitlines()
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return _process(raw_output)
|
||||
243
jc/parsers/host.py
Normal file
243
jc/parsers/host.py
Normal file
@@ -0,0 +1,243 @@
|
||||
"""jc - JSON Convert `host` command output parser
|
||||
|
||||
Supports parsing of the most commonly used RR types (A, AAAA, MX, TXT)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ host google.com | jc --host
|
||||
|
||||
or
|
||||
|
||||
$ jc host google.com
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('host', host_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"hostname": string,
|
||||
"address": [
|
||||
string
|
||||
],
|
||||
"v6-address": [
|
||||
string
|
||||
],
|
||||
"mail": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
[
|
||||
{
|
||||
"nameserver": string,
|
||||
"zone": string,
|
||||
"mname": string,
|
||||
"rname": string,
|
||||
"serial": integer,
|
||||
"refresh": integer,
|
||||
"retry": integer,
|
||||
"expire": integer,
|
||||
"minimum": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ host google.com | jc --host
|
||||
[
|
||||
{
|
||||
"hostname": "google.com",
|
||||
"address": [
|
||||
"142.251.39.110"
|
||||
],
|
||||
"v6-address": [
|
||||
"2a00:1450:400e:811::200e"
|
||||
],
|
||||
"mail": [
|
||||
"smtp.google.com."
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ jc host -C sunet.se
|
||||
[
|
||||
{
|
||||
"nameserver": "2001:6b0:7::2",
|
||||
"zone": "sunet.se",
|
||||
"mname": "sunic.sunet.se.",
|
||||
"rname": "hostmaster.sunet.se.",
|
||||
"serial": "2023090401",
|
||||
"refresh": "28800",
|
||||
"retry": "7200",
|
||||
"expire": "604800",
|
||||
"minimum": "300"
|
||||
},
|
||||
{
|
||||
...
|
||||
}
|
||||
]
|
||||
"""
|
||||
from typing import Dict, List
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`host` command parser'
|
||||
author = 'Pettai'
|
||||
author_email = 'pettai@sunet.se'
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
tags = ['command']
|
||||
magic_commands = ['host']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured to conform to the schema.
|
||||
"""
|
||||
|
||||
int_list = {'serial', 'refresh', 'retry', 'expire', 'minimum'}
|
||||
|
||||
for entry in proc_data:
|
||||
for key in entry:
|
||||
if key in int_list:
|
||||
entry[key] = jc.utils.convert_to_int(entry[key])
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False):
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output: List[Dict] = []
|
||||
|
||||
warned = False
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
addresses = []
|
||||
v6addresses = []
|
||||
mail = []
|
||||
text = []
|
||||
rrdata = {}
|
||||
soaparse = False
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
line = line.strip()
|
||||
|
||||
# default
|
||||
if ' has address ' in line:
|
||||
linedata = line.split(' ', maxsplit=3)
|
||||
hostname = linedata[0]
|
||||
address = linedata[3]
|
||||
addresses.append(address)
|
||||
rrdata.update({'hostname': hostname})
|
||||
rrdata.update({'address': addresses})
|
||||
continue
|
||||
|
||||
if ' has IPv6 address ' in line:
|
||||
linedata = line.split(' ', maxsplit=4)
|
||||
hostname = linedata[0]
|
||||
v6address = linedata[4]
|
||||
v6addresses.append(v6address)
|
||||
rrdata.update({'hostname': hostname})
|
||||
rrdata.update({'v6-address': v6addresses})
|
||||
continue
|
||||
|
||||
if ' mail is handled by ' in line:
|
||||
linedata = line.split(' ', maxsplit=6)
|
||||
hostname = linedata[0]
|
||||
mx = linedata[6]
|
||||
mail.append(mx)
|
||||
rrdata.update({'hostname': hostname})
|
||||
rrdata.update({'mail': mail})
|
||||
continue
|
||||
|
||||
|
||||
# TXT parsing
|
||||
if ' descriptive text ' in line:
|
||||
linedata = line.split('descriptive text "', maxsplit=1)
|
||||
hostname = linedata[0]
|
||||
txt = linedata[1].strip('"')
|
||||
text.append(txt)
|
||||
rrdata.update({'hostname': hostname})
|
||||
rrdata.update({'text': text})
|
||||
continue
|
||||
|
||||
|
||||
# -C / SOA parsing
|
||||
if line.startswith('Nameserver '):
|
||||
soaparse = True
|
||||
rrdata = {}
|
||||
linedata = line.split(' ', maxsplit=1)
|
||||
nameserverip = linedata[1].rstrip(':')
|
||||
rrdata.update({'nameserver': nameserverip})
|
||||
continue
|
||||
|
||||
if ' has SOA record ' in line:
|
||||
linedata = line.split(' ', maxsplit=10)
|
||||
|
||||
zone = linedata[0]
|
||||
mname = linedata[4]
|
||||
rname = linedata[5]
|
||||
serial = linedata[6]
|
||||
refresh = linedata[7]
|
||||
retry = linedata[8]
|
||||
expire = linedata[9]
|
||||
minimum = linedata[10]
|
||||
|
||||
try:
|
||||
rrdata.update(
|
||||
{
|
||||
'zone': zone,
|
||||
'mname': mname,
|
||||
'rname': rname,
|
||||
'serial': serial,
|
||||
'refresh': refresh,
|
||||
'retry': retry,
|
||||
'expire': expire,
|
||||
'minimum': minimum
|
||||
},
|
||||
)
|
||||
raw_output.append(rrdata)
|
||||
|
||||
except IndexError:
|
||||
if not warned:
|
||||
jc.utils.warning_message(['Unknown format detected.'])
|
||||
warned = True
|
||||
|
||||
if not soaparse:
|
||||
raw_output.append(rrdata)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
@@ -17,12 +17,12 @@ contained in lists/arrays.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.ini | jc --ini
|
||||
$ cat foo.ini | jc --ini-dup
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('ini', ini_file_output)
|
||||
result = jc.parse('ini_dup', ini_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -62,7 +62,7 @@ Examples:
|
||||
fruit = peach
|
||||
color = green
|
||||
|
||||
$ cat example.ini | jc --ini -p
|
||||
$ cat example.ini | jc --ini-dup -p
|
||||
{
|
||||
"foo": [
|
||||
"fiz"
|
||||
@@ -97,7 +97,7 @@ import uuid
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = 'INI with duplicate key file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
145
jc/parsers/ip_route.py
Normal file
145
jc/parsers/ip_route.py
Normal file
@@ -0,0 +1,145 @@
|
||||
"""jc - JSON Convert `ip route` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ip route | jc --ip-route
|
||||
|
||||
or
|
||||
|
||||
$ jc ip-route
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('ip_route', ip_route_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"ip": string,
|
||||
"via": string,
|
||||
"dev": string,
|
||||
"metric": integer,
|
||||
"proto": string,
|
||||
"scope": string,
|
||||
"src": string,
|
||||
"via": string,
|
||||
"status": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ ip route | jc --ip-route -p
|
||||
[
|
||||
{
|
||||
"ip": "10.0.2.0/24",
|
||||
"dev": "enp0s3",
|
||||
"proto": "kernel",
|
||||
"scope": "link",
|
||||
"src": "10.0.2.15",
|
||||
"metric": 100
|
||||
}
|
||||
]
|
||||
"""
|
||||
from typing import Dict
|
||||
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info:
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`ip route` command parser'
|
||||
author = 'Julian Jackson'
|
||||
author_email = 'jackson.julian55@yahoo.com'
|
||||
compatible = ['linux']
|
||||
magic_commands = ['ip route']
|
||||
tags = ['command']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
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 Json objects if data is processed and Raw data if raw = true.
|
||||
"""
|
||||
structure = {}
|
||||
items = []
|
||||
lines = data.splitlines()
|
||||
index = 0
|
||||
place = 0
|
||||
inc = 0
|
||||
|
||||
for line in lines:
|
||||
temp = line.split()
|
||||
for word in temp:
|
||||
if word == 'via':
|
||||
y = {'via': temp[place + 1]}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'dev':
|
||||
y = {'dev': temp[place + 1]}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'metric':
|
||||
if raw:
|
||||
y = {'metric': temp[place + 1]}
|
||||
else:
|
||||
y = {'metric': jc.utils.convert_to_int(temp[place+1])}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'proto':
|
||||
y = {'proto': temp[place + 1]}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'scope':
|
||||
y = {'scope': temp[place + 1]}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'src':
|
||||
y = {'src': temp[place + 1]}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'status':
|
||||
y = {'status': temp[place + 1]}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'default':
|
||||
y = {'ip': 'default'}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
elif word == 'linkdown':
|
||||
y = {'status': 'linkdown'}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
else:
|
||||
y = {'ip': temp[0]}
|
||||
place += 1
|
||||
structure.update(y)
|
||||
if y.get("ip") != "":
|
||||
items.append(structure)
|
||||
structure = {}
|
||||
place = 0
|
||||
index += 1
|
||||
inc += 1
|
||||
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
if not jc.utils.has_data(data):
|
||||
return []
|
||||
|
||||
return items
|
||||
@@ -1,6 +1,6 @@
|
||||
"""jc - JSON Convert `last` and `lastb` command output parser
|
||||
|
||||
Supports `-w` and `-F` options.
|
||||
Supports `-w`, `-F`, and `-x` options.
|
||||
|
||||
Calculated epoch time fields are naive (i.e. based on the local time of the
|
||||
system the parser is run on) since there is no timezone information in the
|
||||
@@ -103,10 +103,15 @@ Examples:
|
||||
import re
|
||||
import jc.utils
|
||||
|
||||
DATE_RE = re.compile(r'[MTWFS][ouerha][nedritnu] [JFMASOND][aepuco][nbrynlgptvc]')
|
||||
LAST_F_DATE_RE = re.compile(r'\d\d:\d\d:\d\d \d\d\d\d')
|
||||
LOGIN_LOGOUT_EPOCH_RE = re.compile(r'.*\d\d:\d\d:\d\d \d\d\d\d.*')
|
||||
LOGOUT_IGNORED_EVENTS = ['down', 'crash']
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.8'
|
||||
version = '1.9'
|
||||
description = '`last` and `lastb` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -138,9 +143,6 @@ def _process(proc_data):
|
||||
if 'tty' in entry and entry['tty'] == '~':
|
||||
entry['tty'] = None
|
||||
|
||||
if 'tty' in entry and entry['tty'] == 'system_boot':
|
||||
entry['tty'] = 'system boot'
|
||||
|
||||
if 'hostname' in entry and entry['hostname'] == '-':
|
||||
entry['hostname'] = None
|
||||
|
||||
@@ -153,11 +155,11 @@ def _process(proc_data):
|
||||
if 'logout' in entry and entry['logout'] == 'gone_-_no_logout':
|
||||
entry['logout'] = 'gone - no logout'
|
||||
|
||||
if 'login' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*', entry['login']):
|
||||
if 'login' in entry and LOGIN_LOGOUT_EPOCH_RE.match(entry['login']):
|
||||
timestamp = jc.utils.timestamp(entry['login'])
|
||||
entry['login_epoch'] = timestamp.naive
|
||||
|
||||
if 'logout' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*', entry['logout']):
|
||||
if 'logout' in entry and LOGIN_LOGOUT_EPOCH_RE.match(entry['logout']):
|
||||
timestamp = jc.utils.timestamp(entry['logout'])
|
||||
entry['logout_epoch'] = timestamp.naive
|
||||
|
||||
@@ -194,66 +196,71 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
if not jc.utils.has_data(data):
|
||||
return []
|
||||
|
||||
for entry in cleandata:
|
||||
output_line = {}
|
||||
for entry in cleandata:
|
||||
output_line = {}
|
||||
|
||||
if (entry.startswith('wtmp begins ') or
|
||||
entry.startswith('btmp begins ') or
|
||||
entry.startswith('utx.log begins ')):
|
||||
if any(
|
||||
entry.startswith(f'{prefix} begins ')
|
||||
for prefix in ['wtmp', 'btmp', 'utx.log']
|
||||
):
|
||||
continue
|
||||
|
||||
continue
|
||||
entry = entry.replace('boot time', 'boot_time')
|
||||
entry = entry.replace(' still logged in', '- still_logged_in')
|
||||
entry = entry.replace(' gone - no logout', '- gone_-_no_logout')
|
||||
|
||||
entry = entry.replace('system boot', 'system_boot')
|
||||
entry = entry.replace('boot time', 'boot_time')
|
||||
entry = entry.replace(' still logged in', '- still_logged_in')
|
||||
entry = entry.replace(' gone - no logout', '- gone_-_no_logout')
|
||||
linedata = entry.split()
|
||||
|
||||
linedata = entry.split()
|
||||
if re.match(r'[MTWFS][ouerha][nedritnu] [JFMASOND][aepuco][nbrynlgptvc]', ' '.join(linedata[2:4])):
|
||||
linedata.insert(2, '-')
|
||||
# Adding "-" before the date part.
|
||||
if DATE_RE.match(' '.join(linedata[2:4])):
|
||||
linedata.insert(2, '-')
|
||||
|
||||
# freebsd fix
|
||||
if linedata[0] == 'boot_time':
|
||||
linedata.insert(1, '-')
|
||||
linedata.insert(1, '~')
|
||||
# freebsd fix
|
||||
if linedata[0] == 'boot_time':
|
||||
linedata.insert(1, '-')
|
||||
linedata.insert(1, '~')
|
||||
|
||||
output_line['user'] = linedata[0]
|
||||
output_line['tty'] = linedata[1]
|
||||
output_line['hostname'] = linedata[2]
|
||||
output_line['user'] = linedata[0]
|
||||
|
||||
# last -F support
|
||||
if re.match(r'\d\d:\d\d:\d\d \d\d\d\d', ' '.join(linedata[6:8])):
|
||||
output_line['login'] = ' '.join(linedata[3:8])
|
||||
# Fix for last -x (runlevel).
|
||||
if output_line['user'] == 'runlevel' and linedata[1] == '(to':
|
||||
linedata[1] += f' {linedata.pop(2)} {linedata.pop(2)}'
|
||||
elif output_line['user'] in ['reboot', 'shutdown'] and linedata[1] == 'system': # system down\system boot
|
||||
linedata[1] += f' {linedata.pop(2)}'
|
||||
|
||||
if len(linedata) > 9 and linedata[9] != 'crash' and linedata[9] != 'down':
|
||||
output_line['tty'] = linedata[1]
|
||||
output_line['hostname'] = linedata[2]
|
||||
|
||||
# last -F support
|
||||
if LAST_F_DATE_RE.match(' '.join(linedata[6:8])):
|
||||
output_line['login'] = ' '.join(linedata[3:8])
|
||||
|
||||
if len(linedata) > 9:
|
||||
if linedata[9] not in LOGOUT_IGNORED_EVENTS:
|
||||
output_line['logout'] = ' '.join(linedata[9:14])
|
||||
|
||||
if len(linedata) > 9 and (linedata[9] == 'crash' or linedata[9] == 'down'):
|
||||
else:
|
||||
output_line['logout'] = linedata[9]
|
||||
# add more items to the list to line up duration
|
||||
linedata.insert(10, '-')
|
||||
linedata.insert(10, '-')
|
||||
linedata.insert(10, '-')
|
||||
linedata.insert(10, '-')
|
||||
for _ in range(4):
|
||||
linedata.insert(10, '-')
|
||||
|
||||
if len(linedata) > 14:
|
||||
output_line['duration'] = linedata[14].replace('(', '').replace(')', '')
|
||||
if len(linedata) > 14:
|
||||
output_line['duration'] = linedata[14].replace('(', '').replace(')', '')
|
||||
else: # normal last support
|
||||
output_line['login'] = ' '.join(linedata[3:7])
|
||||
|
||||
# normal last support
|
||||
else:
|
||||
output_line['login'] = ' '.join(linedata[3:7])
|
||||
if len(linedata) > 8:
|
||||
output_line['logout'] = linedata[8]
|
||||
|
||||
if len(linedata) > 8:
|
||||
output_line['logout'] = linedata[8]
|
||||
if len(linedata) > 9:
|
||||
output_line['duration'] = linedata[9].replace('(', '').replace(')', '')
|
||||
|
||||
if len(linedata) > 9:
|
||||
output_line['duration'] = linedata[9].replace('(', '').replace(')', '')
|
||||
|
||||
raw_output.append(output_line)
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return _process(raw_output)
|
||||
|
||||
return _process(raw_output)
|
||||
|
||||
162
jc/parsers/lsattr.py
Normal file
162
jc/parsers/lsattr.py
Normal file
@@ -0,0 +1,162 @@
|
||||
"""jc - JSON Convert `lsattr` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsattr | jc --lsattr
|
||||
|
||||
or
|
||||
|
||||
$ jc lsattr
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('lsattr', lsattr_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Information from https://github.com/mirror/busybox/blob/2d4a3d9e6c1493a9520b907e07a41aca90cdfd94/e2fsprogs/e2fs_lib.c#L40
|
||||
used to define field names
|
||||
|
||||
[
|
||||
{
|
||||
"file": string,
|
||||
"compressed_file": Optional[boolean],
|
||||
"compressed_dirty_file": Optional[boolean],
|
||||
"compression_raw_access": Optional[boolean],
|
||||
"secure_deletion": Optional[boolean],
|
||||
"undelete": Optional[boolean],
|
||||
"synchronous_updates": Optional[boolean],
|
||||
"synchronous_directory_updates": Optional[boolean],
|
||||
"immutable": Optional[boolean],
|
||||
"append_only": Optional[boolean],
|
||||
"no_dump": Optional[boolean],
|
||||
"no_atime": Optional[boolean],
|
||||
"compression_requested": Optional[boolean],
|
||||
"encrypted": Optional[boolean],
|
||||
"journaled_data": Optional[boolean],
|
||||
"indexed_directory": Optional[boolean],
|
||||
"no_tailmerging": Optional[boolean],
|
||||
"top_of_directory_hierarchies": Optional[boolean],
|
||||
"extents": Optional[boolean],
|
||||
"no_cow": Optional[boolean],
|
||||
"casefold": Optional[boolean],
|
||||
"inline_data": Optional[boolean],
|
||||
"project_hierarchy": Optional[boolean],
|
||||
"verity": Optional[boolean],
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo lsattr /etc/passwd | jc --lsattr
|
||||
[
|
||||
{
|
||||
"file": "/etc/passwd",
|
||||
"extents": true
|
||||
}
|
||||
]
|
||||
"""
|
||||
from typing import List, Dict
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`lsattr` command parser'
|
||||
author = 'Mark Rotner'
|
||||
author_email = 'rotner.mr@gmail.com'
|
||||
compatible = ['linux']
|
||||
magic_commands = ['lsattr']
|
||||
tags = ['command']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
ERROR_PREFIX = "lsattr:"
|
||||
|
||||
# https://github.com/mirror/busybox/blob/2d4a3d9e6c1493a9520b907e07a41aca90cdfd94/e2fsprogs/e2fs_lib.c#L40
|
||||
# https://github.com/landley/toybox/blob/f1682dc79fd75f64042b5438918fe5a507977e1c/toys/other/lsattr.c#L97
|
||||
ATTRIBUTES = {
|
||||
"B": "compressed_file",
|
||||
"Z": "compressed_dirty_file",
|
||||
"X": "compression_raw_access",
|
||||
"s": "secure_deletion",
|
||||
"u": "undelete",
|
||||
"S": "synchronous_updates",
|
||||
"D": "synchronous_directory_updates",
|
||||
"i": "immutable",
|
||||
"a": "append_only",
|
||||
"d": "no_dump",
|
||||
"A": "no_atime",
|
||||
"c": "compression_requested",
|
||||
"E": "encrypted",
|
||||
"j": "journaled_data",
|
||||
"I": "indexed_directory",
|
||||
"t": "no_tailmerging",
|
||||
"T": "top_of_directory_hierarchies",
|
||||
"e": "extents",
|
||||
"C": "no_cow",
|
||||
"F": "casefold",
|
||||
"N": "inline_data",
|
||||
"P": "project_hierarchy",
|
||||
"V": "verity",
|
||||
}
|
||||
|
||||
|
||||
def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> List[JSONDictType]:
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
output: List = []
|
||||
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if not jc.utils.has_data(data):
|
||||
return output
|
||||
|
||||
for line in cleandata:
|
||||
# -R flag returns the output in the format:
|
||||
# Folder:
|
||||
# attributes file_in_folder
|
||||
if line.endswith(':'):
|
||||
continue
|
||||
|
||||
# lsattr: Operation not supported ....
|
||||
if line.startswith(ERROR_PREFIX):
|
||||
continue
|
||||
|
||||
line_output: Dict = {}
|
||||
|
||||
# attributes file
|
||||
# --------------e----- /etc/passwd
|
||||
attributes, file = line.split()
|
||||
line_output['file'] = file
|
||||
for attribute in list(attributes):
|
||||
attribute_key = ATTRIBUTES.get(attribute)
|
||||
if attribute_key:
|
||||
line_output[attribute_key] = True
|
||||
|
||||
if line_output:
|
||||
output.append(line_output)
|
||||
|
||||
return output
|
||||
89
jc/parsers/lsb_release.py
Normal file
89
jc/parsers/lsb_release.py
Normal file
@@ -0,0 +1,89 @@
|
||||
"""jc - JSON Convert `lsb_release` command parser
|
||||
|
||||
This parser is an alias to the Key/Value parser (`--kv`).
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsb_release -a | jc --lsb-release
|
||||
|
||||
or
|
||||
$ jc lsb_release -a
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('lsb_release', lsb_release_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"<key>": string
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsb_release -a | jc --lsb-release -p
|
||||
{
|
||||
"Distributor ID": "Ubuntu",
|
||||
"Description": "Ubuntu 16.04.6 LTS",
|
||||
"Release": "16.04",
|
||||
"Codename": "xenial"
|
||||
}
|
||||
"""
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.parsers.kv
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`lsb_release` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
details = 'Using the Key/Value parser'
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
magic_commands = ['lsb_release']
|
||||
tags = ['command']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured to conform to the schema.
|
||||
"""
|
||||
return jc.parsers.kv._process(proc_data)
|
||||
|
||||
|
||||
def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> 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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
raw_output = jc.parsers.kv.parse(data, raw, quiet)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
@@ -160,7 +160,7 @@ def _aix_parse(data):
|
||||
|
||||
# AIX mount entries have the remote node as the zeroth element. If the
|
||||
# mount is local, the zeroth element is the filesystem instead. We can
|
||||
# detect this by the lenth of the list. For local mounts, length is 7,
|
||||
# detect this by the length of the list. For local mounts, length is 7,
|
||||
# and for remote mounts, the length is 8. In the remote case, pop off
|
||||
# the zeroth element. Then parsed_line has a consistent format.
|
||||
if len(parsed_line) == 8:
|
||||
|
||||
@@ -355,17 +355,18 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.13'
|
||||
version = '1.15'
|
||||
description = '`netstat` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
compatible = ['linux', 'darwin', 'freebsd']
|
||||
compatible = ['linux', 'darwin', 'freebsd', 'win32']
|
||||
magic_commands = ['netstat']
|
||||
tags = ['command']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
WINDOWS_NETSTAT_HEADER = "Active Connections"
|
||||
|
||||
def _process(proc_data):
|
||||
"""
|
||||
@@ -450,9 +451,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
import jc.parsers.netstat_freebsd_osx
|
||||
raw_output = jc.parsers.netstat_freebsd_osx.parse(cleandata)
|
||||
|
||||
# use linux parser
|
||||
else:
|
||||
elif cleandata[0] == WINDOWS_NETSTAT_HEADER: # use windows parser.
|
||||
import jc.parsers.netstat_windows
|
||||
raw_output = jc.parsers.netstat_windows.parse(cleandata)
|
||||
else: # use linux parser.
|
||||
import jc.parsers.netstat_linux
|
||||
raw_output = jc.parsers.netstat_linux.parse(cleandata)
|
||||
|
||||
|
||||
@@ -31,10 +31,19 @@ def normalize_interface_headers(header):
|
||||
|
||||
|
||||
def parse_network(headers, entry):
|
||||
LIST_OF_STATES = [
|
||||
"ESTABLISHED", "SYN_SENT", "SYN_RECV", "FIN_WAIT1", "FIN_WAIT2",
|
||||
"TIME_WAIT", "CLOSED", "CLOSE_WAIT", "LAST_ACK", "LISTEN", "CLOSING",
|
||||
"UNKNOWN", "7"
|
||||
]
|
||||
|
||||
# split entry based on presence of value in "State" column
|
||||
contains_state = any(state in entry for state in LIST_OF_STATES)
|
||||
split_modifier = 1 if contains_state else 2
|
||||
entry = entry.split(maxsplit=len(headers) - split_modifier)
|
||||
|
||||
# Count words in header
|
||||
# if len of line is one less than len of header, then insert None in field 5
|
||||
entry = entry.split(maxsplit=len(headers) - 1)
|
||||
|
||||
if len(entry) == len(headers) - 1:
|
||||
entry.insert(5, None)
|
||||
|
||||
|
||||
75
jc/parsers/netstat_windows.py
Normal file
75
jc/parsers/netstat_windows.py
Normal file
@@ -0,0 +1,75 @@
|
||||
"""
|
||||
jc - JSON Convert Windows `netstat` command output parser
|
||||
"""
|
||||
|
||||
|
||||
from typing import Dict, List
|
||||
|
||||
POSSIBLE_PROTOCOLS = ("TCP", "UDP", "TCPv6", "UDPv6")
|
||||
|
||||
def normalize_headers(headers: str):
|
||||
"""
|
||||
Normalizes the headers to match the jc netstat parser style
|
||||
(local_address -> local_address, local_port...).
|
||||
"""
|
||||
|
||||
headers = headers.lower().strip()
|
||||
headers = headers.replace("local address", "local_address")
|
||||
headers = headers.replace("foreign address", "foreign_address")
|
||||
return headers.split()
|
||||
|
||||
|
||||
def parse(cleandata: List[str]):
|
||||
"""
|
||||
Main text parsing function for Windows netstat
|
||||
|
||||
Parameters:
|
||||
|
||||
cleandata: (string) text data to parse
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw structured data.
|
||||
"""
|
||||
|
||||
raw_output = []
|
||||
cleandata.pop(0) # Removing the "Active Connections" header.
|
||||
headers = normalize_headers(cleandata.pop(0))
|
||||
|
||||
for line in cleandata:
|
||||
line = line.strip()
|
||||
|
||||
if not line.startswith(POSSIBLE_PROTOCOLS): # -b.
|
||||
line_data = raw_output.pop(len(raw_output) - 1)
|
||||
line_data['program_name'] = line
|
||||
raw_output.append(line_data)
|
||||
continue
|
||||
|
||||
line_data = line.split()
|
||||
line_data: Dict[str, str] = dict(zip(headers, line_data))
|
||||
for key in list(line_data.keys()):
|
||||
if key == "local_address":
|
||||
local_address, local_port = line_data[key].rsplit(
|
||||
":", maxsplit=1)
|
||||
line_data["local_address"] = local_address
|
||||
line_data["local_port"] = local_port
|
||||
continue
|
||||
|
||||
if key == "foreign_address":
|
||||
foreign_address, foreign_port = line_data[key].rsplit(
|
||||
":", maxsplit=1)
|
||||
line_data["foreign_address"] = foreign_address
|
||||
line_data["foreign_port"] = foreign_port
|
||||
continue
|
||||
|
||||
# There is no state in UDP, so the data after the "state" header will leak.
|
||||
if key == "proto" and "state" in headers and line_data["proto"] == "UDP":
|
||||
next_header = headers.index("state") + 1
|
||||
if len(headers) > next_header:
|
||||
next_header = headers[next_header]
|
||||
line_data[next_header] = line_data["state"]
|
||||
line_data["state"] = ''
|
||||
|
||||
raw_output.append(line_data)
|
||||
|
||||
return raw_output
|
||||
236
jc/parsers/nsd_control.py
Normal file
236
jc/parsers/nsd_control.py
Normal file
@@ -0,0 +1,236 @@
|
||||
"""jc - JSON Convert `nsd-control` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ nsd-control | jc --nsd-control
|
||||
|
||||
or
|
||||
|
||||
$ jc nsd-control
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('nsd_control', nsd_control_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"version": string,
|
||||
"verbosity": integer,
|
||||
"ratelimit": integer
|
||||
}
|
||||
]
|
||||
|
||||
[
|
||||
{
|
||||
"zone": string
|
||||
"status": {
|
||||
"state": string,
|
||||
"served-serial": string,
|
||||
"commit-serial": string,
|
||||
"wait": string
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ nsd-control | jc --nsd-control status
|
||||
[
|
||||
{
|
||||
"version": "4.6.2",
|
||||
"verbosity": "2",
|
||||
"ratelimit": "0"
|
||||
}
|
||||
]
|
||||
|
||||
$ nsd-control | jc --nsd-control zonestatus sunet.se
|
||||
[
|
||||
{
|
||||
"zone": "sunet.se",
|
||||
"status": {
|
||||
"state": "ok",
|
||||
"served-serial": "2023090704 since 2023-09-07T16:34:27",
|
||||
"commit-serial": "2023090704 since 2023-09-07T16:34:27",
|
||||
"wait": "28684 sec between attempts"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
from typing import List, Dict
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`nsd-control` command parser'
|
||||
author = 'Pettai'
|
||||
author_email = 'pettai@sunet.se'
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
tags = ['command']
|
||||
magic_commands = ['nsd-control']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured to conform to the schema.
|
||||
"""
|
||||
int_list = {'verbosity', 'ratelimit', 'wait'}
|
||||
|
||||
for entry in proc_data:
|
||||
for key in entry:
|
||||
if key in int_list:
|
||||
entry[key] = jc.utils.convert_to_int(entry[key])
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False):
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output: List[Dict] = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
itrparse = False
|
||||
itr: Dict = {}
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
line = line.strip()
|
||||
|
||||
# default 'ok'
|
||||
if line.startswith('ok'):
|
||||
raw_output.append({'command': 'ok'})
|
||||
continue
|
||||
|
||||
# status
|
||||
if line.startswith('version:'):
|
||||
status = {}
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
version = linedata[1].strip()
|
||||
status.update({'version': version})
|
||||
continue
|
||||
|
||||
if line.startswith('verbosity:'):
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
verbosity = linedata[1]
|
||||
status.update({'verbosity': verbosity})
|
||||
continue
|
||||
|
||||
if line.startswith('ratelimit:'):
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
ratelimit = linedata[1]
|
||||
status.update({'ratelimit': ratelimit})
|
||||
raw_output.append(status)
|
||||
continue
|
||||
|
||||
# print_cookie_secrets
|
||||
if line.startswith('active'):
|
||||
itrparse = True
|
||||
itr = {}
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
active = linedata[1].strip()
|
||||
itr.update({'active': active})
|
||||
continue
|
||||
|
||||
if line.startswith('staging'):
|
||||
linedata = line.split(':', maxsplit=1)
|
||||
staging = linedata[1].strip()
|
||||
itr.update({'staging': staging})
|
||||
continue
|
||||
|
||||
# print_tsig
|
||||
if line.startswith('key:'):
|
||||
tsigs = {}
|
||||
tsigdata = dict()
|
||||
linedata = line.split(' ', maxsplit=6)
|
||||
name = linedata[2].strip('"').rstrip('"')
|
||||
tsigdata.update({'name': name})
|
||||
secret = linedata[4].strip('"').rstrip('"')
|
||||
tsigdata.update({'secret': secret})
|
||||
algorithm = linedata[6].strip('"').rstrip('"')
|
||||
tsigdata.update({'algorithm': algorithm})
|
||||
tsigs.update({'key': tsigdata})
|
||||
raw_output.append(tsigs)
|
||||
continue
|
||||
|
||||
# zonestatus
|
||||
if line.startswith('zone:'):
|
||||
zonename: Dict = dict()
|
||||
zstatus: Dict = dict()
|
||||
linedata = line.split(':\t', maxsplit=1)
|
||||
zone = linedata[1]
|
||||
zonename.update({'zone': zone})
|
||||
continue
|
||||
|
||||
if line.startswith('state:'):
|
||||
linedata = line.split(': ', maxsplit=1)
|
||||
state = linedata[1]
|
||||
zstatus.update({'state': state})
|
||||
continue
|
||||
|
||||
if line.startswith('served-serial:'):
|
||||
linedata = line.split(': ', maxsplit=1)
|
||||
served = linedata[1].strip('"').rstrip('"')
|
||||
zstatus.update({'served-serial': served})
|
||||
continue
|
||||
|
||||
if line.startswith('commit-serial:'):
|
||||
linedata = line.split(': ', maxsplit=1)
|
||||
commit = linedata[1].strip('"').rstrip('"')
|
||||
zstatus.update({'commit-serial': commit})
|
||||
continue
|
||||
|
||||
if line.startswith('wait:'):
|
||||
linedata = line.split(': ', maxsplit=1)
|
||||
wait = linedata[1].strip('"').rstrip('"')
|
||||
zstatus.update({'wait': wait})
|
||||
zonename.update({'status': zstatus})
|
||||
raw_output.append(zonename)
|
||||
continue
|
||||
|
||||
# stats
|
||||
if line.startswith('server') or line.startswith('num.') or line.startswith('size.') or line.startswith('time.') or line.startswith('zone.'):
|
||||
itrparse = True
|
||||
linedata = line.split('=', maxsplit=1)
|
||||
key = linedata[0]
|
||||
if key.startswith('time.'):
|
||||
value = float(linedata[1])
|
||||
else:
|
||||
value = int(linedata[1])
|
||||
itr.update({key: value})
|
||||
continue
|
||||
|
||||
if itrparse:
|
||||
raw_output.append(itr)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
113
jc/parsers/os_release.py
Normal file
113
jc/parsers/os_release.py
Normal file
@@ -0,0 +1,113 @@
|
||||
"""jc - JSON Convert `/etc/os-release` file parser
|
||||
|
||||
This parser is an alias to the Key/Value parser (`--kv`).
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/os-release | jc --os-release
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('os_release', os_release_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"<key>": string
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/os-release | jc --os-release -p
|
||||
{
|
||||
"NAME": "CentOS Linux",
|
||||
"VERSION": "7 (Core)",
|
||||
"ID": "centos",
|
||||
"ID_LIKE": "rhel fedora",
|
||||
"VERSION_ID": "7",
|
||||
"PRETTY_NAME": "CentOS Linux 7 (Core)",
|
||||
"ANSI_COLOR": "0;31",
|
||||
"CPE_NAME": "cpe:/o:centos:centos:7",
|
||||
"HOME_URL": "https://www.centos.org/",
|
||||
"BUG_REPORT_URL": "https://bugs.centos.org/",
|
||||
"CENTOS_MANTISBT_PROJECT": "CentOS-7",
|
||||
"CENTOS_MANTISBT_PROJECT_VERSION": "7",
|
||||
"REDHAT_SUPPORT_PRODUCT": "centos",
|
||||
"REDHAT_SUPPORT_PRODUCT_VERSION": "7"
|
||||
}
|
||||
|
||||
$ cat /etc/os-release | jc --os-release -p -r
|
||||
{
|
||||
"NAME": "\\"CentOS Linux\\"",
|
||||
"VERSION": "\\"7 (Core)\\"",
|
||||
"ID": "\\"centos\\"",
|
||||
"ID_LIKE": "\\"rhel fedora\\"",
|
||||
"VERSION_ID": "\\"7\\"",
|
||||
"PRETTY_NAME": "\\"CentOS Linux 7 (Core)\\"",
|
||||
"ANSI_COLOR": "\\"0;31\\"",
|
||||
"CPE_NAME": "\\"cpe:/o:centos:centos:7\\"",
|
||||
"HOME_URL": "\\"https://www.centos.org/\\"",
|
||||
"BUG_REPORT_URL": "\\"https://bugs.centos.org/\\"",
|
||||
"CENTOS_MANTISBT_PROJECT": "\\"CentOS-7\\"",
|
||||
"CENTOS_MANTISBT_PROJECT_VERSION": "\\"7\\"",
|
||||
"REDHAT_SUPPORT_PRODUCT": "\\"centos\\"",
|
||||
"REDHAT_SUPPORT_PRODUCT_VERSION": "\\"7\\""
|
||||
}
|
||||
"""
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.parsers.kv
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`/etc/os-release` file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
details = 'Using the Key/Value parser'
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
tags = ['file', 'standard', 'string']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured to conform to the schema.
|
||||
"""
|
||||
return jc.parsers.kv._process(proc_data)
|
||||
|
||||
|
||||
def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> 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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
raw_output = jc.parsers.kv.parse(data, raw, quiet)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
@@ -40,6 +40,9 @@ Schema:
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"usr_ms": integer,
|
||||
"system_ms": integer,
|
||||
"guest_ms": integer,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
@@ -128,7 +131,7 @@ from jc.exceptions import ParseError
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = '`pidstat -H` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -152,11 +155,16 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
|
||||
|
||||
List of Dictionaries. Structured to conform to the schema.
|
||||
"""
|
||||
int_list = {'time', 'uid', 'pid', 'cpu', 'vsz', 'rss', 'stksize', 'stkref'}
|
||||
int_list = {
|
||||
'time', 'uid', 'pid', 'cpu', 'vsz', 'rss', 'stksize', 'stkref',
|
||||
'usr_ms', 'system_ms', 'guest_ms'
|
||||
}
|
||||
|
||||
float_list = {'percent_usr', 'percent_system', 'percent_guest', 'percent_cpu',
|
||||
'minflt_s', 'majflt_s', 'percent_mem', 'kb_rd_s', 'kb_wr_s',
|
||||
'kb_ccwr_s', 'cswch_s', 'nvcswch_s'}
|
||||
float_list = {
|
||||
'percent_usr', 'percent_system', 'percent_guest', 'percent_cpu',
|
||||
'minflt_s', 'majflt_s', 'percent_mem', 'kb_rd_s', 'kb_wr_s',
|
||||
'kb_ccwr_s', 'cswch_s', 'nvcswch_s', 'percent_wait'
|
||||
}
|
||||
|
||||
for entry in proc_data:
|
||||
for key in entry:
|
||||
@@ -169,6 +177,14 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
|
||||
return proc_data
|
||||
|
||||
|
||||
def normalize_header(header: str) -> str:
|
||||
return header.replace('#', ' ')\
|
||||
.replace('-', '_')\
|
||||
.replace('/', '_')\
|
||||
.replace('%', 'percent_')\
|
||||
.lower()
|
||||
|
||||
|
||||
def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
@@ -191,29 +207,28 @@ def parse(
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output: List = []
|
||||
table_list: List = []
|
||||
header_found = False
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# check for line starting with # as the start of the table
|
||||
data_list = list(filter(None, data.splitlines()))
|
||||
for line in data_list.copy():
|
||||
if line.startswith('#'):
|
||||
break
|
||||
else:
|
||||
data_list.pop(0)
|
||||
|
||||
if not data_list:
|
||||
for line in data_list:
|
||||
if line.startswith('#'):
|
||||
header_found = True
|
||||
if len(table_list) > 1:
|
||||
raw_output.extend(simple_table_parse(table_list))
|
||||
table_list = [normalize_header(line)]
|
||||
continue
|
||||
|
||||
if header_found:
|
||||
table_list.append(line)
|
||||
|
||||
if len(table_list) > 1:
|
||||
raw_output.extend(simple_table_parse(table_list))
|
||||
|
||||
if not header_found:
|
||||
raise ParseError('Could not parse pidstat output. Make sure to use "pidstat -h".')
|
||||
|
||||
# normalize header
|
||||
data_list[0] = data_list[0].replace('#', ' ')\
|
||||
.replace('/', '_')\
|
||||
.replace('%', 'percent_')\
|
||||
.lower()
|
||||
|
||||
# remove remaining header lines (e.g. pidstat -H 2 5)
|
||||
data_list = [i for i in data_list if not i.startswith('#')]
|
||||
|
||||
raw_output = simple_table_parse(data_list)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
|
||||
@@ -34,6 +34,7 @@ Schema:
|
||||
"percent_usr": float,
|
||||
"percent_system": float,
|
||||
"percent_guest": float,
|
||||
"percent_wait": float,
|
||||
"percent_cpu": float,
|
||||
"cpu": integer,
|
||||
"minflt_s": float,
|
||||
@@ -48,6 +49,9 @@ Schema:
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"usr_ms": integer,
|
||||
"system_ms": integer,
|
||||
"guest_ms": integer,
|
||||
"command": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
@@ -72,7 +76,7 @@ Examples:
|
||||
{"time":"1646859134","uid":"0","pid":"9","percent_usr":"0.00","perc...}
|
||||
...
|
||||
"""
|
||||
from typing import Dict, Iterable, Union
|
||||
from typing import List, Dict, Iterable, Union
|
||||
import jc.utils
|
||||
from jc.streaming import (
|
||||
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
||||
@@ -83,7 +87,7 @@ from jc.exceptions import ParseError
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = '`pidstat -H` command streaming parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -107,11 +111,16 @@ def _process(proc_data: Dict) -> Dict:
|
||||
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
int_list = {'time', 'uid', 'pid', 'cpu', 'vsz', 'rss', 'stksize', 'stkref'}
|
||||
int_list = {
|
||||
'time', 'uid', 'pid', 'cpu', 'vsz', 'rss', 'stksize', 'stkref',
|
||||
'usr_ms', 'system_ms', 'guest_ms'
|
||||
}
|
||||
|
||||
float_list = {'percent_usr', 'percent_system', 'percent_guest', 'percent_cpu',
|
||||
'minflt_s', 'majflt_s', 'percent_mem', 'kb_rd_s', 'kb_wr_s',
|
||||
'kb_ccwr_s', 'cswch_s', 'nvcswch_s'}
|
||||
float_list = {
|
||||
'percent_usr', 'percent_system', 'percent_guest', 'percent_wait',
|
||||
'percent_cpu', 'minflt_s', 'majflt_s', 'percent_mem', 'kb_rd_s',
|
||||
'kb_wr_s', 'kb_ccwr_s', 'cswch_s', 'nvcswch_s'
|
||||
}
|
||||
|
||||
for key in proc_data:
|
||||
if key in int_list:
|
||||
@@ -123,6 +132,14 @@ def _process(proc_data: Dict) -> Dict:
|
||||
return proc_data
|
||||
|
||||
|
||||
def normalize_header(header: str) -> str:
|
||||
return header.replace('#', ' ')\
|
||||
.replace('-', '_')\
|
||||
.replace('/', '_')\
|
||||
.replace('%', 'percent_')\
|
||||
.lower()
|
||||
|
||||
|
||||
@add_jc_meta
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
@@ -149,8 +166,8 @@ def parse(
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
streaming_input_type_check(data)
|
||||
|
||||
found_first_hash = False
|
||||
header = ''
|
||||
table_list: List = []
|
||||
header: str = ''
|
||||
|
||||
for line in data:
|
||||
try:
|
||||
@@ -161,29 +178,30 @@ def parse(
|
||||
# skip blank lines
|
||||
continue
|
||||
|
||||
if not line.startswith('#') and not found_first_hash:
|
||||
# skip preamble lines before header row
|
||||
if line.startswith('#'):
|
||||
if len(table_list) > 1:
|
||||
output_line = simple_table_parse(table_list)[0]
|
||||
yield output_line if raw else _process(output_line)
|
||||
header = ''
|
||||
|
||||
header = normalize_header(line)
|
||||
table_list = [header]
|
||||
continue
|
||||
|
||||
if line.startswith('#') and not found_first_hash:
|
||||
# normalize header
|
||||
header = line.replace('#', ' ')\
|
||||
.replace('/', '_')\
|
||||
.replace('%', 'percent_')\
|
||||
.lower()
|
||||
found_first_hash = True
|
||||
continue
|
||||
|
||||
if line.startswith('#') and found_first_hash:
|
||||
# skip header lines after first one is found
|
||||
continue
|
||||
|
||||
output_line = simple_table_parse([header, line])[0]
|
||||
|
||||
if output_line:
|
||||
if header:
|
||||
table_list.append(line)
|
||||
output_line = simple_table_parse(table_list)[0]
|
||||
yield output_line if raw else _process(output_line)
|
||||
else:
|
||||
raise ParseError('Not pidstat data')
|
||||
table_list = [header]
|
||||
continue
|
||||
|
||||
except Exception as e:
|
||||
yield raise_or_yield(ignore_exceptions, e, line)
|
||||
|
||||
try:
|
||||
if len(table_list) > 1:
|
||||
output_line = simple_table_parse(table_list)[0]
|
||||
yield output_line if raw else _process(output_line)
|
||||
|
||||
except Exception as e:
|
||||
yield raise_or_yield(ignore_exceptions, e, str(table_list))
|
||||
|
||||
@@ -30,6 +30,8 @@ Schema:
|
||||
"packets_received": integer,
|
||||
"packet_loss_percent": float,
|
||||
"duplicates": integer,
|
||||
"errors": integer,
|
||||
"corrupted": integer,
|
||||
"round_trip_ms_min": float,
|
||||
"round_trip_ms_avg": float,
|
||||
"round_trip_ms_max": float,
|
||||
@@ -157,6 +159,7 @@ Examples:
|
||||
]
|
||||
}
|
||||
"""
|
||||
import re
|
||||
import string
|
||||
import ipaddress
|
||||
import jc.utils
|
||||
@@ -164,7 +167,7 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.8'
|
||||
version = '1.10'
|
||||
description = '`ping` and `ping6` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -190,7 +193,7 @@ def _process(proc_data):
|
||||
"""
|
||||
int_list = {
|
||||
'data_bytes', 'packets_transmitted', 'packets_received', 'bytes', 'icmp_seq', 'ttl',
|
||||
'duplicates', 'vr', 'hl', 'tos', 'len', 'id', 'flg', 'off', 'pro', 'cks'
|
||||
'duplicates', 'corrupted', 'errors', 'vr', 'hl', 'tos', 'len', 'id', 'flg', 'off', 'pro', 'cks'
|
||||
}
|
||||
|
||||
float_list = {
|
||||
@@ -284,6 +287,8 @@ def _linux_parse(data):
|
||||
|
||||
if ipv4 and linedata[0][5] not in string.digits:
|
||||
hostname = True
|
||||
# fixup for missing hostname
|
||||
linedata[0] = linedata[0][:5] + 'nohost' + linedata[0][5:]
|
||||
elif ipv4 and linedata[0][5] in string.digits:
|
||||
hostname = False
|
||||
elif not ipv4 and ' (' in linedata[0]:
|
||||
@@ -314,45 +319,52 @@ def _linux_parse(data):
|
||||
|
||||
if line.startswith('---'):
|
||||
footer = True
|
||||
raw_output['destination'] = line.split()[1]
|
||||
if line[4] != ' ': # fixup for missing hostname
|
||||
raw_output['destination'] = line.split()[1]
|
||||
continue
|
||||
|
||||
if footer:
|
||||
if 'packets transmitted' in line:
|
||||
if ' duplicates,' in line:
|
||||
raw_output.update(
|
||||
{
|
||||
'packets_transmitted': line.split()[0],
|
||||
'packets_received': line.split()[3],
|
||||
'packet_loss_percent': line.split()[7].rstrip('%'),
|
||||
'duplicates': line.split()[5].lstrip('+'),
|
||||
'time_ms': line.split()[11].replace('ms', '')
|
||||
}
|
||||
)
|
||||
continue
|
||||
else:
|
||||
raw_output.update(
|
||||
{
|
||||
'packets_transmitted': line.split()[0],
|
||||
'packets_received': line.split()[3],
|
||||
'packet_loss_percent': line.split()[5].rstrip('%'),
|
||||
'duplicates': '0',
|
||||
'time_ms': line.split()[9].replace('ms', '')
|
||||
}
|
||||
)
|
||||
continue
|
||||
# Init in zero, to keep compatibility with previous behaviour
|
||||
if 'duplicates' not in raw_output:
|
||||
raw_output['duplicates'] = '0'
|
||||
|
||||
else:
|
||||
split_line = line.split(' = ')[1]
|
||||
split_line = split_line.split('/')
|
||||
raw_output.update(
|
||||
{
|
||||
'round_trip_ms_min': split_line[0],
|
||||
'round_trip_ms_avg': split_line[1],
|
||||
'round_trip_ms_max': split_line[2],
|
||||
'round_trip_ms_stddev': split_line[3].split()[0]
|
||||
}
|
||||
)
|
||||
#
|
||||
# See: https://github.com/dgibson/iputils/blob/master/ping_common.c#L995
|
||||
#
|
||||
m = re.search(r'(\d+) packets transmitted', line)
|
||||
if m:
|
||||
raw_output['packets_transmitted'] = m.group(1)
|
||||
|
||||
m = re.search(r'(\d+) received,', line)
|
||||
if m:
|
||||
raw_output['packets_received'] = m.group(1)
|
||||
|
||||
m = re.search(r'[+](\d+) duplicates', line)
|
||||
if m:
|
||||
raw_output['duplicates'] = m.group(1)
|
||||
|
||||
m = re.search(r'[+](\d+) corrupted', line)
|
||||
if m:
|
||||
raw_output['corrupted'] = m.group(1)
|
||||
|
||||
m = re.search(r'[+](\d+) errors', line)
|
||||
if m:
|
||||
raw_output['errors'] = m.group(1)
|
||||
|
||||
m = re.search(r'([\d\.]+)% packet loss', line)
|
||||
if m:
|
||||
raw_output['packet_loss_percent'] = m.group(1)
|
||||
|
||||
m = re.search(r'time (\d+)ms', line)
|
||||
if m:
|
||||
raw_output['time_ms'] = m.group(1)
|
||||
|
||||
m = re.search(r'rtt min\/avg\/max\/mdev += +([\d\.]+)\/([\d\.]+)\/([\d\.]+)\/([\d\.]+) ms', line)
|
||||
if m:
|
||||
raw_output['round_trip_ms_min'] = m.group(1)
|
||||
raw_output['round_trip_ms_avg'] = m.group(2)
|
||||
raw_output['round_trip_ms_max'] = m.group(3)
|
||||
raw_output['round_trip_ms_stddev'] = m.group(4)
|
||||
|
||||
# ping response lines
|
||||
else:
|
||||
|
||||
@@ -31,7 +31,7 @@ Schema:
|
||||
"source_ip": string,
|
||||
"destination_ip": string,
|
||||
"sent_bytes": integer,
|
||||
"pattern": string, # (null if not set)
|
||||
"pattern": string, # null if not set
|
||||
"destination": string,
|
||||
"timestamp": float,
|
||||
"response_bytes": integer,
|
||||
@@ -44,10 +44,12 @@ Schema:
|
||||
"packets_received": integer,
|
||||
"packet_loss_percent": float,
|
||||
"duplicates": integer,
|
||||
"round_trip_ms_min": float,
|
||||
"round_trip_ms_avg": float,
|
||||
"round_trip_ms_max": float,
|
||||
"round_trip_ms_stddev": float,
|
||||
"errors": integer, # null if not set
|
||||
"corrupted": integer, # null if not set
|
||||
"round_trip_ms_min": float, # null if not set
|
||||
"round_trip_ms_avg": float, # null if not set
|
||||
"round_trip_ms_max": float, # null if not set
|
||||
"round_trip_ms_stddev": float, # null if not set
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
@@ -74,6 +76,7 @@ Examples:
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||
...
|
||||
"""
|
||||
import re
|
||||
import string
|
||||
import ipaddress
|
||||
import jc.utils
|
||||
@@ -85,7 +88,7 @@ from jc.exceptions import ParseError
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.2'
|
||||
version = '1.4'
|
||||
description = '`ping` and `ping6` command streaming parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -110,13 +113,14 @@ def _process(proc_data):
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
int_list = {
|
||||
'sent_bytes', 'packets_transmitted', 'packets_received', 'response_bytes', 'icmp_seq',
|
||||
'ttl', 'duplicates', 'vr', 'hl', 'tos', 'len', 'id', 'flg', 'off', 'pro', 'cks'
|
||||
'sent_bytes', 'packets_transmitted', 'packets_received',
|
||||
'response_bytes', 'icmp_seq', 'ttl', 'duplicates', 'vr', 'hl', 'tos',
|
||||
'len', 'id', 'flg', 'off', 'pro', 'cks', 'errors', 'corrupted'
|
||||
}
|
||||
|
||||
float_list = {
|
||||
'packet_loss_percent', 'round_trip_ms_min', 'round_trip_ms_avg', 'round_trip_ms_max',
|
||||
'round_trip_ms_stddev', 'timestamp', 'time_ms'
|
||||
'packet_loss_percent', 'round_trip_ms_min', 'round_trip_ms_avg',
|
||||
'round_trip_ms_max', 'round_trip_ms_stddev', 'timestamp', 'time_ms'
|
||||
}
|
||||
|
||||
for key in proc_data:
|
||||
@@ -144,6 +148,12 @@ class _state:
|
||||
packet_loss_percent = None
|
||||
time_ms = None
|
||||
duplicates = None
|
||||
corrupted = None
|
||||
errors = None
|
||||
round_trip_ms_min = None
|
||||
round_trip_ms_avg = None
|
||||
round_trip_ms_max = None
|
||||
round_trip_ms_stddev = None
|
||||
|
||||
|
||||
def _ipv6_in(line):
|
||||
@@ -340,6 +350,8 @@ def _linux_parse(line, s):
|
||||
|
||||
if s.ipv4 and line[5] not in string.digits:
|
||||
s.hostname = True
|
||||
# fixup for missing hostname
|
||||
line = line[:5] + 'nohost' + line[5:]
|
||||
elif s.ipv4 and line[5] in string.digits:
|
||||
s.hostname = False
|
||||
elif not s.ipv4 and ' (' in line:
|
||||
@@ -367,24 +379,44 @@ def _linux_parse(line, s):
|
||||
return None
|
||||
|
||||
if s.footer:
|
||||
if 'packets transmitted' in line:
|
||||
if ' duplicates,' in line:
|
||||
s.packets_transmitted = line.split()[0]
|
||||
s.packets_received = line.split()[3]
|
||||
s.packet_loss_percent = line.split()[7].rstrip('%')
|
||||
s.duplicates = line.split()[5].lstrip('+')
|
||||
s.time_ms = line.split()[11].replace('ms', '')
|
||||
return None
|
||||
#
|
||||
# See: https://github.com/dgibson/iputils/blob/master/ping_common.c#L995
|
||||
#
|
||||
m = re.search(r'(\d+) packets transmitted', line)
|
||||
if m:
|
||||
s.packets_transmitted = m.group(1)
|
||||
|
||||
s.packets_transmitted = line.split()[0]
|
||||
s.packets_received = line.split()[3]
|
||||
s.packet_loss_percent = line.split()[5].rstrip('%')
|
||||
s.duplicates = '0'
|
||||
s.time_ms = line.split()[9].replace('ms', '')
|
||||
return None
|
||||
m = re.search(r'(\d+) received,', line)
|
||||
if m:
|
||||
s.packets_received = m.group(1)
|
||||
|
||||
m = re.search(r'[+](\d+) duplicates', line)
|
||||
if m:
|
||||
s.duplicates = m.group(1)
|
||||
|
||||
m = re.search(r'[+](\d+) corrupted', line)
|
||||
if m:
|
||||
s.corrupted = m.group(1)
|
||||
|
||||
m = re.search(r'[+](\d+) errors', line)
|
||||
if m:
|
||||
s.errors = m.group(1)
|
||||
|
||||
m = re.search(r'([\d\.]+)% packet loss', line)
|
||||
if m:
|
||||
s.packet_loss_percent = m.group(1)
|
||||
|
||||
m = re.search(r'time (\d+)ms', line)
|
||||
if m:
|
||||
s.time_ms = m.group(1)
|
||||
|
||||
m = re.search(r'rtt min\/avg\/max\/mdev += +([\d\.]+)\/([\d\.]+)\/([\d\.]+)\/([\d\.]+) ms', line)
|
||||
if m:
|
||||
s.round_trip_ms_min = m.group(1)
|
||||
s.round_trip_ms_avg = m.group(2)
|
||||
s.round_trip_ms_max = m.group(3)
|
||||
s.round_trip_ms_stddev = m.group(4)
|
||||
|
||||
split_line = line.split(' = ')[1]
|
||||
split_line = split_line.split('/')
|
||||
output_line = {
|
||||
'type': 'summary',
|
||||
'destination_ip': s.destination_ip or None,
|
||||
@@ -392,15 +424,16 @@ def _linux_parse(line, s):
|
||||
'pattern': s.pattern or None,
|
||||
'packets_transmitted': s.packets_transmitted or None,
|
||||
'packets_received': s.packets_received or None,
|
||||
'packet_loss_percent': s.packet_loss_percent or None,
|
||||
'duplicates': s.duplicates or None,
|
||||
'time_ms': s.time_ms or None,
|
||||
'round_trip_ms_min': split_line[0],
|
||||
'round_trip_ms_avg': split_line[1],
|
||||
'round_trip_ms_max': split_line[2],
|
||||
'round_trip_ms_stddev': split_line[3].split()[0]
|
||||
'packet_loss_percent': s.packet_loss_percent,
|
||||
'duplicates': s.duplicates or '0',
|
||||
'errors': s.errors,
|
||||
'corrupted': s.corrupted,
|
||||
'time_ms': s.time_ms,
|
||||
'round_trip_ms_min': s.round_trip_ms_min,
|
||||
'round_trip_ms_avg': s.round_trip_ms_avg,
|
||||
'round_trip_ms_max': s.round_trip_ms_max,
|
||||
'round_trip_ms_stddev': s.round_trip_ms_stddev
|
||||
}
|
||||
|
||||
return output_line
|
||||
|
||||
# ping response lines
|
||||
@@ -486,6 +519,7 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
streaming_input_type_check(data)
|
||||
|
||||
s = _state()
|
||||
summary_obj = {}
|
||||
|
||||
for line in data:
|
||||
try:
|
||||
@@ -526,6 +560,12 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
if s.os_detected and s.linux:
|
||||
output_line = _linux_parse(line, s)
|
||||
|
||||
# summary can be multiple lines so don't output until the end
|
||||
if output_line:
|
||||
if output_line.get('type', None) == 'summary':
|
||||
summary_obj = output_line
|
||||
continue
|
||||
|
||||
elif s.os_detected and s.bsd:
|
||||
output_line = _bsd_parse(line, s)
|
||||
|
||||
@@ -540,3 +580,10 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
|
||||
except Exception as e:
|
||||
yield raise_or_yield(ignore_exceptions, e, line)
|
||||
|
||||
# yield summary, if it exists
|
||||
try:
|
||||
if summary_obj:
|
||||
yield summary_obj if raw else _process(summary_obj)
|
||||
except Exception as e:
|
||||
yield raise_or_yield(ignore_exceptions, e, str(summary_obj))
|
||||
|
||||
@@ -194,6 +194,7 @@ def parse(
|
||||
net_packet_p = re.compile(r'^sk RefCnt Type Proto Iface R Rmem User Inode\n')
|
||||
net_protocols_p = re.compile(r'^protocol size sockets memory press maxhdr slab module cl co di ac io in de sh ss gs se re sp bi br ha uh gp em\n')
|
||||
net_route_p = re.compile(r'^Iface\tDestination\tGateway \tFlags\tRefCnt\tUse\tMetric\tMask\t\tMTU\tWindow\tIRTT\s+\n')
|
||||
net_tcp_p = re.compile(r'^\s+sl\s+local_address\s+(?:rem_address|remote_address)\s+st\s+tx_queue\s+rx_queue\s+tr\s+tm->when\s+retrnsmt\s+uid\s+timeout\s+inode')
|
||||
net_unix_p = re.compile(r'^Num RefCount Protocol Flags Type St Inode Path\n')
|
||||
|
||||
pid_fdinfo_p = re.compile(r'^pos:\t\d+\nflags:\t\d+\nmnt_id:\t\d+\n')
|
||||
@@ -249,6 +250,7 @@ def parse(
|
||||
net_packet_p: 'proc_net_packet',
|
||||
net_protocols_p: 'proc_net_protocols',
|
||||
net_route_p: 'proc_net_route',
|
||||
net_tcp_p: 'proc_net_tcp',
|
||||
net_unix_p: 'proc_net_unix',
|
||||
net_ipv6_route_p: 'proc_net_ipv6_route', # before net_dev_mcast
|
||||
net_dev_mcast_p: 'proc_net_dev_mcast', # after net_ipv6_route
|
||||
|
||||
293
jc/parsers/proc_net_tcp.py
Normal file
293
jc/parsers/proc_net_tcp.py
Normal file
@@ -0,0 +1,293 @@
|
||||
"""jc - JSON Convert `/proc/net/tcp` and `proc/net/tcp6` file parser
|
||||
|
||||
IPv4 and IPv6 addresses are converted to standard notation unless the raw
|
||||
(--raw) option is used.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc
|
||||
|
||||
or
|
||||
|
||||
$ jc /proc/net/tcp
|
||||
|
||||
or
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc-net-tcp
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('proc', proc_net_tcp_file)
|
||||
|
||||
or
|
||||
|
||||
import jc
|
||||
result = jc.parse('proc_net_tcp', proc_net_tcp_file)
|
||||
|
||||
Schema:
|
||||
|
||||
Field names and types gathered from the following:
|
||||
|
||||
https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt
|
||||
|
||||
https://github.com/torvalds/linux/blob/master/net/ipv4/tcp_ipv4.c
|
||||
|
||||
https://github.com/torvalds/linux/blob/master/net/ipv6/tcp_ipv6.c
|
||||
|
||||
[
|
||||
{
|
||||
"entry": integer,
|
||||
"local_address": string,
|
||||
"local_port": integer,
|
||||
"remote_address": string,
|
||||
"remote_port": integer,
|
||||
"state": string,
|
||||
"tx_queue": string,
|
||||
"rx_queue": string,
|
||||
"timer_active": integer,
|
||||
"jiffies_until_timer_expires": string,
|
||||
"unrecovered_rto_timeouts": string,
|
||||
"uid": integer,
|
||||
"unanswered_0_window_probes": integer,
|
||||
"inode": integer,
|
||||
"sock_ref_count": integer,
|
||||
"sock_mem_loc": string,
|
||||
"retransmit_timeout": integer,
|
||||
"soft_clock_tick": integer,
|
||||
"ack_quick_pingpong": integer,
|
||||
"sending_congestion_window": integer,
|
||||
"slow_start_size_threshold": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc -p
|
||||
[
|
||||
{
|
||||
"entry": "0",
|
||||
"local_address": "10.0.0.28",
|
||||
"local_port": 42082,
|
||||
"remote_address": "64.12.0.108",
|
||||
"remote_port": 80,
|
||||
"state": "04",
|
||||
"tx_queue": "00000001",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": 1,
|
||||
"jiffies_until_timer_expires": "00000015",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": 0,
|
||||
"unanswered_0_window_probes": 0,
|
||||
"inode": 0,
|
||||
"sock_ref_count": 3,
|
||||
"sock_mem_loc": "ffff8c7a0de930c0",
|
||||
"retransmit_timeout": 21,
|
||||
"soft_clock_tick": 4,
|
||||
"ack_quick_pingpong": 30,
|
||||
"sending_congestion_window": 10,
|
||||
"slow_start_size_threshold": -1
|
||||
},
|
||||
{
|
||||
"entry": "1",
|
||||
"local_address": "10.0.0.28",
|
||||
"local_port": 38864,
|
||||
"remote_address": "104.244.42.65",
|
||||
"remote_port": 80,
|
||||
"state": "06",
|
||||
"tx_queue": "00000000",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": 3,
|
||||
"jiffies_until_timer_expires": "000007C5",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": 0,
|
||||
"unanswered_0_window_probes": 0,
|
||||
"inode": 0,
|
||||
"sock_ref_count": 3,
|
||||
"sock_mem_loc": "ffff8c7a12d31aa0"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ cat /proc/net/tcp | jc --proc -p -r
|
||||
[
|
||||
{
|
||||
"entry": "1",
|
||||
"local_address": "1C00000A",
|
||||
"local_port": "A462",
|
||||
"remote_address": "6C000C40",
|
||||
"remote_port": "0050",
|
||||
"state": "04",
|
||||
"tx_queue": "00000001",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": "01",
|
||||
"jiffies_until_timer_expires": "00000015",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": "0",
|
||||
"unanswered_0_window_probes": "0",
|
||||
"inode": "0",
|
||||
"sock_ref_count": "3",
|
||||
"sock_mem_loc": "ffff8c7a0de930c0",
|
||||
"retransmit_timeout": "21",
|
||||
"soft_clock_tick": "4",
|
||||
"ack_quick_pingpong": "30",
|
||||
"sending_congestion_window": "10",
|
||||
"slow_start_size_threshold": "-1"
|
||||
},
|
||||
{
|
||||
"entry": "2",
|
||||
"local_address": "1C00000A",
|
||||
"local_port": "97D0",
|
||||
"remote_address": "412AF468",
|
||||
"remote_port": "0050",
|
||||
"state": "06",
|
||||
"tx_queue": "00000000",
|
||||
"rx_queue": "00000000",
|
||||
"timer_active": "03",
|
||||
"jiffies_until_timer_expires": "000007C5",
|
||||
"unrecovered_rto_timeouts": "00000000",
|
||||
"uid": "0",
|
||||
"unanswered_0_window_probes": "0",
|
||||
"inode": "0",
|
||||
"sock_ref_count": "3",
|
||||
"sock_mem_loc": "ffff8c7a12d31aa0"
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
import binascii
|
||||
import socket
|
||||
import struct
|
||||
from typing import List, Dict
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`/proc/net/tcp` and `/proc/net/tcp6` file parser'
|
||||
author = 'Alvin Solomon'
|
||||
author_email = 'alvinms01@gmail.com'
|
||||
compatible = ['linux']
|
||||
tags = ['file']
|
||||
hidden = True
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def hex_to_ip(hexaddr: str) -> str:
|
||||
if len(hexaddr) == 8:
|
||||
addr_long = int(hexaddr, 16)
|
||||
return socket.inet_ntop(socket.AF_INET, struct.pack("<L", addr_long))
|
||||
elif len(hexaddr) == 32:
|
||||
addr = binascii.a2b_hex(hexaddr)
|
||||
addr_tup = struct.unpack('>IIII', addr)
|
||||
addr_bytes = struct.pack('@IIII', *addr_tup)
|
||||
return socket.inet_ntop(socket.AF_INET6, addr_bytes)
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
def _process(proc_data: List[Dict]) -> List[Dict]:
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured to conform to the schema.
|
||||
"""
|
||||
int_list = {
|
||||
'timer_active', 'uid', 'unanswered_0_window_probes', 'inode',
|
||||
'sock_ref_count', 'retransmit_timeout', 'soft_clock_tick',
|
||||
'ack_quick_pingpong', 'sending_congestion_window',
|
||||
'slow_start_size_threshold'
|
||||
}
|
||||
|
||||
for entry in proc_data:
|
||||
if 'local_address' in entry:
|
||||
entry['local_address'] = hex_to_ip(entry['local_address'])
|
||||
entry['local_port'] = int(entry['local_port'], 16)
|
||||
entry['remote_address'] = hex_to_ip(entry['remote_address'])
|
||||
entry['remote_port'] = int(entry['remote_port'], 16)
|
||||
|
||||
for item in int_list:
|
||||
if item in entry:
|
||||
entry[item] = jc.utils.convert_to_int(entry[item])
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> List[Dict]:
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output: List = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
line_data = data.splitlines()[1:]
|
||||
|
||||
for entry in line_data:
|
||||
line = entry.split()
|
||||
output_line = {}
|
||||
output_line['entry'] = line[0][:-1]
|
||||
|
||||
local_ip_port = line[1]
|
||||
local_ip = local_ip_port.split(':')[0]
|
||||
local_port = local_ip_port.split(':')[1]
|
||||
|
||||
output_line['local_address'] = local_ip
|
||||
output_line['local_port'] = local_port
|
||||
|
||||
remote_ip_port = line[2]
|
||||
remote_ip = remote_ip_port.split(':')[0]
|
||||
remote_port = remote_ip_port.split(':')[1]
|
||||
|
||||
output_line['remote_address'] = remote_ip
|
||||
output_line['remote_port'] = remote_port
|
||||
|
||||
output_line['state'] = line[3]
|
||||
output_line['tx_queue'] = line[4][:8]
|
||||
output_line['rx_queue'] = line[4][9:]
|
||||
output_line['timer_active'] = line[5][:2]
|
||||
output_line['jiffies_until_timer_expires'] = line[5][3:]
|
||||
output_line['unrecovered_rto_timeouts'] = line[6]
|
||||
output_line['uid'] = line[7]
|
||||
output_line['unanswered_0_window_probes'] = line[8]
|
||||
output_line['inode'] = line[9]
|
||||
output_line['sock_ref_count'] = line[10]
|
||||
output_line['sock_mem_loc'] = line[11]
|
||||
|
||||
# fields not always included
|
||||
if len(line) > 12:
|
||||
output_line['retransmit_timeout'] = line[12]
|
||||
output_line['soft_clock_tick'] = line[13]
|
||||
output_line['ack_quick_pingpong'] = line[14]
|
||||
output_line['sending_congestion_window'] = line[15]
|
||||
output_line['slow_start_size_threshold'] = line[16]
|
||||
|
||||
raw_output.append(output_line)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
171
jc/parsers/resolve_conf.py
Normal file
171
jc/parsers/resolve_conf.py
Normal file
@@ -0,0 +1,171 @@
|
||||
"""jc - JSON Convert `/etc/resolve.conf` file parser
|
||||
|
||||
This parser may be more forgiving than the system parser. For example, if
|
||||
multiple `search` lists are defined, this parser will append all entries to
|
||||
the `search` field, while the system parser may only use the list from the
|
||||
last defined instance.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/resolve.conf | jc --resolve-conf
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('resolve_conf', resolve_conf_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"domain": string,
|
||||
"search": [
|
||||
string
|
||||
],
|
||||
"nameservers": [
|
||||
string
|
||||
],
|
||||
"options": [
|
||||
string
|
||||
],
|
||||
"sortlist": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/resolve.conf | jc --resolve-conf -p
|
||||
{
|
||||
"search": [
|
||||
"eng.myprime.com",
|
||||
"dev.eng.myprime.com",
|
||||
"labs.myprime.com",
|
||||
"qa.myprime.com"
|
||||
],
|
||||
"nameservers": [
|
||||
"10.136.17.15"
|
||||
],
|
||||
"options": [
|
||||
"rotate",
|
||||
"ndots:1"
|
||||
]
|
||||
}
|
||||
"""
|
||||
import re
|
||||
from typing import List, Dict
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`/etc/resolve.conf` file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
tags = ['file']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: Dictionary raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured to conform to the schema.
|
||||
"""
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> 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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output: Dict = {}
|
||||
search: List[str] = []
|
||||
nameservers: List[str] = []
|
||||
options: List[str] = []
|
||||
sortlist: List[str] = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
for line in filter(None, data.splitlines()):
|
||||
|
||||
# comments start with # or ; and can be inline
|
||||
if '#' in line or ';' in line:
|
||||
userdata = list(filter(None, re.split("[#;]+", line, maxsplit=1)))
|
||||
userdata = [x for x in userdata if x.strip()]
|
||||
if len(userdata) <= 1: # whole line is a comment
|
||||
continue
|
||||
|
||||
userdata_str = userdata[0].strip()
|
||||
|
||||
else:
|
||||
userdata_str = line.strip()
|
||||
|
||||
if userdata_str.startswith('domain'):
|
||||
raw_output['domain'] = userdata_str.split()[1].strip()
|
||||
continue
|
||||
|
||||
if userdata_str.startswith('search'):
|
||||
search_items = userdata_str.split(maxsplit=1)[1]
|
||||
search_list = search_items.split()
|
||||
search.extend(search_list)
|
||||
continue
|
||||
|
||||
if userdata_str.startswith('nameserver'):
|
||||
ns_str = userdata_str.split()[1]
|
||||
nameservers.append(ns_str)
|
||||
continue
|
||||
|
||||
if userdata_str.startswith('options'):
|
||||
option_items = userdata_str.split(maxsplit=1)[1]
|
||||
option_list = option_items.split()
|
||||
options.extend(option_list)
|
||||
continue
|
||||
|
||||
if userdata_str.startswith('sortlist'):
|
||||
sortlist_items = userdata_str.split(maxsplit=1)[1]
|
||||
sortlist_list = sortlist_items.split()
|
||||
sortlist.extend(sortlist_list)
|
||||
continue
|
||||
|
||||
if search:
|
||||
raw_output['search'] = search
|
||||
|
||||
if nameservers:
|
||||
raw_output['nameservers'] = nameservers
|
||||
|
||||
if options:
|
||||
raw_output['options'] = options
|
||||
|
||||
if sortlist:
|
||||
raw_output['sortlist'] = sortlist
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
@@ -17,6 +17,13 @@ Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"interfaces": [
|
||||
{
|
||||
"id": string,
|
||||
"mac": string,
|
||||
"name": string,
|
||||
}
|
||||
]
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"genmask": string,
|
||||
@@ -109,11 +116,11 @@ import jc.parsers.universal
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.8'
|
||||
version = '1.9'
|
||||
description = '`route` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
compatible = ['linux']
|
||||
compatible = ['linux', 'win32']
|
||||
magic_commands = ['route']
|
||||
tags = ['command']
|
||||
|
||||
@@ -152,6 +159,14 @@ def _process(proc_data):
|
||||
if key in int_list:
|
||||
entry[key] = jc.utils.convert_to_int(entry[key])
|
||||
|
||||
if 'interfaces' in entry:
|
||||
interfaces = []
|
||||
for interface in entry["interfaces"]:
|
||||
# 00 ff 58 60 5f 61 -> 00:ff:58:60:5f:61
|
||||
interface['mac'] = interface['mac'].replace(' ', ':').replace('.', '')
|
||||
interfaces.append(interface)
|
||||
entry["interfaces"] = interfaces
|
||||
|
||||
# add flags_pretty
|
||||
# Flag mapping from https://www.man7.org/linux/man-pages/man8/route.8.html
|
||||
if 'flags' in entry:
|
||||
@@ -165,6 +180,16 @@ def _process(proc_data):
|
||||
|
||||
return proc_data
|
||||
|
||||
def normalize_headers(headers: str):
|
||||
# fixup header row for ipv6
|
||||
if ' Next Hop ' in headers:
|
||||
headers = headers.replace(' If', ' Iface')
|
||||
|
||||
headers = headers.replace(' Next Hop ', ' Next_Hop ')
|
||||
headers = headers.replace(' Flag ', ' Flags ')
|
||||
headers = headers.replace(' Met ', ' Metric ')
|
||||
headers = headers.lower()
|
||||
return headers
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
@@ -180,24 +205,22 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
import jc.utils
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
cleandata = data.splitlines()
|
||||
|
||||
raw_output = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# fixup header row for ipv6
|
||||
if ' Next Hop ' in cleandata[0]:
|
||||
cleandata[0] = cleandata[0].replace(' If', ' Iface')
|
||||
cleandata[0] = cleandata[0].replace(' Next Hop ', ' Next_Hop ')\
|
||||
.replace(' Flag ', ' Flags ')\
|
||||
.replace(' Met ', ' Metric ')
|
||||
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
import jc.parsers.route_windows
|
||||
if cleandata[0] in jc.parsers.route_windows.SEPARATORS:
|
||||
raw_output = jc.parsers.route_windows.parse(cleandata)
|
||||
else:
|
||||
cleandata.pop(0) # Removing "Kernel IP routing table".
|
||||
cleandata[0] = normalize_headers(cleandata[0])
|
||||
import jc.parsers.universal
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
||||
128
jc/parsers/route_windows.py
Normal file
128
jc/parsers/route_windows.py
Normal file
@@ -0,0 +1,128 @@
|
||||
"""
|
||||
jc - JSON Convert Windows `route` command output parser
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
from typing import List
|
||||
|
||||
SEPARATORS = (
|
||||
"===========================================================================",
|
||||
" None"
|
||||
)
|
||||
|
||||
# 22...00 50 56 c0 00 01 ......VMware Virtual Ethernet Adapter for VMnet1
|
||||
# {"id": 22, "mac": "00 50 56 c0 00 01", "name": "VMware Virtual Ethernet Adapter for VMnet1"}
|
||||
INTERFACE_REGEX = re.compile(
|
||||
r"^(?P<id>\d+)\.{3}(?P<mac>.{17})[\s+\.]+(?P<name>[^\n\r]+)$"
|
||||
)
|
||||
|
||||
ROUTE_TABLES = ("IPv4 Route Table", "IPv6 Route Table")
|
||||
ROUTE_TYPES = ("Active Routes:", "Persistent Routes:")
|
||||
|
||||
|
||||
def get_lines_until_seperator(iterator):
|
||||
lines = []
|
||||
for line in iterator:
|
||||
if line in SEPARATORS:
|
||||
break
|
||||
lines.append(line)
|
||||
return lines
|
||||
|
||||
|
||||
def normalize_route_table(route_table: List[str]):
|
||||
headers = route_table[0]
|
||||
headers = headers.lower()
|
||||
headers = headers.replace("network destination", "destination")
|
||||
headers = headers.replace("if", "iface")
|
||||
headers = headers.replace("interface", "iface")
|
||||
headers = headers.replace("netmask", "genmask")
|
||||
headers_count = len(headers.split())
|
||||
|
||||
previous_line_has_all_the_data = True
|
||||
normalized_route_table = [headers]
|
||||
for row in route_table[1:]:
|
||||
row = row.strip()
|
||||
|
||||
has_all_the_data = len(row.split()) == headers_count
|
||||
# If the number of columns doesn't match the number of headers in the current and previous line, concatenating them.
|
||||
if not has_all_the_data and not previous_line_has_all_the_data:
|
||||
previous_line = normalized_route_table.pop(
|
||||
len(normalized_route_table) - 1)
|
||||
row = f'{previous_line} {row}'
|
||||
has_all_the_data = True
|
||||
|
||||
normalized_route_table.append(row.strip())
|
||||
previous_line_has_all_the_data = has_all_the_data
|
||||
|
||||
return normalized_route_table
|
||||
|
||||
|
||||
def parse(cleandata: List[str]):
|
||||
"""
|
||||
Main text parsing function for Windows route
|
||||
|
||||
Parameters:
|
||||
|
||||
cleandata: (string) text data to parse
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw structured data.
|
||||
"""
|
||||
|
||||
raw_output = []
|
||||
data_iterator = iter(cleandata)
|
||||
for line in data_iterator:
|
||||
if not line:
|
||||
continue
|
||||
|
||||
if line == "Interface List":
|
||||
# Interface List
|
||||
# 8...00 ff 58 60 5f 61 ......TAP-Windows Adapter V9
|
||||
# 52...00 15 5d fd 0d 45 ......Hyper-V Virtual Ethernet Adapter
|
||||
# ===========================================================================
|
||||
|
||||
interfaces = []
|
||||
for interface_line in data_iterator:
|
||||
interface_line = interface_line.strip()
|
||||
if interface_line in SEPARATORS:
|
||||
break
|
||||
|
||||
interface_match = INTERFACE_REGEX.search(interface_line)
|
||||
if interface_match:
|
||||
interfaces.append(interface_match.groupdict())
|
||||
|
||||
if interfaces:
|
||||
raw_output.append({"interfaces": interfaces})
|
||||
continue
|
||||
|
||||
full_route_table = []
|
||||
if line in ROUTE_TABLES:
|
||||
next(data_iterator) # Skipping the table title.
|
||||
|
||||
# Persistent Routes:
|
||||
# Network Address Netmask Gateway Address Metric
|
||||
# 157.0.0.0 255.0.0.0 157.55.80.1 3
|
||||
# ===========================================================================
|
||||
for route_line in data_iterator:
|
||||
if route_line in ROUTE_TYPES:
|
||||
import jc.parsers.universal
|
||||
route_table = get_lines_until_seperator(
|
||||
data_iterator
|
||||
)
|
||||
if not route_table:
|
||||
continue
|
||||
|
||||
route_table = normalize_route_table(
|
||||
route_table
|
||||
)
|
||||
full_route_table.extend(
|
||||
jc.parsers.universal.simple_table_parse(
|
||||
route_table
|
||||
)
|
||||
)
|
||||
|
||||
raw_output.extend(full_route_table)
|
||||
|
||||
return raw_output
|
||||
281
jc/parsers/srt.py
Normal file
281
jc/parsers/srt.py
Normal file
@@ -0,0 +1,281 @@
|
||||
"""jc - JSON Convert `SRT` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.srt | jc --srt
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('srt', srt_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"index": int,
|
||||
"start": {
|
||||
"hours": int,
|
||||
"minutes": int,
|
||||
"seconds": int,
|
||||
"milliseconds": int,
|
||||
"timestamp": string
|
||||
},
|
||||
"end": {
|
||||
"hours": int,
|
||||
"minutes": int,
|
||||
"seconds": int,
|
||||
"milliseconds": int,
|
||||
"timestamp": string
|
||||
},
|
||||
"content": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat attack_of_the_clones.srt
|
||||
1
|
||||
00:02:16,612 --> 00:02:19,376
|
||||
Senator, we're making
|
||||
our final approach into Coruscant.
|
||||
|
||||
2
|
||||
00:02:19,482 --> 00:02:21,609
|
||||
Very good, Lieutenant.
|
||||
...
|
||||
|
||||
$ cat attack_of_the_clones.srt | jc --srt
|
||||
[
|
||||
{
|
||||
"index": 1,
|
||||
"start": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 16,
|
||||
"milliseconds": 612,
|
||||
"timestamp": "00:02:16,612"
|
||||
},
|
||||
"end": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 19,
|
||||
"milliseconds": 376,
|
||||
"timestamp": "00:02:19,376"
|
||||
},
|
||||
"content": "Senator, we're making\nour final approach into Coruscant."
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"start": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 19,
|
||||
"milliseconds": 482,
|
||||
"timestamp": "00:02:19,482"
|
||||
},
|
||||
"end": {
|
||||
"hours": 0,
|
||||
"minutes": 2,
|
||||
"seconds": 21,
|
||||
"milliseconds": 609,
|
||||
"timestamp": "00:02:21,609"
|
||||
},
|
||||
"content": "Very good, Lieutenant."
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import re
|
||||
from typing import List, Dict
|
||||
from jc.jc_types import JSONDictType
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = 'SRT file parser'
|
||||
author = 'Mark Rotner'
|
||||
author_email = 'rotner.mr@gmail.com'
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
tags = ['standard', 'file', 'string']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
# Regex from https://github.com/cdown/srt/blob/434d0c1c9d5c26d5c3fb1ce979fc05b478e9253c/srt.py#LL16C1.
|
||||
|
||||
# The MIT License
|
||||
|
||||
# Copyright (c) 2014-present Christopher Down
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
# The format: (int)index\n(timestamp)start --> (timestamp)end\n(str)content\n.
|
||||
# Example:
|
||||
# 1
|
||||
# 00:02:16,612 --> 00:02:19,376
|
||||
# Senator, we're making our final approach into Coruscant.
|
||||
|
||||
# Start & End timestamp format: hours:minutes:seconds,millisecond.
|
||||
# "." is not technically valid as a delimiter, but many editors create SRT
|
||||
# files with this delimiter for whatever reason. Many editors and players
|
||||
# accept it, so we do too.
|
||||
RGX_TIMESTAMP_MAGNITUDE_DELIM = r"[,.:,.。:]"
|
||||
RGX_POSITIVE_INT = r"[0-9]+"
|
||||
RGX_POSITIVE_INT_OPTIONAL = r"[0-9]*"
|
||||
RGX_TIMESTAMP = '{field}{separator}{field}{separator}{field}{separator}?{optional_field}'.format(
|
||||
separator=RGX_TIMESTAMP_MAGNITUDE_DELIM,
|
||||
field=RGX_POSITIVE_INT,
|
||||
optional_field=RGX_POSITIVE_INT_OPTIONAL
|
||||
)
|
||||
RGX_INDEX = r"-?[0-9]+\.?[0-9]*" # int\float\negative.
|
||||
RGX_CONTENT = r".*?" # Anything(except newline) but lazy.
|
||||
RGX_NEWLINE = r"\r?\n" # Newline(CRLF\LF).
|
||||
SRT_REGEX = re.compile(
|
||||
r"\s*(?:({index})\s*{newline})?({ts}) *-[ -] *> *({ts}) ?(?:{newline}|\Z)({content})"
|
||||
# Many sub editors don't add a blank line to the end, and many editors and
|
||||
# players accept that. We allow it to be missing in input.
|
||||
#
|
||||
# We also allow subs that are missing a double blank newline. This often
|
||||
# happens on subs which were first created as a mixed language subtitle,
|
||||
# for example chs/eng, and then were stripped using naive methods (such as
|
||||
# ed/sed) that don't understand newline preservation rules in SRT files.
|
||||
#
|
||||
# This means that when you are, say, only keeping chs, and the line only
|
||||
# contains english, you end up with not only no content, but also all of
|
||||
# the content lines are stripped instead of retaining a newline.
|
||||
r"(?:{newline}|\Z)(?:{newline}|\Z|(?=(?:{index}\s*{newline}{ts})))"
|
||||
# Some SRT blocks, while this is technically invalid, have blank lines
|
||||
# inside the subtitle content. We look ahead a little to check that the
|
||||
# next lines look like an index and a timestamp as a best-effort
|
||||
# solution to work around these.
|
||||
r"(?=(?:(?:{index}\s*{newline})?{ts}|\Z))".format(
|
||||
index=RGX_INDEX,
|
||||
ts=RGX_TIMESTAMP,
|
||||
content=RGX_CONTENT,
|
||||
newline=RGX_NEWLINE,
|
||||
),
|
||||
re.DOTALL,
|
||||
)
|
||||
TIMESTAMP_REGEX = re.compile(
|
||||
'^({field}){separator}({field}){separator}({field}){separator}?({optional_field})$'.format(
|
||||
separator=RGX_TIMESTAMP_MAGNITUDE_DELIM,
|
||||
field=RGX_POSITIVE_INT,
|
||||
optional_field=RGX_POSITIVE_INT_OPTIONAL
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries representing an SRT document.
|
||||
"""
|
||||
|
||||
int_list = {'index'}
|
||||
timestamp_list = {"start", "end"}
|
||||
timestamp_int_list = {"hours", "minutes", "seconds", "milliseconds"}
|
||||
|
||||
for entry in proc_data:
|
||||
# Converting {"index"} to int.
|
||||
for key in entry:
|
||||
if key in int_list:
|
||||
entry[key] = jc.utils.convert_to_int(entry[key])
|
||||
|
||||
# Converting {"hours", "minutes", "seconds", "milliseconds"} to int.
|
||||
if key in timestamp_list:
|
||||
timestamp = entry[key]
|
||||
for timestamp_key in timestamp:
|
||||
if timestamp_key in timestamp_int_list:
|
||||
timestamp[timestamp_key] = jc.utils.convert_to_int(
|
||||
timestamp[timestamp_key])
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse_timestamp(timestamp: str) -> Dict:
|
||||
"""
|
||||
timestamp: "hours:minutes:seconds,milliseconds" --->
|
||||
{
|
||||
"hours": "hours",
|
||||
"minutes": "minutes",
|
||||
"seconds": "seconds",
|
||||
"milliseconds": "milliseconds",
|
||||
"timestamp": "hours:minutes:seconds,milliseconds"
|
||||
}
|
||||
"""
|
||||
ts_match = TIMESTAMP_REGEX.match(timestamp)
|
||||
if ts_match:
|
||||
hours, minutes, seconds, milliseconds = ts_match.groups()
|
||||
return {
|
||||
"hours": hours,
|
||||
"minutes": minutes,
|
||||
"seconds": seconds,
|
||||
"milliseconds": milliseconds,
|
||||
"timestamp": timestamp
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
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:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output: List[Dict] = []
|
||||
if not jc.utils.has_data(data):
|
||||
return raw_output
|
||||
|
||||
for subtitle in SRT_REGEX.finditer(data):
|
||||
index, start, end, content = subtitle.groups()
|
||||
raw_output.append(
|
||||
{
|
||||
"index": index,
|
||||
"start": parse_timestamp(start),
|
||||
"end": parse_timestamp(end),
|
||||
"content": content.replace("\r\n", "\n")
|
||||
}
|
||||
)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
109
jc/parsers/ss.py
109
jc/parsers/ss.py
@@ -1,8 +1,5 @@
|
||||
"""jc - JSON Convert `ss` command output parser
|
||||
|
||||
Extended information options like `-e` and `-p` are not supported and may
|
||||
cause parsing irregularities.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ss | jc --ss
|
||||
@@ -23,21 +20,29 @@ field names
|
||||
|
||||
[
|
||||
{
|
||||
"netid": string,
|
||||
"state": string,
|
||||
"recv_q": integer,
|
||||
"send_q": integer,
|
||||
"local_address": string,
|
||||
"local_port": string,
|
||||
"local_port_num": integer,
|
||||
"peer_address": string,
|
||||
"peer_port": string,
|
||||
"peer_port_num": integer,
|
||||
"interface": string,
|
||||
"link_layer" string,
|
||||
"channel": string,
|
||||
"path": string,
|
||||
"pid": integer
|
||||
"netid": string,
|
||||
"state": string,
|
||||
"recv_q": integer,
|
||||
"send_q": integer,
|
||||
"local_address": string,
|
||||
"local_port": string,
|
||||
"local_port_num": integer,
|
||||
"peer_address": string,
|
||||
"peer_port": string,
|
||||
"peer_port_num": integer,
|
||||
"interface": string,
|
||||
"link_layer" string,
|
||||
"channel": string,
|
||||
"path": string,
|
||||
"pid": integer,
|
||||
"opts": {
|
||||
"process_id": {
|
||||
"<process_id>": {
|
||||
"user": string,
|
||||
"file_descriptor": string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -275,13 +280,15 @@ Examples:
|
||||
}
|
||||
]
|
||||
"""
|
||||
import re
|
||||
import ast
|
||||
import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.6'
|
||||
version = '1.7'
|
||||
description = '`ss` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -324,6 +331,57 @@ def _process(proc_data):
|
||||
|
||||
return proc_data
|
||||
|
||||
def _parse_opts(proc_data):
|
||||
""" Process extra options -e, -o, -p
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (List of Dictionaries) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Structured data dictionary for extra/optional headerless options.
|
||||
"""
|
||||
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(')', ']')
|
||||
val = ast.literal_eval(re.sub(r'([a-z0-9\.]+)', '"\\1"', val))
|
||||
val = {
|
||||
'timer_name': val[0],
|
||||
'expire_time': val[1],
|
||||
'retrans': val[2]
|
||||
}
|
||||
opts[key] = val
|
||||
# -p option
|
||||
if key == "users":
|
||||
key = 'process_id'
|
||||
val = val.replace('(', '[').replace(')', ']')
|
||||
val = ast.literal_eval(re.sub(r'([a-z]+=[0-9]+)', '"\\1"', val))
|
||||
data = {}
|
||||
for rec in val:
|
||||
params = {}
|
||||
params['user'] = rec[0]
|
||||
for i in [x for x in rec if '=' in x]:
|
||||
k, v = i.split('=')
|
||||
params[k] = v
|
||||
data.update({
|
||||
params['pid']: {
|
||||
'user': params['user'],
|
||||
'file_descriptor': params['fd']
|
||||
}
|
||||
})
|
||||
val = data
|
||||
opts[key] = val
|
||||
return opts
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
@@ -357,15 +415,20 @@ def parse(data, raw=False, quiet=False):
|
||||
header_text = header_text.replace('-', '_')
|
||||
|
||||
header_list = header_text.split()
|
||||
extra_opts = False
|
||||
|
||||
for entry in cleandata[1:]:
|
||||
output_line = {}
|
||||
if entry[0] not in string.whitespace:
|
||||
|
||||
# fix weird ss bug where first two columns have no space between them sometimes
|
||||
entry = entry[:5] + ' ' + entry[5:]
|
||||
entry = entry[:5] + ' ' + entry[5:]
|
||||
|
||||
entry_list = entry.split()
|
||||
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())
|
||||
extra_opts = True
|
||||
|
||||
if entry_list[0] in contains_colon and ':' in entry_list[4]:
|
||||
l_field = entry_list[4].rsplit(':', maxsplit=1)
|
||||
@@ -381,6 +444,10 @@ def parse(data, raw=False, quiet=False):
|
||||
entry_list[6] = p_address
|
||||
entry_list.insert(7, p_port)
|
||||
|
||||
if re.search(r'ino:|uid:|sk:|users:|timer:',entry_list[-1]):
|
||||
header_list.append('opts')
|
||||
entry_list[-1] = _parse_opts(entry_list[-1])
|
||||
|
||||
output_line = dict(zip(header_list, entry_list))
|
||||
|
||||
# some post processing to pull out fields: interface, link_layer, path, pid, channel
|
||||
|
||||
@@ -171,7 +171,7 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.12'
|
||||
version = '1.13'
|
||||
description = '`stat` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -238,112 +238,115 @@ def parse(data, raw=False, quiet=False):
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
# linux output
|
||||
if cleandata[0].startswith(' File: '):
|
||||
# stats output contains 8 lines
|
||||
for line in cleandata:
|
||||
|
||||
# line #1
|
||||
if line.find('File:') == 2:
|
||||
output_line = {}
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['file'] = line_list[1]
|
||||
|
||||
# populate link_to field if -> found
|
||||
if ' -> ' in output_line['file']:
|
||||
filename = output_line['file'].split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
link = output_line['file'].split(' -> ')[1].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
output_line['link_to'] = link
|
||||
else:
|
||||
filename = output_line['file'].split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
|
||||
continue
|
||||
|
||||
# line #2
|
||||
if line.find('Size:') == 2:
|
||||
line_list = line.split(maxsplit=7)
|
||||
output_line['size'] = line_list[1]
|
||||
output_line['blocks'] = line_list[3]
|
||||
output_line['io_blocks'] = line_list[6]
|
||||
output_line['type'] = line_list[7]
|
||||
continue
|
||||
|
||||
# line #3
|
||||
if line.startswith('Device:'):
|
||||
line_list = line.split()
|
||||
output_line['device'] = line_list[1]
|
||||
output_line['inode'] = line_list[3]
|
||||
output_line['links'] = line_list[5]
|
||||
continue
|
||||
|
||||
# line #4
|
||||
if line.startswith('Access: ('):
|
||||
line = line.replace('(', ' ').replace(')', ' ').replace('/', ' ')
|
||||
line_list = line.split()
|
||||
output_line['access'] = line_list[1]
|
||||
output_line['flags'] = line_list[2]
|
||||
output_line['uid'] = line_list[4]
|
||||
output_line['user'] = line_list[5]
|
||||
output_line['gid'] = line_list[7]
|
||||
output_line['group'] = line_list[8]
|
||||
continue
|
||||
|
||||
# line #5
|
||||
if line.startswith('Access: 2'):
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['access_time'] = line_list[1]
|
||||
continue
|
||||
|
||||
# line #6
|
||||
if line.startswith('Modify:'):
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['modify_time'] = line_list[1]
|
||||
continue
|
||||
|
||||
# line #7
|
||||
if line.startswith('Change:'):
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['change_time'] = line_list[1]
|
||||
continue
|
||||
|
||||
# line #8
|
||||
if line.find('Birth:') == 1:
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['birth_time'] = line_list[1]
|
||||
|
||||
raw_output.append(output_line)
|
||||
continue
|
||||
|
||||
# FreeBSD/OSX output
|
||||
else:
|
||||
for line in cleandata:
|
||||
value = shlex.split(line)
|
||||
output_line = {
|
||||
'file': ' '.join(value[15:]),
|
||||
'unix_device': value[0],
|
||||
'inode': value[1],
|
||||
'flags': value[2],
|
||||
'links': value[3],
|
||||
'user': value[4],
|
||||
'group': value[5],
|
||||
'rdev': value[6],
|
||||
'size': value[7],
|
||||
'access_time': value[8],
|
||||
'modify_time': value[9],
|
||||
'change_time': value[10],
|
||||
'birth_time': value[11],
|
||||
'block_size': value[12],
|
||||
'blocks': value[13],
|
||||
'unix_flags': value[14]
|
||||
}
|
||||
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
if not jc.utils.has_data(data):
|
||||
return raw_output
|
||||
|
||||
# linux output
|
||||
if cleandata[0].startswith(' File: '):
|
||||
output_line = {}
|
||||
|
||||
# stats output contains 8 lines
|
||||
for line in cleandata:
|
||||
# line #1
|
||||
if line.find('File:') == 2:
|
||||
if output_line: # Reached a new file stat info.
|
||||
raw_output.append(output_line)
|
||||
output_line = {}
|
||||
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['file'] = line_list[1]
|
||||
|
||||
# populate link_to field if -> found
|
||||
if ' -> ' in output_line['file']:
|
||||
filename = output_line['file'].split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
link = output_line['file'].split(' -> ')[1].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
output_line['link_to'] = link
|
||||
else:
|
||||
filename = output_line['file'].split(' -> ')[0].strip('\u2018').rstrip('\u2019')
|
||||
output_line['file'] = filename
|
||||
|
||||
continue
|
||||
|
||||
# line #2
|
||||
if line.startswith(' Size:'):
|
||||
line_list = line.split(maxsplit=7)
|
||||
output_line['size'] = line_list[1]
|
||||
output_line['blocks'] = line_list[3]
|
||||
output_line['io_blocks'] = line_list[6]
|
||||
output_line['type'] = line_list[7]
|
||||
continue
|
||||
|
||||
# line #3
|
||||
if line.startswith('Device:'):
|
||||
line_list = line.split()
|
||||
output_line['device'] = line_list[1]
|
||||
output_line['inode'] = line_list[3]
|
||||
output_line['links'] = line_list[5]
|
||||
continue
|
||||
|
||||
# line #4
|
||||
if line.startswith('Access: ('):
|
||||
line = line.replace('(', ' ').replace(')', ' ').replace('/', ' ')
|
||||
line_list = line.split()
|
||||
output_line['access'] = line_list[1]
|
||||
output_line['flags'] = line_list[2]
|
||||
output_line['uid'] = line_list[4]
|
||||
output_line['user'] = line_list[5]
|
||||
output_line['gid'] = line_list[7]
|
||||
output_line['group'] = line_list[8]
|
||||
continue
|
||||
|
||||
# line #5
|
||||
if line.startswith('Access: 2'):
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['access_time'] = line_list[1]
|
||||
continue
|
||||
|
||||
# line #6
|
||||
if line.startswith('Modify:'):
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['modify_time'] = line_list[1]
|
||||
continue
|
||||
|
||||
# line #7
|
||||
if line.startswith('Change:'):
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['change_time'] = line_list[1]
|
||||
continue
|
||||
|
||||
# line #8
|
||||
if line.startswith(' Birth:'):
|
||||
line_list = line.split(maxsplit=1)
|
||||
output_line['birth_time'] = line_list[1]
|
||||
continue
|
||||
|
||||
if output_line:
|
||||
raw_output.append(output_line)
|
||||
|
||||
# FreeBSD/OSX output
|
||||
else:
|
||||
return _process(raw_output)
|
||||
for line in cleandata:
|
||||
value = shlex.split(line)
|
||||
output_line = {
|
||||
'file': ' '.join(value[15:]),
|
||||
'unix_device': value[0],
|
||||
'inode': value[1],
|
||||
'flags': value[2],
|
||||
'links': value[3],
|
||||
'user': value[4],
|
||||
'group': value[5],
|
||||
'rdev': value[6],
|
||||
'size': value[7],
|
||||
'access_time': value[8],
|
||||
'modify_time': value[9],
|
||||
'change_time': value[10],
|
||||
'birth_time': value[11],
|
||||
'block_size': value[12],
|
||||
'blocks': value[13],
|
||||
'unix_flags': value[14]
|
||||
}
|
||||
|
||||
raw_output.append(output_line)
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Best-effort attempt to parse various styles of version numbers. This parser
|
||||
is based off of the version parser included in the CPython distutils
|
||||
libary.
|
||||
library.
|
||||
|
||||
If the version string conforms to some de facto-standard versioning rules
|
||||
followed by many developers a `strict` key will be present in the output
|
||||
|
||||
256
jc/parsers/veracrypt.py
Normal file
256
jc/parsers/veracrypt.py
Normal file
@@ -0,0 +1,256 @@
|
||||
"""jc - JSON Convert `veracrypt` command output parser
|
||||
|
||||
Supports the following `veracrypt` subcommands:
|
||||
- `veracrypt --text --list`
|
||||
- `veracrypt --text --list --verbose`
|
||||
- `veracrypt --text --volume-properties <volume>`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ veracrypt --text --list | jc --veracrypt
|
||||
or
|
||||
|
||||
$ jc veracrypt --text --list
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('veracrypt', veracrypt_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Volume:
|
||||
[
|
||||
{
|
||||
"slot": integer,
|
||||
"path": string,
|
||||
"device": string,
|
||||
"mountpoint": string,
|
||||
"size": string,
|
||||
"type": string,
|
||||
"readonly": string,
|
||||
"hidden_protected": string,
|
||||
"encryption_algo": string,
|
||||
"pk_size": string,
|
||||
"sk_size": string,
|
||||
"block_size": string,
|
||||
"mode": string,
|
||||
"prf": string,
|
||||
"format_version": integer,
|
||||
"backup_header": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ veracrypt --text --list | jc --veracrypt -p
|
||||
[
|
||||
{
|
||||
"slot": 1,
|
||||
"path": "/dev/sdb1",
|
||||
"device": "/dev/mapper/veracrypt1",
|
||||
"mountpoint": "/home/bob/mount/encrypt/sdb1"
|
||||
}
|
||||
]
|
||||
|
||||
$ veracrypt --text --list --verbose | jc --veracrypt -p
|
||||
[
|
||||
{
|
||||
"slot": 1,
|
||||
"path": "/dev/sdb1",
|
||||
"device": "/dev/mapper/veracrypt1",
|
||||
"mountpoint": "/home/bob/mount/encrypt/sdb1",
|
||||
"size": "522 MiB",
|
||||
"type": "Normal",
|
||||
"readonly": "No",
|
||||
"hidden_protected": "No",
|
||||
"encryption_algo": "AES",
|
||||
"pk_size": "256 bits",
|
||||
"sk_size": "256 bits",
|
||||
"block_size": "128 bits",
|
||||
"mode": "XTS",
|
||||
"prf": "HMAC-SHA-512",
|
||||
"format_version": 2,
|
||||
"backup_header": "Yes"
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
import re
|
||||
from typing import List, Dict, Optional, Any
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`veracrypt` command parser'
|
||||
author = 'Jake Ob'
|
||||
author_email = 'iakopap at gmail.com'
|
||||
compatible = ["linux"]
|
||||
magic_commands = ["veracrypt"]
|
||||
tags = ['command']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
try:
|
||||
from typing import TypedDict
|
||||
|
||||
Volume = TypedDict(
|
||||
"Volume",
|
||||
{
|
||||
"slot": int,
|
||||
"path": str,
|
||||
"device": str,
|
||||
"mountpoint": str,
|
||||
"size": str,
|
||||
"type": str,
|
||||
"readonly": str,
|
||||
"hidden_protected": str,
|
||||
"encryption_algo": str,
|
||||
"pk_size": str,
|
||||
"sk_size": str,
|
||||
"block_size": str,
|
||||
"mode": str,
|
||||
"prf": str,
|
||||
"format_version": int,
|
||||
"backup_header": str
|
||||
},
|
||||
)
|
||||
except ImportError:
|
||||
Volume = Dict[str, Any] # type: ignore
|
||||
|
||||
_volume_line_pattern = r"(?P<slot>[0-9]+): (?P<path>.+?) (?P<device>.+?) (?P<mountpoint>.*)"
|
||||
|
||||
_volume_verbose_pattern = (
|
||||
r"(Slot:\s(?P<slot>.+)"
|
||||
+ r"|Volume:\s(?P<path>.+)"
|
||||
+ r"|Virtual\sDevice:\s(?P<device>.+)"
|
||||
+ r"|Mount\sDirectory:\s(?P<mountpoint>.+)"
|
||||
+ r"|Size:\s(?P<size>.+)"
|
||||
+ r"|Type:\s(?P<type>.+)"
|
||||
+ r"|Read-Only:\s(?P<readonly>.+)"
|
||||
+ r"|Hidden\sVolume Protected:\s(?P<hidden_protected>.+)"
|
||||
+ r"|Encryption\sAlgorithm:\s(?P<encryption_algo>.+)"
|
||||
+ r"|Primary\sKey\sSize:\s(?P<pk_size>.+)"
|
||||
+ r"|Secondary\sKey\sSize\s.*:\s(?P<sk_size>.+)"
|
||||
+ r"|Block\sSize:\s(?P<block_size>.+)"
|
||||
+ r"|Mode\sof\sOperation:\s(?P<mode>.+)"
|
||||
+ r"|PKCS-5\sPRF:\s(?P<prf>.+)"
|
||||
+ r"|Volume\sFormat\sVersion:\s(?P<format_version>.+)"
|
||||
+ r"|Embedded\sBackup\sHeader:\s(?P<backup_header>.+))"
|
||||
)
|
||||
|
||||
def _parse_volume(next_lines: List[str]) -> Optional[Volume]:
|
||||
next_line = next_lines.pop()
|
||||
result = re.match(_volume_line_pattern, next_line)
|
||||
|
||||
# Parse and return the volume given as a single line (veracrypt -t --list)
|
||||
if result:
|
||||
matches = result.groupdict()
|
||||
volume: Volume = { # type: ignore
|
||||
"slot": int(matches["slot"]),
|
||||
"path": matches["path"],
|
||||
"device": matches["device"],
|
||||
"mountpoint": matches["mountpoint"],
|
||||
}
|
||||
|
||||
return volume
|
||||
else:
|
||||
next_lines.append(next_line)
|
||||
|
||||
# Otherwise parse the volume given in multiple lines (veracrypt -t --list -v)
|
||||
volume: Volume = {} # type: ignore
|
||||
|
||||
while next_lines:
|
||||
next_line = next_lines.pop()
|
||||
|
||||
# Return when encounter an empty line
|
||||
if not next_line:
|
||||
return volume
|
||||
|
||||
result = re.match(_volume_verbose_pattern, next_line)
|
||||
|
||||
# Skip to the next line in case of an unknown field line
|
||||
if not result:
|
||||
continue
|
||||
|
||||
matches = result.groupdict()
|
||||
|
||||
if matches["slot"]:
|
||||
volume["slot"] = int(matches["slot"])
|
||||
elif matches["path"]:
|
||||
volume["path"] = matches["path"]
|
||||
elif matches["device"]:
|
||||
volume["device"] = matches["device"]
|
||||
elif matches["mountpoint"]:
|
||||
volume["mountpoint"] = matches["mountpoint"]
|
||||
elif matches["size"]:
|
||||
volume["size"] = matches["size"]
|
||||
elif matches["type"]:
|
||||
volume["type"] = matches["type"]
|
||||
elif matches["readonly"]:
|
||||
volume["readonly"] = matches["readonly"]
|
||||
elif matches["hidden_protected"]:
|
||||
volume["hidden_protected"] = matches["hidden_protected"]
|
||||
elif matches["encryption_algo"]:
|
||||
volume["encryption_algo"] = matches["encryption_algo"]
|
||||
elif matches["pk_size"]:
|
||||
volume["pk_size"] = matches["pk_size"]
|
||||
elif matches["sk_size"]:
|
||||
volume["sk_size"] = matches["sk_size"]
|
||||
elif matches["block_size"]:
|
||||
volume["block_size"] = matches["block_size"]
|
||||
elif matches["mode"]:
|
||||
volume["mode"] = matches["mode"]
|
||||
elif matches["prf"]:
|
||||
volume["prf"] = matches["prf"]
|
||||
elif matches["format_version"]:
|
||||
volume["format_version"] = int(matches["format_version"])
|
||||
elif matches["backup_header"]:
|
||||
volume["backup_header"] = matches["backup_header"]
|
||||
|
||||
return volume
|
||||
|
||||
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.
|
||||
"""
|
||||
result: List = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
first_line = linedata[0]
|
||||
line_mode = re.search(_volume_line_pattern, first_line)
|
||||
verbose_mode = re.search(_volume_verbose_pattern, first_line)
|
||||
|
||||
if not line_mode and not verbose_mode:
|
||||
return []
|
||||
|
||||
linedata.reverse()
|
||||
|
||||
while linedata:
|
||||
volume = _parse_volume(linedata)
|
||||
|
||||
if volume:
|
||||
result.append(volume)
|
||||
else:
|
||||
break
|
||||
|
||||
return result
|
||||
@@ -408,12 +408,12 @@ from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from typing import List, Dict, Union
|
||||
import jc.utils
|
||||
from jc.parsers.asn1crypto import pem, x509
|
||||
from jc.parsers.asn1crypto import pem, x509, jc_global
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
version = '1.3'
|
||||
description = 'X.509 PEM and DER certificate file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -462,6 +462,9 @@ def _fix_objects(obj):
|
||||
Recursively traverse the nested dictionary or list and convert objects
|
||||
into JSON serializable types.
|
||||
"""
|
||||
if isinstance(obj, tuple):
|
||||
obj = list(obj)
|
||||
|
||||
if isinstance(obj, set):
|
||||
obj = sorted(list(obj))
|
||||
|
||||
@@ -474,7 +477,10 @@ def _fix_objects(obj):
|
||||
# according to the spec this field can be string or integer
|
||||
if isinstance(v, int):
|
||||
v_str = str(v)
|
||||
v_hex = _b2a(_i2b(v))
|
||||
if v < 0:
|
||||
v_hex = "(Negative)" + _b2a(_i2b(abs(v)))
|
||||
else:
|
||||
v_hex = _b2a(_i2b(v))
|
||||
else:
|
||||
v_str = str(v)
|
||||
v_hex = _b2a(v_str.encode())
|
||||
@@ -501,6 +507,10 @@ def _fix_objects(obj):
|
||||
obj.update({k: v})
|
||||
continue
|
||||
|
||||
if isinstance(v, tuple):
|
||||
v = list(v)
|
||||
obj.update({k: v})
|
||||
|
||||
if isinstance(v, set):
|
||||
v = sorted(list(v))
|
||||
obj.update({k: v})
|
||||
@@ -548,6 +558,7 @@ def parse(
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc_global.quiet = quiet # to inject quiet setting into asn1crypto library
|
||||
|
||||
raw_output: List = []
|
||||
|
||||
|
||||
318
jc/parsers/x509_csr.py
Normal file
318
jc/parsers/x509_csr.py
Normal file
@@ -0,0 +1,318 @@
|
||||
"""jc - JSON Convert X.509 Certificate Request format file parser
|
||||
|
||||
This parser will convert DER and PEM encoded X.509 certificate request files.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat certificateRequest.pem | jc --x509-csr
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('x509_csr', x509_csr_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"certification_request_info": {
|
||||
"version": string,
|
||||
"serial_number": string, # [0]
|
||||
"serial_number_str": string,
|
||||
"signature": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null,
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": string,
|
||||
"state_or_province_name" string,
|
||||
"locality_name": string,
|
||||
"organization_name": array/string,
|
||||
"organizational_unit_name": array/string,
|
||||
"common_name": string,
|
||||
"email_address": string,
|
||||
"serial_number": string, # [0]
|
||||
"serial_number_str": string
|
||||
},
|
||||
"validity": {
|
||||
"not_before": integer, # [1]
|
||||
"not_after": integer, # [1]
|
||||
"not_before_iso": string,
|
||||
"not_after_iso": string
|
||||
},
|
||||
"subject": {
|
||||
"country_name": string,
|
||||
"state_or_province_name": string,
|
||||
"locality_name": string,
|
||||
"organization_name": array/string,
|
||||
"organizational_unit_name": array/string,
|
||||
"common_name": string,
|
||||
"email_address": string,
|
||||
"serial_number": string, # [0]
|
||||
"serial_number_str": string
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null,
|
||||
},
|
||||
"public_key": {
|
||||
"modulus": string, # [0]
|
||||
"public_exponent": integer
|
||||
}
|
||||
},
|
||||
"issuer_unique_id": string/null,
|
||||
"subject_unique_id": string/null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": string,
|
||||
"critical": boolean,
|
||||
"extn_value": array/object/string/integer # [2]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null
|
||||
},
|
||||
"signature_value": string # [0]
|
||||
}
|
||||
]
|
||||
|
||||
[0] in colon-delimited hex notation
|
||||
[1] time-zone-aware (UTC) epoch timestamp
|
||||
[2] See below for well-known Extension schemas:
|
||||
|
||||
Basic Constraints:
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": boolean,
|
||||
"extn_value": {
|
||||
"ca": boolean,
|
||||
"path_len_constraint": string/null
|
||||
}
|
||||
}
|
||||
|
||||
Key Usage:
|
||||
{
|
||||
"extn_id": "key_usage",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
Key Identifier:
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": boolean,
|
||||
"extn_value": string # [0]
|
||||
}
|
||||
|
||||
Authority Key Identifier:
|
||||
{
|
||||
"extn_id": "authority_key_identifier",
|
||||
"critical": boolean,
|
||||
"extn_value": {
|
||||
"key_identifier": string, # [0]
|
||||
"authority_cert_issuer": string/null,
|
||||
"authority_cert_serial_number": string/null
|
||||
}
|
||||
}
|
||||
|
||||
Subject Alternative Name:
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
Certificate Policies:
|
||||
{
|
||||
"extn_id": "certificate_policies",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
{
|
||||
"policy_identifier": string,
|
||||
"policy_qualifiers": [ array or null
|
||||
{
|
||||
"policy_qualifier_id": string,
|
||||
"qualifier": string
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Signed Certificate Timestamp List:
|
||||
{
|
||||
"extn_id": "signed_certificate_timestamp_list",
|
||||
"critical": boolean,
|
||||
"extn_value": string # [0]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat server.csr| jc --x509-csr -p
|
||||
[
|
||||
{
|
||||
"certification_request_info": {
|
||||
"version": "v1",
|
||||
"subject": {
|
||||
"common_name": "myserver.for.example"
|
||||
},
|
||||
"subject_pk_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp256r1"
|
||||
},
|
||||
"public_key": "04:40:33:c0:91:8f:e9:46:ea:d0:dc:d0:f9:63:2..."
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "extension_request",
|
||||
"values": [
|
||||
[
|
||||
{
|
||||
"extn_id": "extended_key_usage",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"server_auth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"myserver.for.example"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature": "30:45:02:20:77:ac:5b:51:bf:c5:f5:43:02:52:ae:66:..."
|
||||
}
|
||||
]
|
||||
|
||||
$ openssl req -in server.csr | jc --x509-csr -p
|
||||
[
|
||||
{
|
||||
"certification_request_info": {
|
||||
"version": "v1",
|
||||
"subject": {
|
||||
"common_name": "myserver.for.example"
|
||||
},
|
||||
"subject_pk_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp256r1"
|
||||
},
|
||||
"public_key": "04:40:33:c0:91:8f:e9:46:ea:d0:dc:d0:f9:63:2..."
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "extension_request",
|
||||
"values": [
|
||||
[
|
||||
{
|
||||
"extn_id": "extended_key_usage",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"server_auth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": false,
|
||||
"extn_value": [
|
||||
"myserver.for.example"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature": "30:45:02:20:77:ac:5b:51:bf:c5:f5:43:02:52:ae:66:..."
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
# import binascii
|
||||
# from collections import OrderedDict
|
||||
# from datetime import datetime
|
||||
from typing import List, Dict, Union
|
||||
import jc.utils
|
||||
from jc.parsers.asn1crypto import pem, csr, jc_global
|
||||
from jc.parsers.x509_cert import _fix_objects, _process
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = 'X.509 PEM and DER certificate request file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
details = 'Using the asn1crypto library at https://github.com/wbond/asn1crypto/releases/tag/1.5.1'
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
tags = ['standard', 'file', 'string', 'binary']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def parse(
|
||||
data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> List[Dict]:
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string or bytes) text or binary 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.
|
||||
"""
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc_global.quiet = quiet # to inject quiet setting into asn1crypto library
|
||||
|
||||
raw_output: List = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
# convert to bytes, if not already, for PEM detection since that's
|
||||
# what pem.detect() needs. (cli.py will auto-convert to UTF-8 if it can)
|
||||
try:
|
||||
der_bytes = bytes(data, 'utf-8') # type: ignore
|
||||
except TypeError:
|
||||
der_bytes = data # type: ignore
|
||||
|
||||
certs = []
|
||||
if pem.detect(der_bytes):
|
||||
for type_name, headers, der_bytes in pem.unarmor(der_bytes, multiple=True):
|
||||
if type_name == 'CERTIFICATE REQUEST' or type_name == 'NEW CERTIFICATE REQUEST':
|
||||
certs.append(csr.CertificationRequest.load(der_bytes))
|
||||
|
||||
else:
|
||||
certs.append(csr.CertificationRequest.load(der_bytes))
|
||||
|
||||
raw_output = [_fix_objects(cert.native) for cert in certs]
|
||||
|
||||
return raw_output if raw else _process(raw_output)
|
||||
@@ -81,7 +81,7 @@ except Exception:
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.7'
|
||||
version = '1.8'
|
||||
description = 'XML file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@@ -105,13 +105,18 @@ def _process(proc_data, has_data=False):
|
||||
|
||||
Dictionary representing an XML document.
|
||||
"""
|
||||
raw_output = []
|
||||
proc_output = []
|
||||
|
||||
if has_data:
|
||||
# standard output with @ prefix for attributes
|
||||
raw_output = xmltodict.parse(proc_data, dict_constructor=dict)
|
||||
try:
|
||||
proc_output = xmltodict.parse(proc_data,
|
||||
dict_constructor=dict,
|
||||
process_comments=True)
|
||||
except ValueError:
|
||||
proc_output = xmltodict.parse(proc_data, dict_constructor=dict)
|
||||
|
||||
return raw_output
|
||||
return proc_output
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
@@ -137,10 +142,17 @@ def parse(data, raw=False, quiet=False):
|
||||
if jc.utils.has_data(data):
|
||||
has_data = True
|
||||
|
||||
if raw:
|
||||
if has_data:
|
||||
# modified output with _ prefix for attributes
|
||||
raw_output = xmltodict.parse(data, dict_constructor=dict, attr_prefix='_')
|
||||
if raw and has_data:
|
||||
# modified output with _ prefix for attributes
|
||||
try:
|
||||
raw_output = xmltodict.parse(data,
|
||||
dict_constructor=dict,
|
||||
process_comments=True,
|
||||
attr_prefix='_')
|
||||
except ValueError:
|
||||
raw_output = xmltodict.parse(data,
|
||||
dict_constructor=dict,
|
||||
attr_prefix='_')
|
||||
|
||||
return raw_output
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ Schema:
|
||||
"current_height": integer,
|
||||
"maximum_width": integer,
|
||||
"maximum_height": integer,
|
||||
"associated_device": {
|
||||
"associated_modes": [
|
||||
"devices": {
|
||||
"modes": [
|
||||
{
|
||||
"resolution_width": integer,
|
||||
"resolution_height": integer,
|
||||
@@ -58,24 +58,6 @@ Schema:
|
||||
"reflection": string
|
||||
}
|
||||
],
|
||||
"unassociated_devices": [
|
||||
{
|
||||
"associated_modes": [
|
||||
{
|
||||
"resolution_width": integer,
|
||||
"resolution_height": integer,
|
||||
"is_high_resolution": boolean,
|
||||
"frequencies": [
|
||||
{
|
||||
"frequency": float,
|
||||
"is_current": boolean,
|
||||
"is_preferred": boolean
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
@@ -91,8 +73,8 @@ Examples:
|
||||
"current_height": 1080,
|
||||
"maximum_width": 32767,
|
||||
"maximum_height": 32767,
|
||||
"associated_device": {
|
||||
"associated_modes": [
|
||||
"devices": {
|
||||
"modes": [
|
||||
{
|
||||
"resolution_width": 1920,
|
||||
"resolution_height": 1080,
|
||||
@@ -136,8 +118,7 @@ Examples:
|
||||
"reflection": "normal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"unassociated_devices": []
|
||||
]
|
||||
}
|
||||
|
||||
$ xrandr --properties | jc --xrandr -p
|
||||
@@ -151,8 +132,8 @@ Examples:
|
||||
"current_height": 1080,
|
||||
"maximum_width": 32767,
|
||||
"maximum_height": 32767,
|
||||
"associated_device": {
|
||||
"associated_modes": [
|
||||
"devices": {
|
||||
"modes": [
|
||||
{
|
||||
"resolution_width": 1920,
|
||||
"resolution_height": 1080,
|
||||
@@ -199,8 +180,7 @@ Examples:
|
||||
"reflection": "normal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"unassociated_devices": []
|
||||
]
|
||||
}
|
||||
"""
|
||||
import re
|
||||
@@ -212,14 +192,15 @@ from jc.parsers.pyedid.helpers.edid_helper import EdidHelper
|
||||
|
||||
class info:
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = "1.2"
|
||||
|
||||
version = "1.3"
|
||||
description = "`xrandr` command parser"
|
||||
author = "Kevin Lyter"
|
||||
author_email = "lyter_git at sent.com"
|
||||
details = 'Using parts of the pyedid library at https://github.com/jojonas/pyedid.'
|
||||
author_email = "code (at) lyterk.com"
|
||||
details = "Using parts of the pyedid library at https://github.com/jojonas/pyedid."
|
||||
compatible = ["linux", "darwin", "cygwin", "aix", "freebsd"]
|
||||
magic_commands = ["xrandr"]
|
||||
tags = ['command']
|
||||
tags = ["command"]
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
@@ -267,7 +248,7 @@ try:
|
||||
"offset_height": int,
|
||||
"dimension_width": int,
|
||||
"dimension_height": int,
|
||||
"associated_modes": List[Mode],
|
||||
"modes": List[Mode],
|
||||
"rotation": str,
|
||||
"reflection": str,
|
||||
},
|
||||
@@ -282,14 +263,13 @@ try:
|
||||
"current_height": int,
|
||||
"maximum_width": int,
|
||||
"maximum_height": int,
|
||||
"associated_device": Device,
|
||||
"devices": List[Device],
|
||||
},
|
||||
)
|
||||
Response = TypedDict(
|
||||
"Response",
|
||||
{
|
||||
"screens": List[Screen],
|
||||
"unassociated_devices": List[Device],
|
||||
},
|
||||
)
|
||||
except ImportError:
|
||||
@@ -317,14 +297,17 @@ def _parse_screen(next_lines: List[str]) -> Optional[Screen]:
|
||||
return None
|
||||
|
||||
raw_matches = result.groupdict()
|
||||
screen: Screen = {}
|
||||
|
||||
screen: Screen = {"devices": []}
|
||||
for k, v in raw_matches.items():
|
||||
screen[k] = int(v)
|
||||
|
||||
if next_lines:
|
||||
while next_lines:
|
||||
device: Optional[Device] = _parse_device(next_lines)
|
||||
if device:
|
||||
screen["associated_device"] = device
|
||||
if not device:
|
||||
break
|
||||
else:
|
||||
screen["devices"].append(device)
|
||||
|
||||
return screen
|
||||
|
||||
@@ -358,7 +341,7 @@ def _parse_device(next_lines: List[str], quiet: bool = False) -> Optional[Device
|
||||
matches = result.groupdict()
|
||||
|
||||
device: Device = {
|
||||
"associated_modes": [],
|
||||
"modes": [],
|
||||
"is_connected": matches["is_connected"] == "connected",
|
||||
"is_primary": matches["is_primary"] is not None
|
||||
and len(matches["is_primary"]) > 0,
|
||||
@@ -367,14 +350,21 @@ def _parse_device(next_lines: List[str], quiet: bool = False) -> Optional[Device
|
||||
"reflection": matches["reflection"] or "normal",
|
||||
}
|
||||
for k, v in matches.items():
|
||||
if k not in {"is_connected", "is_primary", "device_name", "rotation", "reflection"}:
|
||||
if k not in {
|
||||
"is_connected",
|
||||
"is_primary",
|
||||
"device_name",
|
||||
"rotation",
|
||||
"reflection",
|
||||
}:
|
||||
try:
|
||||
if v:
|
||||
device[k] = int(v)
|
||||
except ValueError and not quiet:
|
||||
jc.utils.warning_message(
|
||||
[f"{next_line} : {k} - {v} is not int-able"]
|
||||
)
|
||||
except ValueError:
|
||||
if not quiet:
|
||||
jc.utils.warning_message(
|
||||
[f"{next_line} : {k} - {v} is not int-able"]
|
||||
)
|
||||
|
||||
model: Optional[Model] = _parse_model(next_lines, quiet)
|
||||
if model:
|
||||
@@ -386,7 +376,7 @@ def _parse_device(next_lines: List[str], quiet: bool = False) -> Optional[Device
|
||||
next_line = next_lines.pop()
|
||||
next_mode: Optional[Mode] = _parse_mode(next_line)
|
||||
if next_mode:
|
||||
device["associated_modes"].append(next_mode)
|
||||
device["modes"].append(next_mode)
|
||||
else:
|
||||
if re.match(_device_pattern, next_line):
|
||||
next_lines.append(next_line)
|
||||
@@ -481,7 +471,7 @@ def _parse_mode(line: str) -> Optional[Mode]:
|
||||
return mode
|
||||
|
||||
|
||||
def parse(data: str, raw: bool =False, quiet: bool =False) -> Dict:
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict:
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
@@ -500,19 +490,12 @@ def parse(data: str, raw: bool =False, quiet: bool =False) -> Dict:
|
||||
|
||||
linedata = data.splitlines()
|
||||
linedata.reverse() # For popping
|
||||
result: Response = {"screens": [], "unassociated_devices": []}
|
||||
result: Response = {"screens": []}
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
while linedata:
|
||||
screen = _parse_screen(linedata)
|
||||
if screen:
|
||||
result["screens"].append(screen)
|
||||
else:
|
||||
device = _parse_device(linedata, quiet)
|
||||
if device:
|
||||
result["unassociated_devices"].append(device)
|
||||
|
||||
if not result["unassociated_devices"] and not result["screens"]:
|
||||
return {}
|
||||
|
||||
return result
|
||||
|
||||
@@ -151,8 +151,9 @@ def compatibility(mod_name: str, compatible: List[str], quiet: bool = False) ->
|
||||
mod = mod_name.split('.')[-1]
|
||||
compat_list = ', '.join(compatible)
|
||||
warning_message([
|
||||
f'{mod} parser is not compatible with your OS ({sys.platform}).',
|
||||
f'Compatible platforms: {compat_list}'
|
||||
f'`{mod}` command output from this OS ({sys.platform}) is not supported.',
|
||||
f'`{mod}` command output from the following platforms is supported: {compat_list}',
|
||||
'Disregard this warning if you are processing output that came from a supported platform. (Use the -q option to suppress this warning)'
|
||||
])
|
||||
|
||||
|
||||
|
||||
62
man/jc.1
62
man/jc.1
@@ -1,4 +1,4 @@
|
||||
.TH jc 1 2023-04-30 1.23.2 "JSON Convert"
|
||||
.TH jc 1 2023-10-21 1.23.5 "JSON Convert"
|
||||
.SH NAME
|
||||
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
|
||||
and strings
|
||||
@@ -192,6 +192,11 @@ Email Address string parser
|
||||
\fB--file\fP
|
||||
`file` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--find\fP
|
||||
`find` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--findmnt\fP
|
||||
@@ -262,6 +267,11 @@ hashsum command parser (`md5sum`, `shasum`, etc.)
|
||||
\fB--history\fP
|
||||
`history` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--host\fP
|
||||
`host` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--hosts\fP
|
||||
@@ -307,6 +317,11 @@ IPv4 and IPv6 Address string parser
|
||||
\fB--iptables\fP
|
||||
`iptables` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--ip-route\fP
|
||||
`ip route` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--iso-datetime\fP
|
||||
@@ -357,6 +372,16 @@ Key/Value file and string parser
|
||||
\fB--ls-s\fP
|
||||
`ls` command streaming parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--lsattr\fP
|
||||
`lsattr` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--lsb-release\fP
|
||||
`lsb_release` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--lsblk\fP
|
||||
@@ -417,6 +442,11 @@ M3U and M3U8 file parser
|
||||
\fB--nmcli\fP
|
||||
`nmcli` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--nsd-control\fP
|
||||
`nsd-control` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--ntpq\fP
|
||||
@@ -432,6 +462,11 @@ openvpn-status.log file parser
|
||||
\fB--os-prober\fP
|
||||
`os-prober` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--os-release\fP
|
||||
`/etc/os-release` file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--passwd\fP
|
||||
@@ -687,6 +722,11 @@ PLIST file parser
|
||||
\fB--proc-net-route\fP
|
||||
`/proc/net/route` file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--proc-net-tcp\fP
|
||||
`/proc/net/tcp` and `/proc/net/tcp6` file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--proc-net-unix\fP
|
||||
@@ -742,6 +782,11 @@ PLIST file parser
|
||||
\fB--ps\fP
|
||||
`ps` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--resolve-conf\fP
|
||||
`/etc/resolve.conf` file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--route\fP
|
||||
@@ -777,6 +822,11 @@ Semantic Version string parser
|
||||
\fB--shadow\fP
|
||||
`/etc/shadow` file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--srt\fP
|
||||
SRT file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--ss\fP
|
||||
@@ -942,6 +992,11 @@ URL string parser
|
||||
\fB--ver\fP
|
||||
Version string parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--veracrypt\fP
|
||||
`veracrypt` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--vmstat\fP
|
||||
@@ -972,6 +1027,11 @@ Version string parser
|
||||
\fB--x509-cert\fP
|
||||
X.509 PEM and DER certificate file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--x509-csr\fP
|
||||
X.509 PEM and DER certificate request file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--xml\fP
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
[metadata]
|
||||
license_file = LICENSE.md
|
||||
license_files = LICENSE.md
|
||||
|
||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
|
||||
|
||||
setuptools.setup(
|
||||
name='jc',
|
||||
version='1.23.2',
|
||||
version='1.23.5',
|
||||
author='Kelly Brazil',
|
||||
author_email='kellyjonbrazil@gmail.com',
|
||||
description='Converts the output of popular command-line tools and file-types to JSON.',
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
|
||||
> Try the `jc` [web demo](https://jc-web.onrender.com/) and [REST API](https://github.com/kellyjonbrazil/jc-restapi)
|
||||
|
||||
> JC is [now available](https://galaxy.ansible.com/community/general) as an
|
||||
> `jc` is [now available](https://galaxy.ansible.com/community/general) as an
|
||||
Ansible filter plugin in the `community.general` collection. See this
|
||||
[blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
|
||||
for an example.
|
||||
|
||||
> Looking for something like `jc` but lower-level? Check out [regex2json](https://gitlab.com/tozd/regex2json).
|
||||
|
||||
# JC
|
||||
JSON Convert
|
||||
|
||||
|
||||
13
tests/fixtures/centos-7.7/find.json
vendored
Normal file
13
tests/fixtures/centos-7.7/find.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
[{"path": null, "node": "."},
|
||||
{"path":".","node":null},
|
||||
{"path": ".","node": "jc"},
|
||||
{"path": "./jc","node": "tests"},
|
||||
{"path": "./jc/tests","node": "test_find.py"},
|
||||
{"path": "./jc/tests","node": "test_history.py"},
|
||||
{"path": "./jc/tests","node": "test_hosts.py"},
|
||||
{"path": "./jc","node": "anotherdirectory"},
|
||||
{"path": null,"node": null,"error": "find: './inaccessible': Permission denied"},
|
||||
{"path": "./jc","node": "directory2"},
|
||||
{"path": "./jc/directory2","node": "file.txt"},
|
||||
{"path": "./jc/directory2","node": "file2.txt"},
|
||||
{"path": ".","node": "newfile.txt"}]
|
||||
13
tests/fixtures/centos-7.7/find.out
vendored
Normal file
13
tests/fixtures/centos-7.7/find.out
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
.
|
||||
./
|
||||
./jc
|
||||
./jc/tests
|
||||
./jc/tests/test_find.py
|
||||
./jc/tests/test_history.py
|
||||
./jc/tests/test_hosts.py
|
||||
./jc/anotherdirectory
|
||||
find: './inaccessible': Permission denied
|
||||
./jc/directory2
|
||||
./jc/directory2/file.txt
|
||||
./jc/directory2/file2.txt
|
||||
./newfile.txt
|
||||
31
tests/fixtures/centos-7.7/ip_route.json
vendored
Normal file
31
tests/fixtures/centos-7.7/ip_route.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
[
|
||||
{
|
||||
"ip": "default",
|
||||
"via": "10.0.2.2",
|
||||
"dev": "enp0s3",
|
||||
"proto": "dhcp",
|
||||
"metric": 100
|
||||
},
|
||||
{
|
||||
"ip": "10.0.2.0/24",
|
||||
"dev": "enp0s3",
|
||||
"proto": "kernel",
|
||||
"scope": "link",
|
||||
"src": "10.0.2.15",
|
||||
"metric": 100
|
||||
},
|
||||
{
|
||||
"ip": "169.254.0.0/16",
|
||||
"dev": "enp0s3",
|
||||
"scope": "link",
|
||||
"metric": 1000
|
||||
},
|
||||
{
|
||||
"ip": "172.17.0.0/16",
|
||||
"dev": "docker0",
|
||||
"proto": "kernel",
|
||||
"scope": "link",
|
||||
"src": "172.17.0.1",
|
||||
"status": "linkdown"
|
||||
}
|
||||
]
|
||||
4
tests/fixtures/centos-7.7/ip_route.out
vendored
Normal file
4
tests/fixtures/centos-7.7/ip_route.out
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
default via 10.0.2.2 dev enp0s3 proto dhcp metric 100
|
||||
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100
|
||||
169.254.0.0/16 dev enp0s3 scope link metric 1000
|
||||
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
|
||||
1
tests/fixtures/centos-7.7/last-wixF.json
vendored
Normal file
1
tests/fixtures/centos-7.7/last-wixF.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"user":"root","tty":"pts/0","hostname":"192.168.255.1","login":"Mon Jun 19 14:18:13 2023","logout":"still logged in","login_epoch":1687209493}, {"user":"mark","tty":"pts/0","hostname":"192.168.255.1","login":"Mon Jun 19 14:15:57 2023","logout":"Mon Jun 19 14:18:00 2023","duration":"00:02","login_epoch":1687209357,"logout_epoch":1687209480,"duration_seconds":123}, {"user":"mark","tty":"pts/0","hostname":"192.168.255.1","login":"Mon Jun 19 14:15:45 2023","logout":"Mon Jun 19 14:15:52 2023","duration":"00:00","login_epoch":1687209345,"logout_epoch":1687209352,"duration_seconds":7}, {"user":"mark","tty":"tty1","hostname":"0.0.0.0","login":"Mon Jun 19 16:59:57 2023","logout":"still logged in","login_epoch":1687219197}, {"user":"runlevel","tty":"(to lvl 3)","hostname":"0.0.0.0","login":"Mon Jun 19 16:59:39 2023","logout":"Mon Jun 19 14:35:00 2023","duration":"-2:-24","login_epoch":1687219179,"logout_epoch":1687210500,"duration_seconds":-8679}, {"user":"reboot","tty":"system boot","hostname":"0.0.0.0","login":"Mon Jun 19 16:59:20 2023","logout":"Mon Jun 19 14:35:00 2023","duration":"-2:-24","login_epoch":1687219160,"logout_epoch":1687210500,"duration_seconds":-8660},{"user": "shutdown","tty": "system down","hostname": "0.0.0.0","login": "Fri Apr 14 13:46:46 2023","logout": "Fri Apr 14 13:47:12 2023","duration": "00:00","login_epoch": 1681505206,"logout_epoch": 1681505232,"duration_seconds": 26}]
|
||||
9
tests/fixtures/centos-7.7/last-wixF.out
vendored
Normal file
9
tests/fixtures/centos-7.7/last-wixF.out
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
root pts/0 192.168.255.1 Mon Jun 19 14:18:13 2023 still logged in
|
||||
mark pts/0 192.168.255.1 Mon Jun 19 14:15:57 2023 - Mon Jun 19 14:18:00 2023 (00:02)
|
||||
mark pts/0 192.168.255.1 Mon Jun 19 14:15:45 2023 - Mon Jun 19 14:15:52 2023 (00:00)
|
||||
mark tty1 0.0.0.0 Mon Jun 19 16:59:57 2023 still logged in
|
||||
runlevel (to lvl 3) 0.0.0.0 Mon Jun 19 16:59:39 2023 - Mon Jun 19 14:35:00 2023 (-2:-24)
|
||||
reboot system boot 0.0.0.0 Mon Jun 19 16:59:20 2023 - Mon Jun 19 14:35:00 2023 (-2:-24)
|
||||
shutdown system down 0.0.0.0 Fri Apr 14 13:46:46 2023 - Fri Apr 14 13:47:12 2023 (00:00)
|
||||
|
||||
wtmp begins Mon Jun 19 16:59:20 2023
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978465.914536,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":1,"ttl":59,"time_ms":31.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978465.993009,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":2,"ttl":59,"time_ms":30.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978467.010196,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":3,"ttl":59,"time_ms":32.0,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978468.033743,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":4,"ttl":59,"time_ms":38.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978469.051227,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":5,"ttl":59,"time_ms":38.0,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978470.048764,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":6,"ttl":59,"time_ms":29.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978471.051945,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":7,"ttl":59,"time_ms":28.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978472.064206,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":8,"ttl":59,"time_ms":37.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978473.062587,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":9,"ttl":59,"time_ms":31.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978474.074343,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":10,"ttl":59,"time_ms":38.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978475.079703,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":11,"ttl":59,"time_ms":38.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978476.076383,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":12,"ttl":59,"time_ms":30.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978477.084119,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":13,"ttl":59,"time_ms":30.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978478.092207,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":14,"ttl":59,"time_ms":31.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978479.104358,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":15,"ttl":59,"time_ms":37.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978480.106907,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":16,"ttl":59,"time_ms":37.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978481.11558,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":17,"ttl":59,"time_ms":37.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978482.119872,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":18,"ttl":59,"time_ms":33.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978483.131901,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":19,"ttl":59,"time_ms":37.0,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978484.141117,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":20,"ttl":59,"time_ms":36.9,"duplicate":false},{"type":"summary","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19146.0,"round_trip_ms_min":28.96,"round_trip_ms_avg":34.468,"round_trip_ms_max":38.892,"round_trip_ms_stddev":3.497}]
|
||||
[{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978465.914536,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":1,"ttl":59,"time_ms":31.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978465.993009,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":2,"ttl":59,"time_ms":30.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978467.010196,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":3,"ttl":59,"time_ms":32.0,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978468.033743,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":4,"ttl":59,"time_ms":38.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978469.051227,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":5,"ttl":59,"time_ms":38.0,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978470.048764,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":6,"ttl":59,"time_ms":29.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978471.051945,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":7,"ttl":59,"time_ms":28.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978472.064206,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":8,"ttl":59,"time_ms":37.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978473.062587,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":9,"ttl":59,"time_ms":31.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978474.074343,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":10,"ttl":59,"time_ms":38.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978475.079703,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":11,"ttl":59,"time_ms":38.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978476.076383,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":12,"ttl":59,"time_ms":30.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978477.084119,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":13,"ttl":59,"time_ms":30.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978478.092207,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":14,"ttl":59,"time_ms":31.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978479.104358,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":15,"ttl":59,"time_ms":37.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978480.106907,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":16,"ttl":59,"time_ms":37.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978481.11558,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":17,"ttl":59,"time_ms":37.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978482.119872,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":18,"ttl":59,"time_ms":33.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978483.131901,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":19,"ttl":59,"time_ms":37.0,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978484.141117,"response_bytes":1408,"response_ip":"151.101.189.67","icmp_seq":20,"ttl":59,"time_ms":36.9,"duplicate":false},{"type":"summary","destination_ip":"151.101.189.67","sent_bytes":1400,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19146.0,"round_trip_ms_min":28.96,"round_trip_ms_avg":34.468,"round_trip_ms_max":38.892,"round_trip_ms_stddev":3.497}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":1,"ttl":59,"time_ms":24.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":2,"ttl":59,"time_ms":23.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":3,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":4,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":5,"ttl":59,"time_ms":26.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":6,"ttl":59,"time_ms":24.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":7,"ttl":59,"time_ms":24.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":8,"ttl":59,"time_ms":33.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":9,"ttl":59,"time_ms":32.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":10,"ttl":59,"time_ms":31.2,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":11,"ttl":59,"time_ms":25.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":12,"ttl":59,"time_ms":33.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":13,"ttl":59,"time_ms":23.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":14,"ttl":59,"time_ms":23.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":15,"ttl":59,"time_ms":33.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":16,"ttl":59,"time_ms":24.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":17,"ttl":59,"time_ms":30.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":18,"ttl":59,"time_ms":24.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":19,"ttl":59,"time_ms":32.2,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":20,"ttl":59,"time_ms":31.0,"duplicate":false},{"type":"summary","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19233.0,"round_trip_ms_min":23.359,"round_trip_ms_avg":28.495,"round_trip_ms_max":33.979,"round_trip_ms_stddev":4.081}]
|
||||
[{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":1,"ttl":59,"time_ms":24.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":2,"ttl":59,"time_ms":23.3,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":3,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":4,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":5,"ttl":59,"time_ms":26.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":6,"ttl":59,"time_ms":24.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":7,"ttl":59,"time_ms":24.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":8,"ttl":59,"time_ms":33.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":9,"ttl":59,"time_ms":32.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":10,"ttl":59,"time_ms":31.2,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":11,"ttl":59,"time_ms":25.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":12,"ttl":59,"time_ms":33.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":13,"ttl":59,"time_ms":23.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":14,"ttl":59,"time_ms":23.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":15,"ttl":59,"time_ms":33.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":16,"ttl":59,"time_ms":24.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":17,"ttl":59,"time_ms":30.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":18,"ttl":59,"time_ms":24.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":19,"ttl":59,"time_ms":32.2,"duplicate":false},{"type":"reply","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"151.101.129.67","icmp_seq":20,"ttl":59,"time_ms":31.0,"duplicate":false},{"type":"summary","destination_ip":"151.101.129.67","sent_bytes":56,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19233.0,"round_trip_ms_min":23.359,"round_trip_ms_avg":28.495,"round_trip_ms_max":33.979,"round_trip_ms_stddev":4.081}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":1,"ttl":59,"time_ms":29.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":2,"ttl":59,"time_ms":30.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":3,"ttl":59,"time_ms":35.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":4,"ttl":59,"time_ms":35.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":5,"ttl":59,"time_ms":34.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":6,"ttl":59,"time_ms":29.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":7,"ttl":59,"time_ms":27.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":8,"ttl":59,"time_ms":28.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":9,"ttl":59,"time_ms":35.2,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":10,"ttl":59,"time_ms":34.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":11,"ttl":59,"time_ms":35.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":12,"ttl":59,"time_ms":35.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":13,"ttl":59,"time_ms":34.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":14,"ttl":59,"time_ms":35.5,"duplicate":false},{"type":"timeout","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"icmp_seq":15},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":16,"ttl":59,"time_ms":36.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":17,"ttl":59,"time_ms":34.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":18,"ttl":59,"time_ms":34.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":19,"ttl":59,"time_ms":36.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":20,"ttl":59,"time_ms":34.3,"duplicate":false},{"type":"summary","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":19,"packet_loss_percent":5.0,"duplicates":0,"time_ms":19125.0,"round_trip_ms_min":27.656,"round_trip_ms_avg":33.717,"round_trip_ms_max":36.758,"round_trip_ms_stddev":2.814}]
|
||||
[{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":1,"ttl":59,"time_ms":29.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":2,"ttl":59,"time_ms":30.1,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":3,"ttl":59,"time_ms":35.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":4,"ttl":59,"time_ms":35.5,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":5,"ttl":59,"time_ms":34.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":6,"ttl":59,"time_ms":29.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":7,"ttl":59,"time_ms":27.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":8,"ttl":59,"time_ms":28.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":9,"ttl":59,"time_ms":35.2,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":10,"ttl":59,"time_ms":34.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":11,"ttl":59,"time_ms":35.9,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":12,"ttl":59,"time_ms":35.8,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":13,"ttl":59,"time_ms":34.4,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":14,"ttl":59,"time_ms":35.5,"duplicate":false},{"type":"timeout","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"icmp_seq":15},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":16,"ttl":59,"time_ms":36.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":17,"ttl":59,"time_ms":34.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":18,"ttl":59,"time_ms":34.6,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":19,"ttl":59,"time_ms":36.7,"duplicate":false},{"type":"reply","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"151.101.189.67","icmp_seq":20,"ttl":59,"time_ms":34.3,"duplicate":false},{"type":"summary","destination_ip":"151.101.189.67","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":19,"packet_loss_percent":5.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19125.0,"round_trip_ms_min":27.656,"round_trip_ms_avg":33.717,"round_trip_ms_max":36.758,"round_trip_ms_stddev":2.814}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037214.261953,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":1,"ttl":64,"time_ms":0.041,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037215.264798,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":2,"ttl":64,"time_ms":0.048,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037216.272296,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":3,"ttl":64,"time_ms":0.047,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037217.275851,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":4,"ttl":64,"time_ms":0.062,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037218.284242,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":5,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037219.283712,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":6,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037220.290949,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":7,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037221.295962,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":8,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037222.30702,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":9,"ttl":64,"time_ms":0.048,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037223.313919,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":10,"ttl":64,"time_ms":0.081,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037224.313679,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":11,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037225.320748,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":12,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037226.324322,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":13,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037227.325835,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":14,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037228.327028,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":15,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037229.329891,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":16,"ttl":64,"time_ms":0.052,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037230.333891,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":17,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037231.338137,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":18,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037232.340475,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":19,"ttl":64,"time_ms":0.048,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037233.343058,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":20,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"summary","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19081.0,"round_trip_ms_min":0.041,"round_trip_ms_avg":0.048,"round_trip_ms_max":0.081,"round_trip_ms_stddev":0.009}]
|
||||
[{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037214.261953,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":1,"ttl":64,"time_ms":0.041,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037215.264798,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":2,"ttl":64,"time_ms":0.048,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037216.272296,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":3,"ttl":64,"time_ms":0.047,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037217.275851,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":4,"ttl":64,"time_ms":0.062,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037218.284242,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":5,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037219.283712,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":6,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037220.290949,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":7,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037221.295962,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":8,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037222.30702,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":9,"ttl":64,"time_ms":0.048,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037223.313919,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":10,"ttl":64,"time_ms":0.081,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037224.313679,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":11,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037225.320748,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":12,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037226.324322,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":13,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037227.325835,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":14,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037228.327028,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":15,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037229.329891,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":16,"ttl":64,"time_ms":0.052,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037230.333891,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":17,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037231.338137,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":18,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037232.340475,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":19,"ttl":64,"time_ms":0.048,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":1595037233.343058,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":20,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"summary","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19081.0,"round_trip_ms_min":0.041,"round_trip_ms_avg":0.048,"round_trip_ms_max":0.081,"round_trip_ms_stddev":0.009}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":1,"ttl":64,"time_ms":0.038,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":2,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":3,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":4,"ttl":64,"time_ms":0.052,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":5,"ttl":64,"time_ms":0.08,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":6,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":7,"ttl":64,"time_ms":0.047,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":8,"ttl":64,"time_ms":0.04,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":9,"ttl":64,"time_ms":0.052,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":10,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":11,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":12,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":13,"ttl":64,"time_ms":0.05,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":14,"ttl":64,"time_ms":0.045,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":15,"ttl":64,"time_ms":0.062,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":16,"ttl":64,"time_ms":0.046,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":17,"ttl":64,"time_ms":0.046,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":18,"ttl":64,"time_ms":0.045,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":19,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":20,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"summary","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19070.0,"round_trip_ms_min":0.038,"round_trip_ms_avg":0.047,"round_trip_ms_max":0.08,"round_trip_ms_stddev":0.011,"_jc_meta":{"success":true}}]
|
||||
[{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":1,"ttl":64,"time_ms":0.038,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":2,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":3,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":4,"ttl":64,"time_ms":0.052,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":5,"ttl":64,"time_ms":0.08,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":6,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":7,"ttl":64,"time_ms":0.047,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":8,"ttl":64,"time_ms":0.04,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":9,"ttl":64,"time_ms":0.052,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":10,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":11,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":12,"ttl":64,"time_ms":0.043,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":13,"ttl":64,"time_ms":0.05,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":14,"ttl":64,"time_ms":0.045,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":15,"ttl":64,"time_ms":0.062,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":16,"ttl":64,"time_ms":0.046,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":17,"ttl":64,"time_ms":0.046,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":18,"ttl":64,"time_ms":0.045,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":19,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":20,"ttl":64,"time_ms":0.044,"duplicate":false,"_jc_meta":{"success":true}},{"type":"summary","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19070.0,"round_trip_ms_min":0.038,"round_trip_ms_avg":0.047,"round_trip_ms_max":0.08,"round_trip_ms_stddev":0.011,"_jc_meta":{"success":true}}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":1,"ttl":64,"time_ms":0.038,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":2,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":3,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":4,"ttl":64,"time_ms":0.052,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":5,"ttl":64,"time_ms":0.08,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":6,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":7,"ttl":64,"time_ms":0.047,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":8,"ttl":64,"time_ms":0.04,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":9,"ttl":64,"time_ms":0.052,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":10,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":11,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":12,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":13,"ttl":64,"time_ms":0.05,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":14,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":15,"ttl":64,"time_ms":0.062,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":16,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":17,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":18,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":19,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":20,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"summary","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19070.0,"round_trip_ms_min":0.038,"round_trip_ms_avg":0.047,"round_trip_ms_max":0.08,"round_trip_ms_stddev":0.011}]
|
||||
[{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":1,"ttl":64,"time_ms":0.038,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":2,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":3,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":4,"ttl":64,"time_ms":0.052,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":5,"ttl":64,"time_ms":0.08,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":6,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":7,"ttl":64,"time_ms":0.047,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":8,"ttl":64,"time_ms":0.04,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":9,"ttl":64,"time_ms":0.052,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":10,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":11,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":12,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":13,"ttl":64,"time_ms":0.05,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":14,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":15,"ttl":64,"time_ms":0.062,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":16,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":17,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":18,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":19,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"127.0.0.1","icmp_seq":20,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"summary","destination_ip":"127.0.0.1","sent_bytes":56,"pattern":null,"packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19070.0,"round_trip_ms_min":0.038,"round_trip_ms_avg":0.047,"round_trip_ms_max":0.08,"round_trip_ms_stddev":0.011}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.221","icmp_seq":1,"ttl":64,"time_ms":0.586,"duplicate":false},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.88","icmp_seq":1,"ttl":64,"time_ms":382.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.78","icmp_seq":1,"ttl":128,"time_ms":382.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.217","icmp_seq":1,"ttl":255,"time_ms":387.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.186","icmp_seq":1,"ttl":64,"time_ms":389.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.89","icmp_seq":1,"ttl":64,"time_ms":389.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.75","icmp_seq":1,"ttl":64,"time_ms":584.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.221","icmp_seq":2,"ttl":64,"time_ms":0.861,"duplicate":false},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.78","icmp_seq":2,"ttl":128,"time_ms":4.17,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.88","icmp_seq":2,"ttl":64,"time_ms":4.19,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.89","icmp_seq":2,"ttl":64,"time_ms":12.7,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.81","icmp_seq":1,"ttl":64,"time_ms":1029.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.72","icmp_seq":1,"ttl":64,"time_ms":1276.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.251","icmp_seq":1,"ttl":64,"time_ms":1276.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.251","icmp_seq":2,"ttl":64,"time_ms":262.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.72","icmp_seq":2,"ttl":64,"time_ms":263.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.246","icmp_seq":2,"ttl":255,"time_ms":263.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.217","icmp_seq":2,"ttl":255,"time_ms":919.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.186","icmp_seq":2,"ttl":64,"time_ms":919.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.75","icmp_seq":2,"ttl":64,"time_ms":919.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.81","icmp_seq":2,"ttl":64,"time_ms":919.0,"duplicate":true},{"type":"summary","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"packets_transmitted":2,"packets_received":2,"packet_loss_percent":0.0,"duplicates":19,"time_ms":1013.0,"round_trip_ms_min":0.586,"round_trip_ms_avg":504.26,"round_trip_ms_max":1276.448,"round_trip_ms_stddev":417.208}]
|
||||
[{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.221","icmp_seq":1,"ttl":64,"time_ms":0.586,"duplicate":false},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.88","icmp_seq":1,"ttl":64,"time_ms":382.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.78","icmp_seq":1,"ttl":128,"time_ms":382.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.217","icmp_seq":1,"ttl":255,"time_ms":387.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.186","icmp_seq":1,"ttl":64,"time_ms":389.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.89","icmp_seq":1,"ttl":64,"time_ms":389.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.75","icmp_seq":1,"ttl":64,"time_ms":584.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.221","icmp_seq":2,"ttl":64,"time_ms":0.861,"duplicate":false},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.78","icmp_seq":2,"ttl":128,"time_ms":4.17,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.88","icmp_seq":2,"ttl":64,"time_ms":4.19,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.89","icmp_seq":2,"ttl":64,"time_ms":12.7,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.81","icmp_seq":1,"ttl":64,"time_ms":1029.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.72","icmp_seq":1,"ttl":64,"time_ms":1276.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.251","icmp_seq":1,"ttl":64,"time_ms":1276.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.251","icmp_seq":2,"ttl":64,"time_ms":262.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.72","icmp_seq":2,"ttl":64,"time_ms":263.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.246","icmp_seq":2,"ttl":255,"time_ms":263.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.217","icmp_seq":2,"ttl":255,"time_ms":919.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.186","icmp_seq":2,"ttl":64,"time_ms":919.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.75","icmp_seq":2,"ttl":64,"time_ms":919.0,"duplicate":true},{"type":"reply","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"192.168.1.81","icmp_seq":2,"ttl":64,"time_ms":919.0,"duplicate":true},{"type":"summary","destination_ip":"192.168.1.255","sent_bytes":56,"pattern":null,"packets_transmitted":2,"packets_received":2,"packet_loss_percent":0.0,"duplicates":19,"errors":null,"corrupted":null,"time_ms":1013.0,"round_trip_ms_min":0.586,"round_trip_ms_avg":504.26,"round_trip_ms_max":1276.448,"round_trip_ms_stddev":417.208}]
|
||||
|
||||
1
tests/fixtures/centos-7.7/ping-missing-hostname-streaming.json
vendored
Normal file
1
tests/fixtures/centos-7.7/ping-missing-hostname-streaming.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"type":"reply","destination_ip":"100.68.105.124","sent_bytes":56,"pattern":null,"timestamp":null,"response_bytes":64,"response_ip":"100.68.105.124","icmp_seq":1,"ttl":64,"time_ms":0.04,"duplicate":false},{"type":"summary","destination_ip":"100.68.105.124","sent_bytes":56,"pattern":null,"packets_transmitted":1,"packets_received":1,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":0.0,"round_trip_ms_min":0.04,"round_trip_ms_avg":0.04,"round_trip_ms_max":0.04,"round_trip_ms_stddev":0.0}]
|
||||
1
tests/fixtures/centos-7.7/ping-missing-hostname.json
vendored
Normal file
1
tests/fixtures/centos-7.7/ping-missing-hostname.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"destination_ip":"100.68.105.124","data_bytes":56,"pattern":null,"packets_transmitted":1,"packets_received":1,"packet_loss_percent":0.0,"duplicates":0,"time_ms":0.0,"round_trip_ms_min":0.04,"round_trip_ms_avg":0.04,"round_trip_ms_max":0.04,"round_trip_ms_stddev":0.0,"responses":[{"type":"reply","timestamp":null,"bytes":64,"response_ip":"100.68.105.124","icmp_seq":1,"ttl":64,"time_ms":0.04,"duplicate":false}]}
|
||||
6
tests/fixtures/centos-7.7/ping-missing-hostname.out
vendored
Normal file
6
tests/fixtures/centos-7.7/ping-missing-hostname.out
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
PING (100.68.105.124) 56(84) bytes of data.
|
||||
64 bytes from 100.68.105.124 (100.68.105.124): icmp_seq=1 ttl=64 time=0.040 ms
|
||||
|
||||
--- ping statistics ---
|
||||
1 packets transmitted, 1 received, 0% packet loss, time 0ms
|
||||
rtt min/avg/max/mdev = 0.040/0.040/0.040/0.000 ms
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978345.609669,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":1,"ttl":59,"time_ms":32.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978346.58542,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":2,"ttl":59,"time_ms":39.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978347.594128,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":3,"ttl":59,"time_ms":42.3,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978348.595221,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":4,"ttl":59,"time_ms":40.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978349.600372,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":5,"ttl":59,"time_ms":43.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978350.590676,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":6,"ttl":59,"time_ms":31.8,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978351.601527,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":7,"ttl":59,"time_ms":41.8,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978352.604195,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":8,"ttl":59,"time_ms":41.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978353.607212,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":9,"ttl":59,"time_ms":42.0,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978354.610771,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":10,"ttl":59,"time_ms":40.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978355.613729,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":11,"ttl":59,"time_ms":40.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978356.611887,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":12,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978357.62481,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":13,"ttl":59,"time_ms":40.1,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978358.629185,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":14,"ttl":59,"time_ms":42.0,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978359.634854,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":15,"ttl":59,"time_ms":41.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978360.638344,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":16,"ttl":59,"time_ms":40.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978361.640968,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":17,"ttl":59,"time_ms":40.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978362.645739,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":18,"ttl":59,"time_ms":39.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978363.6467,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":19,"ttl":59,"time_ms":37.5,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978364.650853,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":20,"ttl":59,"time_ms":33.6,"duplicate":false},{"type":"summary","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19077.0,"round_trip_ms_min":31.845,"round_trip_ms_avg":39.274,"round_trip_ms_max":43.243,"round_trip_ms_stddev":3.522}]
|
||||
[{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978345.609669,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":1,"ttl":59,"time_ms":32.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978346.58542,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":2,"ttl":59,"time_ms":39.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978347.594128,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":3,"ttl":59,"time_ms":42.3,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978348.595221,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":4,"ttl":59,"time_ms":40.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978349.600372,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":5,"ttl":59,"time_ms":43.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978350.590676,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":6,"ttl":59,"time_ms":31.8,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978351.601527,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":7,"ttl":59,"time_ms":41.8,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978352.604195,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":8,"ttl":59,"time_ms":41.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978353.607212,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":9,"ttl":59,"time_ms":42.0,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978354.610771,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":10,"ttl":59,"time_ms":40.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978355.613729,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":11,"ttl":59,"time_ms":40.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978356.611887,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":12,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978357.62481,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":13,"ttl":59,"time_ms":40.1,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978358.629185,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":14,"ttl":59,"time_ms":42.0,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978359.634854,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":15,"ttl":59,"time_ms":41.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978360.638344,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":16,"ttl":59,"time_ms":40.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978361.640968,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":17,"ttl":59,"time_ms":40.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978362.645739,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":18,"ttl":59,"time_ms":39.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978363.6467,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":19,"ttl":59,"time_ms":37.5,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","timestamp":1594978364.650853,"response_bytes":1408,"response_ip":"2a04:4e42:2d::323","icmp_seq":20,"ttl":59,"time_ms":33.6,"duplicate":false},{"type":"summary","destination_ip":"2a04:4e42:2d::323","sent_bytes":1400,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19077.0,"round_trip_ms_min":31.845,"round_trip_ms_avg":39.274,"round_trip_ms_max":43.243,"round_trip_ms_stddev":3.522}]
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":1,"ttl":59,"time_ms":30.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":2,"ttl":59,"time_ms":39.0,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":3,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":4,"ttl":59,"time_ms":38.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":5,"ttl":59,"time_ms":38.8,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":6,"ttl":59,"time_ms":42.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":7,"ttl":59,"time_ms":30.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":8,"ttl":59,"time_ms":39.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":9,"ttl":59,"time_ms":39.3,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":10,"ttl":59,"time_ms":38.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":11,"ttl":59,"time_ms":38.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":12,"ttl":59,"time_ms":38.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":13,"ttl":59,"time_ms":39.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":14,"ttl":59,"time_ms":37.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":15,"ttl":59,"time_ms":33.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":16,"ttl":59,"time_ms":39.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":17,"ttl":59,"time_ms":38.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":18,"ttl":59,"time_ms":41.3,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":19,"ttl":59,"time_ms":32.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":20,"ttl":59,"time_ms":38.4,"duplicate":false},{"type":"summary","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19164.0,"round_trip_ms_min":30.757,"round_trip_ms_avg":37.455,"round_trip_ms_max":42.652,"round_trip_ms_stddev":3.338}]
|
||||
[{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":1,"ttl":59,"time_ms":30.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":2,"ttl":59,"time_ms":39.0,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":3,"ttl":59,"time_ms":32.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":4,"ttl":59,"time_ms":38.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":5,"ttl":59,"time_ms":38.8,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":6,"ttl":59,"time_ms":42.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":7,"ttl":59,"time_ms":30.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":8,"ttl":59,"time_ms":39.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":9,"ttl":59,"time_ms":39.3,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":10,"ttl":59,"time_ms":38.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":11,"ttl":59,"time_ms":38.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":12,"ttl":59,"time_ms":38.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":13,"ttl":59,"time_ms":39.6,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":14,"ttl":59,"time_ms":37.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":15,"ttl":59,"time_ms":33.7,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":16,"ttl":59,"time_ms":39.4,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":17,"ttl":59,"time_ms":38.9,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":18,"ttl":59,"time_ms":41.3,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":19,"ttl":59,"time_ms":32.2,"duplicate":false},{"type":"reply","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","timestamp":null,"response_bytes":64,"response_ip":"2a04:4e42:2d::323","icmp_seq":20,"ttl":59,"time_ms":38.4,"duplicate":false},{"type":"summary","destination_ip":"2a04:4e42:2d::323","sent_bytes":56,"pattern":"0xabcd","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"errors":null,"corrupted":null,"time_ms":19164.0,"round_trip_ms_min":30.757,"round_trip_ms_avg":37.455,"round_trip_ms_max":42.652,"round_trip_ms_stddev":3.338}]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user