Hello,
I am looking to find out if anyone has experience monitoring SNMP traps on a WAGO PFC 200 controller. So far I have tried the WAGOAppSNMP library but don’t see a function to listen for Trap messages. It’s my understanding that in this case the WAGO controller should be the manager, and the device sending the message will be the agent.
Any advice is appreciated!
I am going to try this with Node-RED next, and will report back :
node-red-contrib-snmp-trap-listener (node) - Node-RED
Hello @MikePsaltis ,
You should take a look to SNMP library from CODESYS IIoT libraries. It looks you can send trap from there (not tested).
Did you have any success with trap listener?
I was able to poll my agent (750-362) with a basic SNMP node but not listen for traps.
@MikePsaltis @Justin_513 how is the node doing ?
If you have any problem with this node i can check it and update it if needed.
@WagoIcard I had to move on to something else before I was able to get trap listener to work in Node-RED or CODESYS. SNMP Get works fine in either, just requires polling rather than being event driven. I was using SNMP_Service_SL 1.12.0.0 (from CODESYS IIoT library demo license) due to customer requirements. Have not tried WagoAppSNMP.
Here’s a snippet.
VAR
// SNMP /////////////////////////////////////////////
fbSnmpGet : SNMP.SNMP_GET_REQUEST;
// Addresses - change as needed
sRIOAddr : STRING(255) := '0.0.0.0'; // Remote IO agent address
sCtrlAddr: STRING(255) := '0.0.0.0'; // Manager / Controller address
// OIDs - change as needed
iNumberofOIDs : INT := 2;
Max_User_OIDs : UINT := (iNumberofOIDs - 1);
// X1 & X2 port status OIDs (750-362)
asOIDs : ARRAY[0..MAX_OIDS] OF STRING(255):= ['1.3.6.1.2.1.2.2.1.8.3',
'1.3.6.1.2.1.2.2.1.8.4'];
// Configuration
uiTimeout : UINT := 1000;
// Change to named community as needed
sCommunity : STRING(255) := 'public';
// polling timer
fbPollSnmp_TON : TON;
END_VAR
VAR CONSTANT
MAX_OIDS : UINT := (SNMP.gc_uiMaxOIDs - 1);
AGENT_PORT : UINT := 163;
MANAGER_PORT : UINT := 161;
X1_STATUS_IDX : UINT := 1;
X2_STATUS_IDX : UINT := 3;
END_VAR
// SNMP Get Function Block
fbSnmpGet(
eRequestType := SNMP.RequestType.GET_REQUEST,
sHost := sRIOAddr,
sOwnIP := sCtrlAddr,
uiPeerPort := AGENT_PORT,
uiSendPort := MANAGER_PORT,
asOIDs := asOIDs,
iNumberofOIDs := iNumberofOIDs,
uiTimeout := uiTimeout,
sCommunity := sCommunity,
bySNMPVersion := SNMP.SNMPVersion.V2c
);
// Handle done/error
IF fbSnmpGet.xDone OR fbSnmpGet.xError THEN
fbSnmpGet.xExecute := FALSE;
fbSnmpGet(xClosePeer := TRUE);
END_IF
// Poll for snmp updates
fbPollSnmp_TON(IN:= NOT fbPollSnmp_TON.Q, PT:= T#1S);
IF fbPollSnmp_TON.Q THEN
fbSnmpGet.xExecute := TRUE;
// Process link states
GVL.xX1_LinkUp := fbSnmpGet.aSNMPValues[X1_STATUS_IDX].liValue = 1;
GVL.xX1_LinkDn := fbSnmpGet.aSNMPValues[X1_STATUS_IDX].liValue = 2;
GVL.xX2_LinkUp := fbSnmpGet.aSNMPValues[X2_STATUS_IDX].liValue = 1;
GVL.xX2_LinkDn := fbSnmpGet.aSNMPValues[X2_STATUS_IDX].liValue = 2;
END_IF