Skip to content

Instantly share code, notes, and snippets.

@manoot
Created January 26, 2012 19:59
Show Gist options
  • Save manoot/1684746 to your computer and use it in GitHub Desktop.
Save manoot/1684746 to your computer and use it in GitHub Desktop.
// get graphids
// Login to Zabbix API using ZabbixAPI.class.php
ZabbixAPI::debugEnabled(TRUE);
ZabbixAPI::login($z_server,$z_user,$z_pass)
or die('Unable to login: '.print_r(ZabbixAPI::getLastError(),true));
//fetch graph data for single host
$hosts = ZabbixAPI::fetch_array('host','get',array('extendoutput'=>'shorten','select_graphs'=>'shorten','filter'=>array('host'=>$site)))
or die('Unable to get hostids: '.print_r(ZabbixAPI::getLastError(),true));
echo "Hosts: ".print_r($hosts, true)."\n<br>";
foreach($hosts as $key => $val) {
print "$key = $val" . '<br>';
}
# Value of $hosts
Array ( [0] => Array ( [graphs] => Array ( [0] => Array ( [graphid] => 493 [name] => Processor Utilization [width] => 900 [height] => 200 [yaxismin] => 0.0000 [yaxismax] => 100.0000 [templateid] => 397 [show_work_period] => 1 [show_triggers] => 1 [graphtype] => 1 [show_legend] => 0 [show_3d] => 0 [percent_left] => 0.0000 [percent_right] => 0.0000 [ymin_type] => 0 [ymax_type] => 0 [ymin_itemid] => 0 [ymax_itemid] => 0 ) [1] => Array ( [graphid] => 494 [name] => Trunk_Trends [width] => 900 [height] => 200 [yaxismin] => 0.0000 [yaxismax] => 100.0000 [templateid] => 393 [show_work_period] => 1 [show_triggers] => 1 [graphtype] => 0 [show_legend] => 0 [show_3d] => 0 [percent_left] => 0.0000 [percent_right] => 0.0000 [ymin_type] => 0 [ymax_type] => 0 [ymin_itemid] => 0 [ymax_itemid] => 0 ) [2] => Array ( [graphid] => 495 [name] => PRI_Status [width] => 900 [height] => 300 [yaxismin] => 0.0000 [yaxismax] => 0.0000 [templateid] => 417 [show_work_period] => 0 [show_triggers] => 0 [graphtype] => 2 [show_legend] => 1 [show_3d] => 1 [percent_left] => 0.0000 [percent_right] => 0.0000 [ymin_type] => 0 [ymax_type] => 0 [ymin_itemid] => 0 [ymax_itemid] => 0 ) ) [maintenances] => Array ( [0] => Array ( [maintenanceid] => 0 ) ) [hostid] => 10090 [proxy_hostid] => 0 [host] => hostname [dns] => [useip] => 1 [ip] => xx.xxx.xx.xx [port] => 10050 [status] => 0 [disable_until] => 0 [error] => [available] => 0 [errors_from] => 0 [lastaccess] => 0 [inbytes] => 0 [outbytes] => 0 [useipmi] => 0 [ipmi_port] => 623 [ipmi_authtype] => -1 [ipmi_privilege] => 2 [ipmi_username] => [ipmi_password] => [ipmi_disable_until] => 0 [ipmi_available] => 0 [snmp_disable_until] => 0 [snmp_available] => 1 [maintenanceid] => 0 [maintenance_status] => 0 [maintenance_type] => 0 [maintenance_from] => 0 [ipmi_ip] => [ipmi_errors_from] => 0 [snmp_errors_from] => 0 [ipmi_error] => [snmp_error] => ) )
# For Each Return
0 = Array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment