Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Commit 5c6bf5d

Browse files
lingy1028mayurah
andauthored
feat: added SNMP v1/v3 support (#40)
* fix: fixed the default port for SNMP Agent * feat: added SNMPv1/v3 support * fix: lookup authKey and privKey from config.yaml * fix: handle NoSuchInstance error for snmp v2c/v3 * fix: lookup authKey and privKey from config.yaml & double check translated metric data * refactor: removed unused param - hec_config * fix: added all other optional params for creating CommunityData and CommunityData * feat: added capability to specify the Context Name for SNMP v3 * fix: changed to send out the results to SPLUNK HEC on the fly * fix: added more options for AuthProtocols and PrivProtocols * fix: typo * fix: typo v2 * fix: keeping black module happy Co-authored-by: Mayur Pipaliya <[email protected]>
1 parent 335a675 commit 5c6bf5d

File tree

4 files changed

+446
-139
lines changed

4 files changed

+446
-139
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from pysnmp.entity import config
2+
3+
AuthProtocolMap = {
4+
"MD5": config.usmHMACMD5AuthProtocol,
5+
"SHA": config.usmHMACSHAAuthProtocol,
6+
"SHA224": config.usmHMAC128SHA224AuthProtocol,
7+
"SHA256": config.usmHMAC192SHA256AuthProtocol,
8+
"SHA384": config.usmHMAC256SHA384AuthProtocol,
9+
"SHA512": config.usmHMAC384SHA512AuthProtocol,
10+
"NONE": config.usmNoAuthProtocol,
11+
}
12+
13+
PrivProtocolMap = {
14+
"DES": config.usmDESPrivProtocol,
15+
"3DES": config.usm3DESEDEPrivProtocol,
16+
"AES": config.usmAesCfb128Protocol,
17+
"AES128": config.usmAesCfb128Protocol,
18+
"AES192": config.usmAesCfb192Protocol,
19+
"AES192BLMT": config.usmAesBlumenthalCfb192Protocol,
20+
"AES256": config.usmAesCfb256Protocol,
21+
"AES256BLMT": config.usmAesBlumenthalCfb256Protocol,
22+
"NONE": config.usmNoPrivProtocol,
23+
}

splunk_connect_for_snmp_poller/manager/hec_sender.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def post_data_to_splunk_hec(
3333

3434
# TODO Discuss the format of event data payload
3535
def post_event_data(endpoint, host, variables_binds, index, one_time_flag=False):
36-
3736
if "NoSuchInstance" in str(variables_binds):
3837
variables_binds = "error: " + str(variables_binds)
3938

@@ -61,7 +60,6 @@ def post_event_data(endpoint, host, variables_binds, index, one_time_flag=False)
6160
logger.error(f"Connection error when sending data to HEC index - {index}: {e}")
6261

6362

64-
# TODO Discuss the format of metric data payload
6563
def post_metric_data(endpoint, host, variables_binds, index):
6664

6765
json_val = json.loads(variables_binds)

0 commit comments

Comments
 (0)