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

215 lines
5.1 KiB
Markdown
Raw Normal View History

2019-11-11 18:30:46 -08:00
# jc.parsers.ifconfig
jc - JSON CLI output utility ifconfig Parser
Usage:
2019-12-12 09:47:14 -08:00
2019-11-11 18:30:46 -08:00
specify --ifconfig as the first argument if the piped input is coming from ifconfig
no ifconfig options are supported.
2019-12-12 09:21:20 -08:00
Compatibility:
2019-12-12 09:47:14 -08:00
2019-12-12 09:21:20 -08:00
'linux', 'aix', 'freebsd', 'darwin'
2019-11-11 18:30:46 -08:00
Examples:
$ ifconfig | jc --ifconfig -p
[
{
"name": "ens33",
"flags": 4163,
2019-12-06 11:46:09 -08:00
"state": [
"UP",
"BROADCAST",
"RUNNING",
"MULTICAST"
],
2019-11-11 18:30:46 -08:00
"mtu": 1500,
2019-12-06 11:46:09 -08:00
"ipv4_addr": "192.168.71.137",
2019-11-11 18:30:46 -08:00
"ipv4_mask": "255.255.255.0",
"ipv4_bcast": "192.168.71.255",
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
"ipv6_mask": 64,
2019-12-06 11:46:09 -08:00
"ipv6_scope": "0x20",
2019-11-11 18:30:46 -08:00
"mac_addr": "00:0c:29:3b:58:0e",
"type": "Ethernet",
2019-12-06 11:46:09 -08:00
"rx_packets": 8061,
"rx_bytes": 1514413,
2019-11-11 18:30:46 -08:00
"rx_errors": 0,
"rx_dropped": 0,
"rx_overruns": 0,
"rx_frame": 0,
2019-12-06 11:46:09 -08:00
"tx_packets": 4502,
"tx_bytes": 866622,
2019-11-11 18:30:46 -08:00
"tx_errors": 0,
"tx_dropped": 0,
"tx_overruns": 0,
"tx_carrier": 0,
"tx_collisions": 0,
"metric": null
},
{
"name": "lo",
"flags": 73,
2019-12-06 11:46:09 -08:00
"state": [
"UP",
"LOOPBACK",
"RUNNING"
],
2019-11-11 18:30:46 -08:00
"mtu": 65536,
"ipv4_addr": "127.0.0.1",
"ipv4_mask": "255.0.0.0",
"ipv4_bcast": null,
"ipv6_addr": "::1",
"ipv6_mask": 128,
2019-12-06 11:46:09 -08:00
"ipv6_scope": "0x10",
2019-11-11 18:30:46 -08:00
"mac_addr": null,
"type": "Local Loopback",
2019-12-06 11:46:09 -08:00
"rx_packets": 73,
"rx_bytes": 6009,
2019-11-11 18:30:46 -08:00
"rx_errors": 0,
"rx_dropped": 0,
"rx_overruns": 0,
"rx_frame": 0,
2019-12-06 11:46:09 -08:00
"tx_packets": 73,
"tx_bytes": 6009,
2019-11-11 18:30:46 -08:00
"tx_errors": 0,
"tx_dropped": 0,
"tx_overruns": 0,
"tx_carrier": 0,
"tx_collisions": 0,
"metric": null
}
]
$ ifconfig | jc --ifconfig -p -r
[
{
"name": "ens33",
"flags": "4163",
"state": "UP,BROADCAST,RUNNING,MULTICAST",
"mtu": "1500",
2019-12-06 11:46:09 -08:00
"ipv4_addr": "192.168.71.137",
2019-11-11 18:30:46 -08:00
"ipv4_mask": "255.255.255.0",
"ipv4_bcast": "192.168.71.255",
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
"ipv6_mask": "64",
2019-12-06 11:46:09 -08:00
"ipv6_scope": "0x20",
2019-11-11 18:30:46 -08:00
"mac_addr": "00:0c:29:3b:58:0e",
"type": "Ethernet",
2019-12-06 11:46:09 -08:00
"rx_packets": "8061",
"rx_bytes": "1514413",
2019-11-11 18:30:46 -08:00
"rx_errors": "0",
"rx_dropped": "0",
"rx_overruns": "0",
"rx_frame": "0",
2019-12-06 11:46:09 -08:00
"tx_packets": "4502",
"tx_bytes": "866622",
2019-11-11 18:30:46 -08:00
"tx_errors": "0",
"tx_dropped": "0",
"tx_overruns": "0",
"tx_carrier": "0",
"tx_collisions": "0",
"metric": null
},
{
"name": "lo",
"flags": "73",
"state": "UP,LOOPBACK,RUNNING",
"mtu": "65536",
"ipv4_addr": "127.0.0.1",
"ipv4_mask": "255.0.0.0",
"ipv4_bcast": null,
"ipv6_addr": "::1",
"ipv6_mask": "128",
2019-12-06 11:46:09 -08:00
"ipv6_scope": "0x10",
2019-11-11 18:30:46 -08:00
"mac_addr": null,
"type": "Local Loopback",
2019-12-06 11:46:09 -08:00
"rx_packets": "73",
"rx_bytes": "6009",
2019-11-11 18:30:46 -08:00
"rx_errors": "0",
"rx_dropped": "0",
"rx_overruns": "0",
"rx_frame": "0",
2019-12-06 11:46:09 -08:00
"tx_packets": "73",
"tx_bytes": "6009",
2019-11-11 18:30:46 -08:00
"tx_errors": "0",
"tx_dropped": "0",
"tx_overruns": "0",
"tx_carrier": "0",
"tx_collisions": "0",
"metric": null
}
]
2019-12-14 23:35:42 -08:00
## info
```python
info(self, /, *args, **kwargs)
```
2019-11-11 18:30:46 -08:00
## process
```python
process(proc_data)
```
2019-11-12 11:28:10 -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:28:10 -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,
"flags": integer,
2019-12-06 11:46:09 -08:00
"state": [
string
],
2019-11-11 18:30:46 -08:00
"mtu": integer,
"ipv4_addr": string,
"ipv4_mask": string,
"ipv4_bcast": string,
"ipv6_addr": string,
"ipv6_mask": integer,
"ipv6_scope": string,
"mac_addr": string,
"type": string,
"rx_packets": integer,
2019-12-06 11:46:09 -08:00
"rx_bytes": integer,
2019-11-11 18:30:46 -08:00
"rx_errors": integer,
"rx_dropped": integer,
"rx_overruns": integer,
"rx_frame": integer,
"tx_packets": integer,
2019-12-06 11:46:09 -08:00
"tx_bytes": integer,
2019-11-11 18:30:46 -08:00
"tx_errors": integer,
"tx_dropped": integer,
"tx_overruns": integer,
"tx_carrier": integer,
"tx_collisions": integer,
"metric": integer
}
]
## 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:18:00 -08:00
Parameters:
2019-11-11 18:30:46 -08:00
2019-11-12 11:18:00 -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