mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
formatting
This commit is contained in:
@ -1,7 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
|
||||||
# jc.parsers.crontab
|
# jc.parsers.crontab
|
||||||
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
|
jc - JSON CLI output utility `crontab -l` command output and crontab
|
||||||
|
file parser
|
||||||
|
|
||||||
Supports `crontab -l` command output and crontab files.
|
Supports `crontab -l` command output and crontab files.
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
|
||||||
# jc.parsers.crontab_u
|
# jc.parsers.crontab_u
|
||||||
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
|
jc - JSON CLI output utility `crontab -l` command output and crontab
|
||||||
|
file parser
|
||||||
|
|
||||||
This version of the `crontab -l` parser supports output that contains user information for processes.
|
This version of the `crontab -l` parser supports output that contains user
|
||||||
|
information for processes.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -60,7 +62,7 @@ Examples:
|
|||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "PATH",
|
"name": "PATH",
|
||||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SHELL",
|
"name": "SHELL",
|
||||||
@ -85,7 +87,7 @@ Examples:
|
|||||||
"*"
|
"*"
|
||||||
],
|
],
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"minute": [
|
"minute": [
|
||||||
@ -104,7 +106,7 @@ Examples:
|
|||||||
"7"
|
"7"
|
||||||
],
|
],
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"minute": [
|
"minute": [
|
||||||
@ -123,7 +125,7 @@ Examples:
|
|||||||
"*"
|
"*"
|
||||||
],
|
],
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -133,7 +135,7 @@ Examples:
|
|||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "PATH",
|
"name": "PATH",
|
||||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SHELL",
|
"name": "SHELL",
|
||||||
@ -148,7 +150,7 @@ Examples:
|
|||||||
"month": "*",
|
"month": "*",
|
||||||
"day_of_week": "*",
|
"day_of_week": "*",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"minute": "47",
|
"minute": "47",
|
||||||
@ -157,7 +159,7 @@ Examples:
|
|||||||
"month": "*",
|
"month": "*",
|
||||||
"day_of_week": "7",
|
"day_of_week": "7",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"minute": "52",
|
"minute": "52",
|
||||||
@ -166,7 +168,7 @@ Examples:
|
|||||||
"month": "*",
|
"month": "*",
|
||||||
"day_of_week": "*",
|
"day_of_week": "*",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
# jc.parsers.csv
|
# jc.parsers.csv
|
||||||
jc - JSON CLI output utility `csv` file parser
|
jc - JSON CLI output utility `csv` file parser
|
||||||
|
|
||||||
The `csv` parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
|
The `csv` parser will attempt to automatically detect the delimiter
|
||||||
|
character. If the delimiter cannot be detected it will default to comma. The
|
||||||
|
first row of the file must be a header row.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -21,7 +23,8 @@ Usage (module):
|
|||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
csv file converted to a Dictionary: https://docs.python.org/3/library/csv.html
|
csv file converted to a Dictionary:
|
||||||
|
https://docs.python.org/3/library/csv.html
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -33,7 +36,7 @@ Schema:
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ cat homes.csv
|
$ cat homes.csv
|
||||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres", "Taxes"
|
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
||||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||||
|
@ -5,9 +5,12 @@ jc - JSON CLI output utility `csv` file streaming parser
|
|||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
|
|
||||||
The `csv` streaming parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
|
The `csv` streaming parser will attempt to automatically detect the
|
||||||
|
delimiter character. If the delimiter cannot be detected it will default
|
||||||
|
to comma. The first row of the file must be a header row.
|
||||||
|
|
||||||
Note: The first 100 rows are read into memory to enable delimiter detection, then the rest of the rows are loaded lazily.
|
Note: The first 100 rows are read into memory to enable delimiter detection,
|
||||||
|
then the rest of the rows are loaded lazily.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -16,27 +19,33 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('csv_s', csv_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parse('csv_s', csv_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.csv_s
|
import jc.parsers.csv_s
|
||||||
result = jc.parsers.csv_s.parse(csv_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parsers.csv_s.parse(csv_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
csv file converted to a Dictionary: https://docs.python.org/3/library/csv.html
|
csv file converted to a Dictionary:
|
||||||
|
https://docs.python.org/3/library/csv.html
|
||||||
|
|
||||||
{
|
{
|
||||||
"column_name1": string,
|
"column_name1": string,
|
||||||
"column_name2": string,
|
"column_name2": string,
|
||||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
|
||||||
|
# below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # true if successfully parsed, false if error
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
@ -45,16 +54,16 @@ Schema:
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ cat homes.csv
|
$ cat homes.csv
|
||||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres", "Taxes"
|
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
||||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||||
...
|
...
|
||||||
|
|
||||||
$ cat homes.csv | jc --csv-s
|
$ cat homes.csv | jc --csv-s
|
||||||
{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5","Baths":"3","Age":"60","Acres":"0.28","Taxes":"3167"}
|
{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5"...}
|
||||||
{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4","Baths":"1","Age":"12","Acres":"0.43","Taxes":"4033"}
|
{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4"...}
|
||||||
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3","Baths":"1","Age":"41","Acres":"0.33","Taxes":"1471"}
|
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...}
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
@ -73,7 +82,9 @@ Main text parsing generator function. Returns an iterator object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
data: (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages if True
|
quiet: (boolean) suppress warning messages if True
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
# jc.parsers.date
|
# jc.parsers.date
|
||||||
jc - JSON CLI output utility `date` command output parser
|
jc - JSON CLI output utility `date` command output parser
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive. (i.e. based on the local time of the system the parser is run on)
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||||
|
time of the system the parser is run on)
|
||||||
|
|
||||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||||
|
available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -40,15 +42,19 @@ Schema:
|
|||||||
"second": integer,
|
"second": integer,
|
||||||
"period": string,
|
"period": string,
|
||||||
"timezone": string,
|
"timezone": string,
|
||||||
"utc_offset": string, # null if timezone field is not UTC
|
"utc_offset": string, # null if timezone field is not UTC
|
||||||
"day_of_year": integer,
|
"day_of_year": integer,
|
||||||
"week_of_year": integer,
|
"week_of_year": integer,
|
||||||
"iso": string,
|
"iso": string,
|
||||||
"epoch": integer, # naive timestamp
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
|
"epoch_utc": integer, # [1]
|
||||||
"timezone_aware": boolean # if true, all fields are correctly based on UTC
|
"timezone_aware": boolean # [2]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] naive timestamp
|
||||||
|
[1] timezone-aware timestamp. Only available if timezone field is UTC
|
||||||
|
[2] if true, all fields are correctly based on UTC
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ date | jc --date -p
|
$ date | jc --date -p
|
||||||
|
@ -4,12 +4,15 @@
|
|||||||
jc - JSON CLI output utility `dig` command output parser
|
jc - JSON CLI output utility `dig` command output parser
|
||||||
|
|
||||||
Options supported:
|
Options supported:
|
||||||
- `+noall +answer` options are supported in cases where only the answer information is desired.
|
- `+noall +answer` options are supported in cases where only the answer
|
||||||
|
information is desired.
|
||||||
- `+axfr` option is supported on its own
|
- `+axfr` option is supported on its own
|
||||||
|
|
||||||
The `when_epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `when_epoch` calculated timestamp field is naive. (i.e. based on the
|
||||||
|
local time of the system the parser is run on)
|
||||||
|
|
||||||
The `when_epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
The `when_epoch_utc` calculated timestamp field is timezone-aware and is
|
||||||
|
only available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -98,13 +101,16 @@ Schema:
|
|||||||
"query_time": integer, # in msec
|
"query_time": integer, # in msec
|
||||||
"server": string,
|
"server": string,
|
||||||
"when": string,
|
"when": string,
|
||||||
"when_epoch": integer, # naive timestamp if when field is parsable, else null
|
"when_epoch": integer, # [0]
|
||||||
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
|
"when_epoch_utc": integer, # [1]
|
||||||
"rcvd": integer
|
"rcvd": integer
|
||||||
"size": string
|
"size": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] naive timestamp if when field is parsable, else null
|
||||||
|
[1] timezone aware timestamp availabe for UTC, else null
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ dig example.com | jc --dig -p
|
$ dig example.com | jc --dig -p
|
||||||
|
@ -9,9 +9,11 @@ Options supported:
|
|||||||
- `/C, /-C`
|
- `/C, /-C`
|
||||||
- `/S`
|
- `/S`
|
||||||
|
|
||||||
The "Magic" syntax is not supported since the `dir` command is a shell builtin.
|
The "Magic" syntax is not supported since the `dir` command is a shell
|
||||||
|
builtin.
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||||
|
time of the system the parser is run on)
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
# jc.parsers.dpkg_l
|
# jc.parsers.dpkg_l
|
||||||
jc - JSON CLI output utility `dpkg -l` command output parser
|
jc - JSON CLI output utility `dpkg -l` command output parser
|
||||||
|
|
||||||
Set the `COLUMNS` environment variable to a large value to avoid field truncation. For example:
|
Set the `COLUMNS` environment variable to a large value to avoid field
|
||||||
|
truncation. For example:
|
||||||
|
|
||||||
$ COLUMNS=500 dpkg -l | jc --dpkg-l
|
$ COLUMNS=500 dpkg -l | jc --dpkg-l
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ Examples:
|
|||||||
"name": "acpid",
|
"name": "acpid",
|
||||||
"version": "1:2.0.28-1ubuntu1",
|
"version": "1:2.0.28-1ubuntu1",
|
||||||
"architecture": "amd64",
|
"architecture": "amd64",
|
||||||
"description": "Advanced Configuration and Power Interface event daemon",
|
"description": "Advanced Configuration and Power Interface...",
|
||||||
"desired": "remove",
|
"desired": "remove",
|
||||||
"status": "half installed"
|
"status": "half installed"
|
||||||
},
|
},
|
||||||
@ -121,7 +122,7 @@ Examples:
|
|||||||
"name": "acpid",
|
"name": "acpid",
|
||||||
"version": "1:2.0.28-1ubuntu1",
|
"version": "1:2.0.28-1ubuntu1",
|
||||||
"architecture": "amd64",
|
"architecture": "amd64",
|
||||||
"description": "Advanced Configuration and Power Interface event daemon"
|
"description": "Advanced Configuration and Power Interface..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"codes": "pn",
|
"codes": "pn",
|
||||||
|
@ -40,23 +40,23 @@ Examples:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": 56,
|
"size": 56,
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": 0,
|
"size": 0,
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": 0,
|
"size": 0,
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": 0,
|
"size": 0,
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": 1008,
|
"size": 1008,
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
@ -69,23 +69,23 @@ Examples:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": "56",
|
"size": "56",
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": "0",
|
"size": "0",
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": "0",
|
"size": "0",
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": "0",
|
"size": "0",
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size": "1008",
|
"size": "1008",
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
# jc.parsers.env
|
# jc.parsers.env
|
||||||
jc - JSON CLI output utility `env` and `printenv` command output parser
|
jc - JSON CLI output utility `env` and `printenv` command output parser
|
||||||
|
|
||||||
This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
|
This parser will output a list of dictionaries each containing `name` and
|
||||||
|
`value` keys. If you would like a simple dictionary output, then use the
|
||||||
|
`-r` command-line option or the `raw=True` argument in the `parse()`
|
||||||
|
function.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ Examples:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "cd_catalog.xml",
|
"filename": "cd_catalog.xml",
|
||||||
"type": "XML 1.0 document text, ASCII text, with CRLF line terminators"
|
"type": "XML 1.0 document text, ASCII text, with CRLF line ..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "centosserial.sh",
|
"filename": "centosserial.sh",
|
||||||
"type": "Bourne-Again shell script text executable, UTF-8 Unicode text"
|
"type": "Bourne-Again shell script text executable, UTF-8 ..."
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
# jc.parsers.history
|
# jc.parsers.history
|
||||||
jc - JSON CLI output utility `history` command output parser
|
jc - JSON CLI output utility `history` command output parser
|
||||||
|
|
||||||
This parser will output a list of dictionaries each containing `line` and `command` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
|
This parser will output a list of dictionaries each containing `line` and
|
||||||
|
`command` keys. If you would like a simple dictionary output, then use the
|
||||||
|
`-r` command-line option or the `raw=True` argument in the `parse()`
|
||||||
|
function.
|
||||||
|
|
||||||
The "Magic" syntax is not supported since the `history` command is a shell builtin.
|
The "Magic" syntax is not supported since the `history` command is a shell
|
||||||
|
builtin.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
# jc.parsers.ini
|
# jc.parsers.ini
|
||||||
jc - JSON CLI output utility `INI` file parser
|
jc - JSON CLI output utility `INI` file parser
|
||||||
|
|
||||||
Parses standard `INI` files and files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
|
Parses standard `INI` files and files containing simple key/value pairs.
|
||||||
|
Delimiter can be `=` or `:`. Missing values are supported. Comment prefix
|
||||||
|
can be `#` or `;`. Comments must be on their own line.
|
||||||
|
|
||||||
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` command-line argument or the `raw=True` argument in `parse()`.
|
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`
|
||||||
|
command-line argument or the `raw=True` argument in `parse()`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -23,11 +27,8 @@ Usage (module):
|
|||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
ini or key/value document converted to a dictionary - see configparser standard
|
ini or key/value document converted to a dictionary - see the
|
||||||
library documentation for more details.
|
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.
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"key1": string,
|
"key1": string,
|
||||||
|
@ -14,14 +14,16 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('iostat_s', iostat_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parse('iostat_s', iostat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.iostat_s
|
import jc.parsers.iostat_s
|
||||||
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -78,9 +80,12 @@ Schema:
|
|||||||
"percent_util": float,
|
"percent_util": float,
|
||||||
"percent_rrqm": float,
|
"percent_rrqm": float,
|
||||||
"percent_wrqm": float,
|
"percent_wrqm": float,
|
||||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
|
||||||
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # true if successfully parsed, false if error
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
@ -89,13 +94,13 @@ Schema:
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ iostat | jc --iostat-s
|
$ iostat | jc --iostat-s
|
||||||
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,"percent_iowait":0.0,"percent_steal":0.0,"percent_idle":99.7,"type":"cpu"}
|
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,...}
|
||||||
{"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1,"kb_read":203305,"kb_wrtn":42368,"type":"device"}
|
{"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1...}
|
||||||
...
|
...
|
||||||
|
|
||||||
$ iostat | jc --iostat-s -r
|
$ iostat | jc --iostat-s -r
|
||||||
{"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16","percent_iowait":"0.00","percent_steal":"0.00","percent_idle":"99.70","type":"cpu"}
|
{"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16"...}
|
||||||
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10","kb_read":"203305","kb_wrtn":"42368","type":"device"}
|
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...}
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +119,9 @@ Main text parsing generator function. Returns an iterator object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
data: (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages if True
|
quiet: (boolean) suppress warning messages if True
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
# jc.parsers.iw_scan
|
# jc.parsers.iw_scan
|
||||||
jc - JSON CLI output utility `iw dev <device> scan` command output parser
|
jc - JSON CLI output utility `iw dev <device> scan` command output parser
|
||||||
|
|
||||||
This parser is considered beta quality. Not all fields are parsed and there are not enough samples to test.
|
This parser is considered beta quality. Not all fields are parsed and there
|
||||||
|
are not enough samples to test.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ Schema:
|
|||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"foo": string/integer/float, # best guess based on value
|
"foo": string/integer/float, # best guess based on value
|
||||||
"bar": string/integer/float,
|
"bar": string/integer/float,
|
||||||
"baz": string/integer/float
|
"baz": string/integer/float
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,16 @@ Schema:
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ cat MANIFEST.MF | jc --jar-manifest -p
|
$ cat MANIFEST.MF | jc --jar-manifest -p
|
||||||
$ unzip -c apache-log4j-2.16.0-bin/log4j-core-2.16.0.jar META-INF/MANIFEST.MF | jc --jar-manifest -p
|
$ unzip -c log4j-core-2.16.0.jar META-INF/MANIFEST.MF | \
|
||||||
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar-manifest -p
|
jc --jar-manifest -p
|
||||||
|
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \
|
||||||
|
jc --jar-manifest -p
|
||||||
|
|
||||||
$ cat MANIFEST.MF | jc --jar-manifest -p
|
$ cat MANIFEST.MF | jc --jar-manifest -p
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Import_Package": "com.conversantmedia.util.concurrent;resolution:=optional,com.fasterxml.jackson.annotation;version="[2.12,3)";resolution:=optional,com.fasterxml.jackson.core;version="[2.12,3)";resolution:=optional,com.fasterxml.jackson.core.type;version="[2.12,3)";resolution:=optional,com.fasterxml.jackson.cor...",
|
"Import_Package": "com.conversantmedia.util.concurrent;resoluti...",
|
||||||
"Export_Package": "org.apache.logging.log4j.core;uses:="org.apache.logging.log4j,org.apache.logging.log4j.core.config,org.apache.logging.log4j.core.impl,org.apache.logging.log4j.core.layout,org.apache.logging.log4j.core.time,org.apache.logging.log4j.message,org.apache.logging.log4j.spi,org.apache.logging.log4j.status...",
|
"Export_Package": "org.apache.logging.log4j.core;uses:="org.ap...",
|
||||||
"Manifest_Version": "1.0",
|
"Manifest_Version": "1.0",
|
||||||
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||||
"Bundle_SymbolicName": "org.apache.logging.log4j.core",
|
"Bundle_SymbolicName": "org.apache.logging.log4j.core",
|
||||||
@ -50,28 +51,28 @@ Examples:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar-manifest -p
|
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \
|
||||||
|
jc --jar-manifest -p
|
||||||
[
|
[
|
||||||
...
|
...
|
||||||
{
|
{
|
||||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-sources.jar",
|
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-so...",
|
||||||
"Manifest_Version": "1.0",
|
"Manifest_Version": "1.0",
|
||||||
"Built_By": "matt",
|
"Built_By": "matt",
|
||||||
"Created_By": "Apache Maven 3.8.4",
|
"Created_By": "Apache Maven 3.8.4",
|
||||||
"Build_Jdk": "1.8.0_312"
|
"Build_Jdk": "1.8.0_312"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-javadoc.jar",
|
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-ja...",
|
||||||
"Manifest_Version": "1.0",
|
"Manifest_Version": "1.0",
|
||||||
"Built_By": "matt",
|
"Built_By": "matt",
|
||||||
"Created_By": "Apache Maven 3.8.4",
|
"Created_By": "Apache Maven 3.8.4",
|
||||||
"Build_Jdk": "1.8.0_312"
|
"Build_Jdk": "1.8.0_312"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Bundle_SymbolicName": "org.apache.logging.log4j.spring-cloud-config-client.logging.log4j.core.util;version="[2.16,3)",org.springframework.boot.autoconfigure.condition,org.springframework.cloud.context.environment,org.springframework.context,org.springframework.stereotype",
|
"Bundle_SymbolicName": "org.apache.logging.log4j.spring-cloud-c...",
|
||||||
"Export_Package": "org.apache.logging.log4j.spring.cloud.config.controller;version="2.16.0"ient",
|
"Export_Package": "org.apache.logging.log4j.spring.cloud.config...",
|
||||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-client-2.16.0.jar",
|
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-c...",
|
||||||
"Manifest_Version": "1.0",
|
"Manifest_Version": "1.0",
|
||||||
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||||
...
|
...
|
||||||
|
@ -5,7 +5,8 @@ jc - JSON CLI output utility `jobs` command output parser
|
|||||||
|
|
||||||
Also supports the `-l` option.
|
Also supports the `-l` option.
|
||||||
|
|
||||||
The "Magic" syntax is not supported since the `jobs` command is a shell builtin.
|
The "Magic" syntax is not supported since the `jobs` command is a shell
|
||||||
|
builtin.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
# jc.parsers.kv
|
# jc.parsers.kv
|
||||||
jc - JSON CLI output utility `Key/Value` file parser
|
jc - JSON CLI output utility `Key/Value` file parser
|
||||||
|
|
||||||
Supports files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
|
Supports files containing simple key/value pairs. Delimiter can be `=` or
|
||||||
|
`:`. Missing values are supported. Comment prefix can be `#` or `;`.
|
||||||
|
Comments must be on their own line.
|
||||||
|
|
||||||
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` command-line argument or the `raw=True` argument in `parse()`.
|
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`
|
||||||
|
command-line argument or the `raw=True` argument in `parse()`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -23,7 +27,8 @@ Usage (module):
|
|||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
key/value document converted to a dictionary - see configparser standard library documentation for more details.
|
key/value document converted to a dictionary - see the
|
||||||
|
configparser standard library documentation for more details.
|
||||||
|
|
||||||
{
|
{
|
||||||
"key1": string,
|
"key1": string,
|
||||||
|
@ -5,7 +5,9 @@ jc - JSON CLI output utility `last` and `lastb` command output parser
|
|||||||
|
|
||||||
Supports `-w` and `-F` options.
|
Supports `-w` and `-F` options.
|
||||||
|
|
||||||
Calculated epoch time fields are naive (i.e. based on the local time of the system the parser is run on) since there is no timezone information in the `last` command output.
|
Calculated epoch time fields are naive (i.e. based on the local time of the
|
||||||
|
system the parser is run on) since there is no timezone information in the
|
||||||
|
`last` command output.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -35,9 +37,9 @@ Schema:
|
|||||||
"login": string,
|
"login": string,
|
||||||
"logout": string,
|
"logout": string,
|
||||||
"duration": string,
|
"duration": string,
|
||||||
"login_epoch": integer, # (naive) available with last -F option
|
"login_epoch": integer, # (naive) available with last -F option
|
||||||
"logout_epoch": integer, # (naive) available with last -F option
|
"logout_epoch": integer, # (naive) available with last -F option
|
||||||
"duration_seconds": integer # available with last -F option
|
"duration_seconds": integer # available with last -F option
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -7,11 +7,17 @@ Options supported:
|
|||||||
- `lbaR1`
|
- `lbaR1`
|
||||||
- `--time-style=full-iso`
|
- `--time-style=full-iso`
|
||||||
|
|
||||||
Note: The `-1`, `-l`, or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-1`, `-l`, or `-b` is not used. Alternatively, `vdir` can be used, which is the same as running `ls -lb`.
|
Note: The `-1`, `-l`, or `-b` option of `ls` should be used to correctly
|
||||||
|
parse filenames that include newline characters. Since `ls` does not encode
|
||||||
|
newlines in filenames when outputting to a pipe it will cause `jc` to see
|
||||||
|
multiple files instead of a single file if `-1`, `-l`, or `-b` is not used.
|
||||||
|
Alternatively, `vdir` can be used, which is the same as running `ls -lb`.
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||||
|
time of the system the parser is run on)
|
||||||
|
|
||||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||||
|
available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -43,11 +49,14 @@ Schema:
|
|||||||
"group": string,
|
"group": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"date": string,
|
"date": string,
|
||||||
"epoch": integer, # naive timestamp if date field exists and can be converted
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer # timezone aware timestamp if date field is in UTC and can be converted
|
"epoch_utc": integer # [1]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] naive timestamp if date field exists and can be converted
|
||||||
|
[1] timezone aware timestamp if date field is in UTC and can be converted
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ls /usr/bin | jc --ls -p
|
$ ls /usr/bin | jc --ls -p
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
|
||||||
# jc.parsers.ls_s
|
# jc.parsers.ls_s
|
||||||
jc - JSON CLI output utility `ls` and `vdir` command output streaming parser
|
jc - JSON CLI output utility `ls` and `vdir` command output streaming
|
||||||
|
parser
|
||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
|
|
||||||
Requires the `-l` option to be used on `ls`. If there are newline characters in the filename, then make sure to use the `-b` option on `ls`.
|
Requires the `-l` option to be used on `ls`. If there are newline characters
|
||||||
|
in the filename, then make sure to use the `-b` option on `ls`.
|
||||||
|
|
||||||
The `jc` `-qq` option can be used to ignore parsing errors. (e.g. filenames with newline characters, but `-b` was not used)
|
The `jc` `-qq` option can be used to ignore parsing errors. (e.g. filenames
|
||||||
|
with newline characters, but `-b` was not used)
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `epoch` calculated timestamp field is naive (i.e. based on the local time
|
||||||
|
of the system the parser is run on)
|
||||||
|
|
||||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||||
|
available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -20,14 +25,16 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ls_s', ls_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parse('ls_s', ls_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ls_s
|
import jc.parsers.ls_s
|
||||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -42,28 +49,34 @@ Schema:
|
|||||||
"group": string,
|
"group": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"date": string,
|
"date": string,
|
||||||
"epoch": integer, # naive timestamp if date field exists and can be converted
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer, # timezone aware timestamp if date field is in UTC and can be converted
|
"epoch_utc": integer, # [1]
|
||||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
|
||||||
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # true if successfully parsed, false if error
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] naive timestamp if date field exists and can be converted
|
||||||
|
[1] timezone aware timestamp if date field is in UTC and can be converted
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls-s
|
$ ls -l /usr/bin | jc --ls-s
|
||||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","group":"wheel","size":925,"date":"Feb 22 2019"}
|
{"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","...}
|
||||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7","flags":"lrwxr-xr-x","links":1,"owner":"root","group":"wheel","size":74,"date":"May 4 2019"}
|
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
||||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,"owner":"root","group":"wheel","size":55152,"date":"May 3 2019"}
|
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,...}
|
||||||
...
|
...
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls-s -r
|
$ ls -l /usr/bin | jc --ls-s -r
|
||||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"root","group":"wheel","size":"925","date":"Feb 22 2019"}
|
{"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"roo"..."}
|
||||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7","flags":"lrwxr-xr-x","links":"1","owner":"root","group":"wheel","size":"74","date":"May 4 2019"}
|
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
||||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1","owner":"root","group":"wheel","size":"55152","date":"May 3 2019"}
|
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...}
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +95,9 @@ Main text parsing generator function. Returns an iterator object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
data: (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages if True
|
quiet: (boolean) suppress warning messages if True
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||||
|
@ -93,7 +93,10 @@ Examples:
|
|||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\
|
||||||
|
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\
|
||||||
|
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\
|
||||||
|
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "sda",
|
"name": "sda",
|
||||||
@ -182,7 +185,10 @@ Examples:
|
|||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\
|
||||||
|
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\
|
||||||
|
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\
|
||||||
|
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "sda",
|
"name": "sda",
|
||||||
|
@ -25,8 +25,9 @@ Usage (module):
|
|||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
Note: <item> object keynames are assigned directly from the lsusb output.
|
Note: <item> object keynames are assigned directly from the lsusb
|
||||||
If there are duplicate <item> names in a section, only the last one is converted.
|
output. If there are duplicate <item> names in a section, only the
|
||||||
|
last one is converted.
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,8 @@ jc - JSON CLI output utility `netstat` command output parser
|
|||||||
|
|
||||||
Caveats:
|
Caveats:
|
||||||
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
|
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
|
||||||
- Use of the `A` option is not supported on OSX when using the `r` option (e.g. `netstat -rA`)
|
- Use of the `A` option is not supported on OSX when using the `r` option
|
||||||
|
(e.g. `netstat -rA`)
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ Supports `ping` and `ping6` output.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
Note: Use the ping `-c` (count) option, otherwise data will not be piped to `jc`.
|
Note: Use the ping `-c` (count) option, otherwise data will not be
|
||||||
|
piped to `jc`.
|
||||||
|
|
||||||
$ ping -c 3 1.2.3.4 | jc --ping
|
$ ping -c 3 1.2.3.4 | jc --ping
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ Schema:
|
|||||||
"source_ip": string,
|
"source_ip": string,
|
||||||
"destination_ip": string,
|
"destination_ip": string,
|
||||||
"data_bytes": integer,
|
"data_bytes": integer,
|
||||||
"pattern": string, # (null if not set)
|
"pattern": string, # null if not set
|
||||||
"destination": string,
|
"destination": string,
|
||||||
"packets_transmitted": integer,
|
"packets_transmitted": integer,
|
||||||
"packets_received": integer,
|
"packets_received": integer,
|
||||||
@ -43,8 +44,8 @@ Schema:
|
|||||||
"round_trip_ms_stddev": float,
|
"round_trip_ms_stddev": float,
|
||||||
"responses": [
|
"responses": [
|
||||||
{
|
{
|
||||||
"type": string, # 'reply', 'timeout', 'unparsable_line', etc. See `_error_type.type_map` for all options
|
"type": string, # [0]
|
||||||
"unparsed_line": string, # only if an 'unparsable_line' type
|
"unparsed_line": string, # [1]
|
||||||
"timestamp": float,
|
"timestamp": float,
|
||||||
"bytes": integer,
|
"bytes": integer,
|
||||||
"response_ip": string,
|
"response_ip": string,
|
||||||
@ -52,21 +53,26 @@ Schema:
|
|||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"time_ms": float,
|
"time_ms": float,
|
||||||
"duplicate": boolean,
|
"duplicate": boolean,
|
||||||
"vr": integer, # hex value converted to decimal
|
"vr": integer, # [2]
|
||||||
"hl": integer, # hex value converted to decimal
|
"hl": integer, # [2]
|
||||||
"tos": integer, # hex value converted to decimal
|
"tos": integer, # [2]
|
||||||
"len": integer, # hex value converted to decimal
|
"len": integer, # [2]
|
||||||
"id": integer, # hex value converted to decimal
|
"id": integer, # [2]
|
||||||
"flg": integer, # hex value converted to decimal
|
"flg": integer, # [2]
|
||||||
"off": integer, # hex value converted to decimal
|
"off": integer, # [2]
|
||||||
"pro": integer, # hex value converted to decimal
|
"pro": integer, # [2]
|
||||||
"cks": ingeger, # hex value converted to decimal
|
"cks": ingeger, # [2]
|
||||||
"src": string,
|
"src": string,
|
||||||
"dst": string
|
"dst": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] 'reply', 'timeout', 'unparsable_line', etc. See
|
||||||
|
`_error_type.type_map` for all options
|
||||||
|
[1] only if an 'unparsable_line' type
|
||||||
|
[2] hex value converted to decimal
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ping -c 3 -p ff cnn.com | jc --ping -p
|
$ ping -c 3 -p ff cnn.com | jc --ping -p
|
||||||
|
@ -11,66 +11,79 @@ Usage (cli):
|
|||||||
|
|
||||||
$ ping | jc --ping-s
|
$ ping | jc --ping-s
|
||||||
|
|
||||||
> Note: When piping `jc` converted `ping` output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `ping` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output) for more information.
|
> Note: When piping `jc` converted `ping` output to other processes it may
|
||||||
|
appear the output is hanging due to the OS pipe buffers. This is because
|
||||||
|
`ping` output is too small to quickly fill up the buffer. Use the `-u`
|
||||||
|
option to unbuffer the `jc` output if you would like immediate output.
|
||||||
|
See the[readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||||
|
for more information.
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ping_s', ping_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parse('ping_s', ping_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ping_s
|
import jc.parsers.ping_s
|
||||||
result = jc.parsers.ping_s.parse(ping_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parsers.ping_s.parse(ping_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"type": string, # 'reply', 'timeout', 'summary', etc. See `_error_type.type_map` for all options.
|
"type": string, # [0]
|
||||||
"source_ip": string,
|
"source_ip": string,
|
||||||
"destination_ip": string,
|
"destination_ip": string,
|
||||||
"sent_bytes": integer,
|
"sent_bytes": integer,
|
||||||
"pattern": string, # (null if not set)
|
"pattern": string, # (null if not set)
|
||||||
"destination": string,
|
"destination": string,
|
||||||
"timestamp": float,
|
"timestamp": float,
|
||||||
"response_bytes": integer,
|
"response_bytes": integer,
|
||||||
"response_ip": string,
|
"response_ip": string,
|
||||||
"icmp_seq": integer,
|
"icmp_seq": integer,
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"time_ms": float,
|
"time_ms": float,
|
||||||
"duplicate": boolean,
|
"duplicate": boolean,
|
||||||
"packets_transmitted": integer,
|
"packets_transmitted": integer,
|
||||||
"packets_received": integer,
|
"packets_received": integer,
|
||||||
"packet_loss_percent": float,
|
"packet_loss_percent": float,
|
||||||
"duplicates": integer,
|
"duplicates": integer,
|
||||||
"round_trip_ms_min": float,
|
"round_trip_ms_min": float,
|
||||||
"round_trip_ms_avg": float,
|
"round_trip_ms_avg": float,
|
||||||
"round_trip_ms_max": float,
|
"round_trip_ms_max": float,
|
||||||
"round_trip_ms_stddev": float,
|
"round_trip_ms_stddev": float,
|
||||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
|
||||||
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # true if successfully parsed, false if error
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] 'reply', 'timeout', 'summary', etc. See `_error_type.type_map`
|
||||||
|
for all options.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ping 1.1.1.1 | jc --ping-s
|
$ ping 1.1.1.1 | jc --ping-s
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"pattern":null,"response_bytes":64,"response_ip":"1.1.1.1","icmp_seq":0,"ttl":56,"time_ms":23.703}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"pattern":null,"response_bytes":64,"response_ip":"1.1.1.1","icmp_seq":1,"ttl":56,"time_ms":22.862}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"pattern":null,"response_bytes":64,"response_ip":"1.1.1.1","icmp_seq":2,"ttl":56,"time_ms":22.82}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||||
...
|
...
|
||||||
|
|
||||||
$ ping 1.1.1.1 | jc --ping-s -r
|
$ ping 1.1.1.1 | jc --ping-s -r
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","pattern":null,"response_bytes":"64","response_ip":"1.1.1.1","icmp_seq":"0","ttl":"56","time_ms":"23.054"}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","pattern":null,"response_bytes":"64","response_ip":"1.1.1.1","icmp_seq":"1","ttl":"56","time_ms":"24.739"}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","pattern":null,"response_bytes":"64","response_ip":"1.1.1.1","icmp_seq":"2","ttl":"56","time_ms":"23.232"}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +102,9 @@ Main text parsing generator function. Returns an iterator object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
data: (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages if True
|
quiet: (boolean) suppress warning messages if True
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||||
|
@ -61,7 +61,7 @@ Examples:
|
|||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": null,
|
"tty": null,
|
||||||
"time": "00:00:11",
|
"time": "00:00:11",
|
||||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
@ -96,7 +96,7 @@ Examples:
|
|||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"time": "00:00:11",
|
"time": "00:00:11",
|
||||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
@ -134,7 +134,7 @@ Examples:
|
|||||||
"stat": "Ss",
|
"stat": "Ss",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:08",
|
"time": "0:08",
|
||||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
@ -178,7 +178,7 @@ Examples:
|
|||||||
"stat": "Ss",
|
"stat": "Ss",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:08",
|
"time": "0:08",
|
||||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
|
@ -5,9 +5,11 @@ jc - JSON CLI output utility `rpm -qi` command output parser
|
|||||||
|
|
||||||
Works with `rpm -qi [package]` or `rpm -qia`.
|
Works with `rpm -qi [package]` or `rpm -qia`.
|
||||||
|
|
||||||
The `..._epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
|
The `..._epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||||
|
local time of the system the parser is run on)
|
||||||
|
|
||||||
The `..._epoch_utc` calculated timestamp fields are timezone-aware and is only available if the timezone field is UTC.
|
The `..._epoch_utc` calculated timestamp fields are timezone-aware and is
|
||||||
|
only available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -37,16 +39,16 @@ Schema:
|
|||||||
"release": string,
|
"release": string,
|
||||||
"architecture": string,
|
"architecture": string,
|
||||||
"install_date": string,
|
"install_date": string,
|
||||||
"install_date_epoch": integer, # naive timestamp
|
"install_date_epoch": integer, # [0]
|
||||||
"install_date_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
"install_date_epoch_utc": integer, # [1]
|
||||||
"group": string,
|
"group": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"license": string,
|
"license": string,
|
||||||
"signature": string,
|
"signature": string,
|
||||||
"source_rpm": string,
|
"source_rpm": string,
|
||||||
"build_date": string,
|
"build_date": string,
|
||||||
"build_epoch": integer, # naive timestamp
|
"build_epoch": integer, # [0]
|
||||||
"build_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
"build_epoch_utc": integer, # [1]
|
||||||
"build_host": string,
|
"build_host": string,
|
||||||
"relocations": string,
|
"relocations": string,
|
||||||
"packager": string,
|
"packager": string,
|
||||||
@ -57,6 +59,9 @@ Schema:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] naive timestamp
|
||||||
|
[1] Aware timestamp if timezone is UTC
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ rpm -qia | jc --rpm-qi -p
|
$ rpm -qia | jc --rpm-qi -p
|
||||||
@ -71,7 +76,7 @@ Examples:
|
|||||||
"group": "Development/Tools",
|
"group": "Development/Tools",
|
||||||
"size": 1160660,
|
"size": 1160660,
|
||||||
"license": "GPLv2+",
|
"license": "GPLv2+",
|
||||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
|
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
||||||
"source_rpm": "make-3.82-24.el7.src.rpm",
|
"source_rpm": "make-3.82-24.el7.src.rpm",
|
||||||
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
"build_host": "x86-01.bsys.centos.org",
|
||||||
@ -79,8 +84,8 @@ Examples:
|
|||||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
||||||
"vendor": "CentOS",
|
"vendor": "CentOS",
|
||||||
"url": "http://www.gnu.org/software/make/",
|
"url": "http://www.gnu.org/software/make/",
|
||||||
"summary": "A GNU tool which simplifies the build process for users",
|
"summary": "A GNU tool which simplifies the build process for ...",
|
||||||
"description": "A GNU tool for controlling the generation of executables and other...",
|
"description": "A GNU tool for controlling the generation of ex...",
|
||||||
"build_epoch": 1565311645,
|
"build_epoch": 1565311645,
|
||||||
"build_epoch_utc": null,
|
"build_epoch_utc": null,
|
||||||
"install_date_epoch": 1571242902,
|
"install_date_epoch": 1571242902,
|
||||||
@ -95,7 +100,7 @@ Examples:
|
|||||||
"group": "System Environment/Base",
|
"group": "System Environment/Base",
|
||||||
"size": 503608,
|
"size": 503608,
|
||||||
"license": "GPLv2+",
|
"license": "GPLv2+",
|
||||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
|
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
||||||
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
||||||
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
"build_host": "x86-01.bsys.centos.org",
|
||||||
@ -104,7 +109,7 @@ Examples:
|
|||||||
"vendor": "CentOS",
|
"vendor": "CentOS",
|
||||||
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
||||||
"summary": "Legacy data for kbd package",
|
"summary": "Legacy data for kbd package",
|
||||||
"description": "The kbd-legacy package contains original keymaps for kbd package...",
|
"description": "The kbd-legacy package contains original keymap...",
|
||||||
"build_epoch": 1540939200,
|
"build_epoch": 1540939200,
|
||||||
"build_epoch_utc": null,
|
"build_epoch_utc": null,
|
||||||
"install_date_epoch": 1565891588,
|
"install_date_epoch": 1565891588,
|
||||||
@ -125,7 +130,7 @@ Examples:
|
|||||||
"group": "Development/Tools",
|
"group": "Development/Tools",
|
||||||
"size": "1160660",
|
"size": "1160660",
|
||||||
"license": "GPLv2+",
|
"license": "GPLv2+",
|
||||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
|
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
||||||
"source_rpm": "make-3.82-24.el7.src.rpm",
|
"source_rpm": "make-3.82-24.el7.src.rpm",
|
||||||
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
"build_host": "x86-01.bsys.centos.org",
|
||||||
@ -133,8 +138,8 @@ Examples:
|
|||||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
||||||
"vendor": "CentOS",
|
"vendor": "CentOS",
|
||||||
"url": "http://www.gnu.org/software/make/",
|
"url": "http://www.gnu.org/software/make/",
|
||||||
"summary": "A GNU tool which simplifies the build process for users",
|
"summary": "A GNU tool which simplifies the build process for...",
|
||||||
"description": "A GNU tool for controlling the generation of executables and other..."
|
"description": "A GNU tool for controlling the generation of exe..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "kbd-legacy",
|
"name": "kbd-legacy",
|
||||||
@ -145,7 +150,7 @@ Examples:
|
|||||||
"group": "System Environment/Base",
|
"group": "System Environment/Base",
|
||||||
"size": "503608",
|
"size": "503608",
|
||||||
"license": "GPLv2+",
|
"license": "GPLv2+",
|
||||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
|
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
||||||
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
||||||
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
"build_host": "x86-01.bsys.centos.org",
|
||||||
@ -154,7 +159,7 @@ Examples:
|
|||||||
"vendor": "CentOS",
|
"vendor": "CentOS",
|
||||||
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
||||||
"summary": "Legacy data for kbd package",
|
"summary": "Legacy data for kbd package",
|
||||||
"description": "The kbd-legacy package contains original keymaps for kbd package..."
|
"description": "The kbd-legacy package contains original keymaps..."
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
@ -58,7 +58,7 @@ Schema:
|
|||||||
"boot": boolean,
|
"boot": boolean,
|
||||||
"start": integer,
|
"start": integer,
|
||||||
"end": integer,
|
"end": integer,
|
||||||
"size": string, # Note: will be integer when using deprecated -d sfdisk option
|
"size": string, # [0]
|
||||||
"cyls": integer,
|
"cyls": integer,
|
||||||
"mib": integer,
|
"mib": integer,
|
||||||
"blocks": integer,
|
"blocks": integer,
|
||||||
@ -71,6 +71,8 @@ Schema:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] will be integer when using deprecated -d sfdisk option
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
# sfdisk -l | jc --sfdisk -p
|
# sfdisk -l | jc --sfdisk -p
|
||||||
@ -80,7 +82,7 @@ Examples:
|
|||||||
"cylinders": 2610,
|
"cylinders": 2610,
|
||||||
"heads": 255,
|
"heads": 255,
|
||||||
"sectors_per_track": 63,
|
"sectors_per_track": 63,
|
||||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0",
|
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, ...",
|
||||||
"partitions": [
|
"partitions": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sda1",
|
"device": "/dev/sda1",
|
||||||
@ -145,7 +147,7 @@ Examples:
|
|||||||
"cylinders": "2610",
|
"cylinders": "2610",
|
||||||
"heads": "255",
|
"heads": "255",
|
||||||
"sectors_per_track": "63",
|
"sectors_per_track": "63",
|
||||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0",
|
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, co...",
|
||||||
"partitions": [
|
"partitions": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sda1",
|
"device": "/dev/sda1",
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
# jc.parsers.ss
|
# jc.parsers.ss
|
||||||
jc - JSON CLI output utility `ss` command output parser
|
jc - JSON CLI output utility `ss` command output parser
|
||||||
|
|
||||||
Extended information options like -e and -p are not supported and may cause parsing irregularities.
|
Extended information options like -e and -p are not supported and may cause
|
||||||
|
parsing irregularities.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -25,7 +26,8 @@ Usage (module):
|
|||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
Information from https://www.cyberciti.biz/files/ss.html used to define
|
||||||
|
field names
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
# jc.parsers.stat
|
# jc.parsers.stat
|
||||||
jc - JSON CLI output utility `stat` command output parser
|
jc - JSON CLI output utility `stat` command output parser
|
||||||
|
|
||||||
The `xxx_epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
|
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||||
|
local time of the system the parser is run on)
|
||||||
|
|
||||||
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are only available if the timezone field is UTC.
|
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are
|
||||||
|
only available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@ jc - JSON CLI output utility `stat` command output streaming parser
|
|||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
|
|
||||||
The `xxx_epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on).
|
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||||
|
local time of the system the parser is run on).
|
||||||
|
|
||||||
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are only available if the timezone field is UTC.
|
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are
|
||||||
|
only available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -16,14 +18,16 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('stat_s', stat_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parse('stat_s', stat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.stat_s
|
import jc.parsers.stat_s
|
||||||
result = jc.parsers.stat_s.parse(stat_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parsers.stat_s.parse(stat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -61,9 +65,12 @@ Schema:
|
|||||||
"rdev": integer,
|
"rdev": integer,
|
||||||
"block_size": integer,
|
"block_size": integer,
|
||||||
"unix_flags": string,
|
"unix_flags": string,
|
||||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
|
||||||
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # true if successfully parsed, false if error
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
@ -72,10 +79,10 @@ Schema:
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ stat | jc --stat-s
|
$ stat | jc --stat-s
|
||||||
{"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"crw--w----","links":1,"user":"kbrazil","group":"tty","rdev":268435456,"size":0,"access_time":"Jan 4 15:27:44 2022","modify_time":"Jan 4 15:27:44 2022","change_time":"Jan 4 15:27:44 2022","birth_time":"Dec 31 16:00:00 1969","block_size":131072,"blocks":0,"unix_flags":"0","access_time_epoch":1641338864,"access_time_epoch_utc":null,"modify_time_epoch":1641338864,"modify_time_epoch_utc":null,"change_time_epoch":1641338864,"change_time_epoch_utc":null,"birth_time_epoch":null,"birth_time_epoch_utc":null}
|
{"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"cr...}
|
||||||
|
|
||||||
$ stat | jc --stat-s -r
|
$ stat | jc --stat-s -r
|
||||||
{"file":"(stdin)","unix_device":"1027739696","inode":"1155","flags":"crw--w----","links":"1","user":"kbrazil","group":"tty","rdev":"268435456","size":"0","access_time":"Jan 4 15:28:08 2022","modify_time":"Jan 4 15:28:08 2022","change_time":"Jan 4 15:28:08 2022","birth_time":"Dec 31 16:00:00 1969","block_size":"131072","blocks":"0","unix_flags":"0"}
|
{"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...}
|
||||||
|
|
||||||
|
|
||||||
## info
|
## info
|
||||||
@ -93,7 +100,9 @@ Main text parsing generator function. Returns an iterator object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
data: (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages if True
|
quiet: (boolean) suppress warning messages if True
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
# jc.parsers.sysctl
|
# jc.parsers.sysctl
|
||||||
jc - JSON CLI output utility `sysctl -a` command output parser
|
jc - JSON CLI output utility `sysctl -a` command output parser
|
||||||
|
|
||||||
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` command-line argument or the `raw=True` argument in `parse()`.
|
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`
|
||||||
|
command-line argument or the `raw=True` argument in `parse()`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -26,7 +29,7 @@ Usage (module):
|
|||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"key1": string/integer/float, # best guess based on value
|
"key1": string/integer/float, # best guess based on value
|
||||||
"key2": string/integer/float,
|
"key2": string/integer/float,
|
||||||
"key3": string/integer/float
|
"key3": string/integer/float
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,14 @@ Examples:
|
|||||||
"load": "loaded",
|
"load": "loaded",
|
||||||
"active": "active",
|
"active": "active",
|
||||||
"sub": "waiting",
|
"sub": "waiting",
|
||||||
"description": "Arbitrary Executable File Formats File System Automount Point"
|
"description": "Arbitrary Executable File Formats File System ..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"unit": "dev-block-8:2.device",
|
"unit": "dev-block-8:2.device",
|
||||||
"load": "loaded",
|
"load": "loaded",
|
||||||
"active": "active",
|
"active": "active",
|
||||||
"sub": "plugged",
|
"sub": "plugged",
|
||||||
"description": "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM on /dev/sda2 2"
|
"description": "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM o..."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"unit": "dev-cdrom.device",
|
"unit": "dev-cdrom.device",
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
|
||||||
# jc.parsers.systemctl_ls
|
# jc.parsers.systemctl_ls
|
||||||
jc - JSON CLI output utility `systemctl list-sockets` command output parser
|
jc - JSON CLI output utility `systemctl list-sockets` command output
|
||||||
|
parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
|
||||||
# jc.parsers.systemctl_luf
|
# jc.parsers.systemctl_luf
|
||||||
jc - JSON CLI output utility `systemctl list-unit-files` command output parser
|
jc - JSON CLI output utility `systemctl list-unit-files` command output
|
||||||
|
parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
|
@ -5,9 +5,13 @@ jc - JSON CLI output utility `systeminfo` command output parser
|
|||||||
|
|
||||||
Blank or missing elements are set to `null`.
|
Blank or missing elements are set to `null`.
|
||||||
|
|
||||||
The `original_install_date_epoch` and `system_boot_time_epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
|
The `original_install_date_epoch` and `system_boot_time_epoch` calculated
|
||||||
|
timestamp fields are naive. (i.e. based on the local time of the system the
|
||||||
|
parser is run on)
|
||||||
|
|
||||||
The `original_install_date_epoch_utc` and `system_boot_time_epoch_utc` calculated timestamp fields are timezone-aware and are only available if the timezone field is UTC.
|
The `original_install_date_epoch_utc` and `system_boot_time_epoch_utc`
|
||||||
|
calculated timestamp fields are timezone-aware and are only available if
|
||||||
|
the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -36,11 +40,11 @@ Schema:
|
|||||||
"registered_organization": string,
|
"registered_organization": string,
|
||||||
"product_id": string,
|
"product_id": string,
|
||||||
"original_install_date": string,
|
"original_install_date": string,
|
||||||
"original_install_date_epoch": integer, # naive timestamp
|
"original_install_date_epoch": integer, # [0]
|
||||||
"original_install_date_epoch_utc": integer, # timezone-aware timestamp
|
"original_install_date_epoch_utc": integer, # [1]
|
||||||
"system_boot_time": string,
|
"system_boot_time": string,
|
||||||
"system_boot_time_epoch": integer, # naive timestamp
|
"system_boot_time_epoch": integer, # [0]
|
||||||
"system_boot_time_epoch_utc": integer, # timezone-aware timestamp
|
"system_boot_time_epoch_utc": integer, # [1]
|
||||||
"system_manufacturer": string,
|
"system_manufacturer": string,
|
||||||
"system_model": string,
|
"system_model": string,
|
||||||
"system_type": string,
|
"system_type": string,
|
||||||
@ -85,6 +89,9 @@ Schema:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] naive timestamp
|
||||||
|
[1] timezone-aware timestamp
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ systeminfo | jc --systeminfo -p
|
$ systeminfo | jc --systeminfo -p
|
||||||
|
@ -3,15 +3,19 @@
|
|||||||
# jc.parsers.time
|
# jc.parsers.time
|
||||||
jc - JSON CLI output utility `/usr/bin/time` command output parser
|
jc - JSON CLI output utility `/usr/bin/time` command output parser
|
||||||
|
|
||||||
Output from `/usr/bin/time` is sent to `STDERR`, so the `-o` option can be used to redirect the output to a file that can be read by `jc`.
|
Output from `/usr/bin/time` is sent to `STDERR`, so the `-o` option can be
|
||||||
|
used to redirect the output to a file that can be read by `jc`.
|
||||||
|
|
||||||
Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT` so `jc` can receive it.
|
Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT`
|
||||||
|
so `jc` can receive it.
|
||||||
|
|
||||||
Note: `/usr/bin/time` is similar but different from the Bash builtin `time` command.
|
Note: `/usr/bin/time` is similar but different from the Bash builtin
|
||||||
|
`time` command.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ /usr/bin/time -o timefile.out sleep 2.5; cat timefile.out | jc --time -p
|
$ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \
|
||||||
|
jc --time -p
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
@ -44,8 +48,8 @@ Schema:
|
|||||||
"average_unshared_stack_size": integer,
|
"average_unshared_stack_size": integer,
|
||||||
"average_shared_memory_size": integer,
|
"average_shared_memory_size": integer,
|
||||||
"maximum_resident_set_size": integer,
|
"maximum_resident_set_size": integer,
|
||||||
"block_input_operations": integer, # aka File system inputs
|
"block_input_operations": integer, # [0]
|
||||||
"block_output_operations": integer, # aka File system outputs
|
"block_output_operations": integer, # [1]
|
||||||
"major_pagefaults": integer,
|
"major_pagefaults": integer,
|
||||||
"minor_pagefaults": integer,
|
"minor_pagefaults": integer,
|
||||||
"swaps": integer,
|
"swaps": integer,
|
||||||
@ -65,15 +69,19 @@ Schema:
|
|||||||
"exit_status": integer
|
"exit_status": integer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] aka File system inputs
|
||||||
|
[1] aka File system outputs
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p
|
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \
|
||||||
|
jc --time -p
|
||||||
{
|
{
|
||||||
"command_being_timed": "sleep 2.5",
|
"command_being_timed": "sleep 2",
|
||||||
"user_time": 0.0,
|
"user_time": 0.0,
|
||||||
"system_time": 0.0,
|
"system_time": 0.0,
|
||||||
"cpu_percent": 0,
|
"cpu_percent": 0,
|
||||||
"elapsed_time": "0:02.50",
|
"elapsed_time": "0:02.00",
|
||||||
"average_shared_text_size": 0,
|
"average_shared_text_size": 0,
|
||||||
"average_unshared_data_size": 0,
|
"average_unshared_data_size": 0,
|
||||||
"average_stack_size": 0,
|
"average_stack_size": 0,
|
||||||
@ -99,13 +107,14 @@ Examples:
|
|||||||
"elapsed_time_total_seconds": 2.5
|
"elapsed_time_total_seconds": 2.5
|
||||||
}
|
}
|
||||||
|
|
||||||
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p -r
|
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \
|
||||||
|
jc --time -p -r
|
||||||
{
|
{
|
||||||
"command_being_timed": ""sleep 2.5"",
|
"command_being_timed": ""sleep 2"",
|
||||||
"user_time": "0.00",
|
"user_time": "0.00",
|
||||||
"system_time": "0.00",
|
"system_time": "0.00",
|
||||||
"cpu_percent": "0",
|
"cpu_percent": "0",
|
||||||
"elapsed_time": "0:02.50",
|
"elapsed_time": "0:02.00",
|
||||||
"average_shared_text_size": "0",
|
"average_shared_text_size": "0",
|
||||||
"average_unshared_data_size": "0",
|
"average_unshared_data_size": "0",
|
||||||
"average_stack_size": "0",
|
"average_stack_size": "0",
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
# jc.parsers.timedatectl
|
# jc.parsers.timedatectl
|
||||||
jc - JSON CLI output utility `timedatectl` command output parser
|
jc - JSON CLI output utility `timedatectl` command output parser
|
||||||
|
|
||||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the `universal_time` field is available.
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||||
|
available if the `universal_time` field is available.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ Schema:
|
|||||||
{
|
{
|
||||||
"local_time": string,
|
"local_time": string,
|
||||||
"universal_time": string,
|
"universal_time": string,
|
||||||
"epoch_utc": integer, # timezone-aware timestamp
|
"epoch_utc": integer, # timezone-aware
|
||||||
"rtc_time": string,
|
"rtc_time": string,
|
||||||
"time_zone": string,
|
"time_zone": string,
|
||||||
"ntp_enabled": boolean,
|
"ntp_enabled": boolean,
|
||||||
|
@ -5,7 +5,10 @@ jc - JSON CLI output utility `traceroute` command output parser
|
|||||||
|
|
||||||
Supports `traceroute` and `traceroute6` output.
|
Supports `traceroute` and `traceroute6` output.
|
||||||
|
|
||||||
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.
|
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`
|
e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute`
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ Schema:
|
|||||||
"end": integer
|
"end": integer
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"to_service": string, # null if any to ports or port_ranges are set
|
"to_service": string, # [0]
|
||||||
"from_ip": string,
|
"from_ip": string,
|
||||||
"from_ip_prefix": integer,
|
"from_ip_prefix": integer,
|
||||||
"from_interface": string,
|
"from_interface": string,
|
||||||
@ -62,12 +62,15 @@ Schema:
|
|||||||
"end": integer
|
"end": integer
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"from_service": string, # null if any from ports or port_ranges are set
|
"from_service": string, # [1]
|
||||||
"comment": string # null if no comment
|
"comment": string # null if no comment
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] null if any 'to' ports or port_ranges are set
|
||||||
|
[1] null if any 'from' ports or port_ranges are set
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ufw status verbose | jc --ufw -p
|
$ ufw status verbose | jc --ufw -p
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
|
||||||
# jc.parsers.ufw_appinfo
|
# jc.parsers.ufw_appinfo
|
||||||
jc - JSON CLI output utility `ufw app info [application]` command output parser
|
jc - JSON CLI output utility `ufw app info [application]` command
|
||||||
|
output parser
|
||||||
|
|
||||||
Supports individual apps via `ufw app info [application]` and all apps list via `ufw app info all`.
|
Supports individual apps via `ufw app info [application]` and all apps list
|
||||||
|
via `ufw app info all`.
|
||||||
|
|
||||||
Because `ufw` application definitions allow overlapping ports and port ranges, this parser preserves that behavior, but also provides `normalized` lists and ranges that remove duplicate ports and merge overlapping ranges.
|
Because `ufw` application definitions allow overlapping ports and port
|
||||||
|
ranges, this parser preserves that behavior, but also provides `normalized`
|
||||||
|
lists and ranges that remove duplicate ports and merge overlapping ranges.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -46,31 +50,35 @@ Schema:
|
|||||||
],
|
],
|
||||||
"udp_ranges": [
|
"udp_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer, # 'any' is converted to start/end: 0/65535
|
"start": integer, # [0]
|
||||||
"end": integer
|
"end": integer
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"normalized_tcp_list": [
|
"normalized_tcp_list": [
|
||||||
integers # duplicates and overlapping are removed
|
integers # [1]
|
||||||
],
|
],
|
||||||
"normalized_tcp_ranges": [
|
"normalized_tcp_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer, # 'any' is converted to start/end: 0/65535
|
"start": integer, # [0]
|
||||||
"end": integers # overlapping are merged
|
"end": integers # [2]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"normalized_udp_list": [
|
"normalized_udp_list": [
|
||||||
integers # duplicates and overlapping are removed
|
integers # [1]
|
||||||
],
|
],
|
||||||
"normalized_udp_ranges": [
|
"normalized_udp_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer, # 'any' is converted to start/end: 0/65535
|
"start": integer, # [0]
|
||||||
"end": integers # overlapping are merged
|
"end": integers # [2]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] 'any' is converted to start/end: 0/65535
|
||||||
|
[1] duplicates and overlapping are removed
|
||||||
|
[2] overlapping are merged
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ufw app info MSN | jc --ufw-appinfo -p
|
$ ufw app info MSN | jc --ufw-appinfo -p
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
# jc.parsers.upower
|
# jc.parsers.upower
|
||||||
jc - JSON CLI output utility `upower` command output parser
|
jc - JSON CLI output utility `upower` command output parser
|
||||||
|
|
||||||
The `updated_epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `updated_epoch` calculated timestamp field is naive. (i.e. based on the
|
||||||
|
local time of the system the parser is run on)
|
||||||
|
|
||||||
The `updated_epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
The `updated_epoch_utc` calculated timestamp field is timezone-aware and is
|
||||||
|
only available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -34,8 +36,8 @@ Schema:
|
|||||||
"native_path": string,
|
"native_path": string,
|
||||||
"power_supply": boolean,
|
"power_supply": boolean,
|
||||||
"updated": string,
|
"updated": string,
|
||||||
"updated_epoch": integer, # null if date-time conversion fails
|
"updated_epoch": integer, # [0]
|
||||||
"updated_epoch_utc": integer, # null if date-time conversion fails
|
"updated_epoch_utc": integer, # [0]
|
||||||
"updated_seconds_ago": integer,
|
"updated_seconds_ago": integer,
|
||||||
"has_history": boolean,
|
"has_history": boolean,
|
||||||
"has_statistics": boolean,
|
"has_statistics": boolean,
|
||||||
@ -87,12 +89,14 @@ Schema:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] null if date-time conversion fails
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p
|
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0",
|
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
|
||||||
"vendor": "NOTEBOOK",
|
"vendor": "NOTEBOOK",
|
||||||
"model": "BAT",
|
"model": "BAT",
|
||||||
"serial": "0001",
|
"serial": "0001",
|
||||||
@ -151,7 +155,7 @@ Examples:
|
|||||||
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p -r
|
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0",
|
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
|
||||||
"vendor": "NOTEBOOK",
|
"vendor": "NOTEBOOK",
|
||||||
"model": "BAT",
|
"model": "BAT",
|
||||||
"serial": "0001",
|
"serial": "0001",
|
||||||
|
@ -5,9 +5,11 @@ jc - JSON CLI output utility `vmstat` command output parser
|
|||||||
|
|
||||||
Options supported: `-a`, `-w`, `-d`, `-t`
|
Options supported: `-a`, `-w`, `-d`, `-t`
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||||
|
time of the system the parser is run on)
|
||||||
|
|
||||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||||
|
available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -63,11 +65,14 @@ Schema:
|
|||||||
"io_seconds": integer,
|
"io_seconds": integer,
|
||||||
"timestamp": string,
|
"timestamp": string,
|
||||||
"timezone": string,
|
"timezone": string,
|
||||||
"epoch": integer, # naive timestamp if -t flag is used
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer # aware timestamp if -t flag is used and UTC TZ
|
"epoch_utc": integer # [1]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] naive timestamp if -t flag is used
|
||||||
|
[1] aware timestamp if -t flag is used and UTC TZ
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ vmstat | jc --vmstat -p
|
$ vmstat | jc --vmstat -p
|
||||||
|
@ -7,83 +7,100 @@ jc - JSON CLI output utility `vmstat` command output streaming parser
|
|||||||
|
|
||||||
Options supported: `-a`, `-w`, `-d`, `-t`
|
Options supported: `-a`, `-w`, `-d`, `-t`
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||||
|
time of the system the parser is run on)
|
||||||
|
|
||||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||||
|
available if the timezone field is UTC.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ vmstat | jc --vmstat-s
|
$ vmstat | jc --vmstat-s
|
||||||
|
|
||||||
> Note: When piping `jc` converted `vmstat` output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `vmstat` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output) for more information.
|
> Note: When piping `jc` converted `vmstat` output to other processes it may
|
||||||
|
appear the output is hanging due to the OS pipe buffers. This is because
|
||||||
|
`vmstat` output is too small to quickly fill up the buffer. Use the `-u`
|
||||||
|
option to unbuffer the `jc` output if you would like immediate output. See
|
||||||
|
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||||
|
for more information.
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('vmstat_s', vmstat_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parse('vmstat_s', vmstat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.vmstat_s
|
import jc.parsers.vmstat_s
|
||||||
result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines()) # result is an iterable object
|
# result is an iterable object (generator)
|
||||||
|
result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"runnable_procs": integer,
|
"runnable_procs": integer,
|
||||||
"uninterruptible_sleeping_procs": integer,
|
"uninterruptible_sleeping_procs": integer,
|
||||||
"virtual_mem_used": integer,
|
"virtual_mem_used": integer,
|
||||||
"free_mem": integer,
|
"free_mem": integer,
|
||||||
"buffer_mem": integer,
|
"buffer_mem": integer,
|
||||||
"cache_mem": integer,
|
"cache_mem": integer,
|
||||||
"inactive_mem": integer,
|
"inactive_mem": integer,
|
||||||
"active_mem": integer,
|
"active_mem": integer,
|
||||||
"swap_in": integer,
|
"swap_in": integer,
|
||||||
"swap_out": integer,
|
"swap_out": integer,
|
||||||
"blocks_in": integer,
|
"blocks_in": integer,
|
||||||
"blocks_out": integer,
|
"blocks_out": integer,
|
||||||
"interrupts": integer,
|
"interrupts": integer,
|
||||||
"context_switches": integer,
|
"context_switches": integer,
|
||||||
"user_time": integer,
|
"user_time": integer,
|
||||||
"system_time": integer,
|
"system_time": integer,
|
||||||
"idle_time": integer,
|
"idle_time": integer,
|
||||||
"io_wait_time": integer,
|
"io_wait_time": integer,
|
||||||
"stolen_time": integer,
|
"stolen_time": integer,
|
||||||
"disk": string,
|
"disk": string,
|
||||||
"total_reads": integer,
|
"total_reads": integer,
|
||||||
"merged_reads": integer,
|
"merged_reads": integer,
|
||||||
"sectors_read": integer,
|
"sectors_read": integer,
|
||||||
"reading_ms": integer,
|
"reading_ms": integer,
|
||||||
"total_writes": integer,
|
"total_writes": integer,
|
||||||
"merged_writes": integer,
|
"merged_writes": integer,
|
||||||
"sectors_written": integer,
|
"sectors_written": integer,
|
||||||
"writing_ms": integer,
|
"writing_ms": integer,
|
||||||
"current_io": integer,
|
"current_io": integer,
|
||||||
"io_seconds": integer,
|
"io_seconds": integer,
|
||||||
"timestamp": string,
|
"timestamp": string,
|
||||||
"timezone": string,
|
"timezone": string,
|
||||||
"epoch": integer, # naive timestamp if -t flag is used
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer # aware timestamp if -t flag is used and UTC TZ
|
"epoch_utc": integer # [1]
|
||||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
|
||||||
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # true if successfully parsed, false if error
|
"success": boolean, # [2]
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # [3]
|
||||||
"line": string # exists if "success" is false
|
"line": string # [3]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0] naive timestamp if -t flag is used
|
||||||
|
[1] aware timestamp if -t flag is used and UTC TZ
|
||||||
|
[2] false if error parsing
|
||||||
|
[3] exists if "success" is false
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ vmstat | jc --vmstat-s
|
$ vmstat | jc --vmstat-s
|
||||||
{"runnable_procs":2,"uninterruptible_sleeping_procs":0,"virtual_mem_used":0,"free_mem":2794468,"buffer_mem":2108,"cache_mem":741208,"inactive_mem":null,"active_mem":null,"swap_in":0,"swap_out":0,"blocks_in":1,"blocks_out":3,"interrupts":29,"context_switches":57,"user_time":0,"system_time":0,"idle_time":99,"io_wait_time":0,"stolen_time":0,"timestamp":null,"timezone":null}
|
{"runnable_procs":2,"uninterruptible_sleeping_procs":0,"virtual_mem...}
|
||||||
...
|
...
|
||||||
|
|
||||||
$ vmstat | jc --vmstat-s -r
|
$ vmstat | jc --vmstat-s -r
|
||||||
{"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtual_mem_used":"0","free_mem":"2794468","buffer_mem":"2108","cache_mem":"741208","inactive_mem":null,"active_mem":null,"swap_in":"0","swap_out":"0","blocks_in":"1","blocks_out":"3","interrupts":"29","context_switches":"57","user_time":"0","system_time":"0","idle_time":"99","io_wait_time":"0","stolen_time":"0","timestamp":null,"timezone":null}
|
{"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtua...}
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
@ -102,7 +119,9 @@ Main text parsing generator function. Returns an iterator object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
data: (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages if True
|
quiet: (boolean) suppress warning messages if True
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||||
|
@ -5,7 +5,8 @@ jc - JSON CLI output utility `who` command output parser
|
|||||||
|
|
||||||
Accepts any of the following who options (or no options): `-aTH`
|
Accepts any of the following who options (or no options): `-aTH`
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||||
|
time of the system the parser is run on)
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ Schema:
|
|||||||
"writeable_tty": string,
|
"writeable_tty": string,
|
||||||
"tty": string,
|
"tty": string,
|
||||||
"time": string,
|
"time": string,
|
||||||
"epoch": integer, # naive timestamp. null if time cannot be converted
|
"epoch": integer, # [0]
|
||||||
"idle": string,
|
"idle": string,
|
||||||
"pid": integer,
|
"pid": integer,
|
||||||
"from": string,
|
"from": string,
|
||||||
@ -42,6 +43,8 @@ Schema:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] naive timestamp. null if time cannot be converted
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ who -a | jc --who -p
|
$ who -a | jc --who -p
|
||||||
|
Reference in New Issue
Block a user