<commit_before>HNMP is a high-level Python library to ease the pain of retrieving and processing data from SNMP-capable devices such as network switches, routers, and printers. It's not meant to provide everything SNMP has to offer, but to get rid of most of the suck inherent to writing Munin or Icinga plugins that process SNMP data.

HNMP is meant to be used like this:

1. acquire MIB files (optional, some luck required)
2. use a MIB browser application like [this freeish and cross-platform one](http://ireasoning.com/mibbrowser.shtml) to figure out the numeric OIDs you're interested in
3. use HNMP to retrieve your data and do some light processing
4. put man on moon :rocket:

Usage
-----

```python
>>> from hnmp import SNMP
>>>
>>> snmp = SNMP("example.com", community="public")

# get a single value
>>> uptime = snmp.get("1.3.6.1.2.1.1.3.0")
>>> uptime
datetime.timedelta(412, 29152)

# build a table
>>> wifi_clients = snmp.table(
>>>     "1.3.6.1.4.1.14179.2.1.4.1",
>>>     columns={
>>>         3: "username",
>>>         25: "protocol",
>>>     },
>>>     column_value_mapping={
>>>         "protocol": {
>>>             3: "802.11g",
>>>             6: "802.11n",
>>>         },
>>>     },
>>> )
>>>
>>> wifi_clients.columns["username"]
("jdoe", "rms", "bwayne")
>>> wifi_clients.columns["protocol"]<commit_msg>document fetch_all_columns<commit_after>HNMP is a high-level Python library to ease the pain of retrieving and processing data from SNMP-capable devices such as network switches, routers, and printers. It's not meant to provide everything SNMP has to offer, but to get rid of most of the suck inherent to writing Munin or Icinga plugins that process SNMP data.

HNMP is meant to be used like this:

1. acquire MIB files (optional, some luck required)
2. use a MIB browser application like [this freeish and cross-platform one](http://ireasoning.com/mibbrowser.shtml) to figure out the numeric OIDs you're interested in
3. use HNMP to retrieve your data and do some light processing
4. put man on moon :rocket:

Usage
-----

```python
>>> from hnmp import SNMP
>>>
>>> snmp = SNMP("example.com", community="public")

# get a single value
>>> uptime = snmp.get("1.3.6.1.2.1.1.3.0")
>>> uptime
datetime.timedelta(412, 29152)

# build a table
>>> wifi_clients = snmp.table(
>>>     "1.3.6.1.4.1.14179.2.1.4.1",
>>>     columns={
>>>         3: "username",
>>>         25: "protocol",
>>>     },
>>>     column_value_mapping={
>>>         "protocol": {
>>>             3: "802.11g",
>>>             6: "802.11n",
>>>         },
>>>     },
>>>     fetch_all_columns=False,  # fetch only named columns (useful with large tables)
>>> )
>>>
>>> wifi_clients.columns["username"]
("jdoe", "rms", "bwayne")
>>> wifi_clients.columns["protocol"]
{'fraction_non_alphanumeric': 0.14994567185802246, 'fraction_numerical': 0.03694313654473017, 'mean_word_length': 3.356466876971609, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 132, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '155123', 'n_tokens_mistral': 946, 'n_tokens_neox': 881, 'n_words': 309}