8000 Enable user to connect to snmp agent with agentx over tcp by hosthvo · Pull Request #13 · hosthvo/pyagentx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enable user to connect to snmp agent with agentx over tcp #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,14 @@ Then you can start and stop it with these commands:

configuration file can be found on the default location "/etc/snmp/snmpd.conf".


### To enable AgentX over tcp
Edit your snmpd.conf file to enable tcp connection
agentXSocket tcp:localhost:705

In your minimal client override the following parameters prior to starting your client

# set the socket family, in this case Internet Protocol v4 Addresses
pyagentx.SOCKET_FAMILY = socket.AF_INET
# set the socket to connect to, in this case localhost on port 705
pyagentx.SOCKET_PATH = ('localhost',705)
2 changes: 2 additions & 0 deletions pyagentx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

import logging
import socket

from pyagentx.updater import Updater
from pyagentx.agent import Agent
Expand All @@ -21,6 +22,7 @@ def setup_logging(debug=False):
logger.addHandler(ch)

SOCKET_PATH = "/var/agentx/master"
SOCKET_FAMILY = socket.AF_UNIX

AGENTX_EMPTY_PDU = 1
AGENTX_OPEN_PDU = 1
Expand Down
2 changes: 1 addition & 1 deletion pyagentx/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, queue, oid_list, sethandlers):
def _connect(self):
while True:
try:
self.socket = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM )
self.socket = socket.socket(pyagentx.SOCKET_FAMILY, socket.SOCK_STREAM )
self.socket.connect(pyagentx.SOCKET_PATH)
self.socket.settimeout(0.1)
return
Expand Down
0