Skip to main content

Parser for iw and iwinfo on OpenWrt devices

Project description

ap-parse

Parser for iw and iwinfo on OpenWrt devices. Currently supports only device list and connected stations data. Output from iw and iwinfo on other platforms might work, but it's not tested.

Table of contents

Installation

python -m pip install -U ap-parse

Usage

Log in to the device via SSH and run the the command of choice. Feed the output to ap-parse either programmatically or via the CLI.

  • List devices with iw:

    iw dev
    
  • List stations with iw:

    iw dev <device name> station dump
    
  • List devices with iwinfo:

    iwinfo
    
  • List stations with iwinfo:

    iwinfo <device name> assoclist
    

CLI

Pipe the command output to ap-parse. Example for iwinfo device list:

ssh <user@host> iwinfo | python -m apparse iwinfo device
Argument Type Values Description
backend str iw, iwinfo Utility used to generate the output data
type str device, station Type of the output data

API

Save the command output to a file and pass it as a string to the appropriate parser. Example for iwinfo device list:

ssh <user@host> iwinfo > output.txt
import apparse

with open('output.txt', 'r', encoding='utf-8') as f:
    raw_data = f.read()

parsed_data = apparse.parse_iwinfo_station(raw_data)
print(parsed_data)

In case you wish to add or remove fields or modify regexes, subclass one of the parser classes under its respective module apparse.*_parser.

License

MIT license. See LICENSE for more information.

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

ap-parse-0.1.0.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

ap_parse-0.1.0-py3-none-any.whl (11.0 kB view hashes)

Uploaded Python 3

Supported by

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