Ad Widget

Collapse

API and Zabbix via PHP => Template update problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zaicnupagadi
    Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2010
    • 73

    #1

    API and Zabbix via PHP => Template update problem

    Hi there everybody!

    I have finally managed to write something into zabbix with API, big success for me!

    When I update a template and assign a host to it, it's all ok. But later as I try to add another host, the new one replace the old one :/ (10049 replaces 10077), As I try to add both of them, it always adds me the second one (only 10049 is in there) . Can anybody tells me what I am doing wrong?

    Many thanks for help! The code is below:

    <?php
    require_once('include/config.inc.php');
    require_once("zabbixapi_class/ZabbixAPI.class.php");
    ZabbixAPI::debugEnabled(TRUE);
    // This logs into Zabbix, and returns false if it fails
    ZabbixAPI::login('http://ZABBIX_IP/','USER','PASS')
    or die('Unable to login: '.print_r(ZabbixAPI::getLastError(),true));

    ZabbixAPI::query('template','update',array('templa teid'=>11058, 'hosts'=> array('hostid' => '10077', 'hostid' => '10049' )))
    or die('Unable to update: '.print_r(ZabbixAPI::getLastError(),true));
    echo "I have updated a host!\n";

    ?>
Working...