1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-04-03 17:44:07 +02:00

Compare commits

...

182 Commits

Author SHA1 Message Date
Kelly Brazil
e30a75e25c Merge pull request #76 from kellyjonbrazil/dev
Dev v1.13.2
2020-08-03 10:18:39 -07:00
Kelly Brazil
85ad5cfd0b date change 2020-08-03 10:14:13 -07:00
Kelly Brazil
88b9d5068c finish date parser 2020-08-03 09:26:37 -07:00
Kelly Brazil
f8c4948a09 remove comment 2020-07-31 16:52:48 -07:00
Kelly Brazil
412322447f add month_num and weekday_num fields 2020-07-31 16:51:05 -07:00
Kelly Brazil
d4f289e40f documentation fixup 2020-07-31 14:47:06 -07:00
Kelly Brazil
e1f3feb8f5 cover empty data case in process 2020-07-31 14:45:30 -07:00
Kelly Brazil
37d3bc699c add date parser 2020-07-31 14:39:02 -07:00
Kelly Brazil
672fd18016 date bump 2020-07-31 12:59:44 -07:00
Kelly Brazil
bc2c23a2a0 version bump 2020-07-31 12:58:58 -07:00
Kelly Brazil
865f7e7812 add kv parser to man page 2020-07-31 12:58:11 -07:00
Kelly Brazil
720212b552 fixup traceroute example with new behavior 2020-07-31 11:02:24 -07:00
Kelly Brazil
d3be61f608 version bump 2020-07-31 10:59:46 -07:00
Kelly Brazil
13418b16b8 doc update 2020-07-31 10:56:51 -07:00
Kelly Brazil
42d2017cd6 traceroute updates: handle missing header row, add annotations, don't print timeouts as probes 2020-07-31 10:53:47 -07:00
Kelly Brazil
4345e76ead change to use --kv for key/value files 2020-07-30 16:49:38 -07:00
Kelly Brazil
741431322b update tests for kv parser 2020-07-30 16:45:36 -07:00
Kelly Brazil
980beaaf41 fix docgen issue 2020-07-30 16:21:03 -07:00
Kelly Brazil
2205034e09 add kv parser 2020-07-30 16:20:51 -07:00
Kelly Brazil
82b9c87a66 update docs 2020-07-30 16:20:24 -07:00
Kelly Brazil
dda517a937 shorten more examples 2020-07-29 14:36:20 -07:00
Kelly Brazil
4e6d283b9e shorten netstat example 2020-07-29 14:27:13 -07:00
Kelly Brazil
55acab05aa change name to CHANGELOG 2020-07-29 11:55:16 -07:00
Kelly Brazil
ed38a18d23 remove more examples 2020-07-29 11:49:00 -07:00
Kelly Brazil
95b3c11203 remove more examples 2020-07-29 11:43:22 -07:00
Kelly Brazil
dce318f4fd remove examples to reduce file size 2020-07-29 11:40:47 -07:00
Kelly Brazil
85127f0fb8 move examples to root 2020-07-29 11:34:43 -07:00
Kelly Brazil
fb45058244 add examples file 2020-07-29 11:32:18 -07:00
Kelly Brazil
45bb5ae389 spelling 2020-07-28 11:03:41 -07:00
Kelly Brazil
339238ab36 version bump and add route -6 tests 2020-07-27 20:37:33 -07:00
Kelly Brazil
032cda8b3d Merge pull request #74 from kellyjonbrazil/dev
Dev v1.13.0
2020-07-27 19:12:21 -07:00
Kelly Brazil
6badd3fb1e add parser count test 2020-07-27 19:02:23 -07:00
Kelly Brazil
724d825745 add tracepath parser 2020-07-27 19:02:11 -07:00
Kelly Brazil
ff1e32ad2e version bump 2020-07-27 16:49:34 -07:00
Kelly Brazil
a5f97febd3 update traceroute, tracepath, and uname tests 2020-07-27 16:47:41 -07:00
Kelly Brazil
5baa6cc865 add route parser update 2020-07-27 15:44:13 -07:00
Kelly Brazil
7a4f30b843 fix for iface issue 2020-07-27 15:37:44 -07:00
Kelly Brazil
b2c385dc4f change 'if' to 'iface' 2020-07-27 15:30:09 -07:00
Kelly Brazil
5d5da8d33f more fixes for ipv6 fix 2020-07-27 15:27:11 -07:00
Kelly Brazil
e604571578 fix next_hop fix 2020-07-27 15:20:51 -07:00
Kelly Brazil
f9dacc3f95 fixup for ipv6 2020-07-27 15:18:13 -07:00
Kelly Brazil
6086920332 update ParseError message 2020-07-27 15:13:32 -07:00
Kelly Brazil
f52f3163bc add tracepath example 2020-07-27 13:57:58 -07:00
Kelly Brazil
d18ff73e88 update author info 2020-07-27 13:51:51 -07:00
Kelly Brazil
1e5d602cae working tracepath parser 2020-07-27 13:48:46 -07:00
Kelly Brazil
12912521ec doc update 2020-07-27 11:04:27 -07:00
Kelly Brazil
842ea3a94b add tracepath parser skeleton 2020-07-27 11:02:13 -07:00
Kelly Brazil
a8560dbc15 add tracepath 2020-07-27 11:01:57 -07:00
Kelly Brazil
a65e27540a update docs 2020-07-27 11:01:45 -07:00
Kelly Brazil
c3c5ed11e6 change name from tr to trparse 2020-07-27 10:33:40 -07:00
Kelly Brazil
ce24149335 formatting 2020-07-27 10:33:25 -07:00
Kelly Brazil
0314ca8c48 add trparse acknowledgement 2020-07-27 10:33:15 -07:00
Kelly Brazil
ebd8ee49a9 add key/value info to ini example 2020-07-27 10:28:15 -07:00
Kelly Brazil
38d10c9781 add ping and traceroute examples 2020-07-27 09:29:30 -07:00
Kelly Brazil
360106c24d add tracepath 2020-07-27 09:23:01 -07:00
Kelly Brazil
ca470a5d02 add tracepath fixtures 2020-07-27 09:20:00 -07:00
Kelly Brazil
57f66e6b1d add exception with hint to use "uname -a" 2020-07-27 09:19:48 -07:00
Kelly Brazil
e774f67924 turn off interpolation and coerce None to '' 2020-07-24 16:53:17 -07:00
Kelly Brazil
ac10e576c1 spelling 2020-07-24 16:29:27 -07:00
Kelly Brazil
bcae0a99cd add key/value to ini description 2020-07-24 16:23:45 -07:00
Kelly Brazil
c73c2ff879 add ping, traceroute, and ini update 2020-07-24 16:23:30 -07:00
Kelly Brazil
c39b1a3356 add ping, traceroute and update ini description 2020-07-24 16:17:51 -07:00
Kelly Brazil
125dc2d9e0 add info about key/value files to doc 2020-07-24 16:17:16 -07:00
Kelly Brazil
b7d4ddc7ce add tests for key/value files 2020-07-24 16:16:54 -07:00
Kelly Brazil
f5e546c6fa add support for simple key/value pairs 2020-07-24 16:16:24 -07:00
Kelly Brazil
928e39cd10 add generic traceroute tests 2020-07-24 14:16:41 -07:00
Kelly Brazil
d0b7ea68a0 check for key in dictionary 2020-07-24 13:47:47 -07:00
Kelly Brazil
8444690133 add traceroute 2020-07-24 13:47:29 -07:00
Kelly Brazil
c03c42d767 add traceroute tests 2020-07-24 13:47:23 -07:00
Kelly Brazil
ab67688a00 add test skeleton 2020-07-23 16:45:09 -07:00
Kelly Brazil
5dcb7166da add traceroute doc 2020-07-23 16:44:57 -07:00
Kelly Brazil
14697b86d7 add MIT license 2020-07-23 15:48:08 -07:00
Kelly Brazil
4f4b6276d4 update docstring 2020-07-23 15:46:22 -07:00
Kelly Brazil
7bc497e129 updated process() function to set integers and floats 2020-07-23 15:42:33 -07:00
Kelly Brazil
68a37a6a5a remove unused function load() 2020-07-23 12:48:33 -07:00
Kelly Brazil
6f5cd1d7c5 change to use f-string 2020-07-23 12:03:21 -07:00
Kelly Brazil
126b1b121c add traceroute6 example 2020-07-23 11:31:56 -07:00
Kelly Brazil
2341e456a0 use ParseError instead of generic Exception 2020-07-23 11:31:35 -07:00
Kelly Brazil
72d80e95bb remove unused regex patterns 2020-07-23 10:52:40 -07:00
Kelly Brazil
f5ec82440c simplify regex patterns 2020-07-23 10:19:56 -07:00
Kelly Brazil
c8e526ead3 fixes for bsd-style ipv6 output 2020-07-22 17:23:24 -07:00
Kelly Brazil
066adfb764 handle warning lines in the traceroute output 2020-07-22 15:02:02 -07:00
Kelly Brazil
5b444d4717 add traceroute parser 2020-07-22 12:19:27 -07:00
Kelly Brazil
69c95adc8d add osx ipv6 ping dup test 2020-07-22 09:06:11 -07:00
Kelly Brazil
2b0e0d8f5c add ipv6 dup test 2020-07-21 17:34:30 -07:00
Kelly Brazil
778d1bacbf update docs to add "duplicates" fields 2020-07-21 15:16:39 -07:00
Kelly Brazil
7e1b041016 add duplicate replies tests 2020-07-21 15:12:43 -07:00
Kelly Brazil
313b9b329c update fixtures for added 'duplicate' fields 2020-07-21 15:05:54 -07:00
Kelly Brazil
6830062256 add support for duplicate replies 2020-07-21 14:47:25 -07:00
Kelly Brazil
323072c982 add source_ip to schema doc 2020-07-21 09:02:44 -07:00
Kelly Brazil
8719d96bdd change description 2020-07-20 16:54:43 -07:00
Kelly Brazil
dd5d318ab5 version bump and add ping command 2020-07-20 16:25:20 -07:00
Kelly Brazil
d6dc7f5e65 add osx ping tests 2020-07-20 16:11:18 -07:00
Kelly Brazil
c203664eb5 freebsd ping tests 2020-07-20 15:46:27 -07:00
Kelly Brazil
19ecf1fa19 add Fedora32 tests 2020-07-20 14:35:41 -07:00
Kelly Brazil
b8deb0426c add ubuntu ping tests 2020-07-20 13:51:39 -07:00
Kelly Brazil
3b8371f020 add centos ping tests 2020-07-20 12:49:05 -07:00
Kelly Brazil
20bb1cdf39 add TypeError to except for None values 2020-07-20 11:53:06 -07:00
Kelly Brazil
301daa48d0 update documentation 2020-07-19 15:30:54 -07:00
Kelly Brazil
8421ec8803 remove cygwin compatibility 2020-07-19 15:19:47 -07:00
Kelly Brazil
74211eb012 add examples 2020-07-19 15:16:04 -07:00
Kelly Brazil
60bd42f298 add process() logic 2020-07-19 15:13:52 -07:00
Kelly Brazil
14bdd74526 add ping test fixtures 2020-07-19 14:46:02 -07:00
Kelly Brazil
fb0f3eda04 add ping commands 2020-07-19 14:45:50 -07:00
Kelly Brazil
91ee6e6701 add osx ping test fixtures 2020-07-19 14:18:56 -07:00
Kelly Brazil
51f4e6927c add support for pattern in osx/bsd 2020-07-19 14:18:40 -07:00
Kelly Brazil
94988d8667 add fedora ping fixtures 2020-07-19 13:50:40 -07:00
Kelly Brazil
fe36f5a98c add fixtures for ping 2020-07-19 12:56:53 -07:00
Kelly Brazil
f9eb18b927 change 'request_timeout' field to 'type', fix compatibility, other formatting fixes 2020-07-19 12:56:34 -07:00
Kelly Brazil
cc60f36748 add ping parser 2020-07-18 12:35:46 -07:00
Kelly Brazil
604ade791f add ping parser 2020-07-17 15:57:07 -07:00
Kelly Brazil
690ac52a91 add man page 2020-07-13 07:18:48 -07:00
Kelly Brazil
34ed772775 version bump 2020-07-11 09:46:47 -07:00
Kelly Brazil
d5ab95571f fix tests when using older versions of pygments 2020-07-11 09:44:08 -07:00
Kelly Brazil
ffb3a0ee5f Merge pull request #73 from kellyjonbrazil/dev
Dev v1.12.0
2020-07-10 16:34:56 -07:00
Kelly Brazil
94b12b57aa spelling 2020-07-10 16:30:08 -07:00
Kelly Brazil
6d149e8457 version bump 2020-07-10 16:25:03 -07:00
Kelly Brazil
1ad89c90d8 add pacman 2020-07-10 15:58:02 -07:00
Kelly Brazil
fb71c7b020 function name spelling 2020-07-10 15:49:35 -07:00
Kelly Brazil
28ed17ad3b add parser_count test to test_cli_about_jc 2020-07-10 15:45:21 -07:00
Kelly Brazil
0c2a4e2bf7 add cli tests 2020-07-10 15:35:05 -07:00
Kelly Brazil
62bec30de2 add json_out tests 2020-07-10 14:44:50 -07:00
Kelly Brazil
3fced77e4e add set_env_colors tests 2020-07-10 12:23:48 -07:00
Kelly Brazil
a09d1d8b76 move environment variable assignment to main() to simplify tests 2020-07-10 12:23:25 -07:00
Kelly Brazil
8f4243fbd8 formatting 2020-07-10 10:54:34 -07:00
Kelly Brazil
47aaf20549 add sysctl command parser 2020-07-10 10:50:51 -07:00
Kelly Brazil
0c5289ea50 add sysctl tests 2020-07-10 10:47:23 -07:00
Kelly Brazil
3e53323514 don't filter out empty lines 2020-07-10 09:58:56 -07:00
Kelly Brazil
a5ee9861b9 update fixtures 2020-07-10 09:28:32 -07:00
Kelly Brazil
feb8ca7654 spelling 2020-07-10 09:28:20 -07:00
Kelly Brazil
a7abe4473b spelling 2020-07-10 09:03:04 -07:00
Kelly Brazil
780b9b61de specify IndexError exception in try/except block 2020-07-10 08:30:31 -07:00
Kelly Brazil
19ace36ffa add fixtures 2020-07-10 08:21:30 -07:00
Kelly Brazil
5fff8afc9f add fixes for freebsd where values can be on separate lines under the key 2020-07-10 08:21:15 -07:00
Kelly Brazil
4ad230c927 doc update and add test fixtures 2020-07-09 16:35:36 -07:00
Kelly Brazil
dd98eb1ec8 append duplicate key values to original key instead of adding unique keys 2020-07-09 16:25:41 -07:00
Kelly Brazil
c6baf42e72 doc updates 2020-07-09 16:18:33 -07:00
Kelly Brazil
e2bac97d56 fix for multiple identical keys in sysctl output 2020-07-09 14:51:15 -07:00
Kelly Brazil
d112ee94d0 use try/except and add support for floats in process() 2020-07-09 14:26:35 -07:00
Kelly Brazil
27b21b2faf formatting and docstring updates 2020-07-09 11:11:29 -07:00
Kelly Brazil
8c96d5cd20 reduce pygments version requirement 2020-07-09 10:59:36 -07:00
Kelly Brazil
c29ed3fd69 formatting of quotation marks and docstrings 2020-07-09 10:54:49 -07:00
Kelly Brazil
cedf603f12 minor formatting 2020-07-09 09:59:00 -07:00
Kelly Brazil
279161c36f Merge pull request #72 from duelafn/pygments-2.3
Support older pygments
2020-07-09 09:48:58 -07:00
Dean Serenevy
ce0b43d919 Remove dependency on 3rd party packaging library 2020-07-09 12:44:41 -04:00
Dean Serenevy
ddafa5bf06 Support older pygments 2020-07-09 11:39:34 -04:00
Kelly Brazil
bc7116c31b fix JC_COLORS env bug and simplify set_env_colors() 2020-07-09 08:30:10 -07:00
Kelly Brazil
53b7092721 remove side-effects from functions and print in main() 2020-07-08 16:40:28 -07:00
Kelly Brazil
beb9174b1b add sysctl parser 2020-07-08 15:42:06 -07:00
Kelly Brazil
aea41ed341 move verbose_debug enable earlier in code to catch more issues. add sysctl and version bump 2020-07-08 15:41:46 -07:00
Kelly Brazil
d789494cb1 change type check to use isinstance 2020-07-08 05:59:19 -07:00
Kelly Brazil
608e7b4cff add license info 2020-07-06 10:52:12 -07:00
Kelly Brazil
4ee199c02a use tracebackplus instead of cgitb since cgitb is depricated 2020-07-06 10:41:01 -07:00
Kelly Brazil
fbf47d4085 add arch linux 2020-07-01 13:28:58 -07:00
Kelly Brazil
5a238e4b42 remove updates-testing from fedora command 2020-07-01 09:11:32 -07:00
Kelly Brazil
f852b8246a wrap warning message 2020-06-30 11:50:37 -07:00
Kelly Brazil
88140d929a wrap error message in code 2020-06-30 11:37:33 -07:00
Kelly Brazil
45f7268240 add -dd to error message 2020-06-30 11:34:08 -07:00
Kelly Brazil
3a3c8e4d4a move verbose_debug under debug check 2020-06-30 11:31:08 -07:00
Kelly Brazil
c1ac183a04 simplify debug option 2020-06-30 11:26:09 -07:00
Kelly Brazil
18bb779ee5 formatting: double quotes to single quotes 2020-06-30 09:39:05 -07:00
Kelly Brazil
8b6612fe79 move JC_COLORS parsing error message 2020-06-30 07:56:34 -07:00
Kelly Brazil
fde0bc8534 improve package install info 2020-06-27 18:53:19 -07:00
Kelly Brazil
e661a78939 Merge pull request #71 from wigust/guix
add guix package info
2020-06-27 18:43:02 -07:00
Oleg Pykhalov
847e346602 add guix package info 2020-06-27 13:01:56 +03:00
Kelly Brazil
b969751688 add other references 2020-06-26 09:53:57 -07:00
Kelly Brazil
ad6f2ba03a formatting 2020-06-25 21:16:52 -07:00
Kelly Brazil
63c6a5edc0 formatting 2020-06-25 21:12:30 -07:00
Kelly Brazil
9f4cf9dd5e formatting 2020-06-25 21:11:21 -07:00
Kelly Brazil
51331b6dc0 formatting 2020-06-25 13:01:10 -07:00
Kelly Brazil
efb6761033 formatting 2020-06-25 12:59:56 -07:00
Kelly Brazil
6a4f737a0f update json syntax highlighting 2020-06-25 12:56:06 -07:00
Kelly Brazil
be6864b778 add syntax highlighting tags 2020-06-25 12:28:23 -07:00
Kelly Brazil
de3b91a36c add -dd option 2020-06-25 07:38:39 -07:00
Kelly Brazil
ef5482c3b5 add verbose debug option 2020-06-25 07:29:28 -07:00
Kelly Brazil
d20b795137 Merge pull request #70 from kellyjonbrazil/dev
Dev v1.11.7
2020-06-22 11:28:23 -07:00
Kelly Brazil
8a134065df update fixtures for last chain fix 2020-06-22 11:23:37 -07:00
Kelly Brazil
22aee1bfa4 version bump 2020-06-22 11:23:15 -07:00
Kelly Brazil
b282820fd6 fix to include the final chain in output 2020-06-22 11:09:09 -07:00
Kelly Brazil
3ee098306d version bump 2020-06-22 10:48:51 -07:00
Kelly Brazil
09e8f379a6 iptables code optimizations 2020-06-22 10:47:34 -07:00
Kelly Brazil
69018cdb3a fix date 2020-06-14 17:39:14 -07:00
275 changed files with 15969 additions and 2045 deletions

