コード例 #1
0
<?php

require_once "php/login.php";
require_once "php/config.php";
require_once "php/curl.php";
require_once "php/function.php";
$table = array("history", "history_log", "history_str", "history_text", "history_uint");
if (isset($_GET['hostid'])) {
    $hostid = $_GET['hostid'];
    $hostname = $_GET['hostname'];
} else {
    echo "<script>window.location.href='simplelist.php'</script>";
}
$token = login();
$fun = new fun();
$list = $fun->getItem($token, $hostid);
//return json
$list = $list->result;
?>
<!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>
<link href="css/monitor_list.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="father">
	<div id="monitor">
   	  <div id="mon_top">
コード例 #2
0
ファイル: zabbix.php プロジェクト: youli023023/zabbix_api
<?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);
            if (@$sql_result['clock'][3]) {
                echo "itemid:<a href='showhistory.php?itemid=" . $key->itemid . "&table=" . $t . "&key=" . $key->key_ . "'  target='_blank'>" . $key->itemid . "</a> , key_:" . $key->key_ . "&nbsp;&nbsp;&nbsp;";
                echo "<br />";
            }
        }
    }
    /*
    foreach($result as $key){
    	$rs = "itemid:<a href='showhistory.php?itemid=".$key->itemid."&key=".$key->key_."'  target='_blank'>".$key->itemid."</a> , key_:".$key->key_."&nbsp;&nbsp;&nbsp;<br />";