Ad Widget

Collapse

Assigning Host Value by Macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kbnoc
    Junior Member
    • Oct 2024
    • 2

    #1

    Assigning Host Value by Macro

    I'm attempting to create some more intelligent triggers for our Database Clusters in order to track the service desired state.

    The service.info key item will let me track the service state as I need it - but I'm running into an issue where I need this to be a bit more "dynamic" in that it needs to know if the cluster node is the desired Primary vs. Secondary node.

    I was hoping to do this by creating a templatized User Macro that we can override at the Host level depending on the desired node state (Primary).

    Roughly, I'm attempting to do something like:

    Code:
    ({MSSQL Server Node:service.info[SQLAgent$NAVINET,state].last()}=1 and
    {MSSQL Server Node:service.info[SQLAgent$NAVINET,state].last()}<>255) and
    {MSSQL Server Node:desiredstate.str(PRIMARY)}<>{$NODESTATUS}
    My current blocker is that final trigger - I can not figure out how I can put in a key item to perform the string comparison. I would like the item "desiredstate" to be set to another macro (as in I want to do a string comparison so that if "PRIMARY" = "PRIMARY" output True) OR do a string comparison directly in the trigger without the need for the key item completely.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    #2
    Based on syntax You seem to have some old installation... ??

    find(/MSSQL Server Node/desiredstate,,regexp,"PRIMARY")=1 (or 0 or replace hardcoded value with usermacro name {$NODESTATUS} for example...)

    Or in old syntax, as you have there .. .srt returns also 1 or 0 as result, finds or not. So most probably "{MSSQL Server Node:desiredstate.str({$NODESTATUS})}<>1" (or 0, depending, what you need).

    Comment

    • kbnoc
      Junior Member
      • Oct 2024
      • 2

      #3
      Yah we're currently using 4.4 due to some internal issues. Upgrading is on our roadmap, just need some decision makers to finish up making long term plans.

      I will try what you've provided - I think that might actually do the trick!

      Comment

      Working...