Ad Widget

Collapse

Mass updating devices triggers, via API and Python 3

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skym
    Junior Member
    • Jun 2020
    • 23

    #1

    Mass updating devices triggers, via API and Python 3

    H there,

    We have ~200+ devices which I would need to go though with a script so only specific network interfaces of our network equipment are monitored. What would be the best approach to this as doing it manually is not desired?

    The specific network interfaces that should be monitored are known, and all of the other interfaces should not generate any alerts.

    Zabbix version is 5.0.2
  • skym
    Junior Member
    • Jun 2020
    • 23

    #2
    Anyone?

    I would just need somebody to point me to the right direction.

    Comment

    • LenR
      Senior Member
      • Sep 2009
      • 1005

      #3
      How do you know which interfaces to add or remove? How did the devices get added to Zabbix?

      Comment

      • skym
        Junior Member
        • Jun 2020
        • 23

        #4
        Originally posted by LenR
        How do you know which interfaces to add or remove? How did the devices get added to Zabbix?
        Devices were added by an automatic discovery, and all devices follow a specific pattern on how they're connected to upstream.
        Basically all devices have at least two uplinks, which are usually two last interfaces. If a device has 48 ports, It's ports 47 and 48.

        Currently all of the interfaces are monitored, which makes false alerts as workstations connect/disconnect.

        Comment

        • LenR
          Senior Member
          • Sep 2009
          • 1005

          #5
          Look at this section of the manual :https://www.zabbix.com/documentation...work_devices?s[]=ifcontrol

          This example uses macros to control which interfaces would be alerted. The default $IFCONTROL is 0, for interfaces to trigger, $IFCONTROL:Ethernetx/yy would be set to one. Then your Python would just set the macros for the interfaces with the highest port numbers on each device.

          Comment

          • eithor
            Member
            • May 2020
            • 50

            #6
            Another option if your devices follow the standard MIB and has IFALIAS, is to use the macro {$NET.IF.IFALIAS.MATCHES} in Zabbix. Set it to e.g. ".*zbxmon.*" and then use e.g. Ansible to change the IFALIAS on the ports you want monitored on the devices. In this way you end up with much fewer autodiscovered items.

            Comment

            • skym
              Junior Member
              • Jun 2020
              • 23

              #7
              Originally posted by eithor
              Another option if your devices follow the standard MIB and has IFALIAS, is to use the macro {$NET.IF.IFALIAS.MATCHES} in Zabbix. Set it to e.g. ".*zbxmon.*" and then use e.g. Ansible to change the IFALIAS on the ports you want monitored on the devices. In this way you end up with much fewer autodiscovered items.
              Would I still need to use $IFCONTROL set to 0?

              Comment


              • eithor
                eithor commented
                Editing a comment
                In this scenario, you would end up with only the interfaces that you actually want to monitor and you therefore do not need to change/set IFCONTROL for any interface.
            • skym
              Junior Member
              • Jun 2020
              • 23

              #8
              Originally posted by LenR
              Look at this section of the manual :https://www.zabbix.com/documentation...work_devices?s[]=ifcontrol

              This example uses macros to control which interfaces would be alerted. The default $IFCONTROL is 0, for interfaces to trigger, $IFCONTROL:Ethernetx/yy would be set to one. Then your Python would just set the macros for the interfaces with the highest port numbers on each device.
              So let's say that my interface is 10G interface, called Ten-GigabitEthernet1/0/29, how would I need to enter it? Can't I just get it match only two highest number interfaces without the need to know the exact interface name?

              Comment


              • skym
                skym commented
                Editing a comment
                All triggers for all of the interfaces are also enabled even with that macro.

              • eithor
                eithor commented
                Editing a comment
                I believe that the triggers will be created, but if you look into the triggers there is a condition there, checking for "IFCONTROL = 1", if it is not set to 1 it will not trigger. Still, I would go for the much cleaner solution by using NET.IF.IFALIAS.MATCHES

              • skym
                skym commented
                Editing a comment
                There is no such condition on any of the created triggers.
            • skym
              Junior Member
              • Jun 2020
              • 23

              #9
              Originally posted by eithor
              Another option if your devices follow the standard MIB and has IFALIAS, is to use the macro {$NET.IF.IFALIAS.MATCHES} in Zabbix. Set it to e.g. ".*zbxmon.*" and then use e.g. Ansible to change the IFALIAS on the ports you want monitored on the devices. In this way you end up with much fewer autodiscovered items.
              That does not work though?

              Code:
              IF-MIB::ifAlias.20 = STRING: uplink
              IF-MIB::ifAlias.21 = STRING: uplink

              Click image for larger version  Name:	Macro.JPG Views:	0 Size:	9.0 KB ID:	406948

              Click image for larger version  Name:	uplinks.JPG Views:	0 Size:	81.8 KB ID:	406947

              Comment


              • eithor
                eithor commented
                Editing a comment
                Your regex in the macro is wrong. You are missing the first dot so it should be (without quotes): ".*uplink.*"
            Working...