-
Type:
New Feature Request
-
Resolution: Unresolved
-
Priority:
Trivial
-
None
-
Affects Version/s: 7.4.15
-
Component/s: Proxy (P), Server (S)
-
None
Problem Description
When monitoring environments with strict security requirements where only SNMPv3 (authPriv) is permitted, zabbix_proxy / zabbix_server async SNMP pollers spend over 80% of their CPU time inside libnetsnmp's generate_Ku() function.
Because zbx_snmp_open_session() opens a new netsnmp_session per check/walk and passes plaintext passphrases (securityAuthPassphrase / securityPrivPassphrase) every time, net-snmp re-runs the RFC 3414 key derivation loop (hashing 1 MB of data per passphrase, twice per authPriv session) hundreds of times per second.
Even when following all Zabbix best practices—using async snmp poller processes, enabling bulk requests, and utilizing walk[...] master items with dependent items—CPU usage remains bottlenecked by repeated key generation for the exact same passphrases.
Production Environment & Profiling Data
- Zabbix Proxy version: 7.4.13
- Scale: 350 hosts, 71,696 items (using walk[...] templates, SNMPv3 authPriv, bulk requests enabled)
- Poller configuration: 9 async snmp poller processes running at ~78% sustained CPU each (~7 full CPU cores consumed solely by SNMP polling).
1. Syscall & Session Rate (perf trace -s -p <PID> – sleep 2):
Each poller opens ~40 new SNMP sessions per second (~360 sessions/sec across 9 pollers):
zabbix_proxy (1070), 1279 events, 100.0%
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
sendmsg 80 0 1.598 0.017 0.020 0.038 1.69%
socket 80 0 1.493 0.012 0.019 0.040 2.39%
getsockopt 160 0 0.635 0.004 0.004 0.012 1.78%
epoll_ctl 80 0 0.524 0.006 0.007 0.012 1.53%
bind 80 0 0.428 0.005 0.005 0.006 0.57%
getsockname 80 0 0.320 0.004 0.004 0.004 0.25%
uname 80 0 0.289 0.003 0.004 0.004 0.48%
2. User-space CPU Breakdown (perf top -p <PID> --stdio -n):
83.16% of total CPU cycles in the poller process are spent inside generate_Ku():
PerfTop: 3669 irqs/sec kernel: 0.2% exact: 0.0% lost: 0/0 drop: 0/0 [4000Hz task-clock:ppp], (target_pid: 1070)
-------------------------------------------------------------------------------
83.16% 6102 libnetsnmp.so.40.2.1 [.] generate_Ku
0.65% 48 libcrypto.so.3 [.] SHA1_Update
0.42% 31 libcrypto.so.3 [.] EVP_DigestUpdate
At ~360 sessions/sec with authPriv, net-snmp hashes ~720 MB/s of passphrase data continuously just to derive identical Ku keys that rarely or never change.
Proposed Solution
Note: The following architectural approach was proposed with the assistance of AI based on the profiling data above.
Implement an in-memory cache for derived SNMPv3 master keys (Ku) within the poller process (or shared SNMP cache):
- Compute generate_Ku() once per unique tuple of (hash_algorithm, passphrase).
- Store the resulting Ku byte array (USM_KU_LEN) and its length in a local hash table/cache inside the poller process.
- When initializing netsnmp_session in zbx_snmp_open_session(), populate session.securityAuthKey / session.securityAuthKeyLen and session.securityPrivKey / session.securityPrivKeyLen directly from the cache instead of passing plaintext passphrases.
- Invalidate/clear the cache upon configuration cache reload (zabbix_proxy -R config_cache_reload / snmp_cache_reload) or host credential updates.
Expected Impact
- Eliminates ~80%+ of CPU overhead in SNMPv3-heavy environments (reducing CPU usage in our setup from ~7 cores down to <1.5 cores).
- Memory footprint is negligible (a few kilobytes even for thousands of distinct passphrases).
- Fully transparent to users and requires no changes to templates, items, or SNMPv3 security posture.