1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/arp.md

159 lines
2.9 KiB
Markdown
Raw Normal View History

2020-07-30 16:20:24 -07:00
2019-11-11 18:30:46 -08:00
# jc.parsers.arp
2020-08-05 16:51:58 -07:00
jc - JSON CLI output utility `arp` command output parser
Supports `arp` and `arp -a` output.
2019-11-11 18:30:46 -08:00
2020-08-05 13:32:59 -07:00
Usage (cli):
2019-12-12 09:41:56 -08:00
2020-08-05 16:51:58 -07:00
$ arp | jc --arp
or
2019-12-14 23:35:42 -08:00
2020-08-05 16:51:58 -07:00
$ jc arp
2019-11-11 18:30:46 -08:00
2020-08-05 13:32:59 -07:00
Usage (module):
import jc.parsers.arp
result = jc.parsers.arp.parse(arp_command_output)
2019-12-12 09:21:20 -08:00
Compatibility:
2019-12-12 09:41:56 -08:00
2019-12-12 09:21:20 -08:00
'linux', 'aix', 'freebsd', 'darwin'
2019-11-11 18:30:46 -08:00
Examples:
$ arp | jc --arp -p
[
{
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:f0:98:26",
"flags_mask": "C",
"iface": "ens33"
},
{
"address": "gateway",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"flags_mask": "C",
"iface": "ens33"
}
]
$ arp | jc --arp -p -r
[
{
"address": "gateway",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"flags_mask": "C",
"iface": "ens33"
},
{
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"flags_mask": "C",
"iface": "ens33"
}
]
$ arp -a | jc --arp -p
[
{
"name": null,
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:f0:98:26",
"iface": "ens33"
"permanent": false,
"expires": 1182
2019-11-11 18:30:46 -08:00
},
{
"name": "gateway",
"address": "192.168.71.2",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": 110
2019-11-11 18:30:46 -08:00
}
]
$ arp -a | jc --arp -p -r
[
{
"name": "?",
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"iface": "ens33"
"permanent": false,
"expires": "1182"
2019-11-11 18:30:46 -08:00
},
{
"name": "_gateway",
"address": "192.168.71.2",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": "110"
2019-11-11 18:30:46 -08:00
}
]
2020-07-30 16:20:24 -07:00
2019-12-14 23:35:42 -08:00
## info
```python
2020-07-30 16:20:24 -07:00
info()
2019-12-14 23:35:42 -08:00
```
2020-07-30 16:20:24 -07:00
2019-11-11 18:30:46 -08:00
## process
```python
process(proc_data)
```
2019-11-12 11:22:17 -08:00
Final processing to conform to the schema.
Parameters:
2019-11-13 08:04:40 -08:00
proc_data: (dictionary) raw structured data to process
2019-11-12 11:22:17 -08:00
Returns:
2019-12-17 09:56:09 -08:00
List of dictionaries. Structured data with the following schema:
2019-11-11 18:30:46 -08:00
[
{
"name": string,
"address": string,
"hwtype": string,
"hwaddress": string,
"flags_mask": string,
"iface": string,
"permanent": boolean,
"expires": integer
2019-11-11 18:30:46 -08:00
}
]
2020-07-30 16:20:24 -07:00
2019-11-11 18:30:46 -08:00
## parse
```python
parse(data, raw=False, quiet=False)
```
2019-11-12 11:18:00 -08:00
Main text parsing function
2019-11-11 18:30:46 -08:00
2019-11-12 11:12:41 -08:00
Parameters:
2019-11-11 18:30:46 -08:00
2019-11-12 11:12:41 -08:00
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
2019-12-17 10:09:19 -08:00
List of dictionaries. Raw or processed structured data.
2019-11-11 18:30:46 -08:00