Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Philipp STEINER
eonweb
Commits
1e15fd4b
Unverified
Commit
1e15fd4b
authored
Jul 26, 2018
by
EyesOfNetwork
Committed by
GitHub
Jul 26, 2018
Browse files
Merge pull request #27 from EyesOfNetworkCommunity/nagios_bp_services
Closes #26. Use correct cfg file to list host services
parents
caa5ef71
3f0a7a14
Changes
1
Hide whitespace changes
Inline
Side-by-side
module/admin_bp/php/function_bp.php
View file @
1e15fd4b
...
...
@@ -93,38 +93,21 @@ function delete_bp($bp,$bdd){
}
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
[
'service'
]
=
array
()
;
$tabServices
[
'service'
]
=
array
()
;
$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
){
$sql
=
"select name from bp where is_define = 1 and name!=? and priority = ?"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment