PDF report array debugging script (mostly for 1.8.x installations)
Waardd, could you make a file called chooser.debug.php with this contents:
Then, after you have validated your credentials, or if $user_login is zero, point to chooser.debug.php in stead of chooser.php and see what results you get. If you don't see the hosts here, then the API must be incompatible in some way.
I am thinking you'll get a value in the 'host' column, but a blank in the 'name' column. If so, you need to alter the occurences of 'name' to be 'host' wherever calls to the host method is made. Host groups have only 'name' so be carefull not to alter 'name' there.
That ought to do it, or at least get you further.
The easy solution, though (easy for me to say), is to upgrade Zabbix to at least 2.0
Regards,
/Martin.
Waardd, could you make a file called chooser.debug.php with this contents:
Code:
<?php
///////////
//
// DEBUG VERSON OF CHOOSER. ONLY SHOWS HOST AND
// HOST GROUPS ARRAYS, THEN EXITS.
// YOU MAY NEED TO COMMENT THE LOGOUT PART ON Zabbix 1.8.x
//
///////////
include("config.inc.php");
if ( $user_login == 1 ) {
session_start();
//print_r($_SESSION);
$z_user=$_SESSION['username'];
$z_pass=$_SESSION['password'];
if ( $z_user == "" ) {
header("Location: index.php");
}
$z_login_data = "name=" .$z_user ."&password=" .$z_pass ."&autologin=1&enter=Sign+in";
}
global $z_user, $z_pass, $z_login_data;
require_once("inc/ZabbixAPI.class.php");
include("inc/index.functions.php");
header( 'Content-type: text/html; charset=utf-8' );
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>Zabbix Dynamic PDF Report</title>
<meta charset="utf-8" />
</head>
<body>
<?php
// ERROR REPORTING
error_reporting(E_ALL);
set_time_limit(60);
echo "<pre>\n";
// ZabbixAPI Connection
ZabbixAPI::debugEnabled(TRUE);
ZabbixAPI::login($z_server,$z_user,$z_pass)
or die('Unable to login: '.print_r(ZabbixAPI::getLastError(),true));
//fetch graph data host
$hosts = ZabbixAPI::fetch_array('host','get',array('output'=>array('hostid','name','host'),'sortfield'=>'host','with_graphs'=>'1'))
or die('Unable to get hosts: '.print_r(ZabbixAPI::getLastError(),true));
echo "Hosts array:\n";
print_r($hosts);
$host_groups = ZabbixAPI::fetch_array('hostgroup','get', array('output'=>array('groupid','name'),'real_hosts'=>'1','with_graphs'=>'1','sortfield'=>'name') )
or die('Unable to get hosts: '.print_r(ZabbixAPI::getLastError(),true));
echo "Host Groups Array:\n";
print_r($host_groups);
ZabbixAPI::logout($z_server,$z_user,$z_pass)
or die('Unable to logout: '.print_r(ZabbixAPI::getLastError(),true));
//var_dump($hosts);
//var_dump($host_group);
?>
</pre>
</html></body>
I am thinking you'll get a value in the 'host' column, but a blank in the 'name' column. If so, you need to alter the occurences of 'name' to be 'host' wherever calls to the host method is made. Host groups have only 'name' so be carefull not to alter 'name' there.
That ought to do it, or at least get you further.
The easy solution, though (easy for me to say), is to upgrade Zabbix to at least 2.0
Regards,
/Martin.


Comment