I've successfully used the API (with PHP) to gather some data and present this in a web page that is then inserted into a screen. Looks awesome, but I need more information - from another remote Zabbix server...
Here's some sample code to illustrate:
This is what the result is on our servers:
I've been trying to figure out how to logout, I'm not new to PHP, but I'm not very good with OO PHP and I can't seem to create a function to logout in the ZabbixAPI.class.php
Help?
advTHANKSance,
Eric
Here's some sample code to illustrate:
PHP Code:
<?php
require_once('include/config.inc.php');
require_once("zabbix_php_api_v1_0/ZabbixAPI.class.php");
ZabbixAPI::debugEnabled(TRUE);
// This logs into Zabbix, and returns false if it fails
ZabbixAPI::login('http://zabbix1.com/zabbix/','api','password')
or die('Unable to login: '.print_r(ZabbixAPI::getLastError(),true));
$version = ZabbixAPI::fetch_string('apiinfo','version')
or die('Unable to get Zabbix Version: '.print_r(ZabbixAPI::getLastError(),true));
echo "Server running Zabbix API Version: $version\n<br>";
// second server
ZabbixAPI::login('http://zabbix2.com/zabbix/','api','password')
or die('Unable to login: '.print_r(ZabbixAPI::getLastError(),true));
$version = ZabbixAPI::fetch_string('apiinfo','version')
or die('Unable to get Zabbix Version: '.print_r(ZabbixAPI::getLastError(),true));
echo "Server running Zabbix API Version: $version\n<br>";
?>
HTML Code:
Server running Zabbix API Version: 1.3 Unable to login: Array ( [code] => -32602 [message] => Invalid params. [data] => Not authorized )
Help?
advTHANKSance,
Eric
Comment