Update zabbix.api.php

This commit is contained in:
Namhyeon Go 2019-11-12 16:41:50 +09:00 committed by GitHub
parent 50d086de36
commit cc606cf278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,20 +45,14 @@ if(!check_function_exists("zabbix_authenticate")) {
// connect to zabbix server // connect to zabbix server
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
$response = get_web_json($zabbix_api_url, "jsondata", array( $response = get_web_json($zabbix_api_url, "jsonrpc2", array(
"headers" => array( "method" => "user.login",
"Content-Type" => "application/json-rpc", "params" => array(
), "user" => $cnf['username'],
"data" => array( "password" => $cnf['password'],
"jsonrpc" => "2.0",
"method" => "user.login",
"params" => array(
"user" => $cnf['username'],
"password" => $cnf['password'],
),
"id" => zabbix_get_id(),
"auth" => null,
), ),
"id" => zabbix_get_id(),
"auth" => null
)); ));
} }
@ -81,20 +75,14 @@ if(!check_function_exists("zabbix_retrieve_hosts")) {
// connect to zabbix server // connect to zabbix server
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
$response = get_web_json($zabbix_api_url, "jsondata", array( $response = get_web_json($zabbix_api_url, "jsonrpc2", array(
"headers" => array( "method" => "host.get",
"Content-Type" => "application/json-rpc", "params" => array(
), "output" => array("hostid", "host"),
"data" => array( "selectInterfaces" => array("interfaceid", "ip"),
"jsonrpc" => "2.0",
"method" => "host.get",
"params" => array(
"output" => array("hostid", "host"),
"selectInterfaces" => array("interfaceid", "ip"),
),
"id" => zabbix_get_id(),
"auth" => $zabbix_auth,
), ),
"id" => zabbix_get_id(),
"auth" => $zabbix_auth
)); ));
$hosts = get_property_value("result", $response); $hosts = get_property_value("result", $response);
@ -116,24 +104,18 @@ if(!check_function_exists("zabbix_get_items")) {
// connect to zabbix server // connect to zabbix server
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
$response = get_web_json($zabbix_api_url, "jsondata", array( $response = get_web_json($zabbix_api_url, "jsonrpc2", array(
"headers" => array( "method" => "host.get",
"Content-Type" => "application/json-rpc", "params" => array(
), "selectInventory" => true,
"data" => array( "selectItems" => array("name", "lastvalue", "units", "itemid", "lastclock", "value_type", "itemid"),
"jsonrpc" => "2.0", "output" => "extend",
"method" => "host.get", "hostids" => $hostids,
"params" => array( "expandDescription" => 1,
"selectInventory" => true, "expandData" => 1,
"selectItems" => array("name", "lastvalue", "units", "itemid", "lastclock", "value_type", "itemid"),
"output" => "extend",
"hostids" => $hostids,
"expandDescription" => 1,
"expandData" => 1,
),
"id" => zabbix_get_id(),
"auth" => $zabbix_auth,
), ),
"id" => zabbix_get_id(),
"auth" => $zabbix_auth
)); ));
$results = get_property_value("result", $response); $results = get_property_value("result", $response);
foreach($results as $result) { foreach($results as $result) {
@ -157,29 +139,23 @@ if(!check_function_exists("zabbix_get_problems")) {
// connect to zabbix server // connect to zabbix server
if(loadHelper("webpagetool")) { if(loadHelper("webpagetool")) {
$response = get_web_json($zabbix_api_url, "jsondata", array( $response = get_web_json($zabbix_api_url, "jsonrpc2", array(
"headers" => array( "method" => "problem.get",
"Content-Type" => "application/json-rpc", "params" => array(
), "output" => "extend",
"data" => array( "selectAcknowledges" => "extend",
"jsonrpc" => "2.0", "selectTags" => "extend",
"method" => "problem.get", "selectSuppressionData" => "extend",
"params" => array( "hostids" => $hostids,
"output" => "extend", "recent" => "false",
"selectAcknowledges" => "extend", //"suppressed" => "false",
"selectTags" => "extend", //"acknowledged" => "false",
"selectSuppressionData" => "extend", //"sortfield" => ["eventid"],
"hostids" => $hostids, //"sortorder" => "DESC",
"recent" => "false", //"time_from" => get_current_datetime(array("adjust" => "1 hour"))
//"suppressed" => "false",
//"acknowledged" => "false",
//"sortfield" => ["eventid"],
//"sortorder" => "DESC",
//"time_from" => get_current_datetime(array("adjust" => "1 hour"))
),
"id" => zabbix_get_id(),
"auth" => $zabbix_auth,
), ),
"id" => zabbix_get_id(),
"auth" => $zabbix_auth
)); ));
} }
@ -188,3 +164,9 @@ if(!check_function_exists("zabbix_get_problems")) {
return $problems; return $problems;
} }
} }
if(!check_function_exists("zabbix_get_triggers")) {
function zabbix_get_triggers($hostids=array()) {
}
}