I've been looking at tuning some elements of my OPNsense system and whilst doing that I've noticed the the SNMP process is using over 5% of my CPU when idle (when no SNMP queries are being sent to it).
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
67970 root 1 22 0 26004K 15188K select 2 0:17 5.04% /usr/local/sbin/snmpd -p /var/run/net_snmpd.pid
If you update 'top' manually with the space bar or set the interval to 1 second, the snmpd process spikes sometimes to 15-30% cpu when idle (no SNMP queries).
(the above was just after a reboot so the total CPU time was still low - I'll post an update once the server has been running for some time).
I don't see why SNMPD should be using quite so much CPU (for reference, this server is running on an i3-8300T).
I see a few errors in /var/log/snmpd.log but these only seem to written ever 30 seconds or so when idle:
error on subcontainer 'ia_addr' insert (-1)
When receiving an actual SNMP query (every 5 mins), quite a few of these get written to the log:
error on subcontainer 'swrun container' insert (-1)
There's very little configuration changes that can be done to Net-SNMP so was wondering if there was an issue in the implementation.
Not sure if this helps, but when trussing the process some errors do appear regularly every few seconds:
socket(PF_INET,SOCK_DGRAM,0) = 10 (0xa)
ioctl(10,SIOCGIFMEDIA,0x6ecaa4521270) ERR#22 'Invalid argument'
close(10) = 0 (0x0)
socket(PF_INET,SOCK_DGRAM,0) = 10 (0xa)
ioctl(10,SIOCGIFMEDIA,0x6ecaa4521270) ERR#22 'Invalid argument'
close(10) = 0 (0x0)
socket(PF_INET,SOCK_DGRAM,0) = 10 (0xa)
ioctl(10,SIOCGIFMEDIA,0x6ecaa4521270) ERR#25 'Inappropriate ioctl for device'
close(10) = 0 (0x0)
socket(PF_INET,SOCK_DGRAM,0) = 10 (0xa)
ioctl(10,SIOCGIFMEDIA,0x6ecaa4521270) ERR#25 'Inappropriate ioctl for device'
close(10) = 0 (0x0)
socket(PF_INET,SOCK_DGRAM,0) = 10 (0xa)
ioctl(10,SIOCGIFMEDIA,0x6ecaa4521270) ERR#22 'Invalid argument'
close(10) = 0 (0x0)
socket(PF_INET,SOCK_DGRAM,0) = 10 (0xa)
ioctl(10,SIOCGIFMEDIA,0x6ecaa4521270) ERR#22 'Invalid argument'
close(10) = 0 (0x0)