Commit c9ecdc92 authored by Jean-Philippe Levy's avatar Jean-Philippe Levy
Browse files

Revert "Multi backends in dashboard"

This reverts commit dc77638b.
parent 14e2a341
......@@ -150,11 +150,4 @@ $array_serv_system = array (
"reload" => "sudo /etc/init.d/snmptt reload")),
);
// sockets definition (for multi-backends !)
$sockets = array(
"unix::-1:/srv/eyesofnetwork/nagios/var/log/rw/live"
//"tcp:192.168.197.100:6557:",
//"tcp:192.168.197.102:6557:"
);
?>
......@@ -17,72 +17,36 @@ if( !empty($_GET["action"]) )
}
}
function checkHost($type, $address, $port, $path){
$host = false;
if($type == "unix"){
$socket_path_connexion = "unix://".$path;
$host = fsockopen($socket_path_connexion, $port, $errno, $errstr, 5);
}
else{
$host = fsockopen($address, $port, $errno, $errstr, 5);
}
return $host;
}
/**
* Get the number of services, ordered by state, and according to the logged user
*/
function getServicesStateNbr()
{
global $sockets;
$result = array();
$nbr_services_ok = 0;
$nbr_services_warning = 0;
$nbr_services_critical = 0;
$nbr_services_unknown = 0;
foreach($sockets as $socket){
$socket_parts = explode(":", $socket);
$socket_type = $socket_parts[0];
$socket_address = $socket_parts[1];
$socket_port = $socket_parts[2];
$socket_path = $socket_parts[3];
if( checkHost($socket_type, $socket_address, $socket_port, $socket_path) ){
if($socket_port == -1){
$socket_port = "";
$socket_address = "";
}
$options = array(
'socketType' => $socket_type,
'socketAddress' => $socket_address,
'socketPort' => $socket_port,
'socketPath' => $socket_path,
);
// construct mklivestatus request, and get the response
$client = new Client($options);
// construct mklivestatus request, and get the response
$response = $client
->get('services')
->stat('state = 0')
->stat('state = 1')
->stat('state = 2')
->stat('state = 3')
->filter('contacts >= '. $_SERVER["REMOTE_USER"])
->execute();
$nbr_services_ok += $response[0][0];
$nbr_services_warning += $response[0][1];
$nbr_services_critical += $response[0][2];
$nbr_services_unknown += $response[0][3];
}
}
// create a new client with options
$options = array(
'socketType' => 'unix',
'socketAddress' => '',
'socketPort' => '',
'socketPath' => '/srv/eyesofnetwork/nagios/var/log/rw/live',
);
$client = new Client($options);
// construct mklivestatus request, and get the response
$response = $client
->get('services')
->stat('state = 0')
->stat('state = 1')
->stat('state = 2')
->stat('state = 3')
->filter('contacts >= '. $_SERVER["REMOTE_USER"])
->execute();
// fill an empty array with previous response, in order to have a beautiful JSON to use
array_push($result, $nbr_services_ok);
array_push($result, $nbr_services_warning);
array_push($result, $nbr_services_critical);
array_push($result, $nbr_services_unknown);
$result = array();
array_push($result, $response[0][0]);
array_push($result, $response[0][1]);
array_push($result, $response[0][2]);
array_push($result, $response[0][3]);
$client->command(
array(
......@@ -100,55 +64,32 @@ foreach($sockets as $socket){
*/
function getHostsStateNbr()
{
global $sockets;
$result = array();
$nbr_host_ok = 0;
$nbr_host_warning = 0;
$nbr_host_critical = 0;
$nbr_host_unknown = 0;
foreach($sockets as $socket){
$socket_parts = explode(":", $socket);
$socket_type = $socket_parts[0];
$socket_address = $socket_parts[1];
$socket_port = $socket_parts[2];
$socket_path = $socket_parts[3];
if( checkHost($socket_type, $socket_address, $socket_port, $socket_path) ){
if($socket_port == -1){
$socket_port = "";
$socket_address = "";
}
$options = array(
'socketType' => $socket_type,
'socketAddress' => $socket_address,
'socketPort' => $socket_port,
'socketPath' => $socket_path,
);
// construct mklivestatus request, and get the response
$client = new Client($options);
// construct mklivestatus request, and get the response
$response = $client
->get('hosts')
->stat('state = 0')
->stat('state = 1')
->stat('state = 2')
->stat('state = 3')
->filter('contacts >= '. $_SERVER["REMOTE_USER"])
->execute();
$nbr_host_ok += $response[0][0];
$nbr_host_warning += $response[0][1];
$nbr_host_critical += $response[0][2];
$nbr_host_unknown += $response[0][3];
}
}
array_push($result, $nbr_host_ok);
array_push($result, $nbr_host_warning);
array_push($result, $nbr_host_critical);
array_push($result, $nbr_host_unknown);
// create a new client with options
$options = array(
'socketType' => 'unix',
'socketAddress' => '',
'socketPort' => '',
'socketPath' => '/srv/eyesofnetwork/nagios/var/log/rw/live',
);
$client = new Client($options);
// construct mklivestatus request, and get the response
$response = $client
->get('hosts')
->stat('state = 0')
->stat('state = 1')
->stat('state = 2')
->stat('state = 3')
->filter('contacts >= '. $_SERVER["REMOTE_USER"])
->execute();
// fill an empty array with previous response, in order to have a beautiful JSON to use
$result = array();
array_push($result, $response[0][0]);
array_push($result, $response[0][1]);
array_push($result, $response[0][2]);
array_push($result, $response[0][3]);
$client->command(
array(
'ACKNOWLEDGE_SVC_PROBLEM',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment