Ad Widget

Collapse

sql for adding triggers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marc
    Senior Member
    • Oct 2004
    • 146

    #1

    sql for adding triggers

    dear alexei and staff,

    iam looking for a way to automate adding items and triggers directly into zabbix from a 3rd. party application. i managed to add an item to the database but after reading lots of the triggers*.php files i still have no idea how to exactly add an item/trigger pair.
    my application will need a dynamic amount of custom parameters to monitor.
    it would be great if someone can post the sql statements for adding item to an existing template and although a trigger.

    thanks,
    marc
    Last edited by marc; 11-05-2006, 10:53.
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    Look at function add_trigger() in triggers.inc.php.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • marc
      Senior Member
      • Oct 2004
      • 146

      #3
      hi all,
      from triggers.inc.php
      /*
      add_trigger(
      $expression, $description, $priority, $status, $comments, $url, $deps=array(), $templateid=0);
      */

      i have always key companies.mtas and [filenamefromc] as a variable passed to my CustomParameter=...

      code from customized mta setup gui:

      add_item is working as expected:
      add_item($_POST[typename],"companies.mtas"."[".$cffilename."]",10001,60,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,365,0, $templateid=1);

      but i still aint get any triggers added to all hosts from template. lost in code pls help. thats what iam trying to to:
      $expressionsendmail='{'."Host.Unix:companies.mtas" ."[".$cffilename."]".".last(0)}".">0";
      add_trigger($expression, $expressionsendmail, 4, 0, 0, 0, "new_dependence" , $templateid=1);

      i think i miss some points like adding function and the hostid to triggerid part. a little working example to add a trigger to all hosts from a template would be great.
      what do i have to do?
      thanks,
      marc
      Last edited by marc; 01-06-2006, 09:44.

      Comment

      • marc
        Senior Member
        • Oct 2004
        • 146

        #4
        ok, got it...

        $triggerid=add_trigger($expressionsendmail, $cffilename, 4, 0, 0, 0, "new_dependence");
        will add a trigger to all hosts with Template Host.Unix (see $expressionsendmail in post above. maybe its from help to someone else.)

        Comment

        Working...