User Tools

Site Tools


onboarding:snmpmanager:trap_rule_template

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
onboarding:snmpmanager:trap_rule_template [2024/11/11 12:29] 10.91.120.100onboarding:snmpmanager:trap_rule_template [2026/01/07 11:10] (current) 10.91.120.100
Line 6: Line 6:
 <code groovy> <code groovy>
 com.errigal.snmpmanager.Trap trap -> com.errigal.snmpmanager.Trap trap ->
 + 
   /* Logging Rule: Output information for Technology and Trap rule name */   /* Logging Rule: Output information for Technology and Trap rule name */
-  log.info "Trap-${trap.id}: Starting Trap Rule: {technologyName}-{trapName}...." +  String techName = "TECHNOLOGY_NAME" 
 +  log.info "Trap-${trap.id}: Starting Trap Rule: ${techName}-${trap?.name}...." 
 + 
   com.errigal.snmpmanager.wrapper.TrapWrapper trapWrapper = new com.errigal.snmpmanager.wrapper.TrapWrapper(trap)   com.errigal.snmpmanager.wrapper.TrapWrapper trapWrapper = new com.errigal.snmpmanager.wrapper.TrapWrapper(trap)
-  + 
   /* Extract and Define trap varbind details */   /* Extract and Define trap varbind details */
