A few cosmetic changes in session handling

This commit is contained in:
Pim van Pelt
2025-11-22 06:18:01 +01:00
parent 4935f5a8ef
commit 9596e16887
2 changed files with 42 additions and 27 deletions

View File

@@ -20,18 +20,15 @@ var (
// StartAgentXRoutine initializes the AgentX client and registers the interface MIB
func StartAgentXRoutine(interfaceMIB *ifmib.InterfaceMIB) error {
var network, address string
// Determine network type based on address format
network := "tcp"
if strings.HasPrefix(*AgentXAddr, "/") {
network = "unix"
address = *AgentXAddr
} else {
network = "tcp"
address = *AgentXAddr
}
logger.Debugf("Connecting to AgentX at %s://%s", network, address)
logger.Debugf("Connecting to AgentX at %s://%s", network, *AgentXAddr)
client, err := agentx.Dial(network, address,
client, err := agentx.Dial(network, *AgentXAddr,
agentx.WithTimeout(1*time.Minute),
agentx.WithReconnectInterval(1*time.Second),
)
@@ -44,6 +41,6 @@ func StartAgentXRoutine(interfaceMIB *ifmib.InterfaceMIB) error {
return err
}
logger.Printf("Successfully registered with AgentX at %s://%s", network, address)
logger.Printf("Successfully registered with AgentX at %s://%s", network, *AgentXAddr)
return nil
}