Ad Widget

Collapse

Zabbix Server-based scripts and MACROS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spajjie
    Junior Member
    • Sep 2024
    • 2

    #1

    Zabbix Server-based scripts and MACROS

    Hi,

    I'm trying to create a script that runs on a host. All I want it to do is pass through the following key found on the HOST.
    {HOSTs.windows.inventory.serialnumber.last()}

    The follows commands are saved:
    echo ".."
    echo {HOSTs.windows.inventory.serialnumber.last()}
    echo ".."

    However, when I run this script from latest data on a host, I get an error:

    Details Cannot execute script.
    • ..
    • sh: 2: Syntax error: "(" unexpected
    The problem is that the {HOSTs.windows.inventory.serialnumber.last()} value is not being evaluated. I've changed the script slightly to run a local script, i.e. /tmp/somescript.sh {HOSTs.windows.inventory.serialnumber.last()} and I get the same result. I can confirm there is a value set under that host key.

    I've also tried a USER MACRO, i.e {$TEST} = {HOSTs.windows.inventory.serialnumber.last()}​ and even a GLOBAL MACRO, but none of it renders.

    I'm using Zabbix Server 6

    What am I missing here?

    Thanks






    ​​
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    using older syntax... maybe last(/host/item) will work better? Or expression macros ? https://www.zabbix.com/documentation...ression_macros

    Comment

    Working...