Ad Widget

Collapse

disable host triggers via script temporarily for app build window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tommyboy
    Junior Member
    • Mar 2010
    • 11

    #1

    disable host triggers via script temporarily for app build window

    Hi I would like to disable 1 or more specific host/s triggers - pre an application build run and then enable the host/s triggers once the build finishes - preferably, as a script.

    With the above option - I will not get spammed during the Application build window, but will be notified if the server crashes during the build.

    Running Zabbix 1.8.1

    Thanks in Advance
  • danrog
    Senior Member
    • Sep 2009
    • 164

    #2
    You could do this easily with the API (which is JSON based). If you do some searches on some of my older posts you should find a PHP API class that I use (or there are some other API abstraction libraries you could use that a general search should turn up if PHP is not your thing [I've seen python and ruby]). With the PHP class it you could do something like this:


    Code:
    <?php
    require_once("ZabbixAPI.class.php");
    
    // This enables debugging, this is rather verbose but can help debug problems
    ZabbixAPI::debugEnabled(TRUE);
    
    // This logs into Zabbix (account must have API rights), and returns false if it fails
    ZabbixAPI::login('http://localhost/zabbix183/','zabbix','')
        or die('Unable to login: '.print_r(ZabbixAPI::getLastError(),true));
    
    $triggers = ZabbixAPI::fetch_array('trigger','get',array('extendoutput'=>1,'pattern'=>'some trigger description','select_items'=>1,'select_hosts'=>1));
    print_r($triggers,true);
    
    foreach ($triggers as $disableme) {
      ZabbixAPI::query('trigger','update',array('triggerid'=>$disablme['triggerid'],'status'=>1)); #might be status =>0 can't remember off the top of my head
    }
    Last edited by danrog; 27-08-2010, 02:24.

    Comment

    Working...