Unverified Commit 1e15fd4b authored by EyesOfNetwork's avatar EyesOfNetwork Committed by GitHub
Browse files

Merge pull request #27 from EyesOfNetworkCommunity/nagios_bp_services

Closes #26. Use correct cfg file to list host services
parents caa5ef71 3f0a7a14
...@@ -93,38 +93,21 @@ function delete_bp($bp,$bdd){ ...@@ -93,38 +93,21 @@ function delete_bp($bp,$bdd){
} }
function list_services($host_name){ function list_services($host_name){
$path_nagios_ser = "/srv/eyesofnetwork/nagios/etc/objects/services.cfg"; $path_nagios_ser = "/srv/eyesofnetwork/nagios/etc/objects/hosts/". $host_name .".cfg";
$tabServices = array() ; $tabServices = array() ;
$tabServices['service'] = array() ; $tabServices['service'] = array() ;
$lignes = file($path_nagios_ser); $lignes = file($path_nagios_ser);
$hasMatch = 0;
$pattern = "/^$host_name$/"; /**Modification BVI 15/03/2017 */
foreach( $lignes as $ligne) {
/**Modification BVI 15/03/2017
if ( preg_match("/$host_name$/", trim($ligne), $match)) { //Get Host name
$hasMatch = 1;
}*/
$host_ligne = trim(str_replace("host_name", " ", $ligne));
if ( preg_match($pattern, trim($host_ligne), $match)) { //Get Host name
$hasMatch = 1;
}
elseif ( preg_match("#^service_description#", trim($ligne))) {
//$service = preg_split("/[\s]+/", trim($ligne));
$service = trim(str_replace("service_description", " ", $ligne));
//Modification BVI //$service = preg_split("/[\s]+/", trim($ligne));
if ($hasMatch)
$tabServices['service'][] = $service;
//Modification BVI $tabServices['service'][] = $service[1];
$hasMatch = 0;
}
}
natcasesort($tabServices['service']);
array_unshift($tabServices['service'],"Hoststatus");
echo json_encode($tabServices);
}
foreach( $lignes as $ligne) {
if ( preg_match("#^service_description#", trim($ligne))) {
$service = trim(str_replace("service_description", " ", $ligne));
$tabServices['service'][] = $service;
}
}
natcasesort($tabServices['service']);
array_unshift($tabServices['service'],"Hoststatus");
echo json_encode($tabServices);
}
function list_process($bp,$display,$bdd){ function list_process($bp,$display,$bdd){
$sql = "select name from bp where is_define = 1 and name!=? and priority = ?"; $sql = "select name from bp where is_define = 1 and name!=? and priority = ?";
......
Markdown is supported
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