Ejemplo n.º 1
0
<?php

// load the Zabbix Php API which is included in this build (tested on Zabbix v2.2.2)
include_once 'lib/php/ZabbixApiAbstract.class.php';
include_once 'lib/php/ZabbixApi.class.php';
// connect to Zabbix Json API
$api = new ZabbixApi\ZabbixApi('http://s.gcdtechnologies.co.uk/zabbix/api_jsonrpc.php', 'admin', 'gcdtech123!!!');
// Set Defaults
$api->setDefaultParams(array('output' => 'extend'));
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Zabbix Dashboard</title>
	<!-- Let's reset the default style properties -->
	<link rel="stylesheet" type="text/css" href="style/reset.css" />
	<link rel="stylesheet" type="text/css" href="style/theme-alt.css" />
	<!-- added the jQuery library for reloading the page and future features -->
	<script src="lib/js/jquery-2.1.1.min.js"></script>
	<!-- added the masonry js so all blocks are better alligned -->
	<script src="lib/js/masonry.pkgd.min.js"></script>
	<!-- Removed this temporary because I disliked the look -->
	<!--<body class="js-masonry"  data-masonry-options='{ "columnWidth": 250, "itemSelector": ".groupbox" }'>-->
<body id="bg-two">
	
<!-- START GET RENDER DATE - Which will show date and time of generating this file -->
<div id="timestamp">
    <div id="date"><?php 
echo date("d F Y", time());
?>
// 各種初期設定の実施
$SCHEDULER_URL = "http://jobsch_host_name";
$SCHEDULER_PORT = "5555";
$ZABBIX_SERVER = "zabbix_host_name";
$ZABBIX_APIURL = "http://zabbix_host_name/zabbix/api_jsonrpc.php";
$ZABBIX_SENDER = "/usr/local/bin/zabbix_sender";
$ZABBIX_USER = "******";
$ZABBIX_PASS = "******";
$LOG_DIR = "/var/log/zabbix/";
$LOG_FILE = "jobscheudler_to_zabbix.log";
$KEY_ID = ".id";
$KEY_ELAPSE = ".elapse";
$NEXT_JOBS = "100";
// zabbixへの接続
try {
    $api = new ZabbixApi\ZabbixApi($ZABBIX_APIURL, $ZABBIX_USER, $ZABBIX_PASS);
} catch (Exception $e) {
    echo $e->getMessage();
}
// JobSchedulerに定義されている全Job情報を取得
$jsObj = new SOS_JobSchedulerCommand($SCHEDULER_URL, $SCHEDULER_PORT);
$showCmd = '<show_state />';
// 全Jobの情報を取得するxmlコマンド
$jsObj->command($showCmd);
// JobSchedulerに対してコマンドを発行
if ($jsObj->getAnswerError()) {
    $msg = $jsObj->getAnswerError()["text"];
    print 'code was 12 : ' . $msg;
}
$xml = $jsObj->getAnswer();
$jobList = array();