View Full Version : Zaebator - Zabbix PHP Api
hello
i just create Zaebator https://github.com/nike-17/Zaebator
ZAEBATOR - is a skeleton for this JSON-RPC API. Right now i do only user authentication - but it's no problem to implement other methods. You can do it by your self or feel free to ask my (nike-17@ya.ru).
Let me know if you find this project useful
Nikita Groshin
Right now you can:
Login
Get Graph Object
Render Graph Image
i add service layer - now you can get graph image (miss in official API)
EXAMPLE
<?
require './../library/Zaebator.php';
$option = array(
'url' => 'http://zabbixhost/zabbix/api_jsonrpc.php',
'user' => 'user',
'password' => 'password'
);
$zaebator = new Zaebator($option);
$zaebator->userAuthenticate();
$params = array(
"hostids" => array('6666666666666666666')
);
$result = $zaebator->graphGet($params);
$graphcontent = array();
foreach ($result as $item) {
$graphid = $item['graphid'];
$content = Zaebator_Service_Graph::getGraphImageById($zaebato r, $graphid);
$base64 = base64_encode($content);
$graphcontent[] = ('data: image/png ; base64,' . $base64);
}
foreach ($graphcontent as $graph) {
echo "<img src='{$graph}' >";
}
Please let me know is it useful?
maybe i write in wrong tread?
or nobody don't care?
nelsonab
27-10-2011, 18:55
The patches area may not be the best place for this, perhaps the cookbook. Also in my experience from writing Zabcon, you won't really hear much from people until two things happen 1) end users have a need and 2) your program fulfils those needs. Zabcon was around for about 1 year before people started to use it. Now that Zabcon is about 2 years old there is a solid base of people, and features are starting to come along.
Bottom line, it takes time and patience, keep developing and moving forward. Or you could always join another project, such as Zabcon, and help out. :-)
Hi,
What are your objectives with this work? There is already a PHP api module out there. Are you looking to do something different? Or do it better?
Regards,
Dave
LeoCombes
01-12-2011, 15:53
Nike, this could solve my problem?
http://www.zabbix.com/forum/showthread.php?t=23969
Hi,
What are your objectives with this work? There is already a PHP api module out there. Are you looking to do something different? Or do it better?
Regards,
Dave
i just need at my work some kind of OOP wrapper under zabbix api
Nike, this could solve my problem?
http://www.zabbix.com/forum/showthread.php?t=23969
yes shore you can do sommthing like this
require './../library/Zaebator.php';
$option = array(
'url' => 'http://zabbixhost/zabbix/api_jsonrpc.php',
'user' => 'user',
'password' => 'password'
);
$zaebator = new Zaebator($option);
$zaebator->userAuthenticate();
$params = array(
"hostids" => array('6666666666666666666')
);
$result = $zaebator->graphGet($params);
$graphcontent = array();
foreach ($result as $item) {
$graphid = $item['graphid'];
$content = Zaebator_Service_Graph::getGraphImageById($zaebato r, $graphid);
$base64 = base64_encode($content);
$graphcontent[] = ('data: image/png ; base64,' . $base64);
}
foreach ($graphcontent as $graph) {
echo "<img src='{$graph}' >";
}
I'm trying to get this to work, but to no avail, I want to retrieve graphs for PDF generation, I have a php file with the following code
<?
require 'Zaebator.php';
error_reporting(E_ALL);
$option = array(
'url' => 'https://url/zabbix/api_jsonrpc.php',
'user' => 'login',
'password' => 'pass'
);
$zaebator = new Zaebator($option);
$zaebator->userAuthenticate();
$params = array(
"hostids" => array('10064')
);
$result = $zaebator->graphGet($params);
$graphcontent = array();
foreach ($result as $item) {
$graphid = $item['421'];
$content = Zaebator_Service_Graph::getGraphImageById($zaebato r, $graphid);
$base64 = base64_encode($content);
$graphcontent[] = ('data: image/png ; base64,' . $base64);
}
foreach ($graphcontent as $graph) {
echo "<img src='{$graph}' >";
}
but when I visit the page all I see is the following:
'https://url/zabbix/api_jsonrpc.php', 'user' => 'login', 'password' => 'password' ); $zaebator = new Zaebator($option); $zaebator->userAuthenticate(); $params = array( "hostids" => array('10064') ); $result = $zaebator->graphGet($params); $graphcontent = array(); foreach ($result as $item) { $graphid = $item['421']; $content = Zaebator_Service_Graph::getGraphImageById($zaebato r, $graphid); $base64 = base64_encode($content); $graphcontent[] = ('data: image/png ; base64,' . $base64); } foreach ($graphcontent as $graph) { echo "[X]Broken Image"; }
my file and Zaebator.php are in the same directory with the Zaebator folder in the same directory.. What am I doing wrong?