Ad Widget

Collapse

Preprocessing using regex versus string in the "Replace" function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GarrettCO
    Member
    • Jan 2024
    • 44

    #1

    Preprocessing using regex versus string in the "Replace" function

    When an SNMP trap comes in, I have a macro set up to replace the varbind index information with more descriptive text before it is sent to create an incident ticket. However, it appears unable to use a regular repression within a macro and it has to be a specific string. The intent is in this example 193.183.4.1.3.5.1.4.70, the digit "70" will be any digit, and want the replace function to skip that digit in preprocessing. Using the macro in a REGULAR EXPRESSION preprocessing step works fine to produce indicated output, but using the macro as a REPLACE does not recognize the regex parameter.

    MACRO
    {$ALERTNAME} = "SNMPv2-SMI::enterprises.193.183.4.1.3.5.1.4.(.*) type=4 value=STRING: (.*)"
    REPLACE {$ALERTNAME} = "ERICSSON ALERT"

    SNMP TRAP
    RAW TRAP - IN
    VARBINDS:
    DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=5844482
    SNMPv2-SMI::enterprises.193.183.4.1.3.5.1.4.70 type=4 value=STRING: "vDicos, Diameter Link Failure"


    PREPROCESSED REPLACE - OUT
    VARBINDS:
    DISMAN-EVENT-MIB-sysUpTimeInstance type=67 value=5844482
    ERICSSON ALERT = "vDicos, Diameter Link Failure"


    Based on documentation, it appears REPLACE only accepts specific string. Just reaching out to see if there is a known wildcard expression that would work.
    Last edited by GarrettCO; 12-12-2024, 20:14.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Can you give link to mentioned documentation...? I'm struggling to find suitable "replace"...

    Comment

    • GarrettCO
      Member
      • Jan 2024
      • 44

      #3



      These are the two I was looking at. One under Preprocessing and the the function itself.

      Comment

      Working...