Details

      Description

      Scenario

      I want to add a new trigger for some security reasons. The trigger will be true when a network device configuration has occurred outside of working hours.

      To make things flexible and not hard-coded in the trigger expression i want to use a global / user macro to indicate the working hour window for this host. This is also easier for my non-technical Zabbix colleagues who find a time format like 09:00-20:00 much easier to work with.

      Idea

      1. Create a global macro with a human readable time format (for example 09:00-20:00h)
      2. Make a trigger that detects configuration changes
      3. Use the time() function to lock the trigger in a timeframe

      This is where the problem starts. The time() function requires a HHMMSS format. No problem, we can do some nice regex to fix that:

      {$WORKING_HOURS} = "09:00-20:30h"

      .time() < {{$WORKING_HOURS}.regsub("^([0-9]{2})[0-9]{2})-([0-9]{2})[0-9]{2})h", "\1\200") or
      .time() > {{$WORKING_HOURS}.regsub("^([0-9]{2})[0-9]{2})-([0-9]{2})[0-9]{2})h", "\3\400")

      In my example, this would result in: .time() < 090000 or .time() > 203000

      The problem

      This nice piece of Regex won't work because user macro's are not supported with the regsub function (https://www.zabbix.com/documentation/4.0/manual/config/macros/macro_functions#supported_macro_functions)

      Solution

      Implement the Regsub functionality on user / global macro's.

      Workaround

      For now i use 2 separate macro's ({$WORKING_HOUR_START} and {$WORKING_HOUR_END}). It works but the values are for example 073000 which is much harder to read for people who use Zabbix less than for example 07:30h.

      Thanks in advance. I understand that this scenario is quite niece and not a deal breaker. However there might be more users who are facing this issue for other purposes.

        Attachments

          Activity

            People

            • Assignee:
              wiper Andris Zeila
              Reporter:
              TheNetworkGuy Twan K.
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: