Ad Widget

Collapse

how to programmatically fire trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uhdyi
    Junior Member
    • Sep 2015
    • 1

    #1

    how to programmatically fire trigger

    I want to fire trigger in our java application, but have hard time to understand how trigger works, i've tried :

    {"jsonrpc": "2.0","method": "trigger.create","params": {"description": "test trigger"},"auth": "xxxxxx","id": 1}
    it complained 'Invalid params, incorrect fields for trigger'.

    I guess it need 'expression' in params. but the logic here is to fire a trigger whenever there are something wrong detected by the code, so i tried to set expression to 1 assuming that means expression is always true, but it still wont' work:

    {"jsonrpc": "2.0","method": "trigger.create","params": {"description": "dyi test trigger","expression":"1"}
    now it complained:
    "Invalid params.","data":"Trigger expression must contain at least one host:key reference."

    is there any easy to just to fire a trigger only given it a name?
  • gleepwurp
    Senior Member
    • Mar 2014
    • 119

    #2
    Hi uhdyi,

    I think you're missing the way that Zabbix works. I'll summarize and you'll see why what you are trying to do doesn't work...

    Basically, everything that zabbix does is based on collected metrics (items). Triggers are conditions that are defined to generate an event if a metric (item) meets that condition.

    What you were trying to accomplish is to directly generate an event, and as far as I know, you can't do it this way.

    What you can do is the following:

    1- define a "Zabbix Trapper" item;
    2- Create a trigger on that Zabbix Trapper item, triggering an event when the value equals 1 (for example)
    3- on your java application, use zabbix_sender to update the zabbix trapper item value to 1, when you want the event to get generated, and set it to 0 when you want it to clear.

    There might be other ways to accomplish the same thing, this is what I came up off the top of my head...

    Check this if you need more details: https://www.zabbix.com/documentation...mtypes/trapper

    Good luck!

    G.
    Last edited by gleepwurp; 03-09-2015, 22:39. Reason: Added documentation link

    Comment

    Working...