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
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -58,31 +71,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary 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.
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -17,6 +17,29 @@ Usage (module):
|
||||
import jc.parsers.iptables
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -146,44 +169,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -17,6 +17,16 @@ Usage (module):
|
||||
import jc.parsers.iw-scan
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -116,30 +126,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -17,6 +17,18 @@ Usage (module):
|
||||
import jc.parsers.jobs
|
||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job_number": integer,
|
||||
"pid": integer,
|
||||
"history": string,
|
||||
"status": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -88,33 +100,7 @@ Example:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```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()`.
|
||||
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.txt | jc --kv
|
||||
@ -16,6 +15,15 @@ Usage (module):
|
||||
import jc.parsers.kv
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -46,7 +54,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -19,6 +19,22 @@ Usage (module):
|
||||
import jc.parsers.last
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
@ -93,37 +109,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -26,6 +26,23 @@ Usage (module):
|
||||
import jc.parsers.ls
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -159,38 +176,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,53 @@ Usage (module):
|
||||
import jc.parsers.lsblk
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -227,68 +274,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,19 @@ Usage (module):
|
||||
import jc.parsers.lsmod
|
||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"module": string,
|
||||
"size": integer,
|
||||
"used": integer,
|
||||
"by": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -118,34 +131,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,23 @@ Usage (module):
|
||||
import jc.parsers.lsof
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -108,38 +125,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,19 @@ Usage (module):
|
||||
import jc.parsers.mount
|
||||
result = jc.parsers.mount.parse(mount_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
"mount_point": string,
|
||||
"type": string,
|
||||
"access": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -68,34 +81,7 @@ Example:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -19,6 +19,107 @@ Usage (module):
|
||||
import jc.parsers.netstat
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -259,122 +360,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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,
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,24 @@ Usage (module):
|
||||
import jc.parsers.ntpq
|
||||
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:
|
||||
|
||||
'linux', 'freebsd'
|
||||
@ -194,40 +212,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -11,6 +11,20 @@ Usage (module):
|
||||
import jc.parsers.passwd
|
||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"username": string,
|
||||
"password": string,
|
||||
"uid": integer,
|
||||
"gid": integer,
|
||||
"comment": string,
|
||||
"home": string,
|
||||
"shell": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
@ -86,35 +100,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -19,6 +19,36 @@ Usage (module):
|
||||
import jc.parsers.ping
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -121,51 +151,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"source_ip": string,
|
||||
"destination_ip": string,
|
||||
"data_bytes": integer,
|
||||
"pattern": string, (null if not set)
|
||||
"destination": string,
|
||||
"packets_transmitted": integer,
|
||||
"packets_received": integer,
|
||||
"packet_loss_percent": float,
|
||||
"duplicates": integer,
|
||||
"round_trip_ms_min": float,
|
||||
"round_trip_ms_avg": float,
|
||||
"round_trip_ms_max": float,
|
||||
"round_trip_ms_stddev": float,
|
||||
"responses": [
|
||||
{
|
||||
"type": string, ('reply' or 'timeout')
|
||||
"timestamp": float,
|
||||
"bytes": integer,
|
||||
"response_ip": string,
|
||||
"icmp_seq": integer,
|
||||
"ttl": integer,
|
||||
"time_ms": float,
|
||||
"duplicate": boolean
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,16 @@ Usage (module):
|
||||
import jc.parsers.pip_list
|
||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"package": string,
|
||||
"version": string,
|
||||
"location": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -43,31 +53,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,23 @@ Usage (module):
|
||||
import jc.parsers.pip_show
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -54,39 +71,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -19,6 +19,30 @@ Usage (module):
|
||||
import jc.parsers.ps
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -188,45 +212,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,27 @@ Usage (module):
|
||||
import jc.parsers.route
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -95,42 +116,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -21,6 +21,34 @@ Usage (module):
|
||||
import jc.parsers.rpm_qi
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -128,49 +156,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -11,6 +11,21 @@ Usage (module):
|
||||
import jc.parsers.shadow
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
@ -92,36 +107,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -2,6 +2,8 @@
|
||||
# jc.parsers.ss
|
||||
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):
|
||||
|
||||
$ ss | jc --ss
|
||||
@ -15,9 +17,29 @@ Usage (module):
|
||||
import jc.parsers.ss
|
||||
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:
|
||||
|
||||
@ -262,45 +284,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -19,6 +19,44 @@ Usage (module):
|
||||
import jc.parsers.stat
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -136,59 +174,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -17,6 +17,14 @@ Usage (module):
|
||||
import jc.parsers.sysctl
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -52,29 +60,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"bar": string/integer/float,
|
||||
"baz": string/integer/float
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,18 @@ Usage (module):
|
||||
import jc.parsers.systemctl
|
||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit": string,
|
||||
"load": string,
|
||||
"active": string,
|
||||
"sub": string,
|
||||
"description": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -52,33 +64,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,17 @@ Usage (module):
|
||||
import jc.parsers.systemctl_lj
|
||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job": integer,
|
||||
"unit": string,
|
||||
"type": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -66,37 +77,11 @@ Examples:
|
||||
]
|
||||
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,16 @@ Usage (module):
|
||||
import jc.parsers.systemctl_ls
|
||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"listen": string,
|
||||
"unit": string,
|
||||
"activates": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -46,31 +56,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,15 @@ Usage (module):
|
||||
import jc.parsers.systemctl_luf
|
||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit_file": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -43,30 +52,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -17,6 +17,48 @@ Usage (module):
|
||||
import jc.parsers.time
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -87,63 +129,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -17,6 +17,22 @@ Usage (module):
|
||||
import jc.parsers.timedatectl
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -53,37 +69,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"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
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -17,6 +17,25 @@ Usage (module):
|
||||
import jc.parsers.tracepath
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -114,45 +133,11 @@ Examples:
|
||||
}
|
||||
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"pmtu": integer,
|
||||
"forward_hops": integer,
|
||||
"return_hops": integer,
|
||||
"hops": [
|
||||
{
|
||||
"ttl": integer,
|
||||
"guess": boolean,
|
||||
"host": string,
|
||||
"reply_ms": float,
|
||||
"pmtu": integer,
|
||||
"asymmetric_difference": integer,
|
||||
"reached": boolean
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -21,6 +21,27 @@ Usage (module):
|
||||
import jc.parsers.traceroute
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -102,48 +123,7 @@ Examples:
|
||||
```python
|
||||
info()
|
||||
```
|
||||
|
||||
|
||||
## Hop
|
||||
```python
|
||||
Hop(idx)
|
||||
```
|
||||
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (Dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"destination_ip": string,
|
||||
"destination_name": string,
|
||||
"hops": [
|
||||
{
|
||||
"hop": integer,
|
||||
"probes": [
|
||||
{
|
||||
"annotation": string,
|
||||
"asn": integer,
|
||||
"ip": string,
|
||||
"name": string,
|
||||
"rtt": float
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,18 @@ Usage (module):
|
||||
import jc.parsers.jobs
|
||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job_number": integer,
|
||||
"pid": integer,
|
||||
"history": string,
|
||||
"status": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -86,7 +98,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.3'
|
||||
description = '`jobs` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -99,7 +112,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -109,17 +122,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job_number": integer,
|
||||
"pid": integer,
|
||||
"history": string,
|
||||
"status": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['job_number', 'pid']
|
||||
@ -208,4 +211,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
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()`.
|
||||
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.txt | jc --kv
|
||||
@ -14,6 +13,15 @@ Usage (module):
|
||||
import jc.parsers.kv
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -42,7 +50,8 @@ Examples:
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
description = 'Key/Value file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
@ -17,6 +17,22 @@ Usage (module):
|
||||
import jc.parsers.last
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
@ -91,7 +107,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.5'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.6'
|
||||
description = '`last` and `lastb` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -105,7 +122,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -115,21 +132,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
if 'user' in entry and entry['user'] == 'boot_time':
|
||||
@ -253,4 +256,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -24,6 +24,23 @@ Usage (module):
|
||||
import jc.parsers.ls
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -157,7 +174,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.7'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.8'
|
||||
description = '`ls` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -170,7 +188,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -180,22 +198,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['links', 'size']
|
||||
@ -337,4 +340,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,53 @@ Usage (module):
|
||||
import jc.parsers.lsblk
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -225,7 +272,8 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.5'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.6'
|
||||
description = '`lsblk` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -238,7 +286,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -248,52 +296,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# boolean changes
|
||||
@ -357,4 +360,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,19 @@ Usage (module):
|
||||
import jc.parsers.lsmod
|
||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"module": string,
|
||||
"size": integer,
|
||||
"used": integer,
|
||||
"by": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -116,7 +129,8 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`lsmod` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -129,7 +143,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -139,18 +153,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"module": string,
|
||||
"size": integer,
|
||||
"used": integer,
|
||||
"by": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# integer changes
|
||||
@ -199,4 +202,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,23 @@ Usage (module):
|
||||
import jc.parsers.lsof
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -106,7 +123,8 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.3'
|
||||
description = '`lsof` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -119,7 +137,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -129,22 +147,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# integer changes
|
||||
@ -191,4 +194,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,19 @@ Usage (module):
|
||||
import jc.parsers.mount
|
||||
result = jc.parsers.mount.parse(mount_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
"mount_point": string,
|
||||
"type": string,
|
||||
"access": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -65,7 +78,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.5'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.6'
|
||||
description = '`mount` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -78,7 +92,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -88,24 +102,13 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
"mount_point": string,
|
||||
"type": string,
|
||||
"access": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
# nothing to process
|
||||
return proc_data
|
||||
|
||||
|
||||
def osx_parse(data):
|
||||
def _osx_parse(data):
|
||||
output = []
|
||||
|
||||
for entry in data:
|
||||
@ -130,7 +133,7 @@ def osx_parse(data):
|
||||
return output
|
||||
|
||||
|
||||
def linux_parse(data):
|
||||
def _linux_parse(data):
|
||||
output = []
|
||||
|
||||
for entry in data:
|
||||
@ -175,12 +178,12 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
# check for OSX output
|
||||
if ' type ' not in cleandata[0]:
|
||||
raw_output = osx_parse(cleandata)
|
||||
raw_output = _osx_parse(cleandata)
|
||||
|
||||
else:
|
||||
raw_output = linux_parse(cleandata)
|
||||
raw_output = _linux_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -17,6 +17,107 @@ Usage (module):
|
||||
import jc.parsers.netstat
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -255,7 +356,8 @@ Examples:
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.8'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.9'
|
||||
description = '`netstat` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -268,7 +370,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -278,106 +380,7 @@ def process(proc_data):
|
||||
|
||||
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,
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# integer changes
|
||||
@ -467,4 +470,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,24 @@ Usage (module):
|
||||
import jc.parsers.ntpq
|
||||
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:
|
||||
|
||||
'linux', 'freebsd'
|
||||
@ -192,7 +210,8 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`ntpq -p` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -205,7 +224,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -215,24 +234,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
},
|
||||
]
|
||||
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
|
||||
@ -305,4 +307,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -9,6 +9,20 @@ Usage (module):
|
||||
import jc.parsers.passwd
|
||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"username": string,
|
||||
"password": string,
|
||||
"uid": integer,
|
||||
"gid": integer,
|
||||
"comment": string,
|
||||
"home": string,
|
||||
"shell": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
@ -83,7 +97,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.2'
|
||||
description = '`/etc/passwd` file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -96,7 +111,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -106,19 +121,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"username": string,
|
||||
"password": string,
|
||||
"uid": integer,
|
||||
"gid": integer,
|
||||
"comment": string,
|
||||
"home": string,
|
||||
"shell": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['uid', 'gid']
|
||||
@ -177,4 +180,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -17,6 +17,36 @@ Usage (module):
|
||||
import jc.parsers.ping
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -119,7 +149,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.3'
|
||||
description = '`ping` and `ping6` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -132,7 +163,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -142,35 +173,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
}
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
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',
|
||||
@ -208,7 +211,7 @@ def process(proc_data):
|
||||
return proc_data
|
||||
|
||||
|
||||
def linux_parse(data):
|
||||
def _linux_parse(data):
|
||||
raw_output = {}
|
||||
ping_responses = []
|
||||
pattern = None
|
||||
@ -357,7 +360,7 @@ def linux_parse(data):
|
||||
return raw_output
|
||||
|
||||
|
||||
def bsd_parse(data):
|
||||
def _bsd_parse(data):
|
||||
raw_output = {}
|
||||
ping_responses = []
|
||||
pattern = None
|
||||
@ -508,11 +511,11 @@ def parse(data, raw=False, quiet=False):
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
if ' time ' in data.splitlines()[-2] or ' time ' in data.splitlines()[-3]:
|
||||
raw_output = linux_parse(data)
|
||||
raw_output = _linux_parse(data)
|
||||
else:
|
||||
raw_output = bsd_parse(data)
|
||||
raw_output = _bsd_parse(data)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,16 @@ Usage (module):
|
||||
import jc.parsers.pip_list
|
||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"package": string,
|
||||
"version": string,
|
||||
"location": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -41,7 +51,8 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`pip list` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -54,7 +65,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -64,15 +75,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"package": string,
|
||||
"version": string,
|
||||
"location": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
# no further processing
|
||||
return proc_data
|
||||
@ -123,4 +126,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,23 @@ Usage (module):
|
||||
import jc.parsers.pip_show
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -51,7 +68,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.2'
|
||||
description = '`pip show` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -64,7 +82,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -74,23 +92,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
# no further processing
|
||||
return proc_data
|
||||
@ -140,4 +142,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -17,6 +17,30 @@ Usage (module):
|
||||
import jc.parsers.ps
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -186,7 +210,8 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`ps` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -199,7 +224,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -209,29 +234,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# change key name '%cpu' to 'cpu_percent'
|
||||
@ -301,4 +304,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,27 @@ Usage (module):
|
||||
import jc.parsers.route
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -93,7 +114,8 @@ import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.4'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.5'
|
||||
description = '`route` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -106,7 +128,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -116,26 +138,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['metric', 'ref', 'use', 'mss', 'window', 'irtt']
|
||||
@ -207,4 +210,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -19,6 +19,34 @@ Usage (module):
|
||||
import jc.parsers.rpm_qi
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -125,7 +153,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
description = '`rpm -qi` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -139,7 +168,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -149,33 +178,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
|
||||
@ -255,4 +258,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -9,6 +9,21 @@ Usage (module):
|
||||
import jc.parsers.shadow
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
@ -89,7 +104,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.2'
|
||||
description = '`/etc/shadow` file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -102,7 +118,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -112,20 +128,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['last_changed', 'minimum', 'maximum', 'warn', 'inactive', 'expire']
|
||||
@ -185,4 +188,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""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):
|
||||
|
||||
$ ss | jc --ss
|
||||
@ -13,9 +15,29 @@ Usage (module):
|
||||
import jc.parsers.ss
|
||||
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:
|
||||
|
||||
@ -260,7 +282,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.3'
|
||||
description = '`ss` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -273,7 +296,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -283,29 +306,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['recv_q', 'send_q', 'pid']
|
||||
@ -419,4 +420,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -17,6 +17,44 @@ Usage (module):
|
||||
import jc.parsers.stat
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -134,7 +172,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.6'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.7'
|
||||
description = '`stat` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -147,7 +186,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -157,43 +196,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
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:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -15,6 +15,14 @@ Usage (module):
|
||||
import jc.parsers.sysctl
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -49,7 +57,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
description = '`sysctl` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -63,7 +72,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -73,13 +82,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
for key in proc_data:
|
||||
try:
|
||||
@ -158,4 +161,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,18 @@ Usage (module):
|
||||
import jc.parsers.systemctl
|
||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit": string,
|
||||
"load": string,
|
||||
"active": string,
|
||||
"sub": string,
|
||||
"description": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -49,7 +61,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`systemctl` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -62,7 +75,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -72,17 +85,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit": string,
|
||||
"load": string,
|
||||
"active": string,
|
||||
"sub": string,
|
||||
"description": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
# nothing more to process
|
||||
return proc_data
|
||||
@ -133,4 +136,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,17 @@ Usage (module):
|
||||
import jc.parsers.systemctl_lj
|
||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job": integer,
|
||||
"unit": string,
|
||||
"type": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -62,13 +73,13 @@ Examples:
|
||||
"state": "waiting"
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`systemctl list-jobs` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -81,7 +92,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -91,16 +102,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job": integer,
|
||||
"unit": string,
|
||||
"type": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['job']
|
||||
@ -161,4 +163,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,16 @@ Usage (module):
|
||||
import jc.parsers.systemctl_ls
|
||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"listen": string,
|
||||
"unit": string,
|
||||
"activates": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -43,7 +53,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`systemctl list-sockets` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -56,7 +67,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -66,15 +77,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"listen": string,
|
||||
"unit": string,
|
||||
"activates": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
# nothing more to process
|
||||
return proc_data
|
||||
@ -125,4 +128,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,15 @@ Usage (module):
|
||||
import jc.parsers.systemctl_luf
|
||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit_file": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -40,7 +49,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`systemctl list-unit-files` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -53,7 +63,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -63,14 +73,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit_file": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
# nothing more to process
|
||||
return proc_data
|
||||
@ -122,4 +125,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -15,6 +15,48 @@ Usage (module):
|
||||
import jc.parsers.time
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -84,7 +126,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
description = '`/usr/bin/time` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -97,7 +140,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -107,47 +150,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
if 'command_being_timed' in proc_data:
|
||||
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:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -15,6 +15,22 @@ Usage (module):
|
||||
import jc.parsers.timedatectl
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -50,7 +66,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.3'
|
||||
description = '`timedatectl status` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -64,7 +81,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -74,21 +91,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
# boolean changes
|
||||
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:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -15,6 +15,25 @@ Usage (module):
|
||||
import jc.parsers.tracepath
|
||||
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:
|
||||
|
||||
'linux'
|
||||
@ -110,14 +129,14 @@ Examples:
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
"""
|
||||
import re
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
description = '`tracepath` and `tracepath6` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -130,7 +149,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -140,24 +159,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
}
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
int_list = ['pmtu', 'forward_hops', 'return_hops', 'ttl', 'asymmetric_difference']
|
||||
float_list = ['reply_ms']
|
||||
@ -259,4 +261,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -19,6 +19,27 @@ Usage (module):
|
||||
import jc.parsers.traceroute
|
||||
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:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -101,7 +122,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.2'
|
||||
description = '`traceroute` and `traceroute6` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
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*)?')
|
||||
|
||||
|
||||
class Traceroute(object):
|
||||
class _Traceroute(object):
|
||||
def __init__(self, dest_name, dest_ip):
|
||||
self.dest_name = dest_name
|
||||
self.dest_ip = dest_ip
|
||||
@ -167,7 +189,7 @@ class Traceroute(object):
|
||||
return text
|
||||
|
||||
|
||||
class Hop(object):
|
||||
class _Hop(object):
|
||||
def __init__(self, idx):
|
||||
self.idx = idx # Hop count, starting at 1 (usually)
|
||||
self.probes = [] # Series of Probe instances
|
||||
@ -194,7 +216,7 @@ class Hop(object):
|
||||
return text
|
||||
|
||||
|
||||
class Probe(object):
|
||||
class _Probe(object):
|
||||
def __init__(self, name=None, ip=None, asn=None, rtt=None, annotation=None):
|
||||
self.name = name
|
||||
self.ip = ip
|
||||
@ -216,7 +238,7 @@ class Probe(object):
|
||||
return text
|
||||
|
||||
|
||||
def loads(data):
|
||||
def _loads(data):
|
||||
lines = data.splitlines()
|
||||
|
||||
# Get headers
|
||||
@ -227,7 +249,7 @@ def loads(data):
|
||||
dest_ip = match_dest.group(2)
|
||||
|
||||
# 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
|
||||
for line in lines[1:]:
|
||||
@ -243,7 +265,7 @@ def loads(data):
|
||||
hop_index = None
|
||||
|
||||
if hop_index is not None:
|
||||
hop = Hop(hop_index)
|
||||
hop = _Hop(hop_index)
|
||||
traceroute.add_hop(hop)
|
||||
|
||||
hop_string = hop_match.group(2)
|
||||
@ -279,7 +301,7 @@ def loads(data):
|
||||
|
||||
probe_annotation = probe_rtt_annotation[2] or None
|
||||
|
||||
probe = Probe(
|
||||
probe = _Probe(
|
||||
name=probe_name,
|
||||
ip=probe_ip,
|
||||
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.
|
||||
|
||||
@ -310,26 +332,7 @@ def process(proc_data):
|
||||
|
||||
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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Dictionary. Structured to conform to the schema.
|
||||
"""
|
||||
int_list = ['hop', 'asn']
|
||||
float_list = ['rtt']
|
||||
@ -408,7 +411,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
data = '\n'.join(new_data)
|
||||
|
||||
tr = loads(data)
|
||||
tr = _loads(data)
|
||||
hops = tr.hops
|
||||
hops_list = []
|
||||
|
||||
@ -441,4 +444,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
Reference in New Issue
Block a user