Skip to main content

Parse ifconfig output and retrieve values with goodies

Project description

https://travis-ci.org/ssudake21/ifconfig-parser.svg?branch=master

Parse ifconfig output collected from local or remote server and retrieve required interface information.

Usage

Install ifconfig-parser:

pip install -U ifparser

You can access inferface information as below :

>>> import commands
>>> from ifparser import Ifcfg
>>> ifdata = Ifcfg(commands.getoutput('ifconfig -a'))
>>> ifdata.interfaces
['lo', 'docker0', 'eth0']
>>> eth0 = ifdata.get_interface('eth0')
>>> eth0.BROADCAST
True
>>> eth0.hwaddr, eth0.mtu, eth0.ip, eth0.UP
('08:00:27:1f:d8:b0', '1500', '10.0.2.15', True)

You can query for intefaces on particular parameter :

 >>> ifdata.get(itype='Ethernet')
 [obj-docker0, obj-eth0]
 >>> ifdata.get(UP=True)
[obj-lo, obj-docker0, obj-eth0]

Get all interface parameters with get_values. Following dictionary contains all possible values:

>>> eth0 = ifdata.get_interface('eth0')
>>> eth0.get_values()
{'BROADCAST': True,
 'LOOPBACK': False,
 'MULTICAST': True,
 'RUNNING': True,
 'UP': True,
 'bcast': '10.10.2.255',
 'hwaddr': 'FF:FF:27:1f:d8:b0',
 'interface': 'eth0',
 'ip': '10.10.2.15',
 'itype': 'Ethernet',
 'mask': '255.255.255.0',
 'mtu': '1500',
 'rxbytes': '547873',
 'rxpkts': '628',
 'txbytes': '50826',
 'txpkts': '424'}

List of parameters for interface:

  • BROADCAST, LOOPBACK, MULTICAST, RUNNING, UP, DYNAMIC, NOARP, PROMISC

  • interface - Interface name, itype - Interface Type

  • ip - IP, bcast - Broadcast, mask - Mask

  • hwaddr - MAC address, mtu - MTU

  • rxbytes - Received Bytes, rxpkts - Received Packets

  • txbytes - Sent Bytes, txpkts - Sent Packets

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ifparser-0.8.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ifparser-0.8.0-py2-none-any.whl (8.1 kB view details)

Uploaded Python 2

File details

Details for the file ifparser-0.8.0.tar.gz.

File metadata

  • Download URL: ifparser-0.8.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/2.7.15rc1

File hashes

Hashes for ifparser-0.8.0.tar.gz
Algorithm Hash digest
SHA256 2d1b2e32edbaa8ea34c57b484dcce42d4c7de074b5f6a4157456f86618b50234
MD5 c74f65ce7460a3cf4ad8b3d28d2b282e
BLAKE2b-256 4bb258bac293f090d094347f59c25b33f68f9beaf4fac784c6b0ef7db7781d50

See more details on using hashes here.

File details

Details for the file ifparser-0.8.0-py2-none-any.whl.

File metadata

  • Download URL: ifparser-0.8.0-py2-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/2.7.15rc1

File hashes

Hashes for ifparser-0.8.0-py2-none-any.whl
Algorithm Hash digest
SHA256 5466c14ae5d9a9e522d1847886eb0461f29e110332e5c0a4feb783a4880b0f98
MD5 c26582b798deacd31e470aae45dd405f
BLAKE2b-256 8091e649c9243fae32e9f56d94c2a3b6ba54845cc6006acde6effe7bf6e7dee6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page