OPNsense Forum

Archive => 20.1 Legacy Series => Topic started by: didibo on April 21, 2020, 04:53:00 pm

Title: Net-SNMP plugin CPU usage
Post by: didibo on April 21, 2020, 04:53:00 pm
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).

Code: [Select]
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:

Code: [Select]
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:

Code: [Select]
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.
Title: Re: Net-SNMP plugin CPU usage
Post by: didibo on April 21, 2020, 09:38:46 pm
Not sure if this helps, but when trussing the process some errors do appear regularly every few seconds:

Code: [Select]
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)