Skip to main content

Parse ifconfig output and retrieve values

Project description

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


Install ifconfig-parser:

pip install 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
>> eth0.hwaddr, eth0.mtu, eth0.ip, eth0.UP
('08:00:27:1f:d8:b0', '1500', '', True)
>> eth0.get_values()
 'LOOPBACK': False,
 'RUNNING': True,
 'UP': True,
 'bcast': '',
 'hwaddr': 'FF:FF:27:1f:d8:b0',
 'interface': 'eth0',
 'ip': '',
 'itype': 'Ethernet',
 'mask': '',
 'mtu': '1500',
 'rxbytes': '547873',
 'rxpkts': '628',
 'txbytes': '50826',
 'txpkts': '424'}

Project details

Download files

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

Files for ifparser, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size ifparser-0.1.0.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page