?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <?php //登录zabbix获取token $token = login(); $fun = new fun(); $fun->token = $token; //getHost返回带有name、hostid的二维数组 $host = $fun->getHost($fun->token); $count = count($host['name']); echo "共监控" . $count . "台主机<br />"; for ($i = 0; $i < $count; $i++) { echo "hostid:<a href='zabbix.php?hostid=" . $host['hostid'][$i] . "'>" . $host['hostid'][$i] . "</a> , name:" . $host['name'][$i] . "<br />"; } //获取主机Item //先获取itemid才可以获取指定数据的历史内容 if (isset($hostid)) { $result = $fun->getItem($fun->token, $hostid); $result = $result->result; echo "<br><br>"; echo "hostid为" . $hostid . "的有效Item有以下几个:<br />"; foreach ($result as $key) { foreach ($table as $t) { $sql_result = $fun->getHistoryBySql($key->itemid, 1, $t);