Ad Widget

Collapse

Macro expander functionality

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • limo
    Senior Member
    • Dec 2004
    • 192

    #1

    Macro expander functionality

    Hi to all,

    it was discused before, but I think it would be very useable to expand macros from commandline. We use our patch of old zabbix_server because we beed it.

    I think it could be implemented inside zabbix_server process protocol?

    It means we need some commandline which will process stdin , find macros inside and expand them all on stdout. Or similar functionality with commandline..

    Code:
    zabbix_expand [-e eventid] [-t triggerid] [-h hostid] [-m macro]
    will expand macros specific to eventid, triggerid or hostid. If -m is used on commandline, process only string from commandline and exit. If not, process stdin and return values on stdout.
    Example1:
    This example will return values on stdout. We use eventid 1000 to focus on.
    Code:
    zabbix_expand -e 1000 <<EOF
    {HOSTNAME} ({PROFILE.LOCATION}),
    Now: {DATE}-{TIME},
    Event: {EVENT.DATE}-{EVENT.TIME},
    Age: {EVENT.AGE}
    EOF
    Example2:
    This example will return values on stdout. We use hosttid 1000 to focus on.
    Code:
    zabbix_expand -h 1000 <<EOF
    {HOSTNAME} ({PROFILE.LOCATION}),
    Now: {DATE}-{TIME},
    CPU load: {hostname.cpu.load.last(0)}
    EOF
    Example3:
    This example will return values on stdout. We do not focus so we can expand only full name macros, not trigger or host specific.
    Code:
    zabbix_expand <<EOF
    Now: {DATE}-{TIME},
    CPU load: {hostname.cpu.load.last(0)}
    EOF
    Example4:
    We expand only commandline string
    Code:
    zabbix_expand -m '{hostname.cpu.load.last(0)}'
    Thanx !
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    I agree I think such capability would be great and I think it would be best done as a tie into an API.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    Working...