Skip to content

Commit ec6865e

Browse files
author
Alexis Mousset
committed
Improve graph request API
1 parent d2657cb commit ec6865e

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

lib/SimpleZabbixApi.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,36 +84,17 @@ function getItemLastValue($host, $keyname, $key) {
8484
}
8585
}
8686

87-
function getHostId($host) {
88-
$params = array(
89-
'filter'=> array(
90-
'limit' => 1
91-
),
92-
'host'=> $host
93-
);
94-
95-
$result = $this->request('item.get', $params);
96-
97-
if (isset($result['result']) and count($result['result']) > 0) {
98-
return $result['result'][0]['hostid'];
99-
} else {
100-
return null;
101-
}
102-
}
103-
10487
function getGraphId($host, $keyname, $key) {
10588
$params = array(
106-
'output'=> 'extend',
89+
'output'=> 'shorten',
10790
'filter'=> array(
108-
$keyname => $key
109-
),
110-
'hostids'=> array(
111-
$this->getHostId($host)
91+
$keyname => $key,
92+
'host' => $host
11293
)
11394
);
11495

11596
$result = $this->request('graph.get', $params);
116-
97+
11798
if (isset($result['result']) and count($result['result']) == 1) {
11899
return $result['result'][0]['graphid'];
119100
} else {

0 commit comments

Comments
 (0)