Ad Widget

Collapse

SNMPTRAP REGEXP not working as expected

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nms_allinone
    Junior Member
    • Mar 2024
    • 11

    #1

    SNMPTRAP REGEXP not working as expected

    i am able to receive snmptraps and email notification but i am not able to make accurate with use of regexp as i wanted. i want to display interface Descr. from IFMIB in the event but as soon as i use the regexp it throw me full log message of snmptrap. any suggestion solution will be highly appreciated...below are my try

    ITEAM :

    Click image for larger version

Name:	image.png
Views:	221
Size:	28.2 KB
ID:	480300

    Click image for larger version

Name:	image.png
Views:	218
Size:	7.7 KB
ID:	480302

    Click image for larger version

Name:	image.png
Views:	218
Size:	10.7 KB
ID:	480303​​​
    =======================
    Trigger Name and Condition
    =======================
    Interface {{ITEM.LASTVALUE}.regsub(IF-MIB::ifDescr.*"(.*)")} is down on {HOST.HOST} ( i have cheked regex101.com IF-MIB::ifDescr.*"(.*)" matching the condition from snmptap raw data as show below )


    2024-03-05T06:13:12+0000 ZBXTRAP 192.168.253.73
    PDU INFO:
    messageid 0
    errorindex 0
    receivedfrom UDP: [192.168.253.73]:57644->[192.168.253.78]:162
    errorstatus 0
    transactionid 40
    community public
    version 1
    requestid 38
    notificationtype TRAP
    VARBINDS:
    DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (16152623) 1 day, 20:52:06.23
    SNMPv2-MIB::snmpTrapOID.0 type=6 value=OID: IF-MIB::linkUp
    IF-MIB::ifIndex.8 type=2 value=INTEGER: 8
    IF-MIB::ifDescr.8 type=4 value=STRING: "Loopback100"
    IF-MIB::ifType.8 type=2 value=INTEGER: 24
    SNMPv2-SMI::enterprises.9.2.2.1.1.20.8 type=4 value=STRING: "up"

    2024-03-05T06:15:23+0000 ZBXTRAP 192.168.253.73
    PDU INFO:
    messageid 0
    receivedfrom UDP: [192.168.253.73]:57644->[192.168.253.78]:162
    errorstatus 0
    errorindex 0
    transactionid 41
    community public
    version 1
    requestid 40
    notificationtype TRAP
    VARBINDS:
    DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (16165738) 1 day, 20:54:17.38
    SNMPv2-MIB::snmpTrapOID.0 type=6 value=OID: IF-MIB::linkDown
    IF-MIB::ifIndex.8 type=2 value=INTEGER: 8
    IF-MIB::ifDescr.8 type=4 value=STRING: "Loopback100"
    IF-MIB::ifType.8 type=2 value=INTEGER: 24
    SNMPv2-SMI::enterprises.9.2.2.1.1.20.8 type=4 value=STRING: "administratively down"​

    Click image for larger version

Name:	image.png
Views:	369
Size:	31.9 KB
ID:	480299
    what i wanted to dispay is interface <REGEXP MATCH> is down on <HOST> ​
    Attached Files
  • Answer selected by nms_allinone at 13-03-2024, 08:09.
    nms_allinone
    Junior Member
    • Mar 2024
    • 11

    finally its working i have used this int trigger and tag : Interface {{ITEM.VALUE}.regsub("IF-MIB::link(Down|Up).*"(.*)"", "\1")} {{ITEM.VALUE}.regsub("ifDescr.*"(.*)"", "\1")} is down on {HOST.HOST}

    Comment

    • nms_allinone
      Junior Member
      • Mar 2024
      • 11

      #2
      also it works only with public community trap. if i send trap with othercommunity its not coming.
      in snmptrapd.conf i am having below lines
      authCommunity log,execute,net public
      authCommunity log,execute,net ciscosnmp

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #3
        regsub also requires you to specify, which match group you want to show... so {{ITEM.LASTVALUE}.regsub("IF-MIB::ifDescr.*"(.*)"","\1")}

        Comment

        • nms_allinone
          Junior Member
          • Mar 2024
          • 11

          #4
          Click image for larger version

Name:	image.png
Views:	189
Size:	25.8 KB
ID:	480466
          same error no luck...where i am doing wrong ?

          Comment

          • ZaBeast
            Member
            • Sep 2019
            • 42

            #5
            Trigger Name:
            Interface {{ITEM.VALUE}.regsub("ifDescr.*"(.*)"", "\1")} is down on {HOST.HOST}


            Tags→Trigger tags:
            Name: interface
            Value: {{ITEM.VALUE}.regsub("ifDescr.*"(.*)"", "\1")}

            You can find more information and examples in my tutorial:
            Discover the ultimate guide to configuring SNMP traps on Zabbix, with a step-by-step tutorial that will explain everything in a simple way!
            Last edited by ZaBeast; 12-03-2024, 14:04.

            Comment


            • nms_allinone
              nms_allinone commented
              Editing a comment
              Interface {{ITEM.LASTVALUE}.regsub("IF-MIB::ifDescr.*"(.*)"","\1")} is down on {HOST.HOST} and also tried with ITEM.VALUE same issue.

            • nms_allinone
              nms_allinone commented
              Editing a comment
              thanks for well documentation on snmptrap. i have added comment with solution. may be you can make more simple way.
          • nms_allinone
            Junior Member
            • Mar 2024
            • 11

            #6
            tried as suggested same issue

            Click image for larger version

Name:	image.png
Views:	178
Size:	36.8 KB
ID:	480571
            Attached Files

            Comment

            • nms_allinone
              Junior Member
              • Mar 2024
              • 11

              #7
              finally its working i have used this int trigger and tag : Interface {{ITEM.VALUE}.regsub("IF-MIB::link(Down|Up).*"(.*)"", "\1")} {{ITEM.VALUE}.regsub("ifDescr.*"(.*)"", "\1")} is down on {HOST.HOST}

              Comment

              • nms_allinone
                Junior Member
                • Mar 2024
                • 11

                #8
                Click image for larger version

Name:	image.png
Views:	177
Size:	8.2 KB
ID:	480623
                {first condition match Down|Up} and {second condition match ifDescr} in my case it matches name Loopback201 as per image

                Comment

                Working...