Ad Widget

Collapse

Zabbix to add to MySQL database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patryk
    Junior Member
    • Dec 2012
    • 9

    #1

    Zabbix to add to MySQL database

    Hi All,

    I have this interesting problem to solve - everytime item value changes it should be saved in external database!

    My configuration:
    Zabbix server - CENTOS
    Zabbix agent (active) - Mac OSX
    Item: MacOSXUpTime
    Key system.uptime

    Trigger
    MacUpTimeChange - {PatrykMac:system.uptime.now(0)}>1

    Action
    MacUpTimeProblem
    Maintenance status not in "maintenance" AND Trigger value = "PROBLEM" AND Trigger name like "MacUpTimeChange"
    Run remote commands on current host - Global Script - Add_to_database

    Script
    Add_to_database
    mysql -utest -ptest -htest.myexternal.server -Dtest -e "Insert into ptr_test (nazwa) VALUES('{TRIGGER.NAME}');"

    Now, all this workes. Whenever trigger goes up script is adding new line to database called {TRIGGER.NAME}

    My problems
    Whats added to database is {TRIGGER.NAME}, how do I add "MacUpTimeChange"
    And is its possible can I add last item value to that as well?

    Many thanks for help

    Patryk
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    As noted in Scripts:
    "Some macros that are supported in the commands: {HOST.CONN}, {HOST.IP}, {HOST.DNS}, {HOST.HOST}, {HOST.NAME}[...]"

    I'm not sure if the macro {TRIGGER.NAME} is supported in this context.
    For such kind of requirements I used to use either the type 'Custom script' for remote commands or Custom alertscripts for operation type 'Send message'.
    Both allow to use the macros marked for 'Notifications and commands' in Macros supported by location
    Last edited by BDiE8VNy; 16-03-2013, 19:17. Reason: typo

    Comment

    Working...