Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Parse ifconfig output and retrieve values with goodies

Project Description

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
Release History

Release History

This version
History Node

0.7.0

History Node

0.6.0

History Node

0.5.0

History Node

0.4.0

History Node

0.3.0

History Node

0.2.0

History Node

0.1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ifparser-0.7.0.tar.gz (6.0 kB) Copy SHA256 Checksum SHA256 Source Jul 23, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting