Upgrade go-agentx to v0.3.0, containing my ordering fix

This commit is contained in:
Pim van Pelt
2025-11-21 10:08:23 +01:00
parent a0d5c61643
commit b6d2e3b629
6 changed files with 27 additions and 23 deletions

View File

@@ -178,13 +178,9 @@ func (m *InterfaceMIB) UpdateStats(interfaceStats *api.InterfaceStats) {
m.addInterfaceToMIB(&iface)
}
// Update both sessions with the new handler
if m.ifEntrySession != nil {
m.ifEntrySession.Handler = m.handler
}
// Note: With go-agentx 0.3.0, handlers are set during session creation and cannot be changed
if m.ifXTableSession != nil {
m.ifXTableSession.Handler = m.handler
logger.Printf("Updated session handlers with new IF-MIB data for %d interfaces", len(m.stats))
logger.Printf("Updated IF-MIB data for %d interfaces", len(m.stats))
}
logger.Debugf("IF-MIB now contains %d interfaces", len(m.stats))
@@ -460,13 +456,13 @@ func (m *InterfaceMIB) RegisterWithClient(client *agentx.Client) error {
m.mutex.Lock()
defer m.mutex.Unlock()
// Create separate sessions for each MIB
ifEntrySession, err := client.Session()
// Create separate sessions for each MIB with the handler
ifEntrySession, err := client.Session(value.MustParseOID(ifEntryOID), "ifEntry", m.handler)
if err != nil {
return fmt.Errorf("failed to create ifEntry session: %v", err)
}
ifXTableSession, err := client.Session()
ifXTableSession, err := client.Session(value.MustParseOID(ifXTableOID), "ifXTable", m.handler)
if err != nil {
return fmt.Errorf("failed to create ifXTable session: %v", err)
}
@@ -474,10 +470,6 @@ func (m *InterfaceMIB) RegisterWithClient(client *agentx.Client) error {
m.ifEntrySession = ifEntrySession
m.ifXTableSession = ifXTableSession
// Set handlers for both sessions
ifEntrySession.Handler = m.handler
ifXTableSession.Handler = m.handler
// Register the classic ifEntry
err = ifEntrySession.Register(127, value.MustParseOID(ifEntryOID))
if err != nil {