Commit Graph

10 Commits

Author SHA1 Message Date
684400ff9e Reduce logging on AgentX connections
Previous logging was very noisy when the agent connection to snmpd
drops:

[ERROR   ] agentx.network - run            : Empty PDU, connection closed!
[INFO    ] agentx.network - disconnect     : Disconnecting from localhost:705
[ERROR   ] agentx.agent - run            : An exception occurred: Empty PDU, disconnecting
[ERROR   ] agentx.agent - run            : Reconnecting
[INFO    ] agentx.agent - run            : Opening AgentX connection
[INFO    ] agentx.network - connect        : Connecting to localhost:705
[ERROR   ] agentx.network - connect        : Failed to connect to localhost:705
[ERROR   ] agentx.agent - run            : An exception occurred: Not connected
[ERROR   ] agentx.agent - run            : Reconnecting
[INFO    ] agentx.agent - run            : Opening AgentX connection
[INFO    ] agentx.network - connect        : Connecting to localhost:705
[ERROR   ] agentx.network - connect        : Failed to connect to localhost:705
[ERROR   ] agentx.agent - run            : An exception occurred: Not connected
[ERROR   ] agentx.agent - run            : Reconnecting

Also, reconnects were attempted every 0.1s, but field research shows
that snmpd, if it restarts, takes ~3-5 seconds to come back (note: this
is also due to a systemd delay in restarting it upon failures).
Hammering the connection is not useful.

This change refactors the logging, to avoid redundant messages:
- sleep 1s between attempts (reducing the loop by 10x)
- Either print 'Connected to' or 'Failed to connect to', not both.
- Remove the 'reconnecting' superfluous message
2023-01-14 11:12:06 +00:00
31529a2815 improvement: add flag for agentx debugging
agentx/network.py always turned on debugging. It can be useful to have
debugging logs of the main application without the agentx debug logs, as
they are quite noisy.

Now, ./vpp-snmp-agent.py -d will turn on application debugging but NOT
agentx debugging. ./vpp-snmp-agent.py -d -dd will turn on both.

NOTE: ./vpp-snmp-agent.py -dd will do nothing, because the '-d' flag
determines the global logging level.
2023-01-10 15:21:32 +01:00
fe794ed286 Remove all global variables 2023-01-08 13:21:00 +01:00
5e11539b44 Format with black 2023-01-08 13:05:42 +01:00
3be732e6ab Remove the workaround for endianness in VPP; Remove the --disable-lcp flag. Catch connect exceptions for VPPStats and VPP API 2022-07-09 10:14:15 +00:00
968c0abe2f Fail the setup if we can't connect to VPP; exit the daemon with non-zero value to force restart by systemd 2022-03-14 23:14:59 +00:00
a574305fb2 Reconnect faster after errors (0.1s sleep) 2021-09-15 07:57:17 +00:00
7206d92f40 Move all loggers to be members of the class, not global objects 2021-09-12 16:08:35 +00:00
c72890868c s/freq/period/ to be more precies; Set default period to 30s; set wait period on reconnect to 10s; Add explicit INFO logline when replacing dataset 2021-09-11 12:45:28 +00:00
8c9c1e2b4a Replace the pyagentx threaded version with a much simpler, non-threaded version. 2021-09-11 12:19:38 +00:00