mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
update docs
This commit is contained in:
@ -15,6 +15,19 @@ Usage (module):
|
|||||||
import jc.parsers.ini
|
import jc.parsers.ini
|
||||||
result = jc.parsers.ini.parse(ini_file_output)
|
result = jc.parsers.ini.parse(ini_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
ini or key/value document converted to a dictionary - see configparser standard
|
||||||
|
library documentation for more details.
|
||||||
|
|
||||||
|
Note: Values starting and ending with quotation marks will have the marks removed.
|
||||||
|
If you would like to keep the quotation marks, use the -r or raw=True argument.
|
||||||
|
|
||||||
|
{
|
||||||
|
"key1": string,
|
||||||
|
"key2": string
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -58,31 +71,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (Dictionary) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Dictionary representing an ini or simple key/value pair document:
|
|
||||||
|
|
||||||
{
|
|
||||||
ini or key/value document converted to a dictionary - see configparser standard
|
|
||||||
library documentation for more details.
|
|
||||||
|
|
||||||
Note: Values starting and ending with quotation marks will have the marks removed.
|
|
||||||
If you would like to keep the quotation marks, use the -r or raw=True argument.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -17,6 +17,29 @@ Usage (module):
|
|||||||
import jc.parsers.iptables
|
import jc.parsers.iptables
|
||||||
result = jc.parsers.iptables.parse(iptables_command_output)
|
result = jc.parsers.iptables.parse(iptables_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"chain": string,
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"num" integer,
|
||||||
|
"pkts": integer,
|
||||||
|
"bytes": integer, # converted based on suffix
|
||||||
|
"target": string,
|
||||||
|
"prot": string,
|
||||||
|
"opt": string, # "--" = Null
|
||||||
|
"in": string,
|
||||||
|
"out": string,
|
||||||
|
"source": string,
|
||||||
|
"destination": string,
|
||||||
|
"options": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -146,44 +169,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"chain": string,
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"num" integer,
|
|
||||||
"pkts": integer,
|
|
||||||
"bytes": integer, # converted based on suffix
|
|
||||||
"target": string,
|
|
||||||
"prot": string,
|
|
||||||
"opt": string, # "--" = Null
|
|
||||||
"in": string,
|
|
||||||
"out": string,
|
|
||||||
"source": string,
|
|
||||||
"destination": string,
|
|
||||||
"options": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -17,6 +17,16 @@ Usage (module):
|
|||||||
import jc.parsers.iw-scan
|
import jc.parsers.iw-scan
|
||||||
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
|
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"foo": string/integer/float, # best guess based on value
|
||||||
|
"bar": string/integer/float,
|
||||||
|
"baz": string/integer/float
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -116,30 +126,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"foo": string/integer/float, # best guess based on value
|
|
||||||
"bar": string/integer/float,
|
|
||||||
"baz": string/integer/float
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -17,6 +17,18 @@ Usage (module):
|
|||||||
import jc.parsers.jobs
|
import jc.parsers.jobs
|
||||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"job_number": integer,
|
||||||
|
"pid": integer,
|
||||||
|
"history": string,
|
||||||
|
"status": string,
|
||||||
|
"command": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -88,33 +100,7 @@ Example:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"job_number": integer,
|
|
||||||
"pid": integer,
|
|
||||||
"history": string,
|
|
||||||
"status": string,
|
|
||||||
"command": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -6,7 +6,6 @@ Supports files containing simple key/value pairs. Delimiter can be `=` or `:`. M
|
|||||||
|
|
||||||
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):
|
||||||
|
|
||||||
$ cat foo.txt | jc --kv
|
$ cat foo.txt | jc --kv
|
||||||
@ -16,6 +15,15 @@ Usage (module):
|
|||||||
import jc.parsers.kv
|
import jc.parsers.kv
|
||||||
result = jc.parsers.kv.parse(kv_file_output)
|
result = jc.parsers.kv.parse(kv_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
key/value document converted to a dictionary - see configparser standard library documentation for more details.
|
||||||
|
|
||||||
|
{
|
||||||
|
"key1": string,
|
||||||
|
"key2": string
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -46,7 +54,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -19,6 +19,22 @@ Usage (module):
|
|||||||
import jc.parsers.last
|
import jc.parsers.last
|
||||||
result = jc.parsers.last.parse(last_command_output)
|
result = jc.parsers.last.parse(last_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"user": string,
|
||||||
|
"tty": string,
|
||||||
|
"hostname": string,
|
||||||
|
"login": string,
|
||||||
|
"logout": string,
|
||||||
|
"duration": string,
|
||||||
|
"login_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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'aix', 'freebsd'
|
||||||
@ -93,37 +109,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"user": string,
|
|
||||||
"tty": string,
|
|
||||||
"hostname": string,
|
|
||||||
"login": string,
|
|
||||||
"logout": string,
|
|
||||||
"duration": string,
|
|
||||||
"login_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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -26,6 +26,23 @@ Usage (module):
|
|||||||
import jc.parsers.ls
|
import jc.parsers.ls
|
||||||
result = jc.parsers.ls.parse(ls_command_output)
|
result = jc.parsers.ls.parse(ls_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": string,
|
||||||
|
"flags": string,
|
||||||
|
"links": integer,
|
||||||
|
"parent": string,
|
||||||
|
"owner": string,
|
||||||
|
"group": string,
|
||||||
|
"size": integer,
|
||||||
|
"date": string,
|
||||||
|
"epoch": integer, # naive timestamp if date field exists and can be converted
|
||||||
|
"epoch_utc": integer # timezone aware timestamp if date field is in UTC and can be converted
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -159,38 +176,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"filename": string,
|
|
||||||
"flags": string,
|
|
||||||
"links": integer,
|
|
||||||
"parent": string,
|
|
||||||
"owner": string,
|
|
||||||
"group": string,
|
|
||||||
"size": integer,
|
|
||||||
"date": string,
|
|
||||||
"epoch": integer, # naive timestamp if date field exists and can be converted
|
|
||||||
"epoch_utc": integer # timezone aware timestamp if date field is in UTC and can be converted
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,53 @@ Usage (module):
|
|||||||
import jc.parsers.lsblk
|
import jc.parsers.lsblk
|
||||||
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"maj_min": string,
|
||||||
|
"rm": boolean,
|
||||||
|
"size": string,
|
||||||
|
"ro": boolean,
|
||||||
|
"type": string,
|
||||||
|
"mountpoint": string,
|
||||||
|
"kname": string,
|
||||||
|
"fstype": string,
|
||||||
|
"label": string,
|
||||||
|
"uuid": string,
|
||||||
|
"partlabel": string,
|
||||||
|
"partuuid": string,
|
||||||
|
"ra": integer,
|
||||||
|
"model": string,
|
||||||
|
"serial": string,
|
||||||
|
"state": string,
|
||||||
|
"owner": string,
|
||||||
|
"group": string,
|
||||||
|
"mode": string,
|
||||||
|
"alignment": integer,
|
||||||
|
"min_io": integer,
|
||||||
|
"opt_io": integer,
|
||||||
|
"phy_sec": integer,
|
||||||
|
"log_sec": integer,
|
||||||
|
"rota": boolean,
|
||||||
|
"sched": string,
|
||||||
|
"rq_size": integer,
|
||||||
|
"disc_aln": integer,
|
||||||
|
"disc_gran": string,
|
||||||
|
"disc_max": string,
|
||||||
|
"disc_zero": boolean,
|
||||||
|
"wsame": string,
|
||||||
|
"wwn": string,
|
||||||
|
"rand": boolean,
|
||||||
|
"pkname": string,
|
||||||
|
"hctl": string,
|
||||||
|
"tran": string,
|
||||||
|
"rev": string,
|
||||||
|
"vendor": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -227,68 +274,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"maj_min": string,
|
|
||||||
"rm": boolean,
|
|
||||||
"size": string,
|
|
||||||
"ro": boolean,
|
|
||||||
"type": string,
|
|
||||||
"mountpoint": string,
|
|
||||||
"kname": string,
|
|
||||||
"fstype": string,
|
|
||||||
"label": string,
|
|
||||||
"uuid": string,
|
|
||||||
"partlabel": string,
|
|
||||||
"partuuid": string,
|
|
||||||
"ra": integer,
|
|
||||||
"model": string,
|
|
||||||
"serial": string,
|
|
||||||
"state": string,
|
|
||||||
"owner": string,
|
|
||||||
"group": string,
|
|
||||||
"mode": string,
|
|
||||||
"alignment": integer,
|
|
||||||
"min_io": integer,
|
|
||||||
"opt_io": integer,
|
|
||||||
"phy_sec": integer,
|
|
||||||
"log_sec": integer,
|
|
||||||
"rota": boolean,
|
|
||||||
"sched": string,
|
|
||||||
"rq_size": integer,
|
|
||||||
"disc_aln": integer,
|
|
||||||
"disc_gran": string,
|
|
||||||
"disc_max": string,
|
|
||||||
"disc_zero": boolean,
|
|
||||||
"wsame": string,
|
|
||||||
"wwn": string,
|
|
||||||
"rand": boolean,
|
|
||||||
"pkname": string,
|
|
||||||
"hctl": string,
|
|
||||||
"tran": string,
|
|
||||||
"rev": string,
|
|
||||||
"vendor": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,19 @@ Usage (module):
|
|||||||
import jc.parsers.lsmod
|
import jc.parsers.lsmod
|
||||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"module": string,
|
||||||
|
"size": integer,
|
||||||
|
"used": integer,
|
||||||
|
"by": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -118,34 +131,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"module": string,
|
|
||||||
"size": integer,
|
|
||||||
"used": integer,
|
|
||||||
"by": [
|
|
||||||
string
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,23 @@ Usage (module):
|
|||||||
import jc.parsers.lsof
|
import jc.parsers.lsof
|
||||||
result = jc.parsers.lsof.parse(lsof_command_output)
|
result = jc.parsers.lsof.parse(lsof_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"command": string,
|
||||||
|
"pid": integer,
|
||||||
|
"tid": integer,
|
||||||
|
"user": string,
|
||||||
|
"fd": string,
|
||||||
|
"type": string,
|
||||||
|
"device": string,
|
||||||
|
"size_off": integer,
|
||||||
|
"node": integer,
|
||||||
|
"name": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -108,38 +125,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"command": string,
|
|
||||||
"pid": integer,
|
|
||||||
"tid": integer,
|
|
||||||
"user": string,
|
|
||||||
"fd": string,
|
|
||||||
"type": string,
|
|
||||||
"device": string,
|
|
||||||
"size_off": integer,
|
|
||||||
"node": integer,
|
|
||||||
"name": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,19 @@ Usage (module):
|
|||||||
import jc.parsers.mount
|
import jc.parsers.mount
|
||||||
result = jc.parsers.mount.parse(mount_command_output)
|
result = jc.parsers.mount.parse(mount_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": string,
|
||||||
|
"mount_point": string,
|
||||||
|
"type": string,
|
||||||
|
"access": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -68,34 +81,7 @@ Example:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"filesystem": string,
|
|
||||||
"mount_point": string,
|
|
||||||
"type": string,
|
|
||||||
"access": [
|
|
||||||
string
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -19,6 +19,107 @@ Usage (module):
|
|||||||
import jc.parsers.netstat
|
import jc.parsers.netstat
|
||||||
result = jc.parsers.netstat.parse(netstat_command_output)
|
result = jc.parsers.netstat.parse(netstat_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"proto": string,
|
||||||
|
"recv_q": integer,
|
||||||
|
"send_q": integer,
|
||||||
|
"transport_protocol" string,
|
||||||
|
"network_protocol": string,
|
||||||
|
"local_address": string,
|
||||||
|
"local_port": string,
|
||||||
|
"local_port_num": integer,
|
||||||
|
"foreign_address": string,
|
||||||
|
"foreign_port": string,
|
||||||
|
"foreign_port_num": integer,
|
||||||
|
"state": string,
|
||||||
|
"program_name": string,
|
||||||
|
"pid": integer,
|
||||||
|
"user": string,
|
||||||
|
"security_context": string,
|
||||||
|
"refcnt": integer,
|
||||||
|
"flags": string,
|
||||||
|
"type": string,
|
||||||
|
"inode": integer,
|
||||||
|
"path": string,
|
||||||
|
"kind": string,
|
||||||
|
"address": string,
|
||||||
|
"unix_inode": string,
|
||||||
|
"conn": string,
|
||||||
|
"refs": string,
|
||||||
|
"nextref": string,
|
||||||
|
"name": string,
|
||||||
|
"unit": integer,
|
||||||
|
"vendor": integer,
|
||||||
|
"class": integer,
|
||||||
|
"subcla": integer,
|
||||||
|
"unix_flags": integer,
|
||||||
|
"pcbcount": integer,
|
||||||
|
"rcvbuf": integer,
|
||||||
|
"sndbuf": integer,
|
||||||
|
"rxbytes": integer,
|
||||||
|
"txbytes": integer,
|
||||||
|
"destination": string,
|
||||||
|
"gateway": string,
|
||||||
|
"route_flags": string,
|
||||||
|
"route_flags_pretty": [
|
||||||
|
string,
|
||||||
|
]
|
||||||
|
"route_refs": integer,
|
||||||
|
"use": integer,
|
||||||
|
"mtu": integer,
|
||||||
|
"expire": string,
|
||||||
|
"genmask": string,
|
||||||
|
"mss": integer,
|
||||||
|
"window": integer,
|
||||||
|
"irtt": integer,
|
||||||
|
"iface": string,
|
||||||
|
"metric": integer,
|
||||||
|
"network": string,
|
||||||
|
"address": string,
|
||||||
|
"ipkts": integer, # - = null
|
||||||
|
"ierrs": integer, # - = null
|
||||||
|
"idrop": integer, # - = null
|
||||||
|
"opkts": integer, # - = null
|
||||||
|
"oerrs": integer, # - = null
|
||||||
|
"coll": integer, # - = null
|
||||||
|
"rx_ok": integer,
|
||||||
|
"rx_err": integer,
|
||||||
|
"rx_drp": integer,
|
||||||
|
"rx_ovr": integer,
|
||||||
|
"tx_ok": integer,
|
||||||
|
"tx_err": integer,
|
||||||
|
"tx_drp": integer,
|
||||||
|
"tx_ovr": integer,
|
||||||
|
"flg": string,
|
||||||
|
"ibytes": integer,
|
||||||
|
"obytes": integer,
|
||||||
|
"r_mbuf": integer,
|
||||||
|
"s_mbuf": integer,
|
||||||
|
"r_clus": integer,
|
||||||
|
"s_clus": integer,
|
||||||
|
"r_hiwa": integer,
|
||||||
|
"s_hiwa": integer,
|
||||||
|
"r_lowa": integer,
|
||||||
|
"s_lowa": integer,
|
||||||
|
"r_bcnt": integer,
|
||||||
|
"s_bcnt": integer,
|
||||||
|
"r_bmax": integer,
|
||||||
|
"s_bmax": integer,
|
||||||
|
"rexmit": integer,
|
||||||
|
"ooorcv": integer,
|
||||||
|
"0_win": integer,
|
||||||
|
"rexmt": float,
|
||||||
|
"persist": float,
|
||||||
|
"keep": float,
|
||||||
|
"2msl": float,
|
||||||
|
"delack": float,
|
||||||
|
"rcvtime": float,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -259,122 +360,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"proto": string,
|
|
||||||
"recv_q": integer,
|
|
||||||
"send_q": integer,
|
|
||||||
"transport_protocol" string,
|
|
||||||
"network_protocol": string,
|
|
||||||
"local_address": string,
|
|
||||||
"local_port": string,
|
|
||||||
"local_port_num": integer,
|
|
||||||
"foreign_address": string,
|
|
||||||
"foreign_port": string,
|
|
||||||
"foreign_port_num": integer,
|
|
||||||
"state": string,
|
|
||||||
"program_name": string,
|
|
||||||
"pid": integer,
|
|
||||||
"user": string,
|
|
||||||
"security_context": string,
|
|
||||||
"refcnt": integer,
|
|
||||||
"flags": string,
|
|
||||||
"type": string,
|
|
||||||
"inode": integer,
|
|
||||||
"path": string,
|
|
||||||
"kind": string,
|
|
||||||
"address": string,
|
|
||||||
"unix_inode": string,
|
|
||||||
"conn": string,
|
|
||||||
"refs": string,
|
|
||||||
"nextref": string,
|
|
||||||
"name": string,
|
|
||||||
"unit": integer,
|
|
||||||
"vendor": integer,
|
|
||||||
"class": integer,
|
|
||||||
"subcla": integer,
|
|
||||||
"unix_flags": integer,
|
|
||||||
"pcbcount": integer,
|
|
||||||
"rcvbuf": integer,
|
|
||||||
"sndbuf": integer,
|
|
||||||
"rxbytes": integer,
|
|
||||||
"txbytes": integer,
|
|
||||||
"destination": string,
|
|
||||||
"gateway": string,
|
|
||||||
"route_flags": string,
|
|
||||||
"route_flags_pretty": [
|
|
||||||
string,
|
|
||||||
]
|
|
||||||
"route_refs": integer,
|
|
||||||
"use": integer,
|
|
||||||
"mtu": integer,
|
|
||||||
"expire": string,
|
|
||||||
"genmask": string,
|
|
||||||
"mss": integer,
|
|
||||||
"window": integer,
|
|
||||||
"irtt": integer,
|
|
||||||
"iface": string,
|
|
||||||
"metric": integer,
|
|
||||||
"network": string,
|
|
||||||
"address": string,
|
|
||||||
"ipkts": integer, - = null
|
|
||||||
"ierrs": integer, - = null
|
|
||||||
"idrop": integer, - = null
|
|
||||||
"opkts": integer, - = null
|
|
||||||
"oerrs": integer, - = null
|
|
||||||
"coll": integer, - = null
|
|
||||||
"rx_ok": integer,
|
|
||||||
"rx_err": integer,
|
|
||||||
"rx_drp": integer,
|
|
||||||
"rx_ovr": integer,
|
|
||||||
"tx_ok": integer,
|
|
||||||
"tx_err": integer,
|
|
||||||
"tx_drp": integer,
|
|
||||||
"tx_ovr": integer,
|
|
||||||
"flg": string,
|
|
||||||
"ibytes": integer,
|
|
||||||
"obytes": integer,
|
|
||||||
"r_mbuf": integer,
|
|
||||||
"s_mbuf": integer,
|
|
||||||
"r_clus": integer,
|
|
||||||
"s_clus": integer,
|
|
||||||
"r_hiwa": integer,
|
|
||||||
"s_hiwa": integer,
|
|
||||||
"r_lowa": integer,
|
|
||||||
"s_lowa": integer,
|
|
||||||
"r_bcnt": integer,
|
|
||||||
"s_bcnt": integer,
|
|
||||||
"r_bmax": integer,
|
|
||||||
"s_bmax": integer,
|
|
||||||
"rexmit": integer,
|
|
||||||
"ooorcv": integer,
|
|
||||||
"0_win": integer,
|
|
||||||
"rexmt": float,
|
|
||||||
"persist": float,
|
|
||||||
"keep": float,
|
|
||||||
"2msl": float,
|
|
||||||
"delack": float,
|
|
||||||
"rcvtime": float,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,24 @@ Usage (module):
|
|||||||
import jc.parsers.ntpq
|
import jc.parsers.ntpq
|
||||||
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"state": string, # space/~ converted to null
|
||||||
|
"remote": string,
|
||||||
|
"refid": string,
|
||||||
|
"st": integer,
|
||||||
|
"t": string,
|
||||||
|
"when": integer, # - converted to null
|
||||||
|
"poll": integer,
|
||||||
|
"reach": integer,
|
||||||
|
"delay": float,
|
||||||
|
"offset": float,
|
||||||
|
"jitter": float
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'freebsd'
|
'linux', 'freebsd'
|
||||||
@ -194,40 +212,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"state": string, # space/~ converted to null
|
|
||||||
"remote": string,
|
|
||||||
"refid": string,
|
|
||||||
"st": integer,
|
|
||||||
"t": string,
|
|
||||||
"when": integer, # - converted to null
|
|
||||||
"poll": integer,
|
|
||||||
"reach": integer,
|
|
||||||
"delay": float,
|
|
||||||
"offset": float,
|
|
||||||
"jitter": float
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -11,6 +11,20 @@ Usage (module):
|
|||||||
import jc.parsers.passwd
|
import jc.parsers.passwd
|
||||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"username": string,
|
||||||
|
"password": string,
|
||||||
|
"uid": integer,
|
||||||
|
"gid": integer,
|
||||||
|
"comment": string,
|
||||||
|
"home": string,
|
||||||
|
"shell": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'aix', 'freebsd'
|
||||||
@ -86,35 +100,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"username": string,
|
|
||||||
"password": string,
|
|
||||||
"uid": integer,
|
|
||||||
"gid": integer,
|
|
||||||
"comment": string,
|
|
||||||
"home": string,
|
|
||||||
"shell": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -19,6 +19,36 @@ Usage (module):
|
|||||||
import jc.parsers.ping
|
import jc.parsers.ping
|
||||||
result = jc.parsers.ping.parse(ping_command_output)
|
result = jc.parsers.ping.parse(ping_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"source_ip": string,
|
||||||
|
"destination_ip": string,
|
||||||
|
"data_bytes": integer,
|
||||||
|
"pattern": string, # (null if not set)
|
||||||
|
"destination": string,
|
||||||
|
"packets_transmitted": integer,
|
||||||
|
"packets_received": integer,
|
||||||
|
"packet_loss_percent": float,
|
||||||
|
"duplicates": integer,
|
||||||
|
"round_trip_ms_min": float,
|
||||||
|
"round_trip_ms_avg": float,
|
||||||
|
"round_trip_ms_max": float,
|
||||||
|
"round_trip_ms_stddev": float,
|
||||||
|
"responses": [
|
||||||
|
{
|
||||||
|
"type": string, # ('reply' or 'timeout')
|
||||||
|
"timestamp": float,
|
||||||
|
"bytes": integer,
|
||||||
|
"response_ip": string,
|
||||||
|
"icmp_seq": integer,
|
||||||
|
"ttl": integer,
|
||||||
|
"time_ms": float,
|
||||||
|
"duplicate": boolean
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -121,51 +151,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (Dictionary) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
|
||||||
|
|
||||||
{
|
|
||||||
"source_ip": string,
|
|
||||||
"destination_ip": string,
|
|
||||||
"data_bytes": integer,
|
|
||||||
"pattern": string, (null if not set)
|
|
||||||
"destination": string,
|
|
||||||
"packets_transmitted": integer,
|
|
||||||
"packets_received": integer,
|
|
||||||
"packet_loss_percent": float,
|
|
||||||
"duplicates": integer,
|
|
||||||
"round_trip_ms_min": float,
|
|
||||||
"round_trip_ms_avg": float,
|
|
||||||
"round_trip_ms_max": float,
|
|
||||||
"round_trip_ms_stddev": float,
|
|
||||||
"responses": [
|
|
||||||
{
|
|
||||||
"type": string, ('reply' or 'timeout')
|
|
||||||
"timestamp": float,
|
|
||||||
"bytes": integer,
|
|
||||||
"response_ip": string,
|
|
||||||
"icmp_seq": integer,
|
|
||||||
"ttl": integer,
|
|
||||||
"time_ms": float,
|
|
||||||
"duplicate": boolean
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,16 @@ Usage (module):
|
|||||||
import jc.parsers.pip_list
|
import jc.parsers.pip_list
|
||||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"package": string,
|
||||||
|
"version": string,
|
||||||
|
"location": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -43,31 +53,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"package": string,
|
|
||||||
"version": string,
|
|
||||||
"location": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,23 @@ Usage (module):
|
|||||||
import jc.parsers.pip_show
|
import jc.parsers.pip_show
|
||||||
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"version": string,
|
||||||
|
"summary": string,
|
||||||
|
"home_page": string,
|
||||||
|
"author": string,
|
||||||
|
"author_email": string,
|
||||||
|
"license": string,
|
||||||
|
"location": string,
|
||||||
|
"requires": string,
|
||||||
|
"required_by": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -54,39 +71,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"version": string,
|
|
||||||
"summary": string,
|
|
||||||
"home_page": string,
|
|
||||||
"author": string,
|
|
||||||
"author_email": string,
|
|
||||||
"license": string,
|
|
||||||
"location": string,
|
|
||||||
"requires": string,
|
|
||||||
"required_by": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -19,6 +19,30 @@ Usage (module):
|
|||||||
import jc.parsers.ps
|
import jc.parsers.ps
|
||||||
result = jc.parsers.ps.parse(ps_command_output)
|
result = jc.parsers.ps.parse(ps_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"uid": string,
|
||||||
|
"pid": integer,
|
||||||
|
"ppid": integer,
|
||||||
|
"c": integer,
|
||||||
|
"stime": string,
|
||||||
|
"tty": string, # ? or ?? = Null
|
||||||
|
"tt": string, # ?? = Null
|
||||||
|
"time": string,
|
||||||
|
"cmd": string,
|
||||||
|
"user": string,
|
||||||
|
"cpu_percent": float,
|
||||||
|
"mem_percent": float,
|
||||||
|
"vsz": integer,
|
||||||
|
"rss": integer,
|
||||||
|
"stat": string,
|
||||||
|
"start": string,
|
||||||
|
"command": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -188,45 +212,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"uid": string,
|
|
||||||
"pid": integer,
|
|
||||||
"ppid": integer,
|
|
||||||
"c": integer,
|
|
||||||
"stime": string,
|
|
||||||
"tty": string, # ? or ?? = Null
|
|
||||||
"tt": string, # ?? = Null
|
|
||||||
"time": string,
|
|
||||||
"cmd": string,
|
|
||||||
"user": string,
|
|
||||||
"cpu_percent": float,
|
|
||||||
"mem_percent": float,
|
|
||||||
"vsz": integer,
|
|
||||||
"rss": integer,
|
|
||||||
"stat": string,
|
|
||||||
"start": string,
|
|
||||||
"command": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,27 @@ Usage (module):
|
|||||||
import jc.parsers.route
|
import jc.parsers.route
|
||||||
result = jc.parsers.route.parse(route_command_output)
|
result = jc.parsers.route.parse(route_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"destination": string,
|
||||||
|
"gateway": string,
|
||||||
|
"genmask": string,
|
||||||
|
"flags": string,
|
||||||
|
"flags_pretty": [
|
||||||
|
string,
|
||||||
|
]
|
||||||
|
"metric": integer,
|
||||||
|
"ref": integer,
|
||||||
|
"use": integer,
|
||||||
|
"mss": integer,
|
||||||
|
"window": integer,
|
||||||
|
"irtt": integer,
|
||||||
|
"iface": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -95,42 +116,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"destination": string,
|
|
||||||
"gateway": string,
|
|
||||||
"genmask": string,
|
|
||||||
"flags": string,
|
|
||||||
"flags_pretty": [
|
|
||||||
string,
|
|
||||||
]
|
|
||||||
"metric": integer,
|
|
||||||
"ref": integer,
|
|
||||||
"use": integer,
|
|
||||||
"mss": integer,
|
|
||||||
"window": integer,
|
|
||||||
"irtt": integer,
|
|
||||||
"iface": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -21,6 +21,34 @@ Usage (module):
|
|||||||
import jc.parsers.rpm_qi
|
import jc.parsers.rpm_qi
|
||||||
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"epoch": integer,
|
||||||
|
"version": string,
|
||||||
|
"release": string,
|
||||||
|
"architecture": string,
|
||||||
|
"install_date": string,
|
||||||
|
"group": string,
|
||||||
|
"size": integer,
|
||||||
|
"license": string,
|
||||||
|
"signature": string,
|
||||||
|
"source_rpm": string,
|
||||||
|
"build_date": string,
|
||||||
|
"build_epoch": integer, # naive timestamp
|
||||||
|
"build_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
||||||
|
"build_host": string,
|
||||||
|
"relocations": string,
|
||||||
|
"packager": string,
|
||||||
|
"vendor": string,
|
||||||
|
"url": string,
|
||||||
|
"summary": string,
|
||||||
|
"description": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -128,49 +156,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"epoch": integer,
|
|
||||||
"version": string,
|
|
||||||
"release": string,
|
|
||||||
"architecture": string,
|
|
||||||
"install_date": string,
|
|
||||||
"group": string,
|
|
||||||
"size": integer,
|
|
||||||
"license": string,
|
|
||||||
"signature": string,
|
|
||||||
"source_rpm": string,
|
|
||||||
"build_date": string,
|
|
||||||
"build_epoch": integer, # naive timestamp
|
|
||||||
"build_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
|
||||||
"build_host": string,
|
|
||||||
"relocations": string,
|
|
||||||
"packager": string,
|
|
||||||
"vendor": string,
|
|
||||||
"url": string,
|
|
||||||
"summary": string,
|
|
||||||
"description": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -11,6 +11,21 @@ Usage (module):
|
|||||||
import jc.parsers.shadow
|
import jc.parsers.shadow
|
||||||
result = jc.parsers.shadow.parse(shadow_file_output)
|
result = jc.parsers.shadow.parse(shadow_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"username": string,
|
||||||
|
"password": string,
|
||||||
|
"last_changed": integer,
|
||||||
|
"minimum": integer,
|
||||||
|
"maximum": integer,
|
||||||
|
"warn": integer,
|
||||||
|
"inactive": integer,
|
||||||
|
"expire": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'aix', 'freebsd'
|
||||||
@ -92,36 +107,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"username": string,
|
|
||||||
"password": string,
|
|
||||||
"last_changed": integer,
|
|
||||||
"minimum": integer,
|
|
||||||
"maximum": integer,
|
|
||||||
"warn": integer,
|
|
||||||
"inactive": integer,
|
|
||||||
"expire": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -2,6 +2,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.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ss | jc --ss
|
$ ss | jc --ss
|
||||||
@ -15,9 +17,29 @@ Usage (module):
|
|||||||
import jc.parsers.ss
|
import jc.parsers.ss
|
||||||
result = jc.parsers.ss.parse(ss_command_output)
|
result = jc.parsers.ss.parse(ss_command_output)
|
||||||
|
|
||||||
Limitations:
|
Schema:
|
||||||
|
|
||||||
Extended information options like -e and -p are not supported and may cause parsing irregularities
|
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"netid": string,
|
||||||
|
"state": string,
|
||||||
|
"recv_q": integer,
|
||||||
|
"send_q": integer,
|
||||||
|
"local_address": string,
|
||||||
|
"local_port": string,
|
||||||
|
"local_port_num": integer,
|
||||||
|
"peer_address": string,
|
||||||
|
"peer_port": string,
|
||||||
|
"peer_port_num": integer,
|
||||||
|
"interface": string,
|
||||||
|
"link_layer" string,
|
||||||
|
"channel": string,
|
||||||
|
"path": string,
|
||||||
|
"pid": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
@ -262,45 +284,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"netid": string,
|
|
||||||
"state": string,
|
|
||||||
"recv_q": integer,
|
|
||||||
"send_q": integer,
|
|
||||||
"local_address": string,
|
|
||||||
"local_port": string,
|
|
||||||
"local_port_num": integer,
|
|
||||||
"peer_address": string,
|
|
||||||
"peer_port": string,
|
|
||||||
"peer_port_num": integer,
|
|
||||||
"interface": string,
|
|
||||||
"link_layer" string,
|
|
||||||
"channel": string,
|
|
||||||
"path": string,
|
|
||||||
"pid": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -19,6 +19,44 @@ Usage (module):
|
|||||||
import jc.parsers.stat
|
import jc.parsers.stat
|
||||||
result = jc.parsers.stat.parse(stat_command_output)
|
result = jc.parsers.stat.parse(stat_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"file": string,
|
||||||
|
"link_to" string,
|
||||||
|
"size": integer,
|
||||||
|
"blocks": integer,
|
||||||
|
"io_blocks": integer,
|
||||||
|
"type": string,
|
||||||
|
"device": string,
|
||||||
|
"inode": integer,
|
||||||
|
"links": integer,
|
||||||
|
"access": string,
|
||||||
|
"flags": string,
|
||||||
|
"uid": integer,
|
||||||
|
"user": string,
|
||||||
|
"gid": integer,
|
||||||
|
"group": string,
|
||||||
|
"access_time": string, # - = null
|
||||||
|
"access_time_epoch": integer, # naive timestamp
|
||||||
|
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"modify_time": string, # - = null
|
||||||
|
"modify_time_epoch": integer, # naive timestamp
|
||||||
|
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"change_time": string, # - = null
|
||||||
|
"change_time_epoch": integer, # naive timestamp
|
||||||
|
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"birth_time": string, # - = null
|
||||||
|
"birth_time_epoch": integer, # naive timestamp
|
||||||
|
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"unix_device": integer,
|
||||||
|
"rdev": integer,
|
||||||
|
"block_size": integer,
|
||||||
|
"unix_flags": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -136,59 +174,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"file": string,
|
|
||||||
"link_to" string,
|
|
||||||
"size": integer,
|
|
||||||
"blocks": integer,
|
|
||||||
"io_blocks": integer,
|
|
||||||
"type": string,
|
|
||||||
"device": string,
|
|
||||||
"inode": integer,
|
|
||||||
"links": integer,
|
|
||||||
"access": string,
|
|
||||||
"flags": string,
|
|
||||||
"uid": integer,
|
|
||||||
"user": string,
|
|
||||||
"gid": integer,
|
|
||||||
"group": string,
|
|
||||||
"access_time": string, # - = null
|
|
||||||
"access_time_epoch": integer, # naive timestamp
|
|
||||||
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"modify_time": string, # - = null
|
|
||||||
"modify_time_epoch": integer, # naive timestamp
|
|
||||||
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"change_time": string, # - = null
|
|
||||||
"change_time_epoch": integer, # naive timestamp
|
|
||||||
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"birth_time": string, # - = null
|
|
||||||
"birth_time_epoch": integer, # naive timestamp
|
|
||||||
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"unix_device": integer,
|
|
||||||
"rdev": integer,
|
|
||||||
"block_size": integer,
|
|
||||||
"unix_flags": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -17,6 +17,14 @@ Usage (module):
|
|||||||
import jc.parsers.sysctl
|
import jc.parsers.sysctl
|
||||||
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"key1": string/integer/float, # best guess based on value
|
||||||
|
"key2": string/integer/float,
|
||||||
|
"key3": string/integer/float
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -52,29 +60,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (Dictionary) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
|
||||||
|
|
||||||
{
|
|
||||||
"foo": string/integer/float, # best guess based on value
|
|
||||||
"bar": string/integer/float,
|
|
||||||
"baz": string/integer/float
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,18 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl
|
import jc.parsers.systemctl
|
||||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"unit": string,
|
||||||
|
"load": string,
|
||||||
|
"active": string,
|
||||||
|
"sub": string,
|
||||||
|
"description": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -52,33 +64,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"unit": string,
|
|
||||||
"load": string,
|
|
||||||
"active": string,
|
|
||||||
"sub": string,
|
|
||||||
"description": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,17 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl_lj
|
import jc.parsers.systemctl_lj
|
||||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"job": integer,
|
||||||
|
"unit": string,
|
||||||
|
"type": string,
|
||||||
|
"state": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -66,37 +77,11 @@ Examples:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
## info
|
||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"job": integer,
|
|
||||||
"unit": string,
|
|
||||||
"type": string,
|
|
||||||
"state": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,16 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl_ls
|
import jc.parsers.systemctl_ls
|
||||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"listen": string,
|
||||||
|
"unit": string,
|
||||||
|
"activates": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -46,31 +56,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"listen": string,
|
|
||||||
"unit": string,
|
|
||||||
"activates": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,15 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl_luf
|
import jc.parsers.systemctl_luf
|
||||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"unit_file": string,
|
||||||
|
"state": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -43,30 +52,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"unit_file": string,
|
|
||||||
"state": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -17,6 +17,48 @@ Usage (module):
|
|||||||
import jc.parsers.time
|
import jc.parsers.time
|
||||||
result = jc.parsers.time.parse(time_command_output)
|
result = jc.parsers.time.parse(time_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
||||||
|
https://man7.org/linux/man-pages/man1/time.1.html
|
||||||
|
|
||||||
|
{
|
||||||
|
"real_time": float,
|
||||||
|
"user_time": float,
|
||||||
|
"system_time": float,
|
||||||
|
"elapsed_time": string,
|
||||||
|
"elapsed_time_hours": integer,
|
||||||
|
"elapsed_time_minutes": integer,
|
||||||
|
"elapsed_time_seconds": integer,
|
||||||
|
"elapsed_time_centiseconds": integer,
|
||||||
|
"elapsed_time_total_seconds": float,
|
||||||
|
"cpu_percent": integer, # null if ?
|
||||||
|
"average_shared_text_size": integer,
|
||||||
|
"average_unshared_data_size": integer,
|
||||||
|
"average_unshared_stack_size": integer,
|
||||||
|
"average_shared_memory_size": integer,
|
||||||
|
"maximum_resident_set_size": integer,
|
||||||
|
"block_input_operations": integer, # aka File system inputs
|
||||||
|
"block_output_operations": integer, # aka File system outputs
|
||||||
|
"major_pagefaults": integer,
|
||||||
|
"minor_pagefaults": integer,
|
||||||
|
"swaps": integer,
|
||||||
|
"page_reclaims": integer,
|
||||||
|
"page_faults": integer,
|
||||||
|
"messages_sent": integer,
|
||||||
|
"messages_received": integer,
|
||||||
|
"signals_received": integer,
|
||||||
|
"voluntary_context_switches": integer,
|
||||||
|
"involuntary_context_switches": integer
|
||||||
|
"command_being_timed": string,
|
||||||
|
"average_stack_size": integer,
|
||||||
|
"average_total_size": integer,
|
||||||
|
"average_resident_set_size": integer,
|
||||||
|
"signals_delivered": integer,
|
||||||
|
"page_size": integer,
|
||||||
|
"exit_status": integer
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -87,63 +129,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
|
||||||
|
|
||||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
|
||||||
https://man7.org/linux/man-pages/man1/time.1.html
|
|
||||||
|
|
||||||
{
|
|
||||||
"real_time": float,
|
|
||||||
"user_time": float,
|
|
||||||
"system_time": float,
|
|
||||||
"elapsed_time": string,
|
|
||||||
"elapsed_time_hours": integer,
|
|
||||||
"elapsed_time_minutes": integer,
|
|
||||||
"elapsed_time_seconds": integer,
|
|
||||||
"elapsed_time_centiseconds": integer,
|
|
||||||
"elapsed_time_total_seconds": float,
|
|
||||||
"cpu_percent": integer, # null if ?
|
|
||||||
"average_shared_text_size": integer,
|
|
||||||
"average_unshared_data_size": integer,
|
|
||||||
"average_unshared_stack_size": integer,
|
|
||||||
"average_shared_memory_size": integer,
|
|
||||||
"maximum_resident_set_size": integer,
|
|
||||||
"block_input_operations": integer, # aka File system inputs
|
|
||||||
"block_output_operations": integer, # aka File system outputs
|
|
||||||
"major_pagefaults": integer,
|
|
||||||
"minor_pagefaults": integer,
|
|
||||||
"swaps": integer,
|
|
||||||
"page_reclaims": integer,
|
|
||||||
"page_faults": integer,
|
|
||||||
"messages_sent": integer,
|
|
||||||
"messages_received": integer,
|
|
||||||
"signals_received": integer,
|
|
||||||
"voluntary_context_switches": integer,
|
|
||||||
"involuntary_context_switches": integer
|
|
||||||
"command_being_timed": string,
|
|
||||||
"average_stack_size": integer,
|
|
||||||
"average_total_size": integer,
|
|
||||||
"average_resident_set_size": integer,
|
|
||||||
"signals_delivered": integer,
|
|
||||||
"page_size": integer,
|
|
||||||
"exit_status": integer
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -17,6 +17,22 @@ Usage (module):
|
|||||||
import jc.parsers.timedatectl
|
import jc.parsers.timedatectl
|
||||||
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"local_time": string,
|
||||||
|
"universal_time": string,
|
||||||
|
"epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"rtc_time": string,
|
||||||
|
"time_zone": string,
|
||||||
|
"ntp_enabled": boolean,
|
||||||
|
"ntp_synchronized": boolean,
|
||||||
|
"system_clock_synchronized": boolean,
|
||||||
|
"systemd-timesyncd.service_active": boolean,
|
||||||
|
"rtc_in_local_tz": boolean,
|
||||||
|
"dst_active": boolean
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -53,37 +69,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (Dictionary) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
|
||||||
|
|
||||||
{
|
|
||||||
"local_time": string,
|
|
||||||
"universal_time": string,
|
|
||||||
"epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"rtc_time": string,
|
|
||||||
"time_zone": string,
|
|
||||||
"ntp_enabled": boolean,
|
|
||||||
"ntp_synchronized": boolean,
|
|
||||||
"system_clock_synchronized": boolean,
|
|
||||||
"systemd-timesyncd.service_active": boolean,
|
|
||||||
"rtc_in_local_tz": boolean,
|
|
||||||
"dst_active": boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -17,6 +17,25 @@ Usage (module):
|
|||||||
import jc.parsers.tracepath
|
import jc.parsers.tracepath
|
||||||
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"pmtu": integer,
|
||||||
|
"forward_hops": integer,
|
||||||
|
"return_hops": integer,
|
||||||
|
"hops": [
|
||||||
|
{
|
||||||
|
"ttl": integer,
|
||||||
|
"guess": boolean,
|
||||||
|
"host": string,
|
||||||
|
"reply_ms": float,
|
||||||
|
"pmtu": integer,
|
||||||
|
"asymmetric_difference": integer,
|
||||||
|
"reached": boolean
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -114,45 +133,11 @@ Examples:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
## info
|
||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (Dictionary) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
|
||||||
|
|
||||||
{
|
|
||||||
"pmtu": integer,
|
|
||||||
"forward_hops": integer,
|
|
||||||
"return_hops": integer,
|
|
||||||
"hops": [
|
|
||||||
{
|
|
||||||
"ttl": integer,
|
|
||||||
"guess": boolean,
|
|
||||||
"host": string,
|
|
||||||
"reply_ms": float,
|
|
||||||
"pmtu": integer,
|
|
||||||
"asymmetric_difference": integer,
|
|
||||||
"reached": boolean
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -21,6 +21,27 @@ Usage (module):
|
|||||||
import jc.parsers.traceroute
|
import jc.parsers.traceroute
|
||||||
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"destination_ip": string,
|
||||||
|
"destination_name": string,
|
||||||
|
"hops": [
|
||||||
|
{
|
||||||
|
"hop": integer,
|
||||||
|
"probes": [
|
||||||
|
{
|
||||||
|
"annotation": string,
|
||||||
|
"asn": integer,
|
||||||
|
"ip": string,
|
||||||
|
"name": string,
|
||||||
|
"rtt": float
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -102,48 +123,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## Hop
|
|
||||||
```python
|
|
||||||
Hop(idx)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## process
|
|
||||||
```python
|
|
||||||
process(proc_data)
|
|
||||||
```
|
|
||||||
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (Dictionary) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
|
||||||
|
|
||||||
{
|
|
||||||
"destination_ip": string,
|
|
||||||
"destination_name": string,
|
|
||||||
"hops": [
|
|
||||||
{
|
|
||||||
"hop": integer,
|
|
||||||
"probes": [
|
|
||||||
{
|
|
||||||
"annotation": string,
|
|
||||||
"asn": integer,
|
|
||||||
"ip": string,
|
|
||||||
"name": string,
|
|
||||||
"rtt": float
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,18 @@ Usage (module):
|
|||||||
import jc.parsers.jobs
|
import jc.parsers.jobs
|
||||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"job_number": integer,
|
||||||
|
"pid": integer,
|
||||||
|
"history": string,
|
||||||
|
"status": string,
|
||||||
|
"command": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -86,7 +98,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.2'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.3'
|
||||||
description = '`jobs` command parser'
|
description = '`jobs` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -99,7 +112,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -109,17 +122,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"job_number": integer,
|
|
||||||
"pid": integer,
|
|
||||||
"history": string,
|
|
||||||
"status": string,
|
|
||||||
"command": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['job_number', 'pid']
|
int_list = ['job_number', 'pid']
|
||||||
@ -208,4 +211,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -4,7 +4,6 @@ Supports files containing simple key/value pairs. Delimiter can be `=` or `:`. M
|
|||||||
|
|
||||||
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):
|
||||||
|
|
||||||
$ cat foo.txt | jc --kv
|
$ cat foo.txt | jc --kv
|
||||||
@ -14,6 +13,15 @@ Usage (module):
|
|||||||
import jc.parsers.kv
|
import jc.parsers.kv
|
||||||
result = jc.parsers.kv.parse(kv_file_output)
|
result = jc.parsers.kv.parse(kv_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
key/value document converted to a dictionary - see configparser standard library documentation for more details.
|
||||||
|
|
||||||
|
{
|
||||||
|
"key1": string,
|
||||||
|
"key2": string
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -42,7 +50,8 @@ Examples:
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.1'
|
||||||
description = 'Key/Value file parser'
|
description = 'Key/Value file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
@ -17,6 +17,22 @@ Usage (module):
|
|||||||
import jc.parsers.last
|
import jc.parsers.last
|
||||||
result = jc.parsers.last.parse(last_command_output)
|
result = jc.parsers.last.parse(last_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"user": string,
|
||||||
|
"tty": string,
|
||||||
|
"hostname": string,
|
||||||
|
"login": string,
|
||||||
|
"logout": string,
|
||||||
|
"duration": string,
|
||||||
|
"login_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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'aix', 'freebsd'
|
||||||
@ -91,7 +107,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.5'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.6'
|
||||||
description = '`last` and `lastb` command parser'
|
description = '`last` and `lastb` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -105,7 +122,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -115,21 +132,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"user": string,
|
|
||||||
"tty": string,
|
|
||||||
"hostname": string,
|
|
||||||
"login": string,
|
|
||||||
"logout": string,
|
|
||||||
"duration": string,
|
|
||||||
"login_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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
if 'user' in entry and entry['user'] == 'boot_time':
|
if 'user' in entry and entry['user'] == 'boot_time':
|
||||||
@ -253,4 +256,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -24,6 +24,23 @@ Usage (module):
|
|||||||
import jc.parsers.ls
|
import jc.parsers.ls
|
||||||
result = jc.parsers.ls.parse(ls_command_output)
|
result = jc.parsers.ls.parse(ls_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": string,
|
||||||
|
"flags": string,
|
||||||
|
"links": integer,
|
||||||
|
"parent": string,
|
||||||
|
"owner": string,
|
||||||
|
"group": string,
|
||||||
|
"size": integer,
|
||||||
|
"date": string,
|
||||||
|
"epoch": integer, # naive timestamp if date field exists and can be converted
|
||||||
|
"epoch_utc": integer # timezone aware timestamp if date field is in UTC and can be converted
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -157,7 +174,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.7'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.8'
|
||||||
description = '`ls` command parser'
|
description = '`ls` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -170,7 +188,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -180,22 +198,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"filename": string,
|
|
||||||
"flags": string,
|
|
||||||
"links": integer,
|
|
||||||
"parent": string,
|
|
||||||
"owner": string,
|
|
||||||
"group": string,
|
|
||||||
"size": integer,
|
|
||||||
"date": string,
|
|
||||||
"epoch": integer, # naive timestamp if date field exists and can be converted
|
|
||||||
"epoch_utc": integer # timezone aware timestamp if date field is in UTC and can be converted
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['links', 'size']
|
int_list = ['links', 'size']
|
||||||
@ -337,4 +340,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,53 @@ Usage (module):
|
|||||||
import jc.parsers.lsblk
|
import jc.parsers.lsblk
|
||||||
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"maj_min": string,
|
||||||
|
"rm": boolean,
|
||||||
|
"size": string,
|
||||||
|
"ro": boolean,
|
||||||
|
"type": string,
|
||||||
|
"mountpoint": string,
|
||||||
|
"kname": string,
|
||||||
|
"fstype": string,
|
||||||
|
"label": string,
|
||||||
|
"uuid": string,
|
||||||
|
"partlabel": string,
|
||||||
|
"partuuid": string,
|
||||||
|
"ra": integer,
|
||||||
|
"model": string,
|
||||||
|
"serial": string,
|
||||||
|
"state": string,
|
||||||
|
"owner": string,
|
||||||
|
"group": string,
|
||||||
|
"mode": string,
|
||||||
|
"alignment": integer,
|
||||||
|
"min_io": integer,
|
||||||
|
"opt_io": integer,
|
||||||
|
"phy_sec": integer,
|
||||||
|
"log_sec": integer,
|
||||||
|
"rota": boolean,
|
||||||
|
"sched": string,
|
||||||
|
"rq_size": integer,
|
||||||
|
"disc_aln": integer,
|
||||||
|
"disc_gran": string,
|
||||||
|
"disc_max": string,
|
||||||
|
"disc_zero": boolean,
|
||||||
|
"wsame": string,
|
||||||
|
"wwn": string,
|
||||||
|
"rand": boolean,
|
||||||
|
"pkname": string,
|
||||||
|
"hctl": string,
|
||||||
|
"tran": string,
|
||||||
|
"rev": string,
|
||||||
|
"vendor": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -225,7 +272,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.5'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.6'
|
||||||
description = '`lsblk` command parser'
|
description = '`lsblk` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -238,7 +286,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -248,52 +296,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"maj_min": string,
|
|
||||||
"rm": boolean,
|
|
||||||
"size": string,
|
|
||||||
"ro": boolean,
|
|
||||||
"type": string,
|
|
||||||
"mountpoint": string,
|
|
||||||
"kname": string,
|
|
||||||
"fstype": string,
|
|
||||||
"label": string,
|
|
||||||
"uuid": string,
|
|
||||||
"partlabel": string,
|
|
||||||
"partuuid": string,
|
|
||||||
"ra": integer,
|
|
||||||
"model": string,
|
|
||||||
"serial": string,
|
|
||||||
"state": string,
|
|
||||||
"owner": string,
|
|
||||||
"group": string,
|
|
||||||
"mode": string,
|
|
||||||
"alignment": integer,
|
|
||||||
"min_io": integer,
|
|
||||||
"opt_io": integer,
|
|
||||||
"phy_sec": integer,
|
|
||||||
"log_sec": integer,
|
|
||||||
"rota": boolean,
|
|
||||||
"sched": string,
|
|
||||||
"rq_size": integer,
|
|
||||||
"disc_aln": integer,
|
|
||||||
"disc_gran": string,
|
|
||||||
"disc_max": string,
|
|
||||||
"disc_zero": boolean,
|
|
||||||
"wsame": string,
|
|
||||||
"wwn": string,
|
|
||||||
"rand": boolean,
|
|
||||||
"pkname": string,
|
|
||||||
"hctl": string,
|
|
||||||
"tran": string,
|
|
||||||
"rev": string,
|
|
||||||
"vendor": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# boolean changes
|
# boolean changes
|
||||||
@ -357,4 +360,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,19 @@ Usage (module):
|
|||||||
import jc.parsers.lsmod
|
import jc.parsers.lsmod
|
||||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"module": string,
|
||||||
|
"size": integer,
|
||||||
|
"used": integer,
|
||||||
|
"by": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -116,7 +129,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`lsmod` command parser'
|
description = '`lsmod` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -129,7 +143,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -139,18 +153,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"module": string,
|
|
||||||
"size": integer,
|
|
||||||
"used": integer,
|
|
||||||
"by": [
|
|
||||||
string
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# integer changes
|
# integer changes
|
||||||
@ -199,4 +202,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,23 @@ Usage (module):
|
|||||||
import jc.parsers.lsof
|
import jc.parsers.lsof
|
||||||
result = jc.parsers.lsof.parse(lsof_command_output)
|
result = jc.parsers.lsof.parse(lsof_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"command": string,
|
||||||
|
"pid": integer,
|
||||||
|
"tid": integer,
|
||||||
|
"user": string,
|
||||||
|
"fd": string,
|
||||||
|
"type": string,
|
||||||
|
"device": string,
|
||||||
|
"size_off": integer,
|
||||||
|
"node": integer,
|
||||||
|
"name": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -106,7 +123,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.2'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.3'
|
||||||
description = '`lsof` command parser'
|
description = '`lsof` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -119,7 +137,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -129,22 +147,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"command": string,
|
|
||||||
"pid": integer,
|
|
||||||
"tid": integer,
|
|
||||||
"user": string,
|
|
||||||
"fd": string,
|
|
||||||
"type": string,
|
|
||||||
"device": string,
|
|
||||||
"size_off": integer,
|
|
||||||
"node": integer,
|
|
||||||
"name": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# integer changes
|
# integer changes
|
||||||
@ -191,4 +194,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,19 @@ Usage (module):
|
|||||||
import jc.parsers.mount
|
import jc.parsers.mount
|
||||||
result = jc.parsers.mount.parse(mount_command_output)
|
result = jc.parsers.mount.parse(mount_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": string,
|
||||||
|
"mount_point": string,
|
||||||
|
"type": string,
|
||||||
|
"access": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -65,7 +78,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.5'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.6'
|
||||||
description = '`mount` command parser'
|
description = '`mount` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -78,7 +92,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -88,24 +102,13 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"filesystem": string,
|
|
||||||
"mount_point": string,
|
|
||||||
"type": string,
|
|
||||||
"access": [
|
|
||||||
string
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
# nothing to process
|
# nothing to process
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def osx_parse(data):
|
def _osx_parse(data):
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for entry in data:
|
for entry in data:
|
||||||
@ -130,7 +133,7 @@ def osx_parse(data):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def linux_parse(data):
|
def _linux_parse(data):
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for entry in data:
|
for entry in data:
|
||||||
@ -175,12 +178,12 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
# check for OSX output
|
# check for OSX output
|
||||||
if ' type ' not in cleandata[0]:
|
if ' type ' not in cleandata[0]:
|
||||||
raw_output = osx_parse(cleandata)
|
raw_output = _osx_parse(cleandata)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raw_output = linux_parse(cleandata)
|
raw_output = _linux_parse(cleandata)
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -17,6 +17,107 @@ Usage (module):
|
|||||||
import jc.parsers.netstat
|
import jc.parsers.netstat
|
||||||
result = jc.parsers.netstat.parse(netstat_command_output)
|
result = jc.parsers.netstat.parse(netstat_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"proto": string,
|
||||||
|
"recv_q": integer,
|
||||||
|
"send_q": integer,
|
||||||
|
"transport_protocol" string,
|
||||||
|
"network_protocol": string,
|
||||||
|
"local_address": string,
|
||||||
|
"local_port": string,
|
||||||
|
"local_port_num": integer,
|
||||||
|
"foreign_address": string,
|
||||||
|
"foreign_port": string,
|
||||||
|
"foreign_port_num": integer,
|
||||||
|
"state": string,
|
||||||
|
"program_name": string,
|
||||||
|
"pid": integer,
|
||||||
|
"user": string,
|
||||||
|
"security_context": string,
|
||||||
|
"refcnt": integer,
|
||||||
|
"flags": string,
|
||||||
|
"type": string,
|
||||||
|
"inode": integer,
|
||||||
|
"path": string,
|
||||||
|
"kind": string,
|
||||||
|
"address": string,
|
||||||
|
"unix_inode": string,
|
||||||
|
"conn": string,
|
||||||
|
"refs": string,
|
||||||
|
"nextref": string,
|
||||||
|
"name": string,
|
||||||
|
"unit": integer,
|
||||||
|
"vendor": integer,
|
||||||
|
"class": integer,
|
||||||
|
"subcla": integer,
|
||||||
|
"unix_flags": integer,
|
||||||
|
"pcbcount": integer,
|
||||||
|
"rcvbuf": integer,
|
||||||
|
"sndbuf": integer,
|
||||||
|
"rxbytes": integer,
|
||||||
|
"txbytes": integer,
|
||||||
|
"destination": string,
|
||||||
|
"gateway": string,
|
||||||
|
"route_flags": string,
|
||||||
|
"route_flags_pretty": [
|
||||||
|
string,
|
||||||
|
]
|
||||||
|
"route_refs": integer,
|
||||||
|
"use": integer,
|
||||||
|
"mtu": integer,
|
||||||
|
"expire": string,
|
||||||
|
"genmask": string,
|
||||||
|
"mss": integer,
|
||||||
|
"window": integer,
|
||||||
|
"irtt": integer,
|
||||||
|
"iface": string,
|
||||||
|
"metric": integer,
|
||||||
|
"network": string,
|
||||||
|
"address": string,
|
||||||
|
"ipkts": integer, # - = null
|
||||||
|
"ierrs": integer, # - = null
|
||||||
|
"idrop": integer, # - = null
|
||||||
|
"opkts": integer, # - = null
|
||||||
|
"oerrs": integer, # - = null
|
||||||
|
"coll": integer, # - = null
|
||||||
|
"rx_ok": integer,
|
||||||
|
"rx_err": integer,
|
||||||
|
"rx_drp": integer,
|
||||||
|
"rx_ovr": integer,
|
||||||
|
"tx_ok": integer,
|
||||||
|
"tx_err": integer,
|
||||||
|
"tx_drp": integer,
|
||||||
|
"tx_ovr": integer,
|
||||||
|
"flg": string,
|
||||||
|
"ibytes": integer,
|
||||||
|
"obytes": integer,
|
||||||
|
"r_mbuf": integer,
|
||||||
|
"s_mbuf": integer,
|
||||||
|
"r_clus": integer,
|
||||||
|
"s_clus": integer,
|
||||||
|
"r_hiwa": integer,
|
||||||
|
"s_hiwa": integer,
|
||||||
|
"r_lowa": integer,
|
||||||
|
"s_lowa": integer,
|
||||||
|
"r_bcnt": integer,
|
||||||
|
"s_bcnt": integer,
|
||||||
|
"r_bmax": integer,
|
||||||
|
"s_bmax": integer,
|
||||||
|
"rexmit": integer,
|
||||||
|
"ooorcv": integer,
|
||||||
|
"0_win": integer,
|
||||||
|
"rexmt": float,
|
||||||
|
"persist": float,
|
||||||
|
"keep": float,
|
||||||
|
"2msl": float,
|
||||||
|
"delack": float,
|
||||||
|
"rcvtime": float,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -255,7 +356,8 @@ Examples:
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.8'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.9'
|
||||||
description = '`netstat` command parser'
|
description = '`netstat` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -268,7 +370,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -278,106 +380,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"proto": string,
|
|
||||||
"recv_q": integer,
|
|
||||||
"send_q": integer,
|
|
||||||
"transport_protocol" string,
|
|
||||||
"network_protocol": string,
|
|
||||||
"local_address": string,
|
|
||||||
"local_port": string,
|
|
||||||
"local_port_num": integer,
|
|
||||||
"foreign_address": string,
|
|
||||||
"foreign_port": string,
|
|
||||||
"foreign_port_num": integer,
|
|
||||||
"state": string,
|
|
||||||
"program_name": string,
|
|
||||||
"pid": integer,
|
|
||||||
"user": string,
|
|
||||||
"security_context": string,
|
|
||||||
"refcnt": integer,
|
|
||||||
"flags": string,
|
|
||||||
"type": string,
|
|
||||||
"inode": integer,
|
|
||||||
"path": string,
|
|
||||||
"kind": string,
|
|
||||||
"address": string,
|
|
||||||
"unix_inode": string,
|
|
||||||
"conn": string,
|
|
||||||
"refs": string,
|
|
||||||
"nextref": string,
|
|
||||||
"name": string,
|
|
||||||
"unit": integer,
|
|
||||||
"vendor": integer,
|
|
||||||
"class": integer,
|
|
||||||
"subcla": integer,
|
|
||||||
"unix_flags": integer,
|
|
||||||
"pcbcount": integer,
|
|
||||||
"rcvbuf": integer,
|
|
||||||
"sndbuf": integer,
|
|
||||||
"rxbytes": integer,
|
|
||||||
"txbytes": integer,
|
|
||||||
"destination": string,
|
|
||||||
"gateway": string,
|
|
||||||
"route_flags": string,
|
|
||||||
"route_flags_pretty": [
|
|
||||||
string,
|
|
||||||
]
|
|
||||||
"route_refs": integer,
|
|
||||||
"use": integer,
|
|
||||||
"mtu": integer,
|
|
||||||
"expire": string,
|
|
||||||
"genmask": string,
|
|
||||||
"mss": integer,
|
|
||||||
"window": integer,
|
|
||||||
"irtt": integer,
|
|
||||||
"iface": string,
|
|
||||||
"metric": integer,
|
|
||||||
"network": string,
|
|
||||||
"address": string,
|
|
||||||
"ipkts": integer, - = null
|
|
||||||
"ierrs": integer, - = null
|
|
||||||
"idrop": integer, - = null
|
|
||||||
"opkts": integer, - = null
|
|
||||||
"oerrs": integer, - = null
|
|
||||||
"coll": integer, - = null
|
|
||||||
"rx_ok": integer,
|
|
||||||
"rx_err": integer,
|
|
||||||
"rx_drp": integer,
|
|
||||||
"rx_ovr": integer,
|
|
||||||
"tx_ok": integer,
|
|
||||||
"tx_err": integer,
|
|
||||||
"tx_drp": integer,
|
|
||||||
"tx_ovr": integer,
|
|
||||||
"flg": string,
|
|
||||||
"ibytes": integer,
|
|
||||||
"obytes": integer,
|
|
||||||
"r_mbuf": integer,
|
|
||||||
"s_mbuf": integer,
|
|
||||||
"r_clus": integer,
|
|
||||||
"s_clus": integer,
|
|
||||||
"r_hiwa": integer,
|
|
||||||
"s_hiwa": integer,
|
|
||||||
"r_lowa": integer,
|
|
||||||
"s_lowa": integer,
|
|
||||||
"r_bcnt": integer,
|
|
||||||
"s_bcnt": integer,
|
|
||||||
"r_bmax": integer,
|
|
||||||
"s_bmax": integer,
|
|
||||||
"rexmit": integer,
|
|
||||||
"ooorcv": integer,
|
|
||||||
"0_win": integer,
|
|
||||||
"rexmt": float,
|
|
||||||
"persist": float,
|
|
||||||
"keep": float,
|
|
||||||
"2msl": float,
|
|
||||||
"delack": float,
|
|
||||||
"rcvtime": float,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# integer changes
|
# integer changes
|
||||||
@ -467,4 +470,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,24 @@ Usage (module):
|
|||||||
import jc.parsers.ntpq
|
import jc.parsers.ntpq
|
||||||
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"state": string, # space/~ converted to null
|
||||||
|
"remote": string,
|
||||||
|
"refid": string,
|
||||||
|
"st": integer,
|
||||||
|
"t": string,
|
||||||
|
"when": integer, # - converted to null
|
||||||
|
"poll": integer,
|
||||||
|
"reach": integer,
|
||||||
|
"delay": float,
|
||||||
|
"offset": float,
|
||||||
|
"jitter": float
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'freebsd'
|
'linux', 'freebsd'
|
||||||
@ -192,7 +210,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`ntpq -p` command parser'
|
description = '`ntpq -p` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -205,7 +224,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -215,24 +234,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"state": string, # space/~ converted to null
|
|
||||||
"remote": string,
|
|
||||||
"refid": string,
|
|
||||||
"st": integer,
|
|
||||||
"t": string,
|
|
||||||
"when": integer, # - converted to null
|
|
||||||
"poll": integer,
|
|
||||||
"reach": integer,
|
|
||||||
"delay": float,
|
|
||||||
"offset": float,
|
|
||||||
"jitter": float
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
|
|
||||||
@ -305,4 +307,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -9,6 +9,20 @@ Usage (module):
|
|||||||
import jc.parsers.passwd
|
import jc.parsers.passwd
|
||||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"username": string,
|
||||||
|
"password": string,
|
||||||
|
"uid": integer,
|
||||||
|
"gid": integer,
|
||||||
|
"comment": string,
|
||||||
|
"home": string,
|
||||||
|
"shell": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'aix', 'freebsd'
|
||||||
@ -83,7 +97,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.1'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.2'
|
||||||
description = '`/etc/passwd` file parser'
|
description = '`/etc/passwd` file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -96,7 +111,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -106,19 +121,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"username": string,
|
|
||||||
"password": string,
|
|
||||||
"uid": integer,
|
|
||||||
"gid": integer,
|
|
||||||
"comment": string,
|
|
||||||
"home": string,
|
|
||||||
"shell": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['uid', 'gid']
|
int_list = ['uid', 'gid']
|
||||||
@ -177,4 +180,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -17,6 +17,36 @@ Usage (module):
|
|||||||
import jc.parsers.ping
|
import jc.parsers.ping
|
||||||
result = jc.parsers.ping.parse(ping_command_output)
|
result = jc.parsers.ping.parse(ping_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"source_ip": string,
|
||||||
|
"destination_ip": string,
|
||||||
|
"data_bytes": integer,
|
||||||
|
"pattern": string, # (null if not set)
|
||||||
|
"destination": string,
|
||||||
|
"packets_transmitted": integer,
|
||||||
|
"packets_received": integer,
|
||||||
|
"packet_loss_percent": float,
|
||||||
|
"duplicates": integer,
|
||||||
|
"round_trip_ms_min": float,
|
||||||
|
"round_trip_ms_avg": float,
|
||||||
|
"round_trip_ms_max": float,
|
||||||
|
"round_trip_ms_stddev": float,
|
||||||
|
"responses": [
|
||||||
|
{
|
||||||
|
"type": string, # ('reply' or 'timeout')
|
||||||
|
"timestamp": float,
|
||||||
|
"bytes": integer,
|
||||||
|
"response_ip": string,
|
||||||
|
"icmp_seq": integer,
|
||||||
|
"ttl": integer,
|
||||||
|
"time_ms": float,
|
||||||
|
"duplicate": boolean
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -119,7 +149,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.2'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.3'
|
||||||
description = '`ping` and `ping6` command parser'
|
description = '`ping` and `ping6` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -132,7 +163,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -142,35 +173,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
Dictionary. Structured data to conform to the schema.
|
||||||
|
|
||||||
{
|
|
||||||
"source_ip": string,
|
|
||||||
"destination_ip": string,
|
|
||||||
"data_bytes": integer,
|
|
||||||
"pattern": string, (null if not set)
|
|
||||||
"destination": string,
|
|
||||||
"packets_transmitted": integer,
|
|
||||||
"packets_received": integer,
|
|
||||||
"packet_loss_percent": float,
|
|
||||||
"duplicates": integer,
|
|
||||||
"round_trip_ms_min": float,
|
|
||||||
"round_trip_ms_avg": float,
|
|
||||||
"round_trip_ms_max": float,
|
|
||||||
"round_trip_ms_stddev": float,
|
|
||||||
"responses": [
|
|
||||||
{
|
|
||||||
"type": string, ('reply' or 'timeout')
|
|
||||||
"timestamp": float,
|
|
||||||
"bytes": integer,
|
|
||||||
"response_ip": string,
|
|
||||||
"icmp_seq": integer,
|
|
||||||
"ttl": integer,
|
|
||||||
"time_ms": float,
|
|
||||||
"duplicate": boolean
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
int_list = ['data_bytes', 'packets_transmitted', 'packets_received', 'bytes', 'icmp_seq', 'ttl', 'duplicates']
|
int_list = ['data_bytes', 'packets_transmitted', 'packets_received', 'bytes', 'icmp_seq', 'ttl', 'duplicates']
|
||||||
float_list = ['packet_loss_percent', 'round_trip_ms_min', 'round_trip_ms_avg', 'round_trip_ms_max',
|
float_list = ['packet_loss_percent', 'round_trip_ms_min', 'round_trip_ms_avg', 'round_trip_ms_max',
|
||||||
@ -208,7 +211,7 @@ def process(proc_data):
|
|||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def linux_parse(data):
|
def _linux_parse(data):
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
ping_responses = []
|
ping_responses = []
|
||||||
pattern = None
|
pattern = None
|
||||||
@ -357,7 +360,7 @@ def linux_parse(data):
|
|||||||
return raw_output
|
return raw_output
|
||||||
|
|
||||||
|
|
||||||
def bsd_parse(data):
|
def _bsd_parse(data):
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
ping_responses = []
|
ping_responses = []
|
||||||
pattern = None
|
pattern = None
|
||||||
@ -508,11 +511,11 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
if ' time ' in data.splitlines()[-2] or ' time ' in data.splitlines()[-3]:
|
if ' time ' in data.splitlines()[-2] or ' time ' in data.splitlines()[-3]:
|
||||||
raw_output = linux_parse(data)
|
raw_output = _linux_parse(data)
|
||||||
else:
|
else:
|
||||||
raw_output = bsd_parse(data)
|
raw_output = _bsd_parse(data)
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,16 @@ Usage (module):
|
|||||||
import jc.parsers.pip_list
|
import jc.parsers.pip_list
|
||||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"package": string,
|
||||||
|
"version": string,
|
||||||
|
"location": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -41,7 +51,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`pip list` command parser'
|
description = '`pip list` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -54,7 +65,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -64,15 +75,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"package": string,
|
|
||||||
"version": string,
|
|
||||||
"location": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
# no further processing
|
# no further processing
|
||||||
return proc_data
|
return proc_data
|
||||||
@ -123,4 +126,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,23 @@ Usage (module):
|
|||||||
import jc.parsers.pip_show
|
import jc.parsers.pip_show
|
||||||
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"version": string,
|
||||||
|
"summary": string,
|
||||||
|
"home_page": string,
|
||||||
|
"author": string,
|
||||||
|
"author_email": string,
|
||||||
|
"license": string,
|
||||||
|
"location": string,
|
||||||
|
"requires": string,
|
||||||
|
"required_by": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -51,7 +68,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.1'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.2'
|
||||||
description = '`pip show` command parser'
|
description = '`pip show` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -64,7 +82,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -74,23 +92,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"version": string,
|
|
||||||
"summary": string,
|
|
||||||
"home_page": string,
|
|
||||||
"author": string,
|
|
||||||
"author_email": string,
|
|
||||||
"license": string,
|
|
||||||
"location": string,
|
|
||||||
"requires": string,
|
|
||||||
"required_by": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# no further processing
|
# no further processing
|
||||||
return proc_data
|
return proc_data
|
||||||
@ -140,4 +142,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -17,6 +17,30 @@ Usage (module):
|
|||||||
import jc.parsers.ps
|
import jc.parsers.ps
|
||||||
result = jc.parsers.ps.parse(ps_command_output)
|
result = jc.parsers.ps.parse(ps_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"uid": string,
|
||||||
|
"pid": integer,
|
||||||
|
"ppid": integer,
|
||||||
|
"c": integer,
|
||||||
|
"stime": string,
|
||||||
|
"tty": string, # ? or ?? = Null
|
||||||
|
"tt": string, # ?? = Null
|
||||||
|
"time": string,
|
||||||
|
"cmd": string,
|
||||||
|
"user": string,
|
||||||
|
"cpu_percent": float,
|
||||||
|
"mem_percent": float,
|
||||||
|
"vsz": integer,
|
||||||
|
"rss": integer,
|
||||||
|
"stat": string,
|
||||||
|
"start": string,
|
||||||
|
"command": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -186,7 +210,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`ps` command parser'
|
description = '`ps` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -199,7 +224,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -209,29 +234,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"uid": string,
|
|
||||||
"pid": integer,
|
|
||||||
"ppid": integer,
|
|
||||||
"c": integer,
|
|
||||||
"stime": string,
|
|
||||||
"tty": string, # ? or ?? = Null
|
|
||||||
"tt": string, # ?? = Null
|
|
||||||
"time": string,
|
|
||||||
"cmd": string,
|
|
||||||
"user": string,
|
|
||||||
"cpu_percent": float,
|
|
||||||
"mem_percent": float,
|
|
||||||
"vsz": integer,
|
|
||||||
"rss": integer,
|
|
||||||
"stat": string,
|
|
||||||
"start": string,
|
|
||||||
"command": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# change key name '%cpu' to 'cpu_percent'
|
# change key name '%cpu' to 'cpu_percent'
|
||||||
@ -301,4 +304,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,27 @@ Usage (module):
|
|||||||
import jc.parsers.route
|
import jc.parsers.route
|
||||||
result = jc.parsers.route.parse(route_command_output)
|
result = jc.parsers.route.parse(route_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"destination": string,
|
||||||
|
"gateway": string,
|
||||||
|
"genmask": string,
|
||||||
|
"flags": string,
|
||||||
|
"flags_pretty": [
|
||||||
|
string,
|
||||||
|
]
|
||||||
|
"metric": integer,
|
||||||
|
"ref": integer,
|
||||||
|
"use": integer,
|
||||||
|
"mss": integer,
|
||||||
|
"window": integer,
|
||||||
|
"irtt": integer,
|
||||||
|
"iface": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -93,7 +114,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.4'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.5'
|
||||||
description = '`route` command parser'
|
description = '`route` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -106,7 +128,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -116,26 +138,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"destination": string,
|
|
||||||
"gateway": string,
|
|
||||||
"genmask": string,
|
|
||||||
"flags": string,
|
|
||||||
"flags_pretty": [
|
|
||||||
string,
|
|
||||||
]
|
|
||||||
"metric": integer,
|
|
||||||
"ref": integer,
|
|
||||||
"use": integer,
|
|
||||||
"mss": integer,
|
|
||||||
"window": integer,
|
|
||||||
"irtt": integer,
|
|
||||||
"iface": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['metric', 'ref', 'use', 'mss', 'window', 'irtt']
|
int_list = ['metric', 'ref', 'use', 'mss', 'window', 'irtt']
|
||||||
@ -207,4 +210,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -19,6 +19,34 @@ Usage (module):
|
|||||||
import jc.parsers.rpm_qi
|
import jc.parsers.rpm_qi
|
||||||
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"epoch": integer,
|
||||||
|
"version": string,
|
||||||
|
"release": string,
|
||||||
|
"architecture": string,
|
||||||
|
"install_date": string,
|
||||||
|
"group": string,
|
||||||
|
"size": integer,
|
||||||
|
"license": string,
|
||||||
|
"signature": string,
|
||||||
|
"source_rpm": string,
|
||||||
|
"build_date": string,
|
||||||
|
"build_epoch": integer, # naive timestamp
|
||||||
|
"build_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
||||||
|
"build_host": string,
|
||||||
|
"relocations": string,
|
||||||
|
"packager": string,
|
||||||
|
"vendor": string,
|
||||||
|
"url": string,
|
||||||
|
"summary": string,
|
||||||
|
"description": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -125,7 +153,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.1'
|
||||||
description = '`rpm -qi` command parser'
|
description = '`rpm -qi` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -139,7 +168,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -149,33 +178,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"epoch": integer,
|
|
||||||
"version": string,
|
|
||||||
"release": string,
|
|
||||||
"architecture": string,
|
|
||||||
"install_date": string,
|
|
||||||
"group": string,
|
|
||||||
"size": integer,
|
|
||||||
"license": string,
|
|
||||||
"signature": string,
|
|
||||||
"source_rpm": string,
|
|
||||||
"build_date": string,
|
|
||||||
"build_epoch": integer, # naive timestamp
|
|
||||||
"build_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
|
||||||
"build_host": string,
|
|
||||||
"relocations": string,
|
|
||||||
"packager": string,
|
|
||||||
"vendor": string,
|
|
||||||
"url": string,
|
|
||||||
"summary": string,
|
|
||||||
"description": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
|
|
||||||
@ -255,4 +258,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -9,6 +9,21 @@ Usage (module):
|
|||||||
import jc.parsers.shadow
|
import jc.parsers.shadow
|
||||||
result = jc.parsers.shadow.parse(shadow_file_output)
|
result = jc.parsers.shadow.parse(shadow_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"username": string,
|
||||||
|
"password": string,
|
||||||
|
"last_changed": integer,
|
||||||
|
"minimum": integer,
|
||||||
|
"maximum": integer,
|
||||||
|
"warn": integer,
|
||||||
|
"inactive": integer,
|
||||||
|
"expire": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'aix', 'freebsd'
|
||||||
@ -89,7 +104,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.1'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.2'
|
||||||
description = '`/etc/shadow` file parser'
|
description = '`/etc/shadow` file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -102,7 +118,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -112,20 +128,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"username": string,
|
|
||||||
"password": string,
|
|
||||||
"last_changed": integer,
|
|
||||||
"minimum": integer,
|
|
||||||
"maximum": integer,
|
|
||||||
"warn": integer,
|
|
||||||
"inactive": integer,
|
|
||||||
"expire": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['last_changed', 'minimum', 'maximum', 'warn', 'inactive', 'expire']
|
int_list = ['last_changed', 'minimum', 'maximum', 'warn', 'inactive', 'expire']
|
||||||
@ -185,4 +188,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""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.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ss | jc --ss
|
$ ss | jc --ss
|
||||||
@ -13,9 +15,29 @@ Usage (module):
|
|||||||
import jc.parsers.ss
|
import jc.parsers.ss
|
||||||
result = jc.parsers.ss.parse(ss_command_output)
|
result = jc.parsers.ss.parse(ss_command_output)
|
||||||
|
|
||||||
Limitations:
|
Schema:
|
||||||
|
|
||||||
Extended information options like -e and -p are not supported and may cause parsing irregularities
|
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"netid": string,
|
||||||
|
"state": string,
|
||||||
|
"recv_q": integer,
|
||||||
|
"send_q": integer,
|
||||||
|
"local_address": string,
|
||||||
|
"local_port": string,
|
||||||
|
"local_port_num": integer,
|
||||||
|
"peer_address": string,
|
||||||
|
"peer_port": string,
|
||||||
|
"peer_port_num": integer,
|
||||||
|
"interface": string,
|
||||||
|
"link_layer" string,
|
||||||
|
"channel": string,
|
||||||
|
"path": string,
|
||||||
|
"pid": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
@ -260,7 +282,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.2'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.3'
|
||||||
description = '`ss` command parser'
|
description = '`ss` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -273,7 +296,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -283,29 +306,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"netid": string,
|
|
||||||
"state": string,
|
|
||||||
"recv_q": integer,
|
|
||||||
"send_q": integer,
|
|
||||||
"local_address": string,
|
|
||||||
"local_port": string,
|
|
||||||
"local_port_num": integer,
|
|
||||||
"peer_address": string,
|
|
||||||
"peer_port": string,
|
|
||||||
"peer_port_num": integer,
|
|
||||||
"interface": string,
|
|
||||||
"link_layer" string,
|
|
||||||
"channel": string,
|
|
||||||
"path": string,
|
|
||||||
"pid": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['recv_q', 'send_q', 'pid']
|
int_list = ['recv_q', 'send_q', 'pid']
|
||||||
@ -419,4 +420,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -17,6 +17,44 @@ Usage (module):
|
|||||||
import jc.parsers.stat
|
import jc.parsers.stat
|
||||||
result = jc.parsers.stat.parse(stat_command_output)
|
result = jc.parsers.stat.parse(stat_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"file": string,
|
||||||
|
"link_to" string,
|
||||||
|
"size": integer,
|
||||||
|
"blocks": integer,
|
||||||
|
"io_blocks": integer,
|
||||||
|
"type": string,
|
||||||
|
"device": string,
|
||||||
|
"inode": integer,
|
||||||
|
"links": integer,
|
||||||
|
"access": string,
|
||||||
|
"flags": string,
|
||||||
|
"uid": integer,
|
||||||
|
"user": string,
|
||||||
|
"gid": integer,
|
||||||
|
"group": string,
|
||||||
|
"access_time": string, # - = null
|
||||||
|
"access_time_epoch": integer, # naive timestamp
|
||||||
|
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"modify_time": string, # - = null
|
||||||
|
"modify_time_epoch": integer, # naive timestamp
|
||||||
|
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"change_time": string, # - = null
|
||||||
|
"change_time_epoch": integer, # naive timestamp
|
||||||
|
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"birth_time": string, # - = null
|
||||||
|
"birth_time_epoch": integer, # naive timestamp
|
||||||
|
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"unix_device": integer,
|
||||||
|
"rdev": integer,
|
||||||
|
"block_size": integer,
|
||||||
|
"unix_flags": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -134,7 +172,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.6'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.7'
|
||||||
description = '`stat` command parser'
|
description = '`stat` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -147,7 +186,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -157,43 +196,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"file": string,
|
|
||||||
"link_to" string,
|
|
||||||
"size": integer,
|
|
||||||
"blocks": integer,
|
|
||||||
"io_blocks": integer,
|
|
||||||
"type": string,
|
|
||||||
"device": string,
|
|
||||||
"inode": integer,
|
|
||||||
"links": integer,
|
|
||||||
"access": string,
|
|
||||||
"flags": string,
|
|
||||||
"uid": integer,
|
|
||||||
"user": string,
|
|
||||||
"gid": integer,
|
|
||||||
"group": string,
|
|
||||||
"access_time": string, # - = null
|
|
||||||
"access_time_epoch": integer, # naive timestamp
|
|
||||||
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"modify_time": string, # - = null
|
|
||||||
"modify_time_epoch": integer, # naive timestamp
|
|
||||||
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"change_time": string, # - = null
|
|
||||||
"change_time_epoch": integer, # naive timestamp
|
|
||||||
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"birth_time": string, # - = null
|
|
||||||
"birth_time_epoch": integer, # naive timestamp
|
|
||||||
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"unix_device": integer,
|
|
||||||
"rdev": integer,
|
|
||||||
"block_size": integer,
|
|
||||||
"unix_flags": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['size', 'blocks', 'io_blocks', 'inode', 'links', 'uid', 'gid', 'unix_device', 'rdev', 'block_size']
|
int_list = ['size', 'blocks', 'io_blocks', 'inode', 'links', 'uid', 'gid', 'unix_device', 'rdev', 'block_size']
|
||||||
@ -349,4 +352,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -15,6 +15,14 @@ Usage (module):
|
|||||||
import jc.parsers.sysctl
|
import jc.parsers.sysctl
|
||||||
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"key1": string/integer/float, # best guess based on value
|
||||||
|
"key2": string/integer/float,
|
||||||
|
"key3": string/integer/float
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -49,7 +57,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.1'
|
||||||
description = '`sysctl` command parser'
|
description = '`sysctl` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -63,7 +72,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -73,13 +82,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
Dictionary. Structured data to conform to the schema.
|
||||||
|
|
||||||
{
|
|
||||||
"foo": string/integer/float, # best guess based on value
|
|
||||||
"bar": string/integer/float,
|
|
||||||
"baz": string/integer/float
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
for key in proc_data:
|
for key in proc_data:
|
||||||
try:
|
try:
|
||||||
@ -158,4 +161,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,18 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl
|
import jc.parsers.systemctl
|
||||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"unit": string,
|
||||||
|
"load": string,
|
||||||
|
"active": string,
|
||||||
|
"sub": string,
|
||||||
|
"description": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -49,7 +61,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`systemctl` command parser'
|
description = '`systemctl` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -62,7 +75,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -72,17 +85,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"unit": string,
|
|
||||||
"load": string,
|
|
||||||
"active": string,
|
|
||||||
"sub": string,
|
|
||||||
"description": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
# nothing more to process
|
# nothing more to process
|
||||||
return proc_data
|
return proc_data
|
||||||
@ -133,4 +136,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,17 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl_lj
|
import jc.parsers.systemctl_lj
|
||||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"job": integer,
|
||||||
|
"unit": string,
|
||||||
|
"type": string,
|
||||||
|
"state": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -62,13 +73,13 @@ Examples:
|
|||||||
"state": "waiting"
|
"state": "waiting"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`systemctl list-jobs` command parser'
|
description = '`systemctl list-jobs` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -81,7 +92,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -91,16 +102,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"job": integer,
|
|
||||||
"unit": string,
|
|
||||||
"type": string,
|
|
||||||
"state": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['job']
|
int_list = ['job']
|
||||||
@ -161,4 +163,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,16 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl_ls
|
import jc.parsers.systemctl_ls
|
||||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"listen": string,
|
||||||
|
"unit": string,
|
||||||
|
"activates": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -43,7 +53,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`systemctl list-sockets` command parser'
|
description = '`systemctl list-sockets` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -56,7 +67,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -66,15 +77,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"listen": string,
|
|
||||||
"unit": string,
|
|
||||||
"activates": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
# nothing more to process
|
# nothing more to process
|
||||||
return proc_data
|
return proc_data
|
||||||
@ -125,4 +128,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -13,6 +13,15 @@ Usage (module):
|
|||||||
import jc.parsers.systemctl_luf
|
import jc.parsers.systemctl_luf
|
||||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"unit_file": string,
|
||||||
|
"state": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -40,7 +49,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = '`systemctl list-unit-files` command parser'
|
description = '`systemctl list-unit-files` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -53,7 +63,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -63,14 +73,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"unit_file": string,
|
|
||||||
"state": string
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
# nothing more to process
|
# nothing more to process
|
||||||
return proc_data
|
return proc_data
|
||||||
@ -122,4 +125,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -15,6 +15,48 @@ Usage (module):
|
|||||||
import jc.parsers.time
|
import jc.parsers.time
|
||||||
result = jc.parsers.time.parse(time_command_output)
|
result = jc.parsers.time.parse(time_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
||||||
|
https://man7.org/linux/man-pages/man1/time.1.html
|
||||||
|
|
||||||
|
{
|
||||||
|
"real_time": float,
|
||||||
|
"user_time": float,
|
||||||
|
"system_time": float,
|
||||||
|
"elapsed_time": string,
|
||||||
|
"elapsed_time_hours": integer,
|
||||||
|
"elapsed_time_minutes": integer,
|
||||||
|
"elapsed_time_seconds": integer,
|
||||||
|
"elapsed_time_centiseconds": integer,
|
||||||
|
"elapsed_time_total_seconds": float,
|
||||||
|
"cpu_percent": integer, # null if ?
|
||||||
|
"average_shared_text_size": integer,
|
||||||
|
"average_unshared_data_size": integer,
|
||||||
|
"average_unshared_stack_size": integer,
|
||||||
|
"average_shared_memory_size": integer,
|
||||||
|
"maximum_resident_set_size": integer,
|
||||||
|
"block_input_operations": integer, # aka File system inputs
|
||||||
|
"block_output_operations": integer, # aka File system outputs
|
||||||
|
"major_pagefaults": integer,
|
||||||
|
"minor_pagefaults": integer,
|
||||||
|
"swaps": integer,
|
||||||
|
"page_reclaims": integer,
|
||||||
|
"page_faults": integer,
|
||||||
|
"messages_sent": integer,
|
||||||
|
"messages_received": integer,
|
||||||
|
"signals_received": integer,
|
||||||
|
"voluntary_context_switches": integer,
|
||||||
|
"involuntary_context_switches": integer
|
||||||
|
"command_being_timed": string,
|
||||||
|
"average_stack_size": integer,
|
||||||
|
"average_total_size": integer,
|
||||||
|
"average_resident_set_size": integer,
|
||||||
|
"signals_delivered": integer,
|
||||||
|
"page_size": integer,
|
||||||
|
"exit_status": integer
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||||
@ -84,7 +126,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.1'
|
||||||
description = '`/usr/bin/time` command parser'
|
description = '`/usr/bin/time` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -97,7 +140,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -107,47 +150,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
Dictionary. Structured data to conform to the schema.
|
||||||
|
|
||||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
|
||||||
https://man7.org/linux/man-pages/man1/time.1.html
|
|
||||||
|
|
||||||
{
|
|
||||||
"real_time": float,
|
|
||||||
"user_time": float,
|
|
||||||
"system_time": float,
|
|
||||||
"elapsed_time": string,
|
|
||||||
"elapsed_time_hours": integer,
|
|
||||||
"elapsed_time_minutes": integer,
|
|
||||||
"elapsed_time_seconds": integer,
|
|
||||||
"elapsed_time_centiseconds": integer,
|
|
||||||
"elapsed_time_total_seconds": float,
|
|
||||||
"cpu_percent": integer, # null if ?
|
|
||||||
"average_shared_text_size": integer,
|
|
||||||
"average_unshared_data_size": integer,
|
|
||||||
"average_unshared_stack_size": integer,
|
|
||||||
"average_shared_memory_size": integer,
|
|
||||||
"maximum_resident_set_size": integer,
|
|
||||||
"block_input_operations": integer, # aka File system inputs
|
|
||||||
"block_output_operations": integer, # aka File system outputs
|
|
||||||
"major_pagefaults": integer,
|
|
||||||
"minor_pagefaults": integer,
|
|
||||||
"swaps": integer,
|
|
||||||
"page_reclaims": integer,
|
|
||||||
"page_faults": integer,
|
|
||||||
"messages_sent": integer,
|
|
||||||
"messages_received": integer,
|
|
||||||
"signals_received": integer,
|
|
||||||
"voluntary_context_switches": integer,
|
|
||||||
"involuntary_context_switches": integer
|
|
||||||
"command_being_timed": string,
|
|
||||||
"average_stack_size": integer,
|
|
||||||
"average_total_size": integer,
|
|
||||||
"average_resident_set_size": integer,
|
|
||||||
"signals_delivered": integer,
|
|
||||||
"page_size": integer,
|
|
||||||
"exit_status": integer
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
if 'command_being_timed' in proc_data:
|
if 'command_being_timed' in proc_data:
|
||||||
proc_data['command_being_timed'] = proc_data['command_being_timed'][1:-1]
|
proc_data['command_being_timed'] = proc_data['command_being_timed'][1:-1]
|
||||||
@ -330,4 +333,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -15,6 +15,22 @@ Usage (module):
|
|||||||
import jc.parsers.timedatectl
|
import jc.parsers.timedatectl
|
||||||
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"local_time": string,
|
||||||
|
"universal_time": string,
|
||||||
|
"epoch_utc": integer, # timezone-aware timestamp
|
||||||
|
"rtc_time": string,
|
||||||
|
"time_zone": string,
|
||||||
|
"ntp_enabled": boolean,
|
||||||
|
"ntp_synchronized": boolean,
|
||||||
|
"system_clock_synchronized": boolean,
|
||||||
|
"systemd-timesyncd.service_active": boolean,
|
||||||
|
"rtc_in_local_tz": boolean,
|
||||||
|
"dst_active": boolean
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -50,7 +66,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.2'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.3'
|
||||||
description = '`timedatectl status` command parser'
|
description = '`timedatectl status` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -64,7 +81,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -74,21 +91,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
Dictionary. Structured data to conform to the schema.
|
||||||
|
|
||||||
{
|
|
||||||
"local_time": string,
|
|
||||||
"universal_time": string,
|
|
||||||
"epoch_utc": integer, # timezone-aware timestamp
|
|
||||||
"rtc_time": string,
|
|
||||||
"time_zone": string,
|
|
||||||
"ntp_enabled": boolean,
|
|
||||||
"ntp_synchronized": boolean,
|
|
||||||
"system_clock_synchronized": boolean,
|
|
||||||
"systemd-timesyncd.service_active": boolean,
|
|
||||||
"rtc_in_local_tz": boolean,
|
|
||||||
"dst_active": boolean
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
# boolean changes
|
# boolean changes
|
||||||
bool_list = ['ntp_enabled', 'ntp_synchronized', 'rtc_in_local_tz', 'dst_active',
|
bool_list = ['ntp_enabled', 'ntp_synchronized', 'rtc_in_local_tz', 'dst_active',
|
||||||
@ -138,4 +141,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -15,6 +15,25 @@ Usage (module):
|
|||||||
import jc.parsers.tracepath
|
import jc.parsers.tracepath
|
||||||
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"pmtu": integer,
|
||||||
|
"forward_hops": integer,
|
||||||
|
"return_hops": integer,
|
||||||
|
"hops": [
|
||||||
|
{
|
||||||
|
"ttl": integer,
|
||||||
|
"guess": boolean,
|
||||||
|
"host": string,
|
||||||
|
"reply_ms": float,
|
||||||
|
"pmtu": integer,
|
||||||
|
"asymmetric_difference": integer,
|
||||||
|
"reached": boolean
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -110,14 +129,14 @@ Examples:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.1'
|
||||||
description = '`tracepath` and `tracepath6` command parser'
|
description = '`tracepath` and `tracepath6` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -130,7 +149,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -140,24 +159,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
Dictionary. Structured data to conform to the schema.
|
||||||
|
|
||||||
{
|
|
||||||
"pmtu": integer,
|
|
||||||
"forward_hops": integer,
|
|
||||||
"return_hops": integer,
|
|
||||||
"hops": [
|
|
||||||
{
|
|
||||||
"ttl": integer,
|
|
||||||
"guess": boolean,
|
|
||||||
"host": string,
|
|
||||||
"reply_ms": float,
|
|
||||||
"pmtu": integer,
|
|
||||||
"asymmetric_difference": integer,
|
|
||||||
"reached": boolean
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
int_list = ['pmtu', 'forward_hops', 'return_hops', 'ttl', 'asymmetric_difference']
|
int_list = ['pmtu', 'forward_hops', 'return_hops', 'ttl', 'asymmetric_difference']
|
||||||
float_list = ['reply_ms']
|
float_list = ['reply_ms']
|
||||||
@ -259,4 +261,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -19,6 +19,27 @@ Usage (module):
|
|||||||
import jc.parsers.traceroute
|
import jc.parsers.traceroute
|
||||||
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"destination_ip": string,
|
||||||
|
"destination_name": string,
|
||||||
|
"hops": [
|
||||||
|
{
|
||||||
|
"hop": integer,
|
||||||
|
"probes": [
|
||||||
|
{
|
||||||
|
"annotation": string,
|
||||||
|
"asn": integer,
|
||||||
|
"ip": string,
|
||||||
|
"name": string,
|
||||||
|
"rtt": float
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'freebsd'
|
'linux', 'darwin', 'freebsd'
|
||||||
@ -101,7 +122,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.1'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.2'
|
||||||
description = '`traceroute` and `traceroute6` command parser'
|
description = '`traceroute` and `traceroute6` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -151,7 +173,7 @@ RE_PROBE_ASN = re.compile(r'\[AS(\d+)\]')
|
|||||||
RE_PROBE_RTT_ANNOTATION = re.compile(r'(?:(\d+(?:\.?\d+)?)\s+ms|(\s+\*\s+))\s*(!\S*)?')
|
RE_PROBE_RTT_ANNOTATION = re.compile(r'(?:(\d+(?:\.?\d+)?)\s+ms|(\s+\*\s+))\s*(!\S*)?')
|
||||||
|
|
||||||
|
|
||||||
class Traceroute(object):
|
class _Traceroute(object):
|
||||||
def __init__(self, dest_name, dest_ip):
|
def __init__(self, dest_name, dest_ip):
|
||||||
self.dest_name = dest_name
|
self.dest_name = dest_name
|
||||||
self.dest_ip = dest_ip
|
self.dest_ip = dest_ip
|
||||||
@ -167,7 +189,7 @@ class Traceroute(object):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
class Hop(object):
|
class _Hop(object):
|
||||||
def __init__(self, idx):
|
def __init__(self, idx):
|
||||||
self.idx = idx # Hop count, starting at 1 (usually)
|
self.idx = idx # Hop count, starting at 1 (usually)
|
||||||
self.probes = [] # Series of Probe instances
|
self.probes = [] # Series of Probe instances
|
||||||
@ -194,7 +216,7 @@ class Hop(object):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
class Probe(object):
|
class _Probe(object):
|
||||||
def __init__(self, name=None, ip=None, asn=None, rtt=None, annotation=None):
|
def __init__(self, name=None, ip=None, asn=None, rtt=None, annotation=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
@ -216,7 +238,7 @@ class Probe(object):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def loads(data):
|
def _loads(data):
|
||||||
lines = data.splitlines()
|
lines = data.splitlines()
|
||||||
|
|
||||||
# Get headers
|
# Get headers
|
||||||
@ -227,7 +249,7 @@ def loads(data):
|
|||||||
dest_ip = match_dest.group(2)
|
dest_ip = match_dest.group(2)
|
||||||
|
|
||||||
# The Traceroute node is the root of the tree
|
# The Traceroute node is the root of the tree
|
||||||
traceroute = Traceroute(dest_name, dest_ip)
|
traceroute = _Traceroute(dest_name, dest_ip)
|
||||||
|
|
||||||
# Parse the remaining lines, they should be only hops/probes
|
# Parse the remaining lines, they should be only hops/probes
|
||||||
for line in lines[1:]:
|
for line in lines[1:]:
|
||||||
@ -243,7 +265,7 @@ def loads(data):
|
|||||||
hop_index = None
|
hop_index = None
|
||||||
|
|
||||||
if hop_index is not None:
|
if hop_index is not None:
|
||||||
hop = Hop(hop_index)
|
hop = _Hop(hop_index)
|
||||||
traceroute.add_hop(hop)
|
traceroute.add_hop(hop)
|
||||||
|
|
||||||
hop_string = hop_match.group(2)
|
hop_string = hop_match.group(2)
|
||||||
@ -279,7 +301,7 @@ def loads(data):
|
|||||||
|
|
||||||
probe_annotation = probe_rtt_annotation[2] or None
|
probe_annotation = probe_rtt_annotation[2] or None
|
||||||
|
|
||||||
probe = Probe(
|
probe = _Probe(
|
||||||
name=probe_name,
|
name=probe_name,
|
||||||
ip=probe_ip,
|
ip=probe_ip,
|
||||||
asn=probe_asn,
|
asn=probe_asn,
|
||||||
@ -300,7 +322,7 @@ class ParseError(Exception):
|
|||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -310,26 +332,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary. Structured data with the following schema:
|
Dictionary. Structured to conform to the schema.
|
||||||
|
|
||||||
{
|
|
||||||
"destination_ip": string,
|
|
||||||
"destination_name": string,
|
|
||||||
"hops": [
|
|
||||||
{
|
|
||||||
"hop": integer,
|
|
||||||
"probes": [
|
|
||||||
{
|
|
||||||
"annotation": string,
|
|
||||||
"asn": integer,
|
|
||||||
"ip": string,
|
|
||||||
"name": string,
|
|
||||||
"rtt": float
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
int_list = ['hop', 'asn']
|
int_list = ['hop', 'asn']
|
||||||
float_list = ['rtt']
|
float_list = ['rtt']
|
||||||
@ -408,7 +411,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
data = '\n'.join(new_data)
|
data = '\n'.join(new_data)
|
||||||
|
|
||||||
tr = loads(data)
|
tr = _loads(data)
|
||||||
hops = tr.hops
|
hops = tr.hops
|
||||||
hops_list = []
|
hops_list = []
|
||||||
|
|
||||||
@ -441,4 +444,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
Reference in New Issue
Block a user