Hello there,
I'm actually working on a way to make ITservices measurable.
Thus, after creating some test ITservices, I worked on an agent php script which purpose is to collect all the existing services with name, status (problems/sla rate) and sla threshold.
So far I stumbled over two problems :
1/ When I create a disovery rule with the key pointing on my script, I can see a beautifull red cross in the infobox of the rule telling me : "Value should be a JSON object"
Ok, very nice, but my output has the appropriate JSON format (JSONlint proof). So I'm a bit lost with this only hint.
2/ In the output itself, I'm able to fetch the service name and threshold (through service.get) and the problems (trigger ids through service.getsla) but it won't show me any actual sla rate.
Here is my script :
So, what have I missed? If someone has any ideas about these issues I'd be glad to hear about it.
And thanks in advance for any usefull reply.
I'm actually working on a way to make ITservices measurable.
Thus, after creating some test ITservices, I worked on an agent php script which purpose is to collect all the existing services with name, status (problems/sla rate) and sla threshold.
So far I stumbled over two problems :
1/ When I create a disovery rule with the key pointing on my script, I can see a beautifull red cross in the infobox of the rule telling me : "Value should be a JSON object"
Ok, very nice, but my output has the appropriate JSON format (JSONlint proof). So I'm a bit lost with this only hint.
2/ In the output itself, I'm able to fetch the service name and threshold (through service.get) and the problems (trigger ids through service.getsla) but it won't show me any actual sla rate.
Here is my script :
PHP Code:
<?php
//Php API path
require './PhpZabbixApiSLA-2.4.2/build/ZabbixApi.class.php';
use ZabbixApi\Zabbixapi;
//Zabbix token creation
$zab = new ZabbixApi("http://myIP/zabbix/api_jsonrpc.php","user","pwd");
$zab->userLogin(array("user"=>"someuser","password"=>"somepwd"));
//Data for service.get
$zab->serviceGet();
$result = $zab->getResponse();
$result = json_decode($result,true);
//Data for service.getsla
$zab->serviceGetSla(array("params"=>array("serviceids","intervals"=>array("from"=>"1420070400","to"=>"1438785000"))));
$result1 = $zab->getResponse();
$result1 = json_decode($result1,true);
$sla = $result1["result"];
//JSON formating
echo "{\n";
echo "\t\"data\":[\n\n";
$first=true;
foreach ($result["result"] as $key=>$srvc) {
if(!$first) echo "\t,\n";
$first = false;
echo "\t{\n";
echo "\t\t\"{#SRVCNAME}\":\"".$srvc["name"]."\",\n";
echo "\t\t\"{#GOODSLA}\": ".$srvc["goodsla"].",\n";
echo "\t\t\"{#STATUS}\": [".json_encode($sla[$srvc["serviceid"]]["problems"]).",".json_encode($sla[$srvc["serviceid"]]["sla"])."]\n";
echo " \t}\n";
};
echo "\n\t]\n";
echo "}\n";
?>
And thanks in advance for any usefull reply.
Comment