Ad Widget

Collapse

Filter out interface in discovery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Freezstyler
    Member
    • Oct 2022
    • 39

    #1

    Filter out interface in discovery


    Hi,
    I created a template where I'm using parts of Network inferfaces discovery. I'm trying to filter out interface with
    Code:
    {#IFTYPE}":"135"}].
    If I do a test from Network interfaces discovery/ Discovery rule I get this output

    Code:
    [{"{#SNMPINDEX}":"1","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Host","{#IFDESCR}":"Host","{#IFTYPE}":"1"},{"{#SNMPINDEX}":"2","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Eth0","{#IFDESCR}":"Eth0","{#IFTYPE}":"188"},{"{#SNMPINDEX}":"3","{#IFOPERSTATUS}":"2","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Eth1","{#IFDESCR}":"Eth 1","{#IFTYPE}":"6"},{"{#SNMPINDEX}":"4","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Eth2","{#IFDESCR}":"Eth 2","{#IFTYPE}":"6"},{"{#SNMPINDEX}":"102","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"vlan 2099","{#IFDESCR}":"vlan 2099","{#IFTYPE}":"135"}]
    I want to filter out the last interface
    Code:
    {"{#SNMPINDEX}":"102","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"vlan 2099","{#IFDESCR}":"vlan 2099","{#IFTYPE}":"135"}]
    In template I have a macro {
    Code:
    $NET.IF.IFNAME.NOT_MATCHES} with values ^135*$
    I created a filter in discovery rule:
    Code:
    {#IFTYPE} does not match {$NET.IF.IFTYPE.NOT_MATCHES}
    But if I do another test I get the same result as above, the interface is not filtered out. I also tried copy all of the macros and filters from original discovery (there is 15 macros and 12 filters) and I edited the original from:

    Code:
    {$NET.IF.IFNAME.NOT_MATCHES} (^Software Loopback Interface|^NULL[0-9.]*$|^[Ll]o[0-9.]*$|^[Ss]ystem$|^Nu[0-9.]*$|^veth[0-9a-z]+$|docker[0-9]+|br-[a-z0-9]{12}) Filter out loopbacks, nulls, docker veth links and docker0 bridge by default
    to:

    Code:
    {$NET.IF.IFNAME.NOT_MATCHES} (^135|^Software Loopback Interface|^NULL[0-9.]*$|^[Ll]o[0-9.]*$|^[Ss]ystem$|^Nu[0-9.]*$|^veth[0-9a-z]+$|docker[0-9]+|br-[a-z0-9]{12}) Filter out loopbacks, nulls, docker veth links and docker0 bridge by default
    But it doesn't work also, so I think I'm doing something wrong, or I can't understand the concept of filters and macros properly.

    Thanks!

  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    #2
    How is "Type of calculation" configured in the LLD filter tab? Usually it should be set to "and".

    Markku

    Comment

    • Freezstyler
      Member
      • Oct 2022
      • 39

      #3
      Now I have only one macro and one filter so there is no such setting, If I just edited the Network Interfaces Discovery where was bunch of filters and macros, there was "and".

      Comment

      • Markku
        Senior Member
        Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
        • Sep 2018
        • 1781

        #4
        Ok. Note that your last example used IFNAME instead of IFTYPE, so if you only have one filter, double-check your macro name, value and the filter rule.

        Markku

        Comment

        • Freezstyler
          Member
          • Oct 2022
          • 39

          #5
          Yeah, there was a typing error, I fixed it, but the result is the same:

          Discovery rules/Filters:

          Code:
          {#IFTYPE} does not match {$NET.IF.IFTYPE.NOT_MATCHES}
          Templates/Macros:

          Code:
          {$NET.IF.IFTYPE.NOT_MATCHES} ^135*$ ^135*$
          Test from discovery rules:

          Code:
          [{"{#SNMPINDEX}":"1","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Host","{#IFDESCR}":"Host","{#IFTYPE}":"1"},{"{#SNMPINDEX}":"2","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Eth0","{#IFDESCR}":"Eth0","{#IFTYPE}":"188"},{"{#SNMPINDEX}":"3","{#IFOPERSTATUS}":"2","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Eth1","{#IFDESCR}":"Eth 1","{#IFTYPE}":"6"},{"{#SNMPINDEX}":"4","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"Eth2","{#IFDESCR}":"Eth 2","{#IFTYPE}":"6"},{"{#SNMPINDEX}":"102","{#IFOPERSTATUS}":"1","{#IFADMINSTATUS}":"1","{#IFALIAS}":"","{#IFNAME}":"vlan 2099","{#IFDESCR}":"vlan 2099","{#IFTYPE}":"135"}]

          Comment

          • Markku
            Senior Member
            Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
            • Sep 2018
            • 1781

            #6
            The filter should match correctly (unless I miss something really obvious).

            If the vlan 2099 was previously discovered (before adjusting the filters), have you manually deleted the item (or configured the LLD rule to delete old items immediately)?

            Markku

            Comment

            • Freezstyler
              Member
              • Oct 2022
              • 39

              #7
              I did not, but I'm discovering it "live" from Test button in Discovery rule, so it should get data from the device and filter them according to my rules, I'm right?

              Comment

              • Markku
                Senior Member
                Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                • Sep 2018
                • 1781

                #8
                The Test button only tests the discovery function, not the full pipeline with preprosessing, filtering and override.

                Go to the host items and check the items that have actually been discovered (in one of the hosts that are using your template).

                Markku

                Comment

                • Freezstyler
                  Member
                  • Oct 2022
                  • 39

                  #9
                  Okay, i will check it tomorrow. Thank you.

                  P.S. Is there any way how to test it with filtering except create a host and link it to template? Because this is very slow way :/

                  Comment

                  • Markku
                    Senior Member
                    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                    • Sep 2018
                    • 1781

                    #10
                    I don't know about slow, you can always set the discovery interval to 1 minute and do "config_cache_reload".

                    Often I use a macro in the discovery interval so that I can easily customize the discovery interval for specific hosts.

                    Markku

                    Comment

                    • Freezstyler
                      Member
                      • Oct 2022
                      • 39

                      #11
                      I tested it today and the vlan2099 is still discovered :/. I deleted the old host, created a new one.

                      Sending screens of my settings:

                      Click image for larger version

Name:	image.png
Views:	4151
Size:	75.7 KB
ID:	454670

                      Click image for larger version

Name:	image.png
Views:	4134
Size:	70.7 KB
ID:	454671
                      Click image for larger version

Name:	image.png
Views:	4126
Size:	48.6 KB
ID:	454672​​

                      Comment

                      • Freezstyler
                        Member
                        • Oct 2022
                        • 39

                        #12
                        Well, I'm stupid . I changed macro for IF.IFDESCR and not for IF.IFTYPE. Now it's working like intended. Thank you very much, you were very helpful. Maybe if you have a minute, you can help me also with this one?



                        I'm really lost :/

                        Comment

                        Working...