Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
* refs #564
Browse files Browse the repository at this point in the history
    * Add filter for servicegroup in servicegroup page in monitoring section
  • Loading branch information
Lionel Assepo committed Sep 16, 2015
1 parent 5a96c26 commit d00def0
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 18 deletions.
1 change: 1 addition & 0 deletions www/include/monitoring/status/Common/commonJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

var _search = '<?php global $url ; echo ($search ? $search : (isset($centreon->historySearchService[$url]) ? $centreon->historySearchService[$url] : ""));?>';
var _host_search = '<?php global $url ; echo (isset($search_host) && $search_host != "" ? $search_host : (isset($centreon->historySearch[$url]) ? $centreon->historySearch[$url] : "")); ?>';
var _sg_search = '<?php global $url ; echo (isset($search_sg) && $search_sg != "" ? $search_sg : (isset($centreon->historySearch[$url]) ? $centreon->historySearch[$url] : "")); ?>';
var _output_search = '<?php global $url ; echo (isset($search_output) && $search_output != "" ? $search_output : (isset($centreon->historySearchOutput[$url]) ? $centreon->historySearchOutput[$url] : "")); ?>';

var _num='<?php echo $num?>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,30 @@
$tpl->assign('pollerStr', _('Poller'));
$tpl->assign('poller_listing', $oreon->user->access->checkAction('poller_listing'));
$tpl->assign("mon_status_information", _("Status information"));



/*
* Get servicegroups list
*/
$query = "SELECT DISTINCT sg.sg_name FROM servicegroup sg";
$DBRESULT = $pearDB->query($query);
$sgSearchSelect = '<select id="sg_search" name="sg_search">';
while ($row = $DBRESULT->fetchRow()) {
$sgSearchSelect .= '<option value="' . $row['sg_name'] . '">' . $row['sg_name'] .'</option>';
//$serviceGroups[] = $row['sg_name'];
}
$DBRESULT->free();
$sgSearchSelect .= '</select>';
$tpl->assign("sgSearchSelect", $sgSearchSelect);


$form = new HTML_QuickForm('select_form', 'GET', "?p=".$p);


$tpl->assign("order", strtolower($order));
$tab_order = array("sort_asc" => "sort_desc", "sort_desc" => "sort_asc");
$tpl->assign("tab_order", $tab_order);






##Toolbar select $lang["lgd_more_actions"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ function mainLoopLocal() {
}
}
_oldInputFieldValue = _currentInputFieldValue;

jQuery("#sg_search").on('change', function(){
monitoring_refresh();
});