-  String trapType = trapWrapper.get("trapType"+  String trapType = trapWrapper.getVarbind("trapType"
-  String alarmName = trapWrapper.get("alarmName"+  String alarmName = trapWrapper.getVarbind("alarmName"
-  String alarmText = trapWrapper.get("alarmText"+  String alarmText = trapWrapper.getVarbind("alarmText"
-  String alarmIdentifier = trapWrapper.get("alarmIdentifier")+  String alarmIdentifier = trapWrapper.getVarbind("alarmIdentifier")
   boolean isClear = //Determine if clear trap   boolean isClear = //Determine if clear trap
-  + 
   /* Logging Rule: Log Varbinds Of your technology specific Trap */   /* Logging Rule: Log Varbinds Of your technology specific Trap */
   log.info "Trap ID-${trap.id}: Trap Type = ${trapType}"   log.info "Trap ID-${trap.id}: Trap Type = ${trapType}"
Line 24: Line 25:
   log.info "Trap ID-${trap.id}: Alarm Text = ${alarmText}"   log.info "Trap ID-${trap.id}: Alarm Text = ${alarmText}"
   log.info "Trap ID-${trap.id}: Alarm Identifier = ${alarmPerceivedSeverity}"   log.info "Trap ID-${trap.id}: Alarm Identifier = ${alarmPerceivedSeverity}"
 + 
   com.errigal.snmpmanager.knowledge.DasHub hub   com.errigal.snmpmanager.knowledge.DasHub hub
   com.errigal.snmpmanager.knowledge.DasHub.withTransaction {   com.errigal.snmpmanager.knowledge.DasHub.withTransaction {
-    hub = com.errigal.snmpmanager.knowledge.DasHub.findByIpAddress(ipAddress)+    hub = com.errigal.snmpmanager.knowledge.DasHub.findByIpAddress(trap?.ipAddress)
     if (!hub) {     if (!hub) {
       /* Logging Rule: Output information hub was not found and we are creating an orphan for it */       /* Logging Rule: Output information hub was not found and we are creating an orphan for it */
       log.warn "Trap-${trap.id}: Hub not found for ${trap?.ipAddress}, creating ORPHAN network element for this trap"       log.warn "Trap-${trap.id}: Hub not found for ${trap?.ipAddress}, creating ORPHAN network element for this trap"
       com.errigal.snmpmanager.NetworkElement orphans = com.errigal.snmpmanager.NetworkElement.findByName("ORPHANS")       com.errigal.snmpmanager.NetworkElement orphans = com.errigal.snmpmanager.NetworkElement.findByName("ORPHANS")
-      com.errigal.snmpmanager.Technology technology = com.errigal.snmpmanager.Technology.findByName("{techName}")+      com.errigal.snmpmanager.Technology technology = com.errigal.snmpmanager.Technology.findByName("${techName}")
       hub = new com.errigal.snmpmanager.knowledge.DasHub(       hub = new com.errigal.snmpmanager.knowledge.DasHub(
-        name: "{techName} ${trap.ipAddress}",+        name: "${techName} ${trap.ipAddress}",
         neType: "Controller",         neType: "Controller",
         ipAddress: trap.ipAddress,         ipAddress: trap.ipAddress,
         onAir: true,         onAir: true,
         showInMonitor: true,         showInMonitor: true,
-        technology: "{techName}",+        technology: "${techName}",
         assignedTechnology: technology,         assignedTechnology: technology,
         clusterName: "ORPHANS",         clusterName: "ORPHANS",
Line 49: Line 50:
     }     }
   }   }
-   +  
 + 
   String neName = // Determine or parse Node Name If applicable   String neName = // Determine or parse Node Name If applicable
   boolean isHub = false //Assuming it a child  element, we are checking soon   boolean isHub = false //Assuming it a child  element, we are checking soon
 + 
   if(/* Tech specific determination if Trap Is Hub Trap */) {   if(/* Tech specific determination if Trap Is Hub Trap */) {
     log.info "Trap ID-${trap.id}: Trap association being made with hub: ${hub?.name}"     log.info "Trap ID-${trap.id}: Trap association being made with hub: ${hub?.name}"
Line 63: Line 64:
     alarmingNe = com.errigal.snmpmanager.wrapper.NetworkElementWrapper.findNetworkElement(hub.name, neName, false)     alarmingNe = com.errigal.snmpmanager.wrapper.NetworkElementWrapper.findNetworkElement(hub.name, neName, false)
   }   }
- +  
-  + 
   /* If alarming NE is null here, we could not find a child when we expected to find one */   /* If alarming NE is null here, we could not find a child when we expected to find one */
   if (!alarmingNe) {   if (!alarmingNe) {
Line 77: Line 78:
     log.warn "Trap ID-${trap.id}: Alarm fallback to hub for device missing issue...."     log.warn "Trap ID-${trap.id}: Alarm fallback to hub for device missing issue...."
   }   }
 + 
 /* Time to process trap to gts at this stage */ /* Time to process trap to gts at this stage */
   com.errigal.snmpmanager.GeneralTrapSummary gts   com.errigal.snmpmanager.GeneralTrapSummary gts
Line 100: Line 101:
     log.info "Trap ID-${trap.id}: Successfully General Trap Summary...."     log.info "Trap ID-${trap.id}: Successfully General Trap Summary...."
   }   }
 + 
   /* We need to create new alarm or access an existing alarm if already created previously */   /* We need to create new alarm or access an existing alarm if already created previously */
   com.errigal.snmpmanager.wrapper.GeneralTrapSummaryWrapper gtsw = new com.errigal.snmpmanager.wrapper.GeneralTrapSummaryWrapper(gts)   com.errigal.snmpmanager.wrapper.GeneralTrapSummaryWrapper gtsw = new com.errigal.snmpmanager.wrapper.GeneralTrapSummaryWrapper(gts)
   com.errigal.snmpmanager.ActiveAlarm alarm = gtsw.getActiveAlarmWrapper()?.getDomain()   com.errigal.snmpmanager.ActiveAlarm alarm = gtsw.getActiveAlarmWrapper()?.getDomain()
 + 
   /* If we have a clear, we need to find the alarm corresponsing to the clear */   /* If we have a clear, we need to find the alarm corresponsing to the clear */
   if(isClear) {   if(isClear) {
Line 146: Line 147:
       String summaryString = formNeName + ":" + alarmText       String summaryString = formNeName + ":" + alarmText
       int ticketCreationDelay = 60       int ticketCreationDelay = 60
 + 
       /* Logging Rule: Output information ticket scheduling is in progress for Hub/Child name with given alarm */       /* Logging Rule: Output information ticket scheduling is in progress for Hub/Child name with given alarm */
       log.info "Trap ID-${trap.id}: Scheduling ticket: ${formNeName} - ${alarmText}"       log.info "Trap ID-${trap.id}: Scheduling ticket: ${formNeName} - ${alarmText}"
 + 
       /* In order create a ticket certain values are needed */       /* In order create a ticket certain values are needed */
       String workflowName = ne.workflow ? ne.workflow : "SNMP Trap"       String workflowName = ne.workflow ? ne.workflow : "SNMP Trap"
       HashMap < String, String > ticketValues = new HashMap < String, String > ()       HashMap < String, String > ticketValues = new HashMap < String, String > ()
       ticketValues.put("WORKFLOW", workflowName)       ticketValues.put("WORKFLOW", workflowName)
-      ticketValues.put("MARKET", parentNe.cluster.name)+      ticketValues.put("MARKET", ne.clusterName)
       ticketValues.put("STATUS", "Alarm Received")       ticketValues.put("STATUS", "Alarm Received")
       ticketValues.put("CREATOR", "monitor")       ticketValues.put("CREATOR", "monitor")
       ticketValues.put("SUMMARY", summaryString)       ticketValues.put("SUMMARY", summaryString)
-      ticketValues.put("VISIBILITY", parentNe.cluster.name)+      ticketValues.put("VISIBILITY", ne.clusterName)
       ticketValues.put("PRIORITY", "5")       ticketValues.put("PRIORITY", "5")
 + 
       /* Value which are needed to add SNMP Trap form to ticket */       /* Value which are needed to add SNMP Trap form to ticket */
       HashMap < String, String > formValues = new HashMap < String, String > ()       HashMap < String, String > formValues = new HashMap < String, String > ()
Line 173: Line 174:
       formValues.put("received_date", trap.date)       formValues.put("received_date", trap.date)
       formValues.put("received_time", new java.sql.Time(trap.date.time))       formValues.put("received_time", new java.sql.Time(trap.date.time))
 + 
       HashMap < String, String > [] formsArray = new HashMap < String, String > [1]       HashMap < String, String > [] formsArray = new HashMap < String, String > [1]
       formsArray[0] = formValues       formsArray[0] = formValues
       final int TO_SEC = 60       final int TO_SEC = 60
 + 
       if (gtsw.getDomain().alarmStatus.equalsIgnoreCase("CRITICAL")) {       if (gtsw.getDomain().alarmStatus.equalsIgnoreCase("CRITICAL")) {
         ticketValues.put("PRIORITY", "2")         ticketValues.put("PRIORITY", "2")
Line 188: Line 189:
         ticketCreationDelay = 60         ticketCreationDelay = 60
       }       }
 + 
       gtsw.scheduleAlarmAndTicketForLaterWithForms(0, ticketCreationDelay*TO_SEC, ticketValues, formsArray, com.errigal.snmpmanager.TicketerConfiguration.findByName("default"))       gtsw.scheduleAlarmAndTicketForLaterWithForms(0, ticketCreationDelay*TO_SEC, ticketValues, formsArray, com.errigal.snmpmanager.TicketerConfiguration.findByName("default"))
       /* Logging Rule: Output information ticket scheduling is complete */       /* Logging Rule: Output information ticket scheduling is complete */
onboarding/snmpmanager/trap_rule_template.1731328145.txt.gz · Last modified: 2024/11/11 12:29 by 10.91.120.100