View File

@@ -1,6 +1,40 @@
jc changelog
20200612 v1.11.6
20200803 v1.13.2
- Add key/value file parser (wrapper for ini parser)
- Add date command parser
- Update traceroute parser to more gracefully handle missing header row
- Update traceroute parser to handle annotations
- Update traceroute parser to only return successful probes
20200727 v1.13.1
- Add route -6 tests
20200727 v1.13.0
- Add ping and ping6 command parser tested on linux, macos, and freebsd
- Add traceroute and traceroute6 command parser tested on linux, macos, and freebsd
- Add tracepath command parser tested on linux
- Update ini parser to support files only containing key/value pairs
- Update uname parser exception with a hint to use "uname -a"
- Update route parser to support IPv6 tables
20200711 v1.12.1
- Fix tests when using older version of pygments library
20200710 v1.12.0
- Add sysctl command parser tested on linux, macOS, and freebsd
- Update the cli code to allow older versions of the pygments library (2.3.0) for debian packaging
- Code cleanup on the cli
- Add tests for the cli
- Vendorize cgitb as tracebackplus for verbose debug messages
20200625 v1.11.8
- Add verbose debug option using -dd argument
20200622 v1.11.7
- Fix iptables parser issue which would not output the last chain
20200614 v1.11.6
- Improve and standardize empty data check for all parsers
20200612 v1.11.5

2651
EXAMPLES.md Normal file

File diff suppressed because it is too large Load Diff

2095
README.md

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,7 @@ pydocmd simple jc.parsers.blkid+ > ../docs/parsers/blkid.md
pydocmd simple jc.parsers.crontab+ > ../docs/parsers/crontab.md
pydocmd simple jc.parsers.crontab_u+ > ../docs/parsers/crontab_u.md
pydocmd simple jc.parsers.csv+ > ../docs/parsers/csv.md
pydocmd simple jc.parsers.date+ > ../docs/parsers/date.md
pydocmd simple jc.parsers.df+ > ../docs/parsers/df.md
pydocmd simple jc.parsers.dig+ > ../docs/parsers/dig.md
pydocmd simple jc.parsers.dmidecode+ > ../docs/parsers/dmidecode.md
@@ -28,6 +29,7 @@ pydocmd simple jc.parsers.ifconfig+ > ../docs/parsers/ifconfig.md
pydocmd simple jc.parsers.ini+ > ../docs/parsers/ini.md
pydocmd simple jc.parsers.iptables+ > ../docs/parsers/iptables.md
pydocmd simple jc.parsers.jobs+ > ../docs/parsers/jobs.md
pydocmd simple jc.parsers.kv+ > ../docs/parsers/kv.md
pydocmd simple jc.parsers.last+ > ../docs/parsers/last.md
pydocmd simple jc.parsers.ls+ > ../docs/parsers/ls.md
pydocmd simple jc.parsers.lsblk+ > ../docs/parsers/lsblk.md
@@ -37,6 +39,7 @@ pydocmd simple jc.parsers.mount+ > ../docs/parsers/mount.md
pydocmd simple jc.parsers.netstat+ > ../docs/parsers/netstat.md
pydocmd simple jc.parsers.ntpq+ > ../docs/parsers/ntpq.md
pydocmd simple jc.parsers.passwd+ > ../docs/parsers/passwd.md
pydocmd simple jc.parsers.ping+ > ../docs/parsers/ping.md
pydocmd simple jc.parsers.pip_list+ > ../docs/parsers/pip_list.md
pydocmd simple jc.parsers.pip_show+ > ../docs/parsers/pip_show.md
pydocmd simple jc.parsers.ps+ > ../docs/parsers/ps.md
@@ -44,11 +47,14 @@ pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
pydocmd simple jc.parsers.shadow+ > ../docs/parsers/shadow.md
pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md
pydocmd simple jc.parsers.stat+ > ../docs/parsers/stat.md
pydocmd simple jc.parsers.sysctl+ > ../docs/parsers/sysctl.md
pydocmd simple jc.parsers.systemctl+ > ../docs/parsers/systemctl.md
pydocmd simple jc.parsers.systemctl_lj+ > ../docs/parsers/systemctl_lj.md
pydocmd simple jc.parsers.systemctl_ls+ > ../docs/parsers/systemctl_ls.md
pydocmd simple jc.parsers.systemctl_luf+ > ../docs/parsers/systemctl_luf.md
pydocmd simple jc.parsers.timedatectl+ > ../docs/parsers/timedatectl.md
pydocmd simple jc.parsers.tracepath+ > ../docs/parsers/tracepath.md
pydocmd simple jc.parsers.traceroute+ > ../docs/parsers/traceroute.md
pydocmd simple jc.parsers.uname+ > ../docs/parsers/uname.md
pydocmd simple jc.parsers.uptime+ > ../docs/parsers/uptime.md
pydocmd simple jc.parsers.w+ > ../docs/parsers/w.md

View File

@@ -1,3 +1,4 @@
# jc.parsers.airport
jc - JSON CLI output utility airport -I Parser
@@ -52,11 +53,13 @@ Examples:
"channel": "48,80"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -90,6 +93,7 @@ Returns:
"channel": string
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.airport_s
jc - JSON CLI output utility airport -s Parser
@@ -84,11 +85,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -117,6 +120,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.arp
jc - JSON CLI output utility arp Parser
@@ -95,11 +96,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -128,6 +131,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.blkid
jc - JSON CLI output utility blkid Parser
@@ -75,11 +76,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -129,6 +132,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.crontab
jc - JSON CLI output utility crontab command and file Parser
@@ -128,11 +129,13 @@ Examples:
]
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -178,6 +181,7 @@ Returns:
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.crontab_u
jc - JSON CLI output utility crontab file Parser
@@ -129,11 +130,13 @@ Examples:
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -180,6 +183,7 @@ Returns:
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.csv
jc - JSON CLI output utility csv Parser
@@ -59,11 +60,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -86,6 +89,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

93
docs/parsers/date.md Normal file
View File

@@ -0,0 +1,93 @@
# jc.parsers.date
jc - JSON CLI output utility date Parser
Usage:
specify --date as the first argument if the piped input is coming from date
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ date | jc --date -p
{
"year": 2020,
"month_num": 7,
"day": 31,
"hour": 16,
"minute": 48,
"second": 11,
"month": "Jul",
"weekday": "Fri",
"weekday_num": 6,
"timezone": "PDT"
}
$ date | jc --date -p -r
{
"year": "2020",
"month": "Jul",
"day": "31",
"weekday": "Fri",
"hour": "16",
"minute": "50",
"second": "01",
"timezone": "PDT"
}
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"year": integer,
"month_num": integer,
"day": integer,
"hour": integer,
"minute": integer,
"second": integer,
"month": string,
"weekday": string,
"weekday_num": integer,
"timezone": string
}
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.

View File

@@ -1,3 +1,4 @@
# jc.parsers.df
jc - JSON CLI output utility df Parser
@@ -69,11 +70,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -106,6 +109,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.dig
jc - JSON CLI output utility dig Parser
@@ -321,11 +322,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -393,6 +396,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.dmidecode
jc - JSON CLI output utility dmidecode Parser
@@ -99,11 +100,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -134,6 +137,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.du
jc - JSON CLI output utility du Parser
@@ -69,11 +70,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -96,6 +99,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.env
jc - JSON CLI output utility env Parser
@@ -49,11 +50,13 @@ Examples:
"_": "/usr/bin/env"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -76,6 +79,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.file
jc - JSON CLI output utility file command Parser
@@ -44,11 +45,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -71,6 +74,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.free
jc - JSON CLI output utility free Parser
@@ -49,11 +50,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -81,6 +84,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.fstab
jc - JSON CLI output utility fstab Parser
@@ -67,11 +68,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -98,6 +101,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.group
jc - JSON CLI output utility /etc/group file Parser
@@ -91,11 +92,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -122,6 +125,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.gshadow
jc - JSON CLI output utility /etc/gshadow file Parser
@@ -57,11 +58,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -90,6 +93,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.history
jc - JSON CLI output utility history Parser
@@ -41,11 +42,13 @@ Examples:
...
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -68,6 +71,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.hosts
jc - JSON CLI output utility hosts Parser
@@ -58,11 +59,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -87,6 +90,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.id
jc - JSON CLI output utility id Parser
@@ -67,11 +68,13 @@ Examples:
}
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -114,6 +117,7 @@ Returns:
}
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.ifconfig
jc - JSON CLI output utility ifconfig Parser
@@ -142,19 +143,16 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## IfconfigParser
```python
IfconfigParser(self, console_output)
```
## InterfaceNotFound
```python
InterfaceNotFound(self, /, *args, **kwargs)
IfconfigParser(console_output)
```
@@ -206,6 +204,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,9 +1,12 @@
# jc.parsers.ini
jc - JSON CLI output utility INI Parser
Usage:
specify --ini as the first argument if the piped input is coming from an INI file
Specify --ini as the first argument if the piped input is coming from an INI file or any
simple key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Compatibility:
@@ -43,11 +46,13 @@ Examples:
}
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -61,13 +66,17 @@ Parameters:
Returns:
Dictionary representing an ini document:
Dictionary representing an ini or simple key/value pair document:
{
ini document converted to a dictionary
see configparser standard library documentation for more details
ini or key/value document converted to a dictionary - see configparser standard
library documentation for more details.
Note: Values starting and ending with quotation marks will have the marks removed.
If you would like to keep the quotation marks, use the -r or raw=True argument.
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.iptables
jc - JSON CLI output utility ipables Parser
@@ -131,11 +132,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -172,6 +175,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.jobs
jc - JSON CLI output utility jobs Parser
@@ -73,11 +74,13 @@ Example:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -103,6 +106,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

61
docs/parsers/kv.md Normal file
View File

@@ -0,0 +1,61 @@
# jc.parsers.kv
jc - JSON CLI output utility Key/Value File Parser
Usage:
Specify --kv as the first argument if the piped input is coming from a simple
key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
Examples:
$ cat keyvalue.txt
# this file contains key/value pairs
name = John Doe
address=555 California Drive
age: 34
; comments can include # or ;
# delimiter can be = or :
# quoted values have quotation marks stripped by default
# but can be preserved with the -r argument
occupation:"Engineer"
$ cat keyvalue.txt | jc --ini -p
{
"name": "John Doe",
"address": "555 California Drive",
"age": "34",
"occupation": "Engineer"
}
## info
```python
info()
```
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Note: this is just a wrapper for jc.parsers.ini
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary representing the key/value file

View File

@@ -1,3 +1,4 @@
# jc.parsers.last
jc - JSON CLI output utility last Parser
@@ -68,11 +69,13 @@ Examples:
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -99,6 +102,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.ls
jc - JSON CLI output utility ls Parser
@@ -145,11 +146,13 @@ Examples:
"date": "May 3 2019"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -178,6 +181,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.lsblk
jc - JSON CLI output utility lsblk Parser
@@ -212,11 +213,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -277,6 +280,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.lsmod
jc - JSON CLI output utility lsmod Parser
@@ -103,11 +104,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -134,6 +137,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.lsof
jc - JSON CLI output utility lsof Parser
@@ -93,11 +94,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -128,6 +131,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.mount
jc - JSON CLI output utility mount Parser
@@ -53,11 +54,13 @@ Example:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -84,6 +87,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.netstat
jc - JSON CLI output utility netstat Parser
@@ -245,11 +246,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -364,6 +367,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.ntpq
jc - JSON CLI output utility ntpq Parser
@@ -179,11 +180,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -216,6 +219,7 @@ Returns:
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.passwd
jc - JSON CLI output utility /etc/passwd file Parser
@@ -75,11 +76,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -107,6 +110,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

175
docs/parsers/ping.md Normal file
View File

@@ -0,0 +1,175 @@
# jc.parsers.ping
jc - JSON CLI output utility ping Parser
Usage:
specify --ping as the first argument if the piped input is coming from ping
Note: Use the ping -c (count) option, otherwise data will not be piped to jc.
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ ping -c 3 -p ff cnn.com | jc --ping -p
{
"destination_ip": "151.101.1.67",
"data_bytes": 56,
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": 3,
"packets_received": 3,
"packet_loss_percent": 0.0,
"duplicates": 0,
"round_trip_ms_min": 28.015,
"round_trip_ms_avg": 32.848,
"round_trip_ms_max": 39.376,
"round_trip_ms_stddev": 4.79,
"responses": [
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 0,
"ttl": 59,
"time_ms": 28.015,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 1,
"ttl": 59,
"time_ms": 39.376,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 2,
"ttl": 59,
"time_ms": 31.153,
"duplicate": false
}
]
}
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
{
"destination_ip": "151.101.129.67",
"data_bytes": "56",
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": "3",
"packets_received": "3",
"packet_loss_percent": "0.0",
"duplicates": "0",
"round_trip_ms_min": "25.078",
"round_trip_ms_avg": "29.543",
"round_trip_ms_max": "32.553",
"round_trip_ms_stddev": "3.221",
"responses": [
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "0",
"ttl": "59",
"time_ms": "25.078",
"duplicate": false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "1",
"ttl": "59",
"time_ms": "30.999",
"duplicate": false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "2",
"ttl": "59",
"time_ms": "32.553",
"duplicate": false
}
]
}
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"source_ip": string,
"destination_ip": string,
"data_bytes": integer,
"pattern": string, (null if not set)
"destination": string,
"packets_transmitted": integer,
"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,
"responses": [
{
"type": string, ('reply' or 'timeout')
"timestamp": float,
"bytes": integer,
"response_ip": string,
"icmp_seq": integer,
"ttl": integer,
"time_ms": float,
"duplicate": boolean
}
]
}
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.

