Update zabbix.api.php

This commit is contained in:
Namhyeon Go 2020-02-04 14:54:42 +09:00 committed by GitHub
parent 1c0b8f302c
commit ce7789b9e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,11 @@
<?php <?php
/** /**
* @file zabbix.api.php * @file zabbix.api.php
* @date 2019-04-08 * @created_on 2019-04-08
* @updated_on 2020-02-04
* @author Go Namhyeon <gnh1201@gmail.com> * @author Go Namhyeon <gnh1201@gmail.com>
* @brief Zabbix JSON-RPC API (3.0) interface module * @brief Zabbix JSON-RPC API (3.0) interface module
* @documentation https://www.zabbix.com/documentation/3.0/manual/api * @documentation https://www.zabbix.com/documentation/current/ (4.4)
*/ */
if(!check_function_exists("get_zabbix_config")) { if(!check_function_exists("get_zabbix_config")) {
@ -57,8 +58,8 @@ if(!check_function_exists("zabbix_authenticate")) {
} }
// set connection to global scope // set connection to global scope
set_shared_var("zabbix_api_url", $zabbix_api_url); set_scope("zabbix_api_url", $zabbix_api_url);
set_shared_var("zabbix_auth", get_property_value("result", $response)); set_scope("zabbix_auth", get_property_value("result", $response));
return $response; return $response;
} }
@ -70,8 +71,8 @@ if(!check_function_exists("zabbix_get_hosts")) {
$response = false; $response = false;
// get zabbix authentication // get zabbix authentication
$zabbix_api_url = get_shared_var("zabbix_api_url"); $zabbix_api_url = get_scope("zabbix_api_url");
$zabbix_auth = get_shared_var("zabbix_auth"); $zabbix_auth = get_scope("zabbix_auth");
// connect to zabbix server // connect to zabbix server
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
@ -105,8 +106,8 @@ if(!check_function_exists("zabbix_get_items")) {
$response = false; $response = false;
// get zabbix authentication // get zabbix authentication
$zabbix_api_url = get_shared_var("zabbix_api_url"); $zabbix_api_url = get_scope("zabbix_api_url");
$zabbix_auth = get_shared_var("zabbix_auth"); $zabbix_auth = get_scope("zabbix_auth");
// connect to zabbix server // connect to zabbix server
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
@ -140,8 +141,8 @@ if(!check_function_exists("zabbix_get_problems")) {
$response = false; $response = false;
// get zabbix authentication // get zabbix authentication
$zabbix_api_url = get_shared_var("zabbix_api_url"); $zabbix_api_url = get_scope("zabbix_api_url");
$zabbix_auth = get_shared_var("zabbix_auth"); $zabbix_auth = get_scope("zabbix_auth");
// connect to zabbix server // connect to zabbix server
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
@ -177,8 +178,8 @@ if(!check_function_exists("zabbix_get_triggers")) {
$response = false; $response = false;
// get zabbix authentication // get zabbix authentication
$zabbix_api_url = get_shared_var("zabbix_api_url"); $zabbix_api_url = get_scope("zabbix_api_url");
$zabbix_auth = get_shared_var("zabbix_auth"); $zabbix_auth = get_scope("zabbix_auth");
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
$response = get_web_json($zabbix_api_url, "jsonrpc2.cache", array( $response = get_web_json($zabbix_api_url, "jsonrpc2.cache", array(
@ -208,8 +209,8 @@ if(!check_function_exists("zabbix_get_alerts")) {
$response = false; $response = false;
// get zabbix authentication // get zabbix authentication
$zabbix_api_url = get_shared_var("zabbix_api_url"); $zabbix_api_url = get_scope("zabbix_api_url");
$zabbix_auth = get_shared_var("zabbix_auth"); $zabbix_auth = get_scope("zabbix_auth");
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
$params = array( $params = array(
@ -257,8 +258,8 @@ if(!check_function_exists("zabbix_get_records")) {
} }
// get zabbix authentication // get zabbix authentication
$zabbix_api_url = get_shared_var("zabbix_api_url"); $zabbix_api_url = get_scope("zabbix_api_url");
$zabbix_auth = get_shared_var("zabbix_auth"); $zabbix_auth = get_scope("zabbix_auth");
// set time range variables // set time range variables
$time_from = get_current_timestamp(array("now" => $now_dt, "adjust" => $adjust)); $time_from = get_current_timestamp(array("now" => $now_dt, "adjust" => $adjust));
@ -268,7 +269,7 @@ if(!check_function_exists("zabbix_get_records")) {
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
$params = array( $params = array(
"output" => "extend", "output" => "extend",
"history" => 3, "history" => array(0, 1, 2, 3, 4), // 0-numeric float; 1-character; 2-log; 3-numeric unsigned; 4-text
"itemids" => $itemids, "itemids" => $itemids,
"sortfield" => "clock", "sortfield" => "clock",
"sortorder" => "DESC", "sortorder" => "DESC",