Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#216 #217

Merged
merged 3 commits into from
Jan 31, 2024
Merged

#216 #217

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions config/objects/nOutput_SNMPServer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Author: Surya Kalyan Jaddu
* Author: Surya Kalyan Jaddu
* Changes: Andreia Brizida
*
* <odoc>
* <key>nAttrmon.nOutput_SNMPServer(aMap)</key>
Expand All @@ -9,6 +10,7 @@
* - baseOID((string) Base Oid is used to send traps.\
* - snmpVersion(string) it defines version of SNMP server.\
* - oidMapping(Map) it contains keys mapped with OID values to send traps.\
* - sysUpTime(double) it defines how long ago in milliseconds the trap occurred.\
*
* </odoc>
*/
Expand All @@ -23,6 +25,7 @@ var nOutput_SNMPServer = function (aMap) {
baseOID = _$(aMap.baseOID, "var aMap.baseOID").isString().regexp(/([0-9]{1,4}\.)/).$_("something")
snmpVersion = _$(aMap.snmpVersion, "snmpVersion").oneOf([1, 2, 3]).isNumber().default(2)
oidMapping = _$(aMap.oidMapping, "oidMapping").isObject().$_("Please Map the oid's")
sysUpTime = _$(aMap.sysUpTime, "var aMap.sysUpTime").isDouble().default(0)

snmpAuthPassPhrase = _$(aMap.snmpAuthPassPhrase, "snmpAuthPassPhrase").isString().$_("Please provide snmpAuthPhrase")
snmpPrivPassPhrase = _$(aMap.snmpPrivPassPhrase, "snmpPrivPassPhrase").isString().$_("Please Provoide snmpPrivPassPhrase")
Expand All @@ -42,7 +45,8 @@ var nOutput_SNMPServer = function (aMap) {
"numOfRetries": aMap.numOfRetries,
"snmpVersion": snmpVersion,
"snmpEngineID": snmpEngineID,
"snmpBaseOID": baseOID
"snmpBaseOID": baseOID,
"sysUpTime": sysUpTime
}

this.snmpProtocols = {
Expand Down Expand Up @@ -165,7 +169,13 @@ nOutput_SNMPServer.prototype.sendTrap = function (argsValue, params, snmpProtoco
if (params.snmpVersion <= 2) var snmp = new SNMP(params.snmpIPAddress, params.snmpCommunity); else var snmp = new SNMP(params.snmpIPAddress, params.snmpCommunity, params.snmpTimeout, params.numOfRetries, params.snmpVersion, snmpProtocols);
var response = this.entitiesExtraction(argsValue, IDMapping)
log(stringify(response.trapArr))
snmp.trap(params.snmpBaseOID, response.trapArr)
//snmp.trap(params.snmpBaseOID, response.trapArr)
if (getVersion() > "20231221") {
snmp.trap(params.snmpBaseOID, params.sysUpTime, response.trapArr)
} else {
logWarn("nOutput_SNMPServer | sysUpTime functionality is not available on the current version " + getVersion() + ". Please upgrade to a more recent version.")
snmp.trap(params.snmpBaseOID, response.trapArr)
}
log("Trap Sent Successfully")
}
catch (e) {
Expand Down
1 change: 1 addition & 0 deletions config/outputs.disabled/yaml/10.SNMPServer_Output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ output:
snmpAuthProtocol: "MD5"
snmpPrivProtocol: "AES128"
snmpSecurityName: "NMS"
sysUpTime: 0

Loading