Ad Widget

Collapse

Filter network interfaces by alias

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Remzo
    Junior Member
    • Nov 2020
    • 5

    #1

    Filter network interfaces by alias

    Hello
    I want to monitor my cisco device and its interfaces but I would like to be notified about link down only on certain interfaces filtered by alias. For example description of interfaces are: sw-sge2000, r-2850, srv-nas, pc-01, pc-02 but I'm interested about interfaces with names started with sw-, r-, srv- I don't want triggers about pc-01, pc-02.

    For this purpose I used original "Template Module Interfaces SNMP" attached with Zabbix 5.04 and modified probled expression of trigger prototype "Interface {#IFNAME}({#IFALIAS}): Link down from original:
    Code:
    {$IFCONTROL:"{#IFNAME}"}=1 and
    ({Template Module Interfaces SNMP:net.if.status[ifOperStatus.{#SNMPINDEX}].last()}=2 and {Template Module Interfaces SNMP:net.if.status[ifOperStatus.{#SNMPINDEX}].diff()}=1)
    to:
    Code:
    [B]{{#IFALIAS}.regexp({$INTF_REGEX})}=1 and[/B]
    {$IFCONTROL:"{#IFNAME}"}=1 and
    ({Template Module Interfaces SNMP:net.if.status[ifOperStatus.{#SNMPINDEX}].last()}=2 and {Template Module Interfaces SNMP:net.if.status[ifOperStatus.{#SNMPINDEX}].diff()}=1)
    I creaded macro ${INTF_REGEX} with value: sw-* to be notified about interfaces with description starting with sw-.
    Unfortunately it doesn't works I get error:
    Code:
    Invalid expression [{{#IFALIAS}.regexp("sw-*")}=1 and
    1=1 and
    ({28933}=2 and {28934}=1)]
    I think there is problem with expression
    Code:
    [B]{{#IFALIAS}.regexp({$INTF_REGEX})}=1 and[/B]
    but I can't figure whats going on.

    The SNMP OID rule is following:
    Code:
    discovery[
    {#IFOPERSTATUS},1.3.6.1.2.1.2.2.1.8,
    {#IFADMINSTATUS},1.3.6.1.2.1.2.2.1.7,
    {#IFALIAS},1.3.6.1.2.1.31.1.1.1.18,
    {#IFNAME},1.3.6.1.2.1.31.1.1.1.1,
    {#IFDESCR},1.3.6.1.2.1.2.2.1.2,
    {#IFTYPE},1.3.6.1.2.1.2.2.1.3]
    Can anyone give me a tip how to resolve my problem?



    Modified trigger prototype:
    Click image for larger version  Name:	trigger_prototype.PNG Views:	10 Size:	77.5 KB ID:	412118


    Error message:
    Click image for larger version  Name:	trigger_error.PNG Views:	8 Size:	4.3 KB ID:	412119
    Last edited by Remzo; 03-11-2020, 09:19.
  • NilsA
    Senior Member
    • Sep 2020
    • 102

    #2
    A solution might be to create a separate discovery rule for the items you want to get notifications about. Use the filter tab according to your needs.
    Something like: "{#IFALIAS} matches ^.*sw.*$" might work.

    Comment

    • Remzo
      Junior Member
      • Nov 2020
      • 5

      #3
      Hmmm... sounds strange. Why I can't simply use {#IFALIAS} in problem expression?

      Comment

      • NilsA
        Senior Member
        • Sep 2020
        • 102

        #4
        I didn't mean to say that's not possible. I was just offering a solution.

        According to documentation, your syntax might be incorrect in your trigger expression. You used {{#MACRO}.regexp(" ")} but documented is {#MACRO:regex:" "}.
        Another thing i found is this: "If the regex: prefix is used elsewhere as user macro context, like in a trigger expression, it will be treated as static context." from https://www.zabbix.com/documentation...ntext#overview.
        This might be why it is not working with regex.

        So to try it with one discovery rule, you definitely need to get the syntax right.

        Comment

        • Remzo
          Junior Member
          • Nov 2020
          • 5

          #5
          Thanks for replay.

          When i try
          Code:
          {#IFALIAS:regex:"^sw-*"}
          I get error
          Code:
          [URL="http://javascript<b></b>:void(0)"]Details [/URL]Expression syntax error.[LIST][*]Incorrect trigger expression. Check expression part starting from "{#IFALIAS:regex:"^sw-*"}=1[/LIST]

          But when I try {{#IFALIAS}.regexp("^sw-*")}=1 and it pass but doesn't work :| Do you have how to achive same result but maybe another way?

          Summarizing:
          - I want to monitor all interfaces of device but I want to be notified only about these whose alias starts with sw-


          Thanks

          Comment

          • NilsA
            Senior Member
            • Sep 2020
            • 102

            #6
            As stated, try creating another discovery rule and filter accordingly - that would be my solution.

            The documentation clearly states that regex will not work like regex in a trigger expression. Instead, something like ^.*LAN.*$ will be seen as the string "^.*LAN.*$".
            I don't think I can help beyond this point.

            Comment

            Working...