Hi,
Thanks for the replies.  I'm working on trying to unregister the oid according 
to the link given below, using unregister_mib(oid, len).  I'm assuming the oid 
can be specified as a byte-string or integer array.  The difficulty I'm having 
is probably related to the ctypes translation mechanism from python.  Here's 
what I'm using in python.  The ctypes module enables the translation from the C 
libraries to python and imports the net-snmp space as libnsa:

import ctypes
from netsnmpapi import *
import netsnmpvartypes
libnsa = ctypes.cdll.LoadLibrary(ctypes.util.find_library("netsnmpagent"))
...
{code that registers oids from new mib}
...
{start subagent}
print(libnsa.unregister_mib(b("SNMPv2-MIB::sysContact"), 
len("SNMPv2-MIB::sysContact"))

This always returns -1, whether I unregister before starting the agent or 
after.  I've also tried unregistering some objects from my mib that were 
previously registered with the same result.

     Winston
________________________________
From: Larry Hayes <lhay...@gmail.com>
Sent: Friday, January 28, 2022 4:48 PM
To: Winston Gadsby <wgad...@enginuitycom.com>
Cc: net-snmp-coders@lists.sourceforge.net 
<net-snmp-coders@lists.sourceforge.net>
Subject: Re: Re-registering sysContact and sysLocation with subagent

Someone just this month asked about taking control of the system description.  
I would suspect that sysContact and sysLocation would follow the same way.

Their solution was to unregister the OID then register your own handler.


unregister_mib() API.

https://sourceforge.net/p/net-snmp/mailman/message/37598495/


It is a hassle, but you can also control the values of those inside of a 
snmpd.local.conf file.

syscontact Nobody <nob...@dev.null>

Your  agent would write the values to that file then SIGHUP the snmpd to pick 
up the changes.


On Fri, Jan 28, 2022 at 3:37 PM Winston Gadsby 
<wgad...@enginuitycom.com<mailto:wgad...@enginuitycom.com>> wrote:
Hi,
I'm running a subagent based on python-netsnmpagent, along with the 
distribution snmpd (net-snmp) agent on a Debian embedded system.  I'm using the 
version of snmpd that comes default with the distribution - 5.7.3.  I have a 
custom MIB for my new variables, similar to SIMPLE-MIB.txt in the 
python-netsnmpagent example.  Through the standard snmp command line commands I 
am able to read and write to the standard MIB defined OIDs, and to the new OIDs 
in my MIB, without issue.

I would like to also be able to take over management of sysContact and 
sysLocation through my subagent.  This makes it easier to control these 
variables through my outside gui.  I've tried registering 
SNMPv2-MIB::sysContact and SNMPv2-MIB::sysLocation through the agentx socket, 
but receive error 263 - duplicate registration.  It seems the primary agent has 
already registered these variables and won't give up control.

How does the agent know which variables the subagent can register and which it 
cannot?  Is my error due to another cause?  My custom MIB is located in the 
same directory as the rest of the system MIBs, in the search path - 
/usr/share/snmp/mibs.  When I register a variable from my MIB, the master agent 
accepts it.  When I attempt to register sysContact or sysLocation it is denied. 
 If all the MIBs are stored together, how does it know my SIMPLE-MIB objects 
can be registered, but the others cannot?  Is there configuration somewhere 
else that determines which MIB variables I can register and which I cannot?  Am 
I only able to register variables in the new MIB?  How does it know which MIBs 
are custom and which are standard?  I've checked the snmpd.conf file, and it 
looks like I can define OID trees that trigger external programs, but there 
doesn't appear to be configuration for which OIDs are under master control and 
which can be controlled by the subagent, for normal snmp command line access.

Is there perhaps a better way of going about doing this?

I've gone through the mail lists and haven't been able to find an answer to 
this question.  Any help/pointers on this would be much appreciated.  Thank you,

Winston

_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net<mailto:Net-snmp-coders@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to