setTimeout("mainLoopLocal()", 250);
}
Expand All @@ -136,10 +140,17 @@ function initM(_time_reload, _sid, _o ){
construct_HostGroupSelectList('hostgroups_selected');

if (document.getElementById("host_search") && document.getElementById("host_search").value) {
_search = document.getElementById("host_search").value;
_host_search = document.getElementById("host_search").value;
viewDebugInfo('search: '+document.getElementById("host_search").value);
} else if (document.getElementById("host_search").lenght == 0) {
_search = "";
} else if (document.getElementById("host_search").lenght === 0) {
_host_search = "";
}

if (document.getElementById("sg_search") && document.getElementById("sg_search").value) {
_sg_search = document.getElementById("sg_search").value;
viewDebugInfo('search: '+document.getElementById("sg_search").value);
} else if (document.getElementById("sg_search").lenght == 0) {
_sg_search = "";
}

if (_first){
Expand All @@ -157,12 +168,13 @@ function goM(_time_reload, _sid, _o) {
_lock = 1;
var proc = new Transformation();
proc.setCallback(monitoringCallBack);
proc.setXml(_addrXML+"?"+'sid='+_sid+'&search='+_search+'&num='+_num+'&limit='+_limit+'&sort_type='+_sort_type+'&order='+_order+'&date_time_format_status='+_date_time_format_status+'&o='+_o+'&p='+_p+'&time=<?php print time(); ?>');
proc.setXml(_addrXML+"?"+'sid='+_sid+'&host_search='+_host_search+'&sg_search='+_sg_search+'&num='+_num+'&limit='+_limit+'&sort_type='+_sort_type+'&order='+_order+'&date_time_format_status='+_date_time_format_status+'&o='+_o+'&p='+_p+'&time=<?php print time(); ?>');
proc.setXslt(_addrXSL);
proc.transform("forAjax");

if (_counter == 0) {
document.getElementById("host_search").value = _host_search;
document.getElementById("sg_search").value = _sg_search;
_counter += 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,21 @@
!isset($_GET["search_type_service"]) ? $search_type_service = 1 : $search_type_service = $_GET["search_type_service"];
!isset($_GET["sort_type"]) ? $sort_type = "host_name" : $sort_type = $_GET["sort_type"];
!isset($_GET["host_search"]) ? $host_search = 0 : $host_search = $_GET["host_search"];
!isset($_GET["sg_search"]) ? $sg_search = 0 : $sg_search = $_GET["sg_search"];

/*
* Check search value in Host search field
*/
if (isset($_GET["host_search"])) {
$centreon->historySearch[$url] = $_GET["host_search"];
}

/*
* Check search value in Service Group search field
*/
if (isset($_GET["sg_search"])) {
$centreon->historySearch[$url] = $_GET["sg_search"];
}

$tab_class = array("0" => "list_one", "1" => "list_two");
$rows = 10;
Expand All @@ -79,6 +87,21 @@
$tpl->assign('pollerStr', _('Poller'));
$tpl->assign('poller_listing', $oreon->user->access->checkAction('poller_listing'));
$tpl->assign("mon_status_information", _("Status information"));


/*
* Get servicegroups list
*/
$query = "SELECT DISTINCT sg.sg_name FROM servicegroup sg";
$DBRESULT = $pearDB->query($query);
$sgSearchSelect = '<select id="sg_search" name="sg_search"><option value="">Choose a service group</option>';
while ($row = $DBRESULT->fetchRow()) {
$sgSearchSelect .= '<option value="' . $row['sg_name'] . '">' . $row['sg_name'] .'</option>';
//$serviceGroups[] = $row['sg_name'];
}
$DBRESULT->free();
$sgSearchSelect .= '</select>';
$tpl->assign("sgSearchSelect", $sgSearchSelect);


$form = new HTML_QuickForm('select_form', 'GET', "?p=".$p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function mainLoopLocal() {
if (!_lock) {
set_search_host(escapeURI(_currentInputFieldValue));
_host_search = _currentInputFieldValue;
_sg_search = _currentInputFieldValue;

monitoring_refresh();

Expand All @@ -115,6 +116,10 @@ function mainLoopLocal() {
}
}
_oldInputFieldValue = _currentInputFieldValue;

jQuery("#sg_search").on('change', function(){
monitoring_refresh();
});

setTimeout("mainLoopLocal()", 250);
}
Expand All @@ -128,9 +133,16 @@ function initM(_time_reload, _sid, _o ){
if (document.getElementById("host_search") && document.getElementById("host_search").value) {
_host_search = document.getElementById("host_search").value;
viewDebugInfo('search: '+document.getElementById("host_search").value);
} else if (document.getElementById("host_search").lenght == 0) {
} else if (document.getElementById("host_search").lenght === 0) {
_host_search = "";
}

if (document.getElementById("sg_search") && document.getElementById("sg_search").value) {
_sg_search = document.getElementById("sg_search").value;
viewDebugInfo('search: '+document.getElementById("sg_search").value);
} else if (document.getElementById("sg_search").lenght == 0) {
_sg_search = "";
}

if (_first){
mainLoopLocal();
Expand All @@ -147,12 +159,13 @@ function goM(_time_reload, _sid, _o) {
_lock = 1;
var proc = new Transformation();
proc.setCallback(monitoringCallBack);
proc.setXml(_addrXML+"?"+'sid='+_sid+'&search='+_host_search+'&num='+_num+'&limit='+_limit+'&sort_type='+_sort_type+'&order='+_order+'&date_time_format_status='+_date_time_format_status+'&o='+_o+'&p='+_p+'&time=<?php print time(); ?>');
proc.setXml(_addrXML+"?"+'sid='+_sid+'&host_search='+_host_search+'&sg_search='+_sg_search+'&num='+_num+'&limit='+_limit+'&sort_type='+_sort_type+'&order='+_order+'&date_time_format_status='+_date_time_format_status+'&o='+_o+'&p='+_p+'&time=<?php print time(); ?>');
proc.setXslt(_addrXSL);
proc.transform("forAjax");

if (_counter == 0) {
document.getElementById("host_search").value = _host_search;
document.getElementById("sg_search").value = _sg_search;
_counter += 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<tr>
<td>{$search}</td>
<td><input size="15" id="host_search" class="search_input" style="padding-top:1px;padding-bottom:1px;" name="host_search" type="text" /></td>
<td>{$sgSearchSelect}</td>
{if $poller_listing}
<td>{$pollerStr}:</td>
<td><span id="instance_selected"></span></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

ini_set("display_errors", "Off");

include_once "@CENTREON_ETC@/centreon.conf.php";
//include_once "@CENTREON_ETC@/centreon.conf.php";
include_once "/etc/centreon/centreon.conf.php";

include_once $centreon_path . "www/class/centreonXMLBGRequest.class.php";
include_once $centreon_path . "www/include/monitoring/status/Common/common-Func.php";
Expand Down Expand Up @@ -74,7 +75,8 @@
$limit = $obj->checkArgument("limit", $_GET, 20);
$instance = $obj->checkArgument("instance", $_GET, $obj->defaultPoller);
$hostgroups = $obj->checkArgument("hostgroups", $_GET, $obj->defaultHostgroups);
$search = $obj->checkArgument("search", $_GET, "");
$hSearch = $obj->checkArgument("host_search", $_GET, "");
$sgSearch = $obj->checkArgument("sg_search", $_GET, "");
$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name");
$order = $obj->checkArgument("order", $_GET, "ASC");
$dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "d/m/Y H:i:s");
Expand All @@ -98,9 +100,14 @@
}
$rq1 = "";
$rq1 .= " h.host_id = s.host_id AND s.host_id = sgm.host_id ";
if ($search != ""){
$rq1 .= " AND h.name like '%" . $search . "%' ";
if ($hSearch != ""){
$rq1 .= " AND h.name like '%" . $hSearch . "%' ";
}

if ($sgSearch != ""){
$rq1 .= " AND sg.name like '=" . $sgSearch . "' ";
}

$rq1 .= $obj->access->queryBuilder("AND", "s.service_id", $obj->access->getServicesString("ID", $obj->DBC));

$rq1 .= " AND s.enabled = 1 AND s.service_id = sgm.service_id AND sgm.servicegroup_id = sg.servicegroup_id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

ini_set("display_errors", "Off");

include_once "@CENTREON_ETC@/centreon.conf.php";
//include_once "@CENTREON_ETC@/centreon.conf.php";
include_once "/etc/centreon/centreon.conf.php";

include_once $centreon_path . "www/class/centreonXMLBGRequest.class.php";
include_once $centreon_path . "www/include/monitoring/status/Common/common-Func.php";
Expand Down Expand Up @@ -72,7 +73,8 @@
$limit = $obj->checkArgument("limit", $_GET, 20);
$instance = $obj->checkArgument("instance", $_GET, $obj->defaultPoller);
$hostgroups = $obj->checkArgument("hostgroups", $_GET, $obj->defaultHostgroups);
$search = $obj->checkArgument("search", $_GET, "");
$hSearch = $obj->checkArgument("host_search", $_GET, "");
$sgSearch = $obj->checkArgument("sg_search", $_GET, "");
$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name");
$order = $obj->checkArgument("order", $_GET, "ASC");
$dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "d/m/Y H:i:s");
Expand All @@ -96,9 +98,14 @@
}
$rq1 = "";
$rq1 .= " h.host_id = s.host_id AND s.host_id = sgm.host_id ";
if ($search != ""){
$rq1 .= " AND h.name like '%" . $search . "%' ";
if ($hSearch != ""){
$rq1 .= " AND h.name like '%" . $hSearch . "%' ";
}

if ($sgSearch != ""){
$rq1 .= " AND sg.name like '=" . $sgSearch . "' ";
}

$rq1 .= $obj->access->queryBuilder("AND", "s.service_id", $obj->access->getServicesString("ID", $obj->DBC));

$rq1 .= " AND s.enabled = 1 AND s.service_id = sgm.service_id AND sgm.servicegroup_id = sg.servicegroup_id";
Expand Down

0 comments on commit d00def0

Please sign in to comment.