puresnmp icon indicating copy to clipboard operation
puresnmp copied to clipboard

is v1 doc still available ?

Open dberardo-com opened this issue 6 months ago • 2 comments

unfortunately i need the sync implementation of this library ...

dberardo-com avatar Jun 19 '25 21:06 dberardo-com

in particular i am trying to reimplement this in v1:

def snmp_definition(
    id, oid, host, credentials="public", port=161, cache={}, 
    verbose=DEBUG_FUNC
):
    
    import asyncio
    from puresnmp import Client, V2C, V3, PyWrapper, Auth,V1
    cache_key = f'{host}-{port}-{credentials}'
    client = cache.get(cache_key) if cache_key in cache.keys() else None
    if not client:
        if "__v1" in credentials: # as in user@password
            if verbose: print("[SNMP] using credentials type v1")
            credentials = V1(credentials)
        elif "@" in credentials: # as in user@password
            if verbose: print("[SNMP] using credentials type v3")
            cs = credentials.split("@")
            if len(cs) == 3:
                [usenrame,key,key_type] = cs
                credentials = V3(username, Auth(key,key_type))
            else:
                username = cs[0]
                credentials = V3(username)
        else: 
            if verbose: print("[SNMP] using credentials type v2")
            credentials = V2C(credentials)
        client = PyWrapper(Client(host, credentials, port = port))
        cache.__setitem__(cache_key, client)
    
    async def do_polling():
        return await client.get(oid)

    #  try:
    loop = asyncio.get_event_loop()
    result = loop.run_until_complete(do_polling())
    print("result is",result,loop)
    return result

noticeably i would like to flexibly handle v1,v2 and v3 authentications, hostname handling (not just IPs) and caching of host connection (like i am doing in the cache above)

dberardo-com avatar Jun 19 '25 21:06 dberardo-com

I see that "ReadTheDocs" has no links to the old versions. I must have made a mistake in the RTD config :(

You can read the source of the documentation here: https://github.com/exhuma/puresnmp/tree/24595699a49e08bc84a39fff40db68bcfbd73028/docs

I know that it's not the most convenient way to read it. But RST is fairly readable and hopefully it helps.

Unfortunately I currently have to focus on other projects and cannot keep the old 1.x version supported. If I ever get around to it I might review the RTD settings to publish it properly so it keeps the versions.

I will keep this open for now as it is a valid issue that should be solved.

If anyone reads this with RTD experience and willing to send a PR to publish it properly over there, please do.

exhuma avatar Jun 23 '25 17:06 exhuma