In the following example, ASL script extracts the substring “Agent Restarted for Reason:” from the contents of a trap’s first varbind, and places the remaining string into the notification attribute EventText. In the script, a list of all of the input and output variables as well as the input-only variables precedes the start of the processing (START).
Only the variables used by the script need to be declared:
/* * The first variable binding is a string of the form: * "Agent Restarted for Reason: <text to extract>" */ // Input/Output variables. CLASSNAME = ""; INSTANCENAME = ""; EVENTNAME = ""; AGGREGATE = ""; SEVERITY = ""; EVENTTEXT = ""; CATEGORY = ""; COMMUNITY = ""; DISCARD = ""; FORCEOCCURREDON = ""; UPDATEUD = ""; EXPIRATION = ""; STATE = ""; INMAINTENANCE = ""; CLEARONACKNOWLEDGE = ""; TRAPSOURCE = ""; EVENTTYPE = ""; MAP = ""; ASL = ""; ELEMENTCLASSNAME =""; ELEMENTNAME =""; SYSNAMEORADDR =""; UNKNOWNAGENT =""; LOGFILE =""; USERDEFINED1 = ""; USERDEFINED2 = ""; USERDEFINED3 = ""; USERDEFINED4 = ""; USERDEFINED5 = ""; USERDEFINED6 = ""; USERDEFINED7 = ""; USERDEFINED8 = ""; USERDEFINED9 = ""; USERDEFINED10 = ""; DISCARD_TRAP = "YES"; // Input Variables TIMESTAMP = "0"; IPADDRESS = ""; ENTERPRISE = ""; GENERIC = "9999"; SPECIFIC = "9999"; V1 = ""; V2 = ""; V3 = ""; V4 = ""; V5 = ""; V6 = ""; V7 = ""; V8 = ""; V9 = ""; V10 = ""; V11 = ""; V12 = ""; V13 = ""; V14 = ""; V15 = ""; V16 = ""; V17 = ""; V18 = ""; V19 = ""; V20 = ""; START { PARSE_EVENT_TEXT } PARSE_EVENT_TEXT { input = V1; .. "Reason:" EVENTTEXT: rep(word) eol }
The processing of the trap’s first varbind occurs in the rule PARSE_EVENT_TEXT. The input to the rule is the contents of the first varbind. The line after the input reads all text up to and including “Reason:”. The rest of the string is assigned to the variable EVENTTEXT. Any change to the value of the input/output variables automatically gets placed in the corresponding attribute in the translated Service Assurance notification. ASL Reference Guide provides more information about ASL.