<?php

$url = "http://127.0.0.1".$siteroot.'/api/driverstatus?format=json';
$content = file_get_contents($url);
$data = json_decode($content);

$con = $data->consolidator;

$final = array();
$pushed = array();

$final[1] = array();
$final[1]['port'] = $con->port;
$final[1]['online'] = $con->status;
if ($con->status == "Offline") $final[1]['critical'] = 1;
$pushed['Consolidators'] = $final; $final = array();

$driverno = 1;
foreach($data->driver as $drv)
{
	$dr = array();
	$dr['status'] = $drv->status;
	$dr['name'] = $drv->name;
	if ($dr['status'] == "Offline") $dr['critical'] = 1;
	
	$final[$driverno] = $dr;
	
	$driverno = $driverno + 1;
}

$pushed['Drivers'] = $final; $final = array();

$sourceno = 1;
foreach($data->source as $drv)
{
	$src = array();
	$src['status'] = $drv->status;
	$src['name'] = $drv->name;
	$src['mode'] = $drv->mode;
	$src['context'] = $drv->context;
	if ($src['status'] == "Offline") $src['critical'] = 1;
	
	$final[$sourceno] = $src;
	
	$sourceno = $sourceno + 1;
}

$pushed['Sources'] = $final; $final = array();
foreach ($pushed as $k => $v)
{
	$points[$k] = $v;
}
?>