View File

@@ -1,3 +1,4 @@
# jc.parsers.pip_list
jc - JSON CLI output utility pip-list Parser
@@ -28,11 +29,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -56,6 +59,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.pip_show
jc - JSON CLI output utility pip-show Parser
@@ -39,11 +40,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -75,6 +78,7 @@ Returns:
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.ps
jc - JSON CLI output utility ps Parser
@@ -173,11 +174,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -215,6 +218,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.route
jc - JSON CLI output utility route Parser
@@ -80,11 +81,13 @@ Examples:
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -119,6 +122,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.shadow
jc - JSON CLI output utility /etc/shadow file Parser
@@ -81,11 +82,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -114,6 +117,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.ss
jc - JSON CLI output utility ss Parser
@@ -247,11 +248,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -289,6 +292,7 @@ Returns:
Information from https://www.cyberciti.biz/files/ss.html used to define field names
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.stat
jc - JSON CLI output utility stat Parser
@@ -101,11 +102,13 @@ Examples:
..
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -149,6 +152,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

88
docs/parsers/sysctl.md Normal file
View File

@@ -0,0 +1,88 @@
# jc.parsers.sysctl
jc - JSON CLI output utility sysctl -a Parser
Usage:
specify --sysctl as the first argument if the piped input is coming from sysctl -a
Note: since sysctl output is not easily parsable only a very simple key/value object
will be output. An attempt is made to convert obvious integers and floats. If no
conversion is desired, use the -r (raw) option.
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ sysctl | jc --sysctl -p
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": 99,
"user.bc_dim_max": 2048,
"user.bc_scale_max": 99,
"user.bc_string_max": 1000,
"user.coll_weights_max": 2,
"user.expr_nest_max": 32
...
}
$ sysctl | jc --sysctl -p -r
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": "99",
"user.bc_dim_max": "2048",
"user.bc_scale_max": "99",
"user.bc_string_max": "1000",
"user.coll_weights_max": "2",
"user.expr_nest_max": "32",
...
}
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"foo": string/integer/float, # best guess based on value
"bar": string/integer/float,
"baz": string/integer/float
}
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.

View File

@@ -1,3 +1,4 @@
# jc.parsers.systemctl
jc - JSON CLI output utility systemctl Parser
@@ -37,11 +38,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -67,6 +70,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.systemctl_lj
jc - JSON CLI output utility systemctl-lj Parser
@@ -56,11 +57,13 @@ Examples:
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -85,6 +88,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.systemctl_ls
jc - JSON CLI output utility systemctl-ls Parser
@@ -31,11 +32,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -59,6 +62,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.systemctl_luf
jc - JSON CLI output utility systemctl-luf Parser
@@ -28,11 +29,13 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -55,6 +58,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.timedatectl
jc - JSON CLI output utility timedatectl Parser
@@ -35,11 +36,13 @@ Examples:
"dst_active": "yes"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -68,6 +71,7 @@ Returns:
"dst_active": boolean
}
## parse
```python
parse(data, raw=False, quiet=False)

162
docs/parsers/tracepath.md Normal file
View File

@@ -0,0 +1,162 @@
# jc.parsers.tracepath
jc - JSON CLI output utility tracepath Parser
Usage:
specify --tracepath as the first argument if the piped input is coming from tracepath
Compatibility:
'linux'
Examples:
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
{
"pmtu": 1480,
"forward_hops": 2,
"return_hops": 2,
"hops": [
{
"ttl": 1,
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": 1500,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": 1,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.411,
"pmtu": null,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": 2,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.39,
"pmtu": 1480,
"asymmetric_difference": 1,
"reached": false
},
{
"ttl": 2,
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": 463.514,
"pmtu": null,
"asymmetric_difference": null,
"reached": true
}
]
}
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p -r
{
"pmtu": "1480",
"forward_hops": "2",
"return_hops": "2",
"hops": [
{
"ttl": "1",
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": "1500",
"asymmetric_difference": null,
"reached": false
},
{
"ttl": "1",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.411",
"pmtu": null,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": "2",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.390",
"pmtu": "1480",
"asymmetric_difference": "1",
"reached": false
},
{
"ttl": "2",
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": "463.514",
"pmtu": null,
"asymmetric_difference": null,
"reached": true
}
]
}
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"pmtu": integer,
"forward_hops": integer,
"return_hops": integer,
"hops": [
{
"ttl": integer,
"guess": boolean,
"host": string,
"reply_ms": float,
"pmtu": integer,
"asymmetric_difference": integer,
"reached": boolean
}
]
}
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.

155
docs/parsers/traceroute.md Normal file
View File

@@ -0,0 +1,155 @@
# jc.parsers.traceroute
jc - JSON CLI output utility traceroute Parser
Usage:
specify --traceroute as the first argument if the piped input is coming from traceroute
Note: On some operating systems you will need to redirect STDERR to STDOUT for destination
info since the header line is sent to STDERR. A warning message will be printed to
STDERR if the header row is not found.
e.g. $ traceroute 8.8.8.8 2>&1 | jc --traceroute
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ traceroute google.com | jc --traceroute -p
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
{
"hop": 1,
"probes": [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.574
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.65
}
]
},
...
]
}
$ traceroute google.com | jc --traceroute -p -r
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
{
"hop": "1",
"probes": [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.574"
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.650"
}
]
},
...
]
}
## info
```python
info()
```
## Hop
```python
Hop(idx)
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"destination_ip": string,
"destination_name": string,
"hops": [
{
"hop": integer,
"probes": [
{
"annotation": string,
"asn": integer,
"ip": string,
"name": string,
"rtt": float
}
]
}
]
}
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.

View File

@@ -1,3 +1,4 @@
# jc.parsers.uname
jc - JSON CLI output utility uname Parser
@@ -27,11 +28,13 @@ Example:
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -58,6 +61,7 @@ Returns:
"kernel_version": string
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.uptime
jc - JSON CLI output utility uptime Parser
@@ -31,11 +32,13 @@ Example:
"load_15m": "0.05"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -60,6 +63,7 @@ Returns:
"load_15m": float
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.w
jc - JSON CLI output utility w Parser
@@ -79,11 +80,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -112,6 +115,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.who
jc - JSON CLI output utility who Parser
@@ -99,11 +100,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -133,6 +136,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.xml
jc - JSON CLI output utility XML Parser
@@ -55,11 +56,13 @@ Examples:
...
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -80,6 +83,7 @@ Returns:
See https://github.com/martinblech/xmltodict for details
}
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc.parsers.yaml
jc - JSON CLI output utility YAML Parser
@@ -67,11 +68,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
@@ -94,6 +97,7 @@ Returns:
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@@ -1,3 +1,4 @@
# jc
JC - JSON CLI output utility

View File

@@ -1,5 +1,7 @@
# utils
jc - JSON CLI output utility utils
## warning_message
```python
warning_message(message)
@@ -15,6 +17,7 @@ Returns:
no return, just prints output to STDERR
## error_message
```python
error_message(message)
@@ -30,6 +33,7 @@ Returns:
no return, just prints output to STDERR
## compatibility
```python
compatibility(mod_name, compatible)
@@ -48,6 +52,7 @@ Returns:
no return, just prints output to STDERR
## has_data
```python
has_data(data)

185
jc/cli.py
View File

@@ -11,18 +11,18 @@ import importlib
import textwrap
import signal
import json
import pygments
from pygments import highlight
from pygments.style import Style
from pygments.token import (Name, Number, String, Keyword)
from pygments.lexers import JsonLexer
from pygments.formatters import Terminal256Formatter
import jc.utils
import jc.appdirs as appdirs
class info():
version = '1.11.6'
description = 'jc cli output JSON conversion tool'
version = '1.13.2'
description = 'JSON CLI output utility'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -37,6 +37,7 @@ parsers = [
'crontab',
'crontab-u',
'csv',
'date',
'df',
'dig',
'dmidecode',
@@ -54,6 +55,7 @@ parsers = [
'ini',
'iptables',
'jobs',
'kv',
'last',
'ls',
'lsblk',
@@ -63,6 +65,7 @@ parsers = [
'netstat',
'ntpq',
'passwd',
'ping',
'pip-list',
'pip-show',
'ps',
@@ -70,11 +73,14 @@ parsers = [
'shadow',
'ss',
'stat',
'sysctl',
'systemctl',
'systemctl-lj',
'systemctl-ls',
'systemctl-luf',
'timedatectl',
'tracepath',
'traceroute',
'uname',
'uptime',
'w',
@@ -86,8 +92,8 @@ parsers = [
# List of custom or override parsers.
# Allow any <user_data_dir>/jc/jcparsers/*.py
local_parsers = []
data_dir = appdirs.user_data_dir("jc", "jc")
local_parsers_dir = os.path.join(data_dir, "jcparsers")
data_dir = appdirs.user_data_dir('jc', 'jc')
local_parsers_dir = os.path.join(data_dir, 'jcparsers')
if os.path.isdir(local_parsers_dir):
sys.path.append(data_dir)
for name in os.listdir(local_parsers_dir):
@@ -98,8 +104,52 @@ if os.path.isdir(local_parsers_dir):
parsers.append(plugin_name)
def set_env_colors():
# We only support 2.3.0+, pygments changed color names in 2.4.0.
# startswith is sufficient and avoids potential exceptions from split and int.
if pygments.__version__.startswith('2.3.'):
PYGMENT_COLOR = {
'black': '#ansiblack',
'red': '#ansidarkred',
'green': '#ansidarkgreen',
'yellow': '#ansibrown',
'blue': '#ansidarkblue',
'magenta': '#ansipurple',
'cyan': '#ansiteal',
'gray': '#ansilightgray',
'brightblack': '#ansidarkgray',
'brightred': '#ansired',
'brightgreen': '#ansigreen',
'brightyellow': '#ansiyellow',
'brightblue': '#ansiblue',
'brightmagenta': '#ansifuchsia',
'brightcyan': '#ansiturquoise',
'white': '#ansiwhite',
}
else:
PYGMENT_COLOR = {
'black': 'ansiblack',
'red': 'ansired',
'green': 'ansigreen',
'yellow': 'ansiyellow',
'blue': 'ansiblue',
'magenta': 'ansimagenta',
'cyan': 'ansicyan',
'gray': 'ansigray',
'brightblack': 'ansibrightblack',
'brightred': 'ansibrightred',
'brightgreen': 'ansibrightgreen',
'brightyellow': 'ansibrightyellow',
'brightblue': 'ansibrightblue',
'brightmagenta': 'ansibrightmagenta',
'brightcyan': 'ansibrightcyan',
'white': 'ansiwhite',
}
def set_env_colors(env_colors=None):
"""
Return a dictionary to be used in Pygments custom style class.
Grab custom colors from JC_COLORS environment variable. JC_COLORS env variable takes 4 comma
separated string values and should be in the format of:
@@ -115,40 +165,36 @@ def set_env_colors():
JC_COLORS=default,default,default,default
"""
env_colors = os.getenv('JC_COLORS')
input_error = False
if env_colors:
color_list = env_colors.split(',')
else:
color_list = ['default', 'default', 'default', 'default']
if len(color_list) != 4:
input_error = True
if env_colors and len(color_list) != 4:
print('jc: Warning: could not parse JC_COLORS environment variable\n', file=sys.stderr)
input_error = True
if env_colors:
for color in color_list:
if color not in ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray', 'brightblack', 'brightred',
'brightgreen', 'brightyellow', 'brightblue', 'brightmagenta', 'brightcyan', 'white', 'default']:
print('jc: Warning: could not parse JC_COLORS environment variable\n', file=sys.stderr)
input_error = True
for color in color_list:
if color != 'default' and color not in PYGMENT_COLOR:
input_error = True
# if there is an issue with the env variable, just set all colors to default and move on
if input_error:
print('jc: Warning: could not parse JC_COLORS environment variable\n', file=sys.stderr)
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
return {
Name.Tag: f'bold ansi{color_list[0]}' if not color_list[0] == 'default' else 'bold ansiblue', # key names
Keyword: f'ansi{color_list[1]}' if not color_list[1] == 'default' else 'ansibrightblack', # true, false, null
Number: f'ansi{color_list[2]}' if not color_list[2] == 'default' else 'ansimagenta', # numbers
String: f'ansi{color_list[3]}' if not color_list[3] == 'default' else 'ansigreen' # strings
Name.Tag: f'bold {PYGMENT_COLOR[color_list[0]]}' if not color_list[0] == 'default' else f"bold {PYGMENT_COLOR['blue']}", # key names
Keyword: PYGMENT_COLOR[color_list[1]] if not color_list[1] == 'default' else PYGMENT_COLOR['brightblack'], # true, false, null
Number: PYGMENT_COLOR[color_list[2]] if not color_list[2] == 'default' else PYGMENT_COLOR['magenta'], # numbers
String: PYGMENT_COLOR[color_list[3]] if not color_list[3] == 'default' else PYGMENT_COLOR['green'] # strings
}
def piped_output():
"""returns False if stdout is a TTY. True if output is being piped to another program"""
"""Return False if stdout is a TTY. True if output is being piped to another program"""
if sys.stdout.isatty():
return False
else:
@@ -156,34 +202,34 @@ def piped_output():
def ctrlc(signum, frame):
"""exit with error on SIGINT"""
"""Exit with error on SIGINT"""
sys.exit(1)
def parser_shortname(parser_argument):
"""short name of the parser with dashes and no -- prefix"""
"""Return short name of the parser with dashes and no -- prefix"""
return parser_argument[2:]
def parser_argument(parser):
"""short name of the parser with dashes and with -- prefix"""
"""Return short name of the parser with dashes and with -- prefix"""
return f'--{parser}'
def parser_mod_shortname(parser):
"""short name of the parser's module name (no -- prefix and dashes converted to underscores)"""
"""Return short name of the parser's module name (no -- prefix and dashes converted to underscores)"""
return parser.replace('--', '').replace('-', '_')
def parser_module(parser):
"""import the module just in time and return the module object"""
"""Import the module just in time and return the module object"""
shortname = parser_mod_shortname(parser)
path = ('jcparsers.' if shortname in local_parsers else 'jc.parsers.')
return importlib.import_module(path + shortname)
def parsers_text(indent=0, pad=0):
"""return the argument and description information from each parser"""
"""Return the argument and description information from each parser"""
ptext = ''
for parser in parsers:
parser_arg = parser_argument(parser)
@@ -201,7 +247,7 @@ def parsers_text(indent=0, pad=0):
def about_jc():
"""return jc info and the contents of each parser.info as a dictionary"""
"""Return jc info and the contents of each parser.info as a dictionary"""
parser_list = []
for parser in parsers:
@@ -231,7 +277,7 @@ def about_jc():
def helptext(message):
"""return the help text with the list of parsers"""
"""Return the help text with the list of parsers"""
parsers_string = parsers_text(indent=12, pad=17)
helptext_string = f'''
@@ -247,7 +293,7 @@ def helptext(message):
{parsers_string}
Options:
-a about jc
-d debug - show trace messages
-d debug - show traceback (-dd for verbose traceback)
-m monochrome output
-p pretty print output
-q quiet - suppress warnings
@@ -260,30 +306,30 @@ def helptext(message):
jc -p ls -al
'''
print(textwrap.dedent(helptext_string), file=sys.stderr)
def json_out(data, pretty=False, mono=False, piped_out=False):
# set colors
class JcStyle(Style):
styles = set_env_colors()
return textwrap.dedent(helptext_string)
def json_out(data, pretty=False, env_colors=None, mono=False, piped_out=False):
"""Return a JSON formatted string. String may include color codes or be pretty printed."""
if not mono and not piped_out:
# set colors
class JcStyle(Style):
styles = set_env_colors(env_colors)
if pretty:
print(highlight(json.dumps(data, indent=2), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
return str(highlight(json.dumps(data, indent=2), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
else:
print(highlight(json.dumps(data), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
return str(highlight(json.dumps(data), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
else:
if pretty:
print(json.dumps(data, indent=2))
return json.dumps(data, indent=2)
else:
print(json.dumps(data))
return json.dumps(data)
def generate_magic_command(args):
"""
Returns a tuple with a boolean and a command, where the boolean signifies that
Return a tuple with a boolean and a command, where the boolean signifies that
the command is valid, and the command is either a command string or None.
"""
@@ -316,7 +362,7 @@ def generate_magic_command(args):
magic_dict = {}
parser_info = about_jc()['parsers']
# Create a dictionary of magic_commands to their respective parsers.
# create a dictionary of magic_commands to their respective parsers.
for entry in parser_info:
# Update the dict with all of the magic commands for this parser, if they exist.
magic_dict.update({mc: entry['argument'] for mc in entry.get('magic_commands', [])})
@@ -325,7 +371,7 @@ def generate_magic_command(args):
one_word_command = args_given[0]
two_word_command = ' '.join(args_given[0:2])
# Try to get a parser for two_word_command, otherwise get one for one_word_command
# try to get a parser for two_word_command, otherwise get one for one_word_command
found_parser = magic_dict.get(two_word_command, magic_dict.get(one_word_command))
# construct a new command line using the standard syntax: COMMAND | jc --PARSER -OPTIONS
@@ -338,6 +384,7 @@ def generate_magic_command(args):
def magic():
"""Runs the command generated by generate_magic_command() to support magic syntax"""
valid_command, run_command = generate_magic_command(sys.argv)
if valid_command:
os.system(run_command)
@@ -345,7 +392,7 @@ def magic():
elif run_command is None:
return
else:
helptext(f'parser not found for "{run_command}"')
print(helptext(f'parser not found for "{run_command}"'), file=sys.stderr)
sys.exit(1)
@@ -359,6 +406,8 @@ def main():
except AttributeError:
pass
jc_colors = os.getenv('JC_COLORS')
# try magic syntax first: e.g. jc -p ls -al
magic()
@@ -370,54 +419,54 @@ def main():
options.extend(opt[1:])
debug = 'd' in options
verbose_debug = True if options.count('d') > 1 else False
mono = 'm' in options
pretty = 'p' in options
quiet = 'q' in options
raw = 'r' in options
if verbose_debug:
import jc.tracebackplus
jc.tracebackplus.enable(context=11)
if 'a' in options:
json_out(about_jc(), pretty=pretty, mono=mono, piped_out=piped_output())
print(json_out(about_jc(), pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
sys.exit(0)
if sys.stdin.isatty():
helptext('missing piped data')
print(helptext('missing piped data'), file=sys.stderr)
sys.exit(1)
data = sys.stdin.read()
found = False
if debug:
for arg in sys.argv:
parser_name = parser_shortname(arg)
for arg in sys.argv:
parser_name = parser_shortname(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
try:
result = parser.parse(data, raw=raw, quiet=quiet)
found = True
break
else:
for arg in sys.argv:
parser_name = parser_shortname(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
try:
result = parser.parse(data, raw=raw, quiet=quiet)
found = True
break
except Exception:
except Exception:
if debug:
raise
else:
import jc.utils
jc.utils.error_message(
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.')
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n'
' For details use the -d or -dd option.')
sys.exit(1)
if not found:
helptext('missing or incorrect arguments')
print(helptext('missing or incorrect arguments'), file=sys.stderr)
sys.exit(1)
json_out(result, pretty=pretty, mono=mono, piped_out=piped_output())
print(json_out(result, pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
if __name__ == '__main__':

160
jc/parsers/date.py Normal file
View File

@@ -0,0 +1,160 @@
"""jc - JSON CLI output utility date Parser
Usage:
specify --date as the first argument if the piped input is coming from date
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ date | jc --date -p
{
"year": 2020,
"month_num": 7,
"day": 31,
"hour": 16,
"minute": 48,
"second": 11,
"month": "Jul",
"weekday": "Fri",
"weekday_num": 6,
"timezone": "PDT"
}
$ date | jc --date -p -r
{
"year": "2020",
"month": "Jul",
"day": "31",
"weekday": "Fri",
"hour": "16",
"minute": "50",
"second": "01",
"timezone": "PDT"
}
"""
import jc.utils
class info():
version = '1.0'
description = 'date command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'freebsd']
magic_commands = ['date']
__version__ = info.version
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"year": integer,
"month_num": integer,
"day": integer,
"hour": integer,
"minute": integer,
"second": integer,
"month": string,
"weekday": string,
"weekday_num": integer,
"timezone": string
}
"""
month_map = {
"Jan": 1,
"Feb": 2,
"Mar": 3,
"Apr": 4,
"May": 5,
"Jun": 6,
"Jul": 7,
"Aug": 8,
"Sep": 9,
"Oct": 10,
"Nov": 11,
"Dec": 12
}
weekday_map = {
"Sun": 1,
"Mon": 2,
"Tue": 3,
"Wed": 4,
"Thu": 5,
"Fri": 6,
"Sat": 7
}
if proc_data:
return {
"year": int(proc_data['year']),
'month_num': month_map[proc_data['month']],
"day": int(proc_data['day']),
"hour": int(proc_data['hour']),
"minute": int(proc_data['minute']),
"second": int(proc_data['second']),
"month": proc_data['month'],
"weekday": proc_data['weekday'],
"weekday_num": weekday_map[proc_data['weekday']],
"timezone": proc_data['timezone']
}
else:
return {}
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = {}
if jc.utils.has_data(data):
data = data.replace(':', ' ')
split_data = data.split()
raw_output = {
"year": split_data[7],
"month": split_data[1],
"day": split_data[2],
"weekday": split_data[0],
"hour": split_data[3],
"minute": split_data[4],
"second": split_data[5],
"timezone": split_data[6]
}
if raw:
return raw_output
else:
return process(raw_output)

View File

@@ -372,8 +372,6 @@ class IfconfigParser(object):
class InterfaceNotFound(Exception):
"""
"""
pass

View File

@@ -2,7 +2,9 @@
Usage:
specify --ini as the first argument if the piped input is coming from an INI file
Specify --ini as the first argument if the piped input is coming from an INI file or any
simple key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Compatibility:
@@ -47,7 +49,7 @@ import configparser
class info():
version = '1.1'
version = '1.3'
description = 'INI file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -70,15 +72,33 @@ def process(proc_data):
Returns:
Dictionary representing an ini document:
Dictionary representing an ini or simple key/value pair document:
{
ini document converted to a dictionary
see configparser standard library documentation for more details
ini or key/value document converted to a dictionary - see configparser standard
library documentation for more details.
Note: Values starting and ending with quotation marks will have the marks removed.
If you would like to keep the quotation marks, use the -r or raw=True argument.
}
"""
# remove quotation marks from beginning and end of values
for heading in proc_data:
# standard ini files with headers
if isinstance(proc_data[heading], dict):
for key, value in proc_data[heading].items():
if value is not None and value.startswith('"') and value.endswith('"'):
proc_data[heading][key] = value.lstrip('"').rstrip('"')
elif value is None:
proc_data[heading][key] = ''
# simple key/value files with no headers
else:
if proc_data[heading] is not None and proc_data[heading].startswith('"') and proc_data[heading].endswith('"'):
proc_data[heading] = proc_data[heading].lstrip('"').rstrip('"')
elif proc_data[heading] is None:
proc_data[heading] = ''
# No further processing
return proc_data
@@ -103,9 +123,17 @@ def parse(data, raw=False, quiet=False):
if jc.utils.has_data(data):
ini = configparser.ConfigParser()
ini.read_string(data)
raw_output = {s: dict(ini.items(s)) for s in ini.sections()}
ini = configparser.ConfigParser(allow_no_value=True, interpolation=None)
try:
ini.read_string(data)
raw_output = {s: dict(ini.items(s)) for s in ini.sections()}
except configparser.MissingSectionHeaderError:
data = '[data]\n' + data
ini.read_string(data)
output_dict = {s: dict(ini.items(s)) for s in ini.sections()}
for key, value in output_dict['data'].items():
raw_output[key] = value
if raw:
return raw_output

View File

@@ -134,7 +134,7 @@ import jc.utils
class info():
version = '1.3'
version = '1.4'
description = 'iptables command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -194,19 +194,19 @@ def process(proc_data):
if 'bytes' in rule:
multiplier = 1
if rule['bytes'][-1] == 'K':
multiplier = 1000
multiplier = 10 ** 3
rule['bytes'] = rule['bytes'].rstrip('K')
elif rule['bytes'][-1] == 'M':
multiplier = 1000000
multiplier = 10 ** 6
rule['bytes'] = rule['bytes'].rstrip('M')
elif rule['bytes'][-1] == 'G':
multiplier = 1000000000
multiplier = 10 ** 9
rule['bytes'] = rule['bytes'].rstrip('G')
elif rule['bytes'][-1] == 'T':
multiplier = 1000000000000
multiplier = 10 ** 12
rule['bytes'] = rule['bytes'].rstrip('T')
elif rule['bytes'][-1] == 'P':
multiplier = 1000000000000000
multiplier = 10 ** 15
rule['bytes'] = rule['bytes'].rstrip('P')
try:
@@ -243,14 +243,14 @@ def parse(data, raw=False, quiet=False):
chain = {}
headers = []
cleandata = data.splitlines()
if jc.utils.has_data(data):
for line in cleandata:
for line in list(filter(None, data.splitlines())):
if line.startswith('Chain'):
raw_output.append(chain)
if chain:
raw_output.append(chain)
chain = {}
headers = []
@@ -274,7 +274,8 @@ def parse(data, raw=False, quiet=False):
if temp_rule:
chain['rules'].append(temp_rule)
raw_output = list(filter(None, raw_output))
if chain:
raw_output.append(chain)
if raw:
return raw_output

67
jc/parsers/kv.py Normal file
View File

@@ -0,0 +1,67 @@
"""jc - JSON CLI output utility Key/Value File Parser
Usage:
Specify --kv as the first argument if the piped input is coming from a simple
key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
Examples:
$ cat keyvalue.txt
# this file contains key/value pairs
name = John Doe
address=555 California Drive
age: 34
; comments can include # or ;
# delimiter can be = or :
# quoted values have quotation marks stripped by default
# but can be preserved with the -r argument
occupation:"Engineer"
$ cat keyvalue.txt | jc --ini -p
{
"name": "John Doe",
"address": "555 California Drive",
"age": "34",
"occupation": "Engineer"
}
"""
class info():
version = '1.0'
description = 'Key/Value file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
details = 'This is a wrapper for the INI parser'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
__version__ = info.version
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Note: this is just a wrapper for jc.parsers.ini
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary representing the key/value file
"""
import jc.parsers.ini
return jc.parsers.ini.parse(data, raw=raw, quiet=quiet)

507
jc/parsers/ping.py Normal file
View File

@@ -0,0 +1,507 @@
"""jc - JSON CLI output utility ping Parser
Usage:
specify --ping as the first argument if the piped input is coming from ping
Note: Use the ping -c (count) option, otherwise data will not be piped to jc.
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ ping -c 3 -p ff cnn.com | jc --ping -p
{
"destination_ip": "151.101.1.67",
"data_bytes": 56,
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": 3,
"packets_received": 3,
"packet_loss_percent": 0.0,
"duplicates": 0,
"round_trip_ms_min": 28.015,
"round_trip_ms_avg": 32.848,
"round_trip_ms_max": 39.376,
"round_trip_ms_stddev": 4.79,
"responses": [
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 0,
"ttl": 59,
"time_ms": 28.015,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 1,
"ttl": 59,
"time_ms": 39.376,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 2,
"ttl": 59,
"time_ms": 31.153,
"duplicate": false
}
]
}
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
{
"destination_ip": "151.101.129.67",
"data_bytes": "56",
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": "3",
"packets_received": "3",
"packet_loss_percent": "0.0",
"duplicates": "0",
"round_trip_ms_min": "25.078",
"round_trip_ms_avg": "29.543",
"round_trip_ms_max": "32.553",
"round_trip_ms_stddev": "3.221",
"responses": [
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "0",
"ttl": "59",
"time_ms": "25.078",
"duplicate": false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "1",
"ttl": "59",
"time_ms": "30.999",
"duplicate": false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "2",
"ttl": "59",
"time_ms": "32.553",
"duplicate": false
}
]
}
"""
import string
import jc.utils
class info():
version = '1.0'
description = 'ping command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'freebsd']
magic_commands = ['ping', 'ping6']
__version__ = info.version
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"source_ip": string,
"destination_ip": string,
"data_bytes": integer,
"pattern": string, (null if not set)
"destination": string,
"packets_transmitted": integer,
"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,
"responses": [
{
"type": string, ('reply' or 'timeout')
"timestamp": float,
"bytes": integer,
"response_ip": string,
"icmp_seq": integer,
"ttl": integer,
"time_ms": float,
"duplicate": boolean
}
]
}
"""
int_list = ['data_bytes', 'packets_transmitted', 'packets_received', 'bytes', 'icmp_seq', 'ttl', 'duplicates']
float_list = ['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.keys():
for item in int_list:
if item == key:
try:
proc_data[key] = int(proc_data[key])
except (ValueError, TypeError):
proc_data[key] = None
for item in float_list:
if item == key:
try:
proc_data[key] = float(proc_data[key])
except (ValueError, TypeError):
proc_data[key] = None
if key == 'responses':
for entry in proc_data['responses']:
for k in entry.keys():
if k in int_list:
try:
entry[k] = int(entry[k])
except (ValueError, TypeError):
entry[k] = None
if k in float_list:
try:
entry[k] = float(entry[k])
except (ValueError, TypeError):
entry[k] = None
return proc_data
def linux_parse(data):
raw_output = {}
ping_responses = []
pattern = None
footer = False
linedata = data.splitlines()
# check for PATTERN
if linedata[0].startswith('PATTERN: '):
pattern = linedata.pop(0).split(': ')[1]
while not linedata[0].startswith('PING '):
linedata.pop(0)
ipv4 = True if 'bytes of data' in linedata[0] else False
if ipv4 and linedata[0][5] not in string.digits:
hostname = True
elif ipv4 and linedata[0][5] in string.digits:
hostname = False
elif not ipv4 and ' (' in linedata[0]:
hostname = True
else:
hostname = False
for line in filter(None, linedata):
if line.startswith('PING '):
if ipv4 and not hostname:
dst_ip, dta_byts = (2, 3)
elif ipv4 and hostname:
dst_ip, dta_byts = (2, 3)
elif not ipv4 and not hostname:
dst_ip, dta_byts = (2, 3)
else:
dst_ip, dta_byts = (3, 4)
line = line.replace('(', ' ').replace(')', ' ')
raw_output.update(
{
'destination_ip': line.split()[dst_ip].lstrip('(').rstrip(')'),
'data_bytes': line.split()[dta_byts],
'pattern': pattern
}
)
continue
if line.startswith('---'):
footer = True
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
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]
}
)
# ping response lines
else:
# request timeout
if 'no answer yet for icmp_seq=' in line:
timestamp = False
isequence = 5
# if timestamp option is specified, then shift icmp sequence field right by one
if line[0] == '[':
timestamp = True
isequence = 6
response = {
'type': 'timeout',
'timestamp': line.split()[0].lstrip('[').rstrip(']') if timestamp else None,
'icmp_seq': line.replace('=', ' ').split()[isequence]
}
ping_responses.append(response)
continue
# normal responses
else:
line = line.replace('(', ' ').replace(')', ' ').replace('=', ' ')
# positions of items depend on whether ipv4/ipv6 and/or ip/hostname is used
if ipv4 and not hostname:
bts, rip, iseq, t2l, tms = (0, 3, 5, 7, 9)
elif ipv4 and hostname:
bts, rip, iseq, t2l, tms = (0, 4, 7, 9, 11)
elif not ipv4 and not hostname:
bts, rip, iseq, t2l, tms = (0, 3, 5, 7, 9)
elif not ipv4 and hostname:
bts, rip, iseq, t2l, tms = (0, 4, 7, 9, 11)
# if timestamp option is specified, then shift everything right by one
timestamp = False
if line[0] == '[':
timestamp = True
bts, rip, iseq, t2l, tms = (bts + 1, rip + 1, iseq + 1, t2l + 1, tms + 1)
response = {
'type': 'reply',
'timestamp': line.split()[0].lstrip('[').rstrip(']') if timestamp else None,
'bytes': line.split()[bts],
'response_ip': line.split()[rip].rstrip(':'),
'icmp_seq': line.split()[iseq],
'ttl': line.split()[t2l],
'time_ms': line.split()[tms],
'duplicate': True if 'DUP!' in line else False
}
ping_responses.append(response)
continue
raw_output['responses'] = ping_responses
return raw_output
def bsd_parse(data):
raw_output = {}
ping_responses = []
pattern = None
footer = False
linedata = data.splitlines()
# check for PATTERN
if linedata[0].startswith('PATTERN: '):
pattern = linedata.pop(0).split(': ')[1]
for line in filter(None, linedata):
if line.startswith('PING '):
raw_output.update(
{
'destination_ip': line.split()[2].lstrip('(').rstrip(':').rstrip(')'),
'data_bytes': line.split()[3],
'pattern': pattern
}
)
continue
if line.startswith('PING6('):
line = line.replace('(', ' ').replace(')', ' ').replace('=', ' ')
raw_output.update(
{
'source_ip': line.split()[4],
'destination_ip': line.split()[6],
'data_bytes': line.split()[1],
'pattern': pattern
}
)
continue
if line.startswith('---'):
footer = True
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()[8].rstrip('%'),
'duplicates': line.split()[6].lstrip('+'),
}
)
continue
else:
raw_output.update(
{
'packets_transmitted': line.split()[0],
'packets_received': line.split()[3],
'packet_loss_percent': line.split()[6].rstrip('%'),
'duplicates': '0',
}
)
continue
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].replace(' ms', '')
}
)
# ping response lines
else:
# ipv4 lines
if ',' not in line:
# request timeout
if line.startswith('Request timeout for '):
response = {
'type': 'timeout',
'icmp_seq': line.split()[4]
}
ping_responses.append(response)
continue
# normal response
else:
line = line.replace(':', ' ').replace('=', ' ')
response = {
'type': 'reply',
'bytes': line.split()[0],
'response_ip': line.split()[3],
'icmp_seq': line.split()[5],
'ttl': line.split()[7],
'time_ms': line.split()[9]
}
ping_responses.append(response)
continue
# ipv6 lines
else:
line = line.replace(',', ' ').replace('=', ' ')
response = {
'type': 'reply',
'bytes': line.split()[0],
'response_ip': line.split()[3],
'icmp_seq': line.split()[5],
'ttl': line.split()[7],
'time_ms': line.split()[9]
}
ping_responses.append(response)
continue
# identify duplicates in responses
if ping_responses:
seq_list = []
for reply in ping_responses:
seq_list.append(reply['icmp_seq'])
reply['duplicate'] = True if seq_list.count(reply['icmp_seq']) > 1 else False
raw_output['responses'] = ping_responses
return raw_output
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = {}
if jc.utils.has_data(data):
if 'time' in data.splitlines()[-2]:
raw_output = linux_parse(data)
else:
raw_output = bsd_parse(data)
if raw:
return raw_output
else:
return process(raw_output)

View File

@@ -84,7 +84,7 @@ import jc.parsers.universal
class info():
version = '1.3'
version = '1.4'
description = 'route command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -182,10 +182,16 @@ def parse(data, raw=False, quiet=False):
jc.utils.compatibility(__name__, info.compatible)
cleandata = data.splitlines()[1:]
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)

154
jc/parsers/sysctl.py Normal file
View File

@@ -0,0 +1,154 @@
"""jc - JSON CLI output utility sysctl -a Parser
Usage:
specify --sysctl as the first argument if the piped input is coming from sysctl -a
Note: since sysctl output is not easily parsable only a very simple key/value object
will be output. An attempt is made to convert obvious integers and floats. If no
conversion is desired, use the -r (raw) option.
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ sysctl | jc --sysctl -p
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": 99,
"user.bc_dim_max": 2048,
"user.bc_scale_max": 99,
"user.bc_string_max": 1000,
"user.coll_weights_max": 2,
"user.expr_nest_max": 32
...
}
$ sysctl | jc --sysctl -p -r
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": "99",
"user.bc_dim_max": "2048",
"user.bc_scale_max": "99",
"user.bc_string_max": "1000",
"user.coll_weights_max": "2",
"user.expr_nest_max": "32",
...
}
"""
import jc.utils
class info():
version = '1.0'
description = 'sysctl command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# details = 'enter any other details here'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'freebsd']
magic_commands = ['sysctl']
__version__ = info.version
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"foo": string/integer/float, # best guess based on value
"bar": string/integer/float,
"baz": string/integer/float
}
"""
for key in proc_data:
try:
proc_data[key] = int(proc_data[key])
except (ValueError):
try:
proc_data[key] = float(proc_data[key])
except (ValueError):
pass
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = {}
if jc.utils.has_data(data):
data = data.splitlines()
# linux uses = and bsd uses :
if ' = ' in data[0]:
delim = ' = '
else:
delim = ': '
for line in data:
linedata = line.split(delim, maxsplit=1)
# bsd adds values to newlines, which need to be fixed up with this try/except block
try:
key = linedata[0]
value = linedata[1]
# syctl -a repeats some keys on linux. Append values from repeating keys
# to the previous key value
if key in raw_output:
existing_value = raw_output[key]
raw_output[key] = existing_value + '\n' + value
continue
# fix for weird multiline output in bsd
# if the key looks strange (has spaces or no dots) then it's probably a value field
# on a separate line. in this case, just append it to the previous key in the dictionary.
if '.' not in key or ' ' in key:
previous_key = [*raw_output.keys()][-1]
raw_output[previous_key] = raw_output[previous_key] + '\n' + line
continue
# if the key looks normal then just add to the dictionary as normal
else:
raw_output[key] = value
continue
# if there is an IndexError exception, then there was no delimiter in the line.
# In this case just append the data line as a value to the previous key.
except IndexError:
prior_key = [*raw_output.keys()][-1]
raw_output[prior_key] = raw_output[prior_key] + '\n' + line
continue
if raw:
return raw_output
else:
return process(raw_output)

251
jc/parsers/tracepath.py Normal file
View File

@@ -0,0 +1,251 @@
"""jc - JSON CLI output utility tracepath Parser
Usage:
specify --tracepath as the first argument if the piped input is coming from tracepath
Compatibility:
'linux'
Examples:
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
{
"pmtu": 1480,
"forward_hops": 2,
"return_hops": 2,
"hops": [
{
"ttl": 1,
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": 1500,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": 1,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.411,
"pmtu": null,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": 2,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.39,
"pmtu": 1480,
"asymmetric_difference": 1,
"reached": false
},
{
"ttl": 2,
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": 463.514,
"pmtu": null,
"asymmetric_difference": null,
"reached": true
}
]
}
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p -r
{
"pmtu": "1480",
"forward_hops": "2",
"return_hops": "2",
"hops": [
{
"ttl": "1",
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": "1500",
"asymmetric_difference": null,
"reached": false
},
{
"ttl": "1",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.411",
"pmtu": null,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": "2",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.390",
"pmtu": "1480",
"asymmetric_difference": "1",
"reached": false
},
{
"ttl": "2",
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": "463.514",
"pmtu": null,
"asymmetric_difference": null,
"reached": true
}
]
}
"""
import re
import jc.utils
class info():
version = '1.0'
description = 'tracepath command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux']
magic_commands = ['tracepath', 'tracepath6']
__version__ = info.version
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"pmtu": integer,
"forward_hops": integer,
"return_hops": integer,
"hops": [
{
"ttl": integer,
"guess": boolean,
"host": string,
"reply_ms": float,
"pmtu": integer,
"asymmetric_difference": integer,
"reached": boolean
}
]
}
"""
int_list = ['pmtu', 'forward_hops', 'return_hops', 'ttl', 'asymmetric_difference']
float_list = ['reply_ms']
for key, value in proc_data.items():
for item in int_list:
if key in int_list:
try:
proc_data[key] = int(proc_data[key])
except (ValueError, TypeError):
proc_data[key] = None
for item in int_list:
if key in float_list:
try:
proc_data[key] = float(proc_data[key])
except (ValueError, TypeError):
proc_data[key] = None
if 'hops' in proc_data:
for entry in proc_data['hops']:
for key in int_list:
if key in entry:
try:
entry[key] = int(entry[key])
except (ValueError, TypeError):
entry[key] = None
for key in float_list:
if key in entry:
try:
entry[key] = float(entry[key])
except (ValueError, TypeError):
entry[key] = None
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
RE_TTL_HOST = re.compile(r'^\s?(?P<ttl>\d+)(?P<ttl_guess>\??):\s+(?P<host>(?:no reply|\S+))') # groups: ttl, ttl_guess, host
RE_PMTU = re.compile(r'\spmtu\s(?P<pmtu>[\d]+)') # group: pmtu
RE_REPLY_MS = re.compile(r'\s(?P<reply_ms>\d*\.\d*)ms') # group: reply_ms
RE_ASYMM = re.compile(r'\sasymm\s+(?P<asymm>[\d]+)') # group: asymm
RE_REACHED = re.compile(r'\sreached')
RE_SUMMARY = re.compile(r'\s+Resume:\s+pmtu\s+(?P<pmtu>\d+)(?:\s+hops\s+(?P<hops>\d+))?(?:\s+back\s+(?P<back>\d+))?') # groups: pmtu, hops, back
raw_output = {}
if jc.utils.has_data(data):
hops = []
for line in filter(None, data.splitlines()):
# grab hop information
ttl_host = re.search(RE_TTL_HOST, line)
pmtu = re.search(RE_PMTU, line)
reply_ms = re.search(RE_REPLY_MS, line)
asymm = re.search(RE_ASYMM, line)
reached = re.search(RE_REACHED, line)
summary = re.search(RE_SUMMARY, line)
if ttl_host:
hop = {
'ttl': ttl_host.group('ttl'),
'guess': bool(ttl_host.group('ttl_guess')),
'host': ttl_host.group('host') if ttl_host.group('host') != 'no reply' else None,
'reply_ms': reply_ms.group('reply_ms') if reply_ms else None,
'pmtu': pmtu.group('pmtu') if pmtu else None,
'asymmetric_difference': asymm.group('asymm') if asymm else None,
'reached': bool(reached)
}
hops.append(hop)
continue
elif summary:
raw_output = {
'pmtu': summary.group('pmtu') if summary.group('pmtu') else None,
'forward_hops': summary.group('hops') if summary.group('hops') else None,
'return_hops': summary.group('back') if summary.group('back') else None,
'hops': hops
}
if raw:
return raw_output
else:
return process(raw_output)

435
jc/parsers/traceroute.py Normal file
View File

@@ -0,0 +1,435 @@
"""jc - JSON CLI output utility traceroute Parser
Usage:
specify --traceroute as the first argument if the piped input is coming from traceroute
Note: On some operating systems you will need to redirect STDERR to STDOUT for destination
info since the header line is sent to STDERR. A warning message will be printed to
STDERR if the header row is not found.
e.g. $ traceroute 8.8.8.8 2>&1 | jc --traceroute
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
$ traceroute google.com | jc --traceroute -p
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
{
"hop": 1,
"probes": [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.574
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.65
}
]
},
...
]
}
$ traceroute google.com | jc --traceroute -p -r
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
{
"hop": "1",
"probes": [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.574"
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.650"
}
]
},
...
]
}
"""
import re
from decimal import Decimal
import jc.utils
class info():
version = '1.1'
description = 'traceroute command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
details = 'Using the trparse library by Luis Benitez at https://github.com/lbenitez000/trparse'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'freebsd']
magic_commands = ['traceroute', 'traceroute6']
__version__ = info.version
'''
Copyright (C) 2015 Luis Benitez
Parses the output of a traceroute execution into an AST (Abstract Syntax Tree).
The MIT License (MIT)
Copyright (c) 2014 Luis Benitez
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.
'''
RE_HEADER = re.compile(r'(\S+)\s+\((\d+\.\d+\.\d+\.\d+|[0-9a-fA-F:]+)\)')
RE_PROBE_NAME_IP = re.compile(r'(\S+)\s+\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[0-9a-fA-F:]+)\)+')
RE_PROBE_BSD_IPV6 = re.compile(r'\b(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}\b')
RE_HOP = re.compile(r'^\s*(\d+)?\s+(.+)$')
RE_PROBE_ASN = re.compile(r'\[AS(\d+)\]')
RE_PROBE_RTT_ANNOTATION = re.compile(r'(?:(\d+(?:\.?\d+)?)\s+ms|(\s+\*\s+))\s*(!\S*)?')
class Traceroute(object):
def __init__(self, dest_name, dest_ip):
self.dest_name = dest_name
self.dest_ip = dest_ip
self.hops = []
def add_hop(self, hop):
self.hops.append(hop)
def __str__(self):
text = "Traceroute for %s (%s)\n\n" % (self.dest_name, self.dest_ip)
for hop in self.hops:
text += str(hop)
return text
class Hop(object):
def __init__(self, idx):
self.idx = idx # Hop count, starting at 1 (usually)
self.probes = [] # Series of Probe instances
def add_probe(self, probe):
"""Adds a Probe instance to this hop's results."""
if self.probes:
probe_last = self.probes[-1]
if not probe.ip:
probe.ip = probe_last.ip
probe.name = probe_last.name
self.probes.append(probe)
def __str__(self):
text = "{:>3d} ".format(self.idx)
text_len = len(text)
for n, probe in enumerate(self.probes):
text_probe = str(probe)
if n:
text += (text_len * " ") + text_probe
else:
text += text_probe
text += "\n"
return text
class Probe(object):
def __init__(self, name=None, ip=None, asn=None, rtt=None, annotation=None):
self.name = name
self.ip = ip
self.asn = asn # Autonomous System number
self.rtt = rtt # RTT in ms
self.annotation = annotation # Annotation, such as !H, !N, !X, etc
def __str__(self):
text = ""
if self.asn is not None:
text += "[AS{:d}] ".format(self.asn)
if self.rtt:
text += "{:s} ({:s}) {:1.3f} ms".format(self.name, self.ip, self.rtt)
else:
text = "*"
if self.annotation:
text += " {:s}".format(self.annotation)
text += "\n"
return text
def loads(data):
lines = data.splitlines()
# Get headers
match_dest = RE_HEADER.search(lines[0])
dest_name, dest_ip = None, None
if match_dest:
dest_name = match_dest.group(1)
dest_ip = match_dest.group(2)
# The Traceroute node is the root of the tree
traceroute = Traceroute(dest_name, dest_ip)
# Parse the remaining lines, they should be only hops/probes
for line in lines[1:]:
# Skip empty lines
if not line:
continue
hop_match = RE_HOP.match(line)
if hop_match.group(1):
hop_index = int(hop_match.group(1))
else:
hop_index = None
if hop_index is not None:
hop = Hop(hop_index)
traceroute.add_hop(hop)
hop_string = hop_match.group(2)
probe_asn_match = RE_PROBE_ASN.search(hop_string)
if probe_asn_match:
probe_asn = int(probe_asn_match.group(1))
else:
probe_asn = None
probe_name_ip_match = RE_PROBE_NAME_IP.search(hop_string)
probe_bsd_ipv6_match = RE_PROBE_BSD_IPV6.search(hop_string)
if probe_name_ip_match:
probe_name = probe_name_ip_match.group(1)
probe_ip = probe_name_ip_match.group(2)
elif probe_bsd_ipv6_match:
probe_name = None
probe_ip = probe_bsd_ipv6_match.group(0)
else:
probe_name = None
probe_ip = None
probe_rtt_annotations = RE_PROBE_RTT_ANNOTATION.findall(hop_string)
for probe_rtt_annotation in probe_rtt_annotations:
if probe_rtt_annotation[0]:
probe_rtt = Decimal(probe_rtt_annotation[0])
elif probe_rtt_annotation[1]:
probe_rtt = None
else:
message = f"Expected probe RTT or *. Got: '{probe_rtt_annotation[0]}'"
raise ParseError(message)
probe_annotation = probe_rtt_annotation[2] or None
probe = Probe(
name=probe_name,
ip=probe_ip,
asn=probe_asn,
rtt=probe_rtt,
annotation=probe_annotation
)
# only add probe if there is data
if any([probe_name, probe_ip, probe_asn, probe_rtt, probe_annotation]):
hop.add_probe(probe)
return traceroute
class ParseError(Exception):
pass
########################################################################################
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"destination_ip": string,
"destination_name": string,
"hops": [
{
"hop": integer,
"probes": [
{
"annotation": string,
"asn": integer,
"ip": string,
"name": string,
"rtt": float
}
]
}
]
}
"""
int_list = ['hop', 'asn']
float_list = ['rtt']
if 'hops' in proc_data:
for entry in proc_data['hops']:
for key in int_list:
if key in entry:
try:
entry[key] = int(entry[key])
except (ValueError, TypeError):
entry[key] = None
for key in float_list:
if key in entry:
try:
entry[key] = float(entry[key])
except (ValueError, TypeError):
entry[key] = None
if 'probes' in entry:
for item in entry['probes']:
for key in int_list:
if key in item:
try:
item[key] = int(item[key])
except (ValueError, TypeError):
item[key] = None
for key in float_list:
if key in item:
try:
item[key] = float(item[key])
except (ValueError, TypeError):
item[key] = None
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = {}
if jc.utils.has_data(data):
# remove any warning lines
new_data = []
for data_line in data.splitlines():
if 'traceroute: Warning: ' not in data_line and 'traceroute6: Warning: ' not in data_line:
new_data.append(data_line)
else:
continue
# check if header row exists, otherwise add a dummy header
if not new_data[0].startswith('traceroute to ') and not new_data[0].startswith('traceroute6 to '):
new_data[:0] = ['traceroute to <<_>> (<<_>>), 30 hops max, 60 byte packets']
# print warning to STDERR
if not quiet:
jc.utils.warning_message('No header row found. For destination info redirect STDERR to STDOUT')
data = '\n'.join(new_data)
tr = loads(data)
hops = tr.hops
hops_list = []
if hops:
for hop in hops:
hop_obj = {}
hop_obj['hop'] = str(hop.idx)
probe_list = []
if hop.probes:
for probe in hop.probes:
probe_obj = {
'annotation': probe.annotation,
'asn': None if probe.asn is None else str(probe.asn),
'ip': probe.ip,
'name': probe.name,
'rtt': None if probe.rtt is None else str(probe.rtt)
}
probe_list.append(probe_obj)
hop_obj['probes'] = probe_list
hops_list.append(hop_obj)
raw_output = {
'destination_ip': tr.dest_ip,
'destination_name': tr.dest_name,
'hops': hops_list
}
if raw:
return raw_output
else:
return process(raw_output)

View File

@@ -30,7 +30,7 @@ import jc.utils
class info():
version = '1.3'
version = '1.4'
description = 'uname -a command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -43,6 +43,10 @@ class info():
__version__ = info.version
class ParseError(Exception):
pass
def process(proc_data):
"""
Final processing to conform to the schema.
@@ -94,6 +98,10 @@ def parse(data, raw=False, quiet=False):
# check for OSX output
if data.startswith('Darwin'):
parsed_line = data.split()
if len(parsed_line) < 5:
raise ParseError('Could not parse uname output. Make sure to use "uname -a".')
raw_output['machine'] = parsed_line.pop(-1)
raw_output['kernel_name'] = parsed_line.pop(0)
raw_output['node_name'] = parsed_line.pop(0)
@@ -103,6 +111,10 @@ def parse(data, raw=False, quiet=False):
# otherwise use linux parser
else:
parsed_line = data.split(maxsplit=3)
if len(parsed_line) < 3:
raise ParseError('Could not parse uname output. Make sure to use "uname -a".')
raw_output['kernel_name'] = parsed_line.pop(0)
raw_output['node_name'] = parsed_line.pop(0)
raw_output['kernel_release'] = parsed_line.pop(0)

247
jc/tracebackplus.py Normal file
View File

@@ -0,0 +1,247 @@
"""More comprehensive traceback formatting for Python scripts.
To enable this module, do:
import tracebackplus; tracebackplus.enable()
at the top of your script. The optional arguments to enable() are:
logdir - if set, tracebacks are written to files in this directory
context - number of lines of source code to show for each stack frame
By default, tracebacks are displayed but not saved and the context is 5 lines.
Alternatively, if you have caught an exception and want tracebackplus to display it
for you, call tracebackplus.handler(). The optional argument to handler() is a
3-item tuple (etype, evalue, etb) just like the value of sys.exc_info().
"""
'''
tracebackplus was derived from the cgitb standard library module. As cgitb is being
deprecated, this simplified version of cgitb was created.
https://github.com/python/cpython/blob/3.8/Lib/cgitb.py
"Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
All Rights Reserved"
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
--------------------------------------------
1. This LICENSE AGREEMENT is between the Python Software Foundation
("PSF"), and the Individual or Organization ("Licensee") accessing and
otherwise using this software ("Python") in source or binary form and
its associated documentation.
2. Subject to the terms and conditions of this License Agreement, PSF hereby
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
analyze, test, perform and/or display publicly, prepare derivative works,
distribute, and otherwise use Python alone or in any derivative version,
provided, however, that PSF's License Agreement and PSF's notice of copyright,
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
All Rights Reserved" are retained in Python alone or in any derivative version
prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on
or incorporates Python or any part thereof, and wants to make
the derivative work available to others as provided herein, then
Licensee hereby agrees to include in any such work a brief summary of
the changes made to Python.
4. PSF is making Python available to Licensee on an "AS IS"
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material
breach of its terms and conditions.
7. Nothing in this License Agreement shall be deemed to create any
relationship of agency, partnership, or joint venture between PSF and
Licensee. This License Agreement does not grant permission to use PSF
trademarks or trade name in a trademark sense to endorse or promote
products or services of Licensee, or any third party.
8. By copying, installing or otherwise using Python, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
'''
import inspect
import keyword
import linecache
import os
import pydoc
import sys
import tempfile
import time
import tokenize
import traceback
__UNDEF__ = [] # a special sentinel object
def lookup(name, frame, locals):
"""Find the value for a given name in the given environment."""
if name in locals:
return 'local', locals[name]
if name in frame.f_globals:
return 'global', frame.f_globals[name]
if '__builtins__' in frame.f_globals:
builtins = frame.f_globals['__builtins__']
if isinstance(builtins, dict):
if name in builtins:
return 'builtin', builtins[name]
else:
if hasattr(builtins, name):
return 'builtin', getattr(builtins, name)
return None, __UNDEF__
def scanvars(reader, frame, locals):
"""Scan one logical line of Python and look up values of variables used."""
vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__
for ttype, token, start, end, line in tokenize.generate_tokens(reader):
if ttype == tokenize.NEWLINE:
break
if ttype == tokenize.NAME and token not in keyword.kwlist:
if lasttoken == '.':
if parent is not __UNDEF__:
value = getattr(parent, token, __UNDEF__)
vars.append((prefix + token, prefix, value))
else:
where, value = lookup(token, frame, locals)
vars.append((token, where, value))
elif token == '.':
prefix += lasttoken + '.'
parent = value
else:
parent, prefix = None, ''
lasttoken = token
return vars
def text(einfo, context=5):
"""Return a plain text document describing a given traceback."""
etype, evalue, etb = einfo
if isinstance(etype, type):
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
date = time.ctime(time.time())
head = '%s\n%s\n%s\n' % (str(etype), pyver, date) + '''
A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.
'''
frames = []
records = inspect.getinnerframes(etb, context)
for frame, file, lnum, func, lines, index in records:
file = file and os.path.abspath(file) or '?'
args, varargs, varkw, locals = inspect.getargvalues(frame)
call = ''
if func != '?':
call = 'in ' + func + \
inspect.formatargvalues(args, varargs, varkw, locals,
formatvalue=lambda value: '=' + pydoc.text.repr(value))
highlight = {}
def reader(lnum=[lnum]):
highlight[lnum[0]] = 1
try:
return linecache.getline(file, lnum[0])
finally:
lnum[0] += 1
vars = scanvars(reader, frame, locals)
rows = [' %s %s' % (file, call)]
if index is not None:
i = lnum - index
for line in lines:
num = '%5d ' % i
rows.append(num + line.rstrip())
i += 1
done, dump = {}, []
for name, where, value in vars:
if name in done:
continue
done[name] = 1
if value is not __UNDEF__:
if where == 'global':
name = 'global ' + name
elif where != 'local':
name = where + name.split('.')[-1]
dump.append('%s = %s' % (name, pydoc.text.repr(value)))
else:
dump.append(name + ' undefined')
rows.append('\n'.join(dump))
frames.append('\n%s\n' % '\n'.join(rows))
exception = ['%s: %s' % (str(etype), str(evalue))]
for name in dir(evalue):
value = pydoc.text.repr(getattr(evalue, name))
exception.append('\n%s%s = %s' % (' ' * 4, name, value))
return head + ''.join(frames) + ''.join(exception) + '''
The above is a description of an error in a Python program. Here is
the original traceback:
%s
''' % ''.join(traceback.format_exception(etype, evalue, etb))
class Hook:
"""A hook to replace sys.excepthook"""
def __init__(self, logdir=None, context=5, file=None):
self.logdir = logdir # log tracebacks to files if not None
self.context = context # number of source code lines per frame
self.file = file or sys.stdout # place to send the output
def __call__(self, etype, evalue, etb):
self.handle((etype, evalue, etb))
def handle(self, info=None):
info = info or sys.exc_info()
formatter = text
try:
doc = formatter(info, self.context)
except: # just in case something goes wrong
doc = ''.join(traceback.format_exception(*info))
self.file.write(doc + '\n')
if self.logdir is not None:
suffix = '.txt'
(fd, path) = tempfile.mkstemp(suffix=suffix, dir=self.logdir)
try:
with os.fdopen(fd, 'w') as file:
file.write(doc)
msg = '%s contains the description of this error.' % path
except:
msg = 'Tried to save traceback to %s, but failed.' % path
self.file.write(msg + '\n')
try:
self.file.flush()
except:
pass
handler = Hook().handle
def enable(logdir=None, context=5):
"""Install an exception handler that sends verbose tracebacks to STDOUT."""
sys.excepthook = Hook(logdir=logdir, context=context)

View File

@@ -66,7 +66,8 @@ def compatibility(mod_name, compatible):
if not platform_found:
mod = mod_name.split('.')[-1]
compat_list = ', '.join(compatible)
warning_message(f'{mod} parser not compatible with your OS ({sys.platform}).\n Compatible platforms: {compat_list}')
warning_message(f'{mod} parser not compatible with your OS ({sys.platform}).\n'
f' Compatible platforms: {compat_list}')
def has_data(data):

281
man/jc.1 Normal file
View File

@@ -0,0 +1,281 @@
.TH jc 1 2020-07-31 1.13.2 "JSON CLI output utility"
.SH NAME
jc \- JSONifies the output of many CLI tools and file-types
.SH SYNOPSIS
COMMAND | jc PARSER [OPTIONS]
or magic syntax:
jc [OPTIONS] COMMAND
.SH DESCRIPTION
jc JSONifies the output of many CLI tools and file-types for easier parsing in scripts. jc accepts piped input from STDIN and outputs a JSON representation of the previous command's output to STDOUT. Alternatively, the "magic" syntax can be used by prepending jc to the command to be converted. Options can be passed to jc immediately before the command is given. (Note: command aliases are not supported).
.SH OPTIONS
.B
Parsers:
.RS
.TP
.B
\fB--airport\fP
airport \fB-I\fP command parser
.TP
.B
\fB--airport-s\fP
airport \fB-s\fP command parser
.TP
.B
\fB--arp\fP
arp command parser
.TP
.B
\fB--blkid\fP
blkid command parser
.TP
.B
\fB--crontab\fP
crontab command and file parser
.TP
.B
\fB--crontab-u\fP
crontab file parser with user support
.TP
.B
\fB--csv\fP
CSV file parser
.TP
.B
\fB--date\fP
date command parser
.TP
.B
\fB--df\fP
df command parser
.TP
.B
\fB--dig\fP
dig command parser
.TP
.B
\fB--dmidecode\fP
dmidecode command parser
.TP
.B
\fB--du\fP
du command parser
.TP
.B
\fB--env\fP
env command parser
.TP
.B
\fB--file\fP
file command parser
.TP
.B
\fB--free\fP
free command parser
.TP
.B
\fB--fstab\fP
fstab file parser
.TP
.B
\fB--group\fP
/etc/group file parser
.TP
.B
\fB--gshadow\fP
/etc/gshadow file parser
.TP
.B
\fB--history\fP
history command parser
.TP
.B
\fB--hosts\fP
/etc/hosts file parser
.TP
.B
\fB--id\fP
id command parser
.TP
.B
\fB--ifconfig\fP
ifconfig command parser
.TP
.B
\fB--ini\fP
INI file parser
.TP
.B
\fB--iptables\fP
iptables command parser
.TP
.B
\fB--jobs\fP
jobs command parser
.TP
.B
\fB--kv\fP
Key/Value file parser
.TP
.B
\fB--last\fP
last and lastb command parser
.TP
.B
\fB--ls\fP
ls command parser
.TP
.B
\fB--lsblk\fP
lsblk command parser
.TP
.B
\fB--lsmod\fP
lsmod command parser
.TP
.B
\fB--lsof\fP
lsof command parser
.TP
.B
\fB--mount\fP
mount command parser
.TP
.B
\fB--netstat\fP
netstat command parser
.TP
.B
\fB--ntpq\fP
ntpq \fB-p\fP command parser
.TP
.B
\fB--passwd\fP
/etc/passwd file parser
.TP
.B
\fB--ping\fP
ping command parser
.TP
.B
\fB--pip-list\fP
pip list command parser
.TP
.B
\fB--pip-show\fP
pip show command parser
.TP
.B
\fB--ps\fP
ps command parser
.TP
.B
\fB--route\fP
route command parser
.TP
.B
\fB--shadow\fP
/etc/shadow file parser
.TP
.B
\fB--ss\fP
ss command parser
.TP
.B
\fB--stat\fP
stat command parser
.TP
.B
\fB--sysctl\fP
sysctl command parser
.TP
.B
\fB--systemctl\fP
systemctl command parser
.TP
.B
\fB--systemctl-lj\fP
systemctl list-jobs command parser
.TP
.B
\fB--systemctl-ls\fP
systemctl list-sockets command parser
.TP
.B
\fB--systemctl-luf\fP
systemctl list-unit-files command parser
.TP
.B
\fB--timedatectl\fP
timedatectl status command parser
.TP
.B
\fB--tracepath\fP
tracepath command parser
.TP
.B
\fB--traceroute\fP
traceroute command parser
.TP
.B
\fB--uname\fP
uname \fB-a\fP command parser
.TP
.B
\fB--uptime\fP
uptime command parser
.TP
.B
\fB--w\fP
w command parser
.TP
.B
\fB--who\fP
who command parser
.TP
.B
\fB--xml\fP
XML file parser
.TP
.B
\fB--yaml\fP
YAML file parser
.RE
.PP
Options:
.RS
.TP
.B
\fB-a\fP
about jc
.TP
.B
\fB-d\fP
debug - show traceback (\fB-dd\fP for verbose traceback)
.TP
.B
\fB-m\fP
monochrome output
.TP
.B
\fB-p\fP
pretty print output
.TP
.B
\fB-q\fP
quiet - suppress warnings
.TP
.B
\fB-r\fP
raw JSON output
.RE
.PP
Example:
ls \fB-al\fP | jc \fB--ls\fP \fB-p\fP
.RS
.PP
or using the magic syntax:
.PP
jc \fB-p\fP ls \fB-al\fP

View File

@@ -1,3 +1,3 @@
ruamel.yaml>=0.15.0
xmltodict>=0.12.0
Pygments>=2.4.2
Pygments>=2.3.0

View File

@@ -5,14 +5,14 @@ with open('README.md', 'r') as f:
setuptools.setup(
name='jc',
version='1.11.6',
version='1.13.2',
author='Kelly Brazil',
author_email='kellyjonbrazil@gmail.com',
description='Converts the output of popular command-line tools and file-types to JSON.',
install_requires=[
'ruamel.yaml>=0.15.0',
'xmltodict>=0.12.0',
'Pygments>=2.4.2'
'Pygments>=2.3.0'
],
license='MIT',
long_description=long_description,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "INPUT", "rules": [{"target": "INPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD", "rules": [{"target": "FORWARD_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POSTROUTING", "rules": [{"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD_direct", "rules": []}, {"chain": "INPUT_direct", "rules": []}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}]
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "INPUT", "rules": [{"target": "INPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD", "rules": [{"target": "FORWARD_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POSTROUTING", "rules": [{"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "FORWARD_direct", "rules": []}, {"chain": "INPUT_direct", "rules": []}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}, {"chain": "PRE_public_log", "rules": []}]

View File

@@ -1 +1 @@
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "INPUT", "rules": []}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "!loopback/8", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "POSTROUTING", "rules": [{"target": "MASQUERADE", "prot": "all", "opt": null, "source": "172.17.0.0/16", "destination": "anywhere"}, {"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "DOCKER", "rules": [{"target": "RETURN", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_ZONES", "rules": [{"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "POSTROUTING_ZONES_SOURCE", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "POST_public", "rules": [{"target": "POST_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POST_public_allow", "rules": []}, {"chain": "POST_public_deny", "rules": []}, {"chain": "POST_public_log", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}]
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "INPUT", "rules": []}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "DOCKER", "prot": "all", "opt": null, "source": "anywhere", "destination": "!loopback/8", "options": "ADDRTYPE match dst-type LOCAL"}]}, {"chain": "POSTROUTING", "rules": [{"target": "MASQUERADE", "prot": "all", "opt": null, "source": "172.17.0.0/16", "destination": "anywhere"}, {"target": "POSTROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POSTROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "DOCKER", "rules": [{"target": "RETURN", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "POSTROUTING_ZONES", "rules": [{"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "POST_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "POSTROUTING_ZONES_SOURCE", "rules": []}, {"chain": "POSTROUTING_direct", "rules": []}, {"chain": "POST_public", "rules": [{"target": "POST_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "POST_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "POST_public_allow", "rules": []}, {"chain": "POST_public_deny", "rules": []}, {"chain": "POST_public_log", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}, {"chain": "PRE_public_log", "rules": []}]

View File

@@ -1 +1 @@
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}]
[{"chain": "PREROUTING", "rules": [{"target": "PREROUTING_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES_SOURCE", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PREROUTING_ZONES", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT", "rules": [{"target": "OUTPUT_direct", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "OUTPUT_direct", "rules": []}, {"chain": "PREROUTING_ZONES", "rules": [{"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}, {"target": "PRE_public", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "[goto] "}]}, {"chain": "PREROUTING_ZONES_SOURCE", "rules": []}, {"chain": "PREROUTING_direct", "rules": []}, {"chain": "PRE_public", "rules": [{"target": "PRE_public_log", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_deny", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"target": "PRE_public_allow", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}]}, {"chain": "PRE_public_allow", "rules": []}, {"chain": "PRE_public_deny", "rules": []}, {"chain": "PRE_public_log", "rules": []}]

View File

@@ -0,0 +1 @@
{"destination_ip": "151.101.189.67", "data_bytes": 1400, "pattern": "0xabcd", "destination": "turner-tls.map.fastly.net", "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, "responses": [{"type": "reply", "timestamp": 1594978465.914536, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 1, "ttl": 59, "time_ms": 31.4, "duplicate": false}, {"type": "reply", "timestamp": 1594978465.993009, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 2, "ttl": 59, "time_ms": 30.3, "duplicate": false}, {"type": "reply", "timestamp": 1594978467.010196, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 3, "ttl": 59, "time_ms": 32.0, "duplicate": false}, {"type": "reply", "timestamp": 1594978468.033743, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 4, "ttl": 59, "time_ms": 38.8, "duplicate": false}, {"type": "reply", "timestamp": 1594978469.051227, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 5, "ttl": 59, "time_ms": 38.0, "duplicate": false}, {"type": "reply", "timestamp": 1594978470.048764, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 6, "ttl": 59, "time_ms": 29.9, "duplicate": false}, {"type": "reply", "timestamp": 1594978471.051945, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 7, "ttl": 59, "time_ms": 28.9, "duplicate": false}, {"type": "reply", "timestamp": 1594978472.064206, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 8, "ttl": 59, "time_ms": 37.4, "duplicate": false}, {"type": "reply", "timestamp": 1594978473.062587, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 9, "ttl": 59, "time_ms": 31.5, "duplicate": false}, {"type": "reply", "timestamp": 1594978474.074343, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 10, "ttl": 59, "time_ms": 38.3, "duplicate": false}, {"type": "reply", "timestamp": 1594978475.079703, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 11, "ttl": 59, "time_ms": 38.8, "duplicate": false}, {"type": "reply", "timestamp": 1594978476.076383, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 12, "ttl": 59, "time_ms": 30.7, "duplicate": false}, {"type": "reply", "timestamp": 1594978477.084119, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 13, "ttl": 59, "time_ms": 30.7, "duplicate": false}, {"type": "reply", "timestamp": 1594978478.092207, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 14, "ttl": 59, "time_ms": 31.6, "duplicate": false}, {"type": "reply", "timestamp": 1594978479.104358, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 15, "ttl": 59, "time_ms": 37.7, "duplicate": false}, {"type": "reply", "timestamp": 1594978480.106907, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 16, "ttl": 59, "time_ms": 37.5, "duplicate": false}, {"type": "reply", "timestamp": 1594978481.11558, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 17, "ttl": 59, "time_ms": 37.3, "duplicate": false}, {"type": "reply", "timestamp": 1594978482.119872, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 18, "ttl": 59, "time_ms": 33.8, "duplicate": false}, {"type": "reply", "timestamp": 1594978483.131901, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 19, "ttl": 59, "time_ms": 37.0, "duplicate": false}, {"type": "reply", "timestamp": 1594978484.141117, "bytes": 1408, "response_ip": "151.101.189.67", "icmp_seq": 20, "ttl": 59, "time_ms": 36.9, "duplicate": false}]}

View File

@@ -0,0 +1,26 @@
PATTERN: 0xabcd
PING turner-tls.map.fastly.net (151.101.189.67) 1400(1428) bytes of data.
[1594978465.914536] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=1 ttl=59 time=31.4 ms
[1594978465.993009] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=2 ttl=59 time=30.3 ms
[1594978467.010196] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=3 ttl=59 time=32.0 ms
[1594978468.033743] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=4 ttl=59 time=38.8 ms
[1594978469.051227] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=5 ttl=59 time=38.0 ms
[1594978470.048764] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=6 ttl=59 time=29.9 ms
[1594978471.051945] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=7 ttl=59 time=28.9 ms
[1594978472.064206] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=8 ttl=59 time=37.4 ms
[1594978473.062587] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=9 ttl=59 time=31.5 ms
[1594978474.074343] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=10 ttl=59 time=38.3 ms
[1594978475.079703] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=11 ttl=59 time=38.8 ms
[1594978476.076383] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=12 ttl=59 time=30.7 ms
[1594978477.084119] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=13 ttl=59 time=30.7 ms
[1594978478.092207] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=14 ttl=59 time=31.6 ms
[1594978479.104358] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=15 ttl=59 time=37.7 ms
[1594978480.106907] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=16 ttl=59 time=37.5 ms
[1594978481.115580] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=17 ttl=59 time=37.3 ms
[1594978482.119872] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=18 ttl=59 time=33.8 ms
[1594978483.131901] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=19 ttl=59 time=37.0 ms
[1594978484.141117] 1408 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=20 ttl=59 time=36.9 ms
--- turner-tls.map.fastly.net ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 19146ms
rtt min/avg/max/mdev = 28.960/34.468/38.892/3.497 ms

View File

@@ -0,0 +1 @@
{"destination_ip": "151.101.129.67", "data_bytes": 56, "pattern": "0xabcd", "destination": "turner-tls.map.fastly.net", "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, "responses": [{"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 1, "ttl": 59, "time_ms": 24.4, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 2, "ttl": 59, "time_ms": 23.3, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 3, "ttl": 59, "time_ms": 32.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 4, "ttl": 59, "time_ms": 32.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 5, "ttl": 59, "time_ms": 26.9, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 6, "ttl": 59, "time_ms": 24.1, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 7, "ttl": 59, "time_ms": 24.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 8, "ttl": 59, "time_ms": 33.9, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 9, "ttl": 59, "time_ms": 32.7, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 10, "ttl": 59, "time_ms": 31.2, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 11, "ttl": 59, "time_ms": 25.7, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 12, "ttl": 59, "time_ms": 33.8, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 13, "ttl": 59, "time_ms": 23.7, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 14, "ttl": 59, "time_ms": 23.9, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 15, "ttl": 59, "time_ms": 33.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 16, "ttl": 59, "time_ms": 24.5, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 17, "ttl": 59, "time_ms": 30.1, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 18, "ttl": 59, "time_ms": 24.1, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 19, "ttl": 59, "time_ms": 32.2, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.129.67", "icmp_seq": 20, "ttl": 59, "time_ms": 31.0, "duplicate": false}]}

View File

@@ -0,0 +1,26 @@
PATTERN: 0xabcd
PING turner-tls.map.fastly.net (151.101.129.67) 56(84) bytes of data.
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=1 ttl=59 time=24.4 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=2 ttl=59 time=23.3 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=3 ttl=59 time=32.6 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=4 ttl=59 time=32.6 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=5 ttl=59 time=26.9 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=6 ttl=59 time=24.1 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=7 ttl=59 time=24.6 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=8 ttl=59 time=33.9 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=9 ttl=59 time=32.7 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=10 ttl=59 time=31.2 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=11 ttl=59 time=25.7 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=12 ttl=59 time=33.8 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=13 ttl=59 time=23.7 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=14 ttl=59 time=23.9 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=15 ttl=59 time=33.6 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=16 ttl=59 time=24.5 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=17 ttl=59 time=30.1 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=18 ttl=59 time=24.1 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=19 ttl=59 time=32.2 ms
64 bytes from 151.101.129.67 (151.101.129.67): icmp_seq=20 ttl=59 time=31.0 ms
--- turner-tls.map.fastly.net ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 19233ms
rtt min/avg/max/mdev = 23.359/28.495/33.979/4.081 ms

View File

@@ -0,0 +1 @@
{"destination_ip": "151.101.189.67", "data_bytes": 56, "pattern": null, "destination": "turner-tls.map.fastly.net", "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, "responses": [{"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 1, "ttl": 59, "time_ms": 29.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 2, "ttl": 59, "time_ms": 30.1, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 3, "ttl": 59, "time_ms": 35.5, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 4, "ttl": 59, "time_ms": 35.5, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 5, "ttl": 59, "time_ms": 34.9, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 6, "ttl": 59, "time_ms": 29.9, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 7, "ttl": 59, "time_ms": 27.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 8, "ttl": 59, "time_ms": 28.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 9, "ttl": 59, "time_ms": 35.2, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 10, "ttl": 59, "time_ms": 34.4, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 11, "ttl": 59, "time_ms": 35.9, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 12, "ttl": 59, "time_ms": 35.8, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 13, "ttl": 59, "time_ms": 34.4, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 14, "ttl": 59, "time_ms": 35.5, "duplicate": false}, {"type": "timeout", "timestamp": null, "icmp_seq": 15}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 16, "ttl": 59, "time_ms": 36.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 17, "ttl": 59, "time_ms": 34.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 18, "ttl": 59, "time_ms": 34.6, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 19, "ttl": 59, "time_ms": 36.7, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "151.101.189.67", "icmp_seq": 20, "ttl": 59, "time_ms": 34.3, "duplicate": false}]}

View File

@@ -0,0 +1,25 @@
PING turner-tls.map.fastly.net (151.101.189.67) 56(84) bytes of data.
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=1 ttl=59 time=29.6 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=2 ttl=59 time=30.1 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=3 ttl=59 time=35.5 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=4 ttl=59 time=35.5 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=5 ttl=59 time=34.9 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=6 ttl=59 time=29.9 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=7 ttl=59 time=27.6 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=8 ttl=59 time=28.6 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=9 ttl=59 time=35.2 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=10 ttl=59 time=34.4 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=11 ttl=59 time=35.9 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=12 ttl=59 time=35.8 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=13 ttl=59 time=34.4 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=14 ttl=59 time=35.5 ms
no answer yet for icmp_seq=15
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=16 ttl=59 time=36.6 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=17 ttl=59 time=34.6 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=18 ttl=59 time=34.6 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=19 ttl=59 time=36.7 ms
64 bytes from 151.101.189.67 (151.101.189.67): icmp_seq=20 ttl=59 time=34.3 ms
--- turner-tls.map.fastly.net ping statistics ---
20 packets transmitted, 19 received, 5% packet loss, time 19125ms
rtt min/avg/max/mdev = 27.656/33.717/36.758/2.814 ms

View File

@@ -0,0 +1 @@
{"destination_ip": "127.0.0.1", "data_bytes": 56, "pattern": null, "destination": "127.0.0.1", "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, "responses": [{"type": "reply", "timestamp": 1595037214.261953, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 1, "ttl": 64, "time_ms": 0.041, "duplicate": false}, {"type": "reply", "timestamp": 1595037215.264798, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 2, "ttl": 64, "time_ms": 0.048, "duplicate": false}, {"type": "reply", "timestamp": 1595037216.272296, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 3, "ttl": 64, "time_ms": 0.047, "duplicate": false}, {"type": "reply", "timestamp": 1595037217.275851, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 4, "ttl": 64, "time_ms": 0.062, "duplicate": false}, {"type": "reply", "timestamp": 1595037218.284242, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 5, "ttl": 64, "time_ms": 0.045, "duplicate": false}, {"type": "reply", "timestamp": 1595037219.283712, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 6, "ttl": 64, "time_ms": 0.043, "duplicate": false}, {"type": "reply", "timestamp": 1595037220.290949, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 7, "ttl": 64, "time_ms": 0.046, "duplicate": false}, {"type": "reply", "timestamp": 1595037221.295962, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 8, "ttl": 64, "time_ms": 0.044, "duplicate": false}, {"type": "reply", "timestamp": 1595037222.30702, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 9, "ttl": 64, "time_ms": 0.048, "duplicate": false}, {"type": "reply", "timestamp": 1595037223.313919, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 10, "ttl": 64, "time_ms": 0.081, "duplicate": false}, {"type": "reply", "timestamp": 1595037224.313679, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 11, "ttl": 64, "time_ms": 0.043, "duplicate": false}, {"type": "reply", "timestamp": 1595037225.320748, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 12, "ttl": 64, "time_ms": 0.044, "duplicate": false}, {"type": "reply", "timestamp": 1595037226.324322, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 13, "ttl": 64, "time_ms": 0.045, "duplicate": false}, {"type": "reply", "timestamp": 1595037227.325835, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 14, "ttl": 64, "time_ms": 0.046, "duplicate": false}, {"type": "reply", "timestamp": 1595037228.327028, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 15, "ttl": 64, "time_ms": 0.046, "duplicate": false}, {"type": "reply", "timestamp": 1595037229.329891, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 16, "ttl": 64, "time_ms": 0.052, "duplicate": false}, {"type": "reply", "timestamp": 1595037230.333891, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 17, "ttl": 64, "time_ms": 0.044, "duplicate": false}, {"type": "reply", "timestamp": 1595037231.338137, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 18, "ttl": 64, "time_ms": 0.046, "duplicate": false}, {"type": "reply", "timestamp": 1595037232.340475, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 19, "ttl": 64, "time_ms": 0.048, "duplicate": false}, {"type": "reply", "timestamp": 1595037233.343058, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 20, "ttl": 64, "time_ms": 0.045, "duplicate": false}]}

View File

@@ -0,0 +1,25 @@
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
[1595037214.261953] 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.041 ms
[1595037215.264798] 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.048 ms
[1595037216.272296] 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.047 ms
[1595037217.275851] 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.062 ms
[1595037218.284242] 64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.045 ms
[1595037219.283712] 64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.043 ms
[1595037220.290949] 64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.046 ms
[1595037221.295962] 64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.044 ms
[1595037222.307020] 64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.048 ms
[1595037223.313919] 64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.081 ms
[1595037224.313679] 64 bytes from 127.0.0.1: icmp_seq=11 ttl=64 time=0.043 ms
[1595037225.320748] 64 bytes from 127.0.0.1: icmp_seq=12 ttl=64 time=0.044 ms
[1595037226.324322] 64 bytes from 127.0.0.1: icmp_seq=13 ttl=64 time=0.045 ms
[1595037227.325835] 64 bytes from 127.0.0.1: icmp_seq=14 ttl=64 time=0.046 ms
[1595037228.327028] 64 bytes from 127.0.0.1: icmp_seq=15 ttl=64 time=0.046 ms
[1595037229.329891] 64 bytes from 127.0.0.1: icmp_seq=16 ttl=64 time=0.052 ms
[1595037230.333891] 64 bytes from 127.0.0.1: icmp_seq=17 ttl=64 time=0.044 ms
[1595037231.338137] 64 bytes from 127.0.0.1: icmp_seq=18 ttl=64 time=0.046 ms
[1595037232.340475] 64 bytes from 127.0.0.1: icmp_seq=19 ttl=64 time=0.048 ms
[1595037233.343058] 64 bytes from 127.0.0.1: icmp_seq=20 ttl=64 time=0.045 ms
--- 127.0.0.1 ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 19081ms
rtt min/avg/max/mdev = 0.041/0.048/0.081/0.009 ms

View File

@@ -0,0 +1 @@
{"destination_ip": "127.0.0.1", "data_bytes": 56, "pattern": null, "destination": "127.0.0.1", "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, "responses": [{"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 1, "ttl": 64, "time_ms": 0.038, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 2, "ttl": 64, "time_ms": 0.043, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 3, "ttl": 64, "time_ms": 0.044, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 4, "ttl": 64, "time_ms": 0.052, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 5, "ttl": 64, "time_ms": 0.08, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 6, "ttl": 64, "time_ms": 0.043, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 7, "ttl": 64, "time_ms": 0.047, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 8, "ttl": 64, "time_ms": 0.04, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 9, "ttl": 64, "time_ms": 0.052, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 10, "ttl": 64, "time_ms": 0.044, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 11, "ttl": 64, "time_ms": 0.043, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 12, "ttl": 64, "time_ms": 0.043, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 13, "ttl": 64, "time_ms": 0.05, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 14, "ttl": 64, "time_ms": 0.045, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 15, "ttl": 64, "time_ms": 0.062, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 16, "ttl": 64, "time_ms": 0.046, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 17, "ttl": 64, "time_ms": 0.046, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 18, "ttl": 64, "time_ms": 0.045, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 19, "ttl": 64, "time_ms": 0.044, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "127.0.0.1", "icmp_seq": 20, "ttl": 64, "time_ms": 0.044, "duplicate": false}]}

25
tests/fixtures/centos-7.7/ping-ip-O.out vendored Normal file
View File

@@ -0,0 +1,25 @@
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.038 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.043 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.044 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.052 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.080 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.043 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.047 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.052 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.044 ms
64 bytes from 127.0.0.1: icmp_seq=11 ttl=64 time=0.043 ms
64 bytes from 127.0.0.1: icmp_seq=12 ttl=64 time=0.043 ms
64 bytes from 127.0.0.1: icmp_seq=13 ttl=64 time=0.050 ms
64 bytes from 127.0.0.1: icmp_seq=14 ttl=64 time=0.045 ms
64 bytes from 127.0.0.1: icmp_seq=15 ttl=64 time=0.062 ms
64 bytes from 127.0.0.1: icmp_seq=16 ttl=64 time=0.046 ms
64 bytes from 127.0.0.1: icmp_seq=17 ttl=64 time=0.046 ms
64 bytes from 127.0.0.1: icmp_seq=18 ttl=64 time=0.045 ms
64 bytes from 127.0.0.1: icmp_seq=19 ttl=64 time=0.044 ms
64 bytes from 127.0.0.1: icmp_seq=20 ttl=64 time=0.044 ms
--- 127.0.0.1 ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 19070ms
rtt min/avg/max/mdev = 0.038/0.047/0.080/0.011 ms

View File

@@ -0,0 +1 @@
{"destination_ip": "192.168.1.255", "data_bytes": 56, "pattern": null, "destination": "192.168.1.255", "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, "responses": [{"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.221", "icmp_seq": 1, "ttl": 64, "time_ms": 0.586, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.88", "icmp_seq": 1, "ttl": 64, "time_ms": 382.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.78", "icmp_seq": 1, "ttl": 128, "time_ms": 382.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.217", "icmp_seq": 1, "ttl": 255, "time_ms": 387.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.186", "icmp_seq": 1, "ttl": 64, "time_ms": 389.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.89", "icmp_seq": 1, "ttl": 64, "time_ms": 389.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.75", "icmp_seq": 1, "ttl": 64, "time_ms": 584.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.221", "icmp_seq": 2, "ttl": 64, "time_ms": 0.861, "duplicate": false}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.78", "icmp_seq": 2, "ttl": 128, "time_ms": 4.17, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.88", "icmp_seq": 2, "ttl": 64, "time_ms": 4.19, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.89", "icmp_seq": 2, "ttl": 64, "time_ms": 12.7, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.81", "icmp_seq": 1, "ttl": 64, "time_ms": 1029.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.72", "icmp_seq": 1, "ttl": 64, "time_ms": 1276.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.251", "icmp_seq": 1, "ttl": 64, "time_ms": 1276.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.251", "icmp_seq": 2, "ttl": 64, "time_ms": 262.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.72", "icmp_seq": 2, "ttl": 64, "time_ms": 263.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.246", "icmp_seq": 2, "ttl": 255, "time_ms": 263.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.217", "icmp_seq": 2, "ttl": 255, "time_ms": 919.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.186", "icmp_seq": 2, "ttl": 64, "time_ms": 919.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.75", "icmp_seq": 2, "ttl": 64, "time_ms": 919.0, "duplicate": true}, {"type": "reply", "timestamp": null, "bytes": 64, "response_ip": "192.168.1.81", "icmp_seq": 2, "ttl": 64, "time_ms": 919.0, "duplicate": true}]}

View File

@@ -0,0 +1,27 @@
WARNING: pinging broadcast address
PING 192.168.1.255 (192.168.1.255) 56(84) bytes of data.
64 bytes from 192.168.1.221: icmp_seq=1 ttl=64 time=0.586 ms
64 bytes from 192.168.1.88: icmp_seq=1 ttl=64 time=382 ms (DUP!)
64 bytes from 192.168.1.78: icmp_seq=1 ttl=128 time=382 ms (DUP!)
64 bytes from 192.168.1.217: icmp_seq=1 ttl=255 time=387 ms (DUP!)
64 bytes from 192.168.1.186: icmp_seq=1 ttl=64 time=389 ms (DUP!)
64 bytes from 192.168.1.89: icmp_seq=1 ttl=64 time=389 ms (DUP!)
64 bytes from 192.168.1.75: icmp_seq=1 ttl=64 time=584 ms (DUP!)
64 bytes from 192.168.1.221: icmp_seq=2 ttl=64 time=0.861 ms
64 bytes from 192.168.1.78: icmp_seq=2 ttl=128 time=4.17 ms (DUP!)
64 bytes from 192.168.1.88: icmp_seq=2 ttl=64 time=4.19 ms (DUP!)
64 bytes from 192.168.1.89: icmp_seq=2 ttl=64 time=12.7 ms (DUP!)
64 bytes from 192.168.1.81: icmp_seq=1 ttl=64 time=1029 ms (DUP!)
64 bytes from 192.168.1.72: icmp_seq=1 ttl=64 time=1276 ms (DUP!)
64 bytes from 192.168.1.251: icmp_seq=1 ttl=64 time=1276 ms (DUP!)
64 bytes from 192.168.1.251: icmp_seq=2 ttl=64 time=262 ms (DUP!)
64 bytes from 192.168.1.72: icmp_seq=2 ttl=64 time=263 ms (DUP!)
64 bytes from 192.168.1.246: icmp_seq=2 ttl=255 time=263 ms (DUP!)
64 bytes from 192.168.1.217: icmp_seq=2 ttl=255 time=919 ms (DUP!)
64 bytes from 192.168.1.186: icmp_seq=2 ttl=64 time=919 ms (DUP!)
64 bytes from 192.168.1.75: icmp_seq=2 ttl=64 time=919 ms (DUP!)
64 bytes from 192.168.1.81: icmp_seq=2 ttl=64 time=919 ms (DUP!)
--- 192.168.1.255 ping statistics ---
2 packets transmitted, 2 received, +19 duplicates, 0% packet loss, time 1013ms
rtt min/avg/max/mdev = 0.586/504.260/1276.448/417.208 ms, pipe 2

View File

@@ -0,0 +1 @@
{"destination_ip": "2a04:4e42:2d::323", "data_bytes": 1400, "pattern": "0xabcd", "destination": "www.cnn.com", "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, "responses": [{"type": "reply", "timestamp": 1594978345.609669, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 1, "ttl": 59, "time_ms": 32.4, "duplicate": false}, {"type": "reply", "timestamp": 1594978346.58542, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 2, "ttl": 59, "time_ms": 39.9, "duplicate": false}, {"type": "reply", "timestamp": 1594978347.594128, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 3, "ttl": 59, "time_ms": 42.3, "duplicate": false}, {"type": "reply", "timestamp": 1594978348.595221, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 4, "ttl": 59, "time_ms": 40.2, "duplicate": false}, {"type": "reply", "timestamp": 1594978349.600372, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 5, "ttl": 59, "time_ms": 43.2, "duplicate": false}, {"type": "reply", "timestamp": 1594978350.590676, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 6, "ttl": 59, "time_ms": 31.8, "duplicate": false}, {"type": "reply", "timestamp": 1594978351.601527, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 7, "ttl": 59, "time_ms": 41.8, "duplicate": false}, {"type": "reply", "timestamp": 1594978352.604195, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 8, "ttl": 59, "time_ms": 41.7, "duplicate": false}, {"type": "reply", "timestamp": 1594978353.607212, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 9, "ttl": 59, "time_ms": 42.0, "duplicate": false}, {"type": "reply", "timestamp": 1594978354.610771, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 10, "ttl": 59, "time_ms": 40.7, "duplicate": false}, {"type": "reply", "timestamp": 1594978355.613729, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 11, "ttl": 59, "time_ms": 40.4, "duplicate": false}, {"type": "reply", "timestamp": 1594978356.611887, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 12, "ttl": 59, "time_ms": 32.6, "duplicate": false}, {"type": "reply", "timestamp": 1594978357.62481, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 13, "ttl": 59, "time_ms": 40.1, "duplicate": false}, {"type": "reply", "timestamp": 1594978358.629185, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 14, "ttl": 59, "time_ms": 42.0, "duplicate": false}, {"type": "reply", "timestamp": 1594978359.634854, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 15, "ttl": 59, "time_ms": 41.2, "duplicate": false}, {"type": "reply", "timestamp": 1594978360.638344, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 16, "ttl": 59, "time_ms": 40.6, "duplicate": false}, {"type": "reply", "timestamp": 1594978361.640968, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 17, "ttl": 59, "time_ms": 40.7, "duplicate": false}, {"type": "reply", "timestamp": 1594978362.645739, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 18, "ttl": 59, "time_ms": 39.9, "duplicate": false}, {"type": "reply", "timestamp": 1594978363.6467, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 19, "ttl": 59, "time_ms": 37.5, "duplicate": false}, {"type": "reply", "timestamp": 1594978364.650853, "bytes": 1408, "response_ip": "2a04:4e42:2d::323", "icmp_seq": 20, "ttl": 59, "time_ms": 33.6, "duplicate": false}]}

View File

@@ -0,0 +1,26 @@
PATTERN: 0xabcd
PING www.cnn.com(2a04:4e42:2d::323 (2a04:4e42:2d::323)) 1400 data bytes
[1594978345.609669] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=1 ttl=59 time=32.4 ms
[1594978346.585420] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=2 ttl=59 time=39.9 ms
[1594978347.594128] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=3 ttl=59 time=42.3 ms
[1594978348.595221] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=4 ttl=59 time=40.2 ms
[1594978349.600372] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=5 ttl=59 time=43.2 ms
[1594978350.590676] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=6 ttl=59 time=31.8 ms
[1594978351.601527] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=7 ttl=59 time=41.8 ms
[1594978352.604195] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=8 ttl=59 time=41.7 ms
[1594978353.607212] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=9 ttl=59 time=42.0 ms
[1594978354.610771] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=10 ttl=59 time=40.7 ms
[1594978355.613729] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=11 ttl=59 time=40.4 ms
[1594978356.611887] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=12 ttl=59 time=32.6 ms
[1594978357.624810] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=13 ttl=59 time=40.1 ms
[1594978358.629185] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=14 ttl=59 time=42.0 ms
[1594978359.634854] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=15 ttl=59 time=41.2 ms
[1594978360.638344] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=16 ttl=59 time=40.6 ms
[1594978361.640968] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=17 ttl=59 time=40.7 ms
[1594978362.645739] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=18 ttl=59 time=39.9 ms
[1594978363.646700] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=19 ttl=59 time=37.5 ms
[1594978364.650853] 1408 bytes from 2a04:4e42:2d::323 (2a04:4e42:2d::323): icmp_seq=20 ttl=59 time=33.6 ms
--- www.cnn.com ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 19077ms
rtt min/avg/max/mdev = 31.845/39.274/43.243/3.522 ms

Some files were not shown because too many files have changed in this diff Show More