Now all my widgets hostgroup-monitoring stay empty on the Home/Custom View, after the upgrade to 24.10.2 !
How to get them back ???
Hi
did you use regex filter in the widget hostgroup-monitoring ?
Just to add my 2 cents to this question :
We have the same behavior after the upgrade (24.4.2 to 24.10.2)
In the widget, we use “Hostgroup Name Search” with either “=” or “LIKE”, none of them work
If I create a new widget with this “hostgroup-monitoring”, I can see a strange behavior :
By default, I can see all of my groups without any filters, but the moment I try to filter by hostgroup name, even if it’s a group name I just copied from the previous view, the widget stays blank.
EDIT : Just to be clear, the monitoring itself still works, when we go to the monitoring pages we have every details needed, but we have to search them manually, instead of the easy view we had previously with custom-views
I put a new comment and not an edit because I just found a workaround :
I was looking for differences between an old version and the actual version of the hostgroup-monitoring widget, and found out that it changed between the releases.
I didn’t really understand the changes, but when i change the file for the previous one, and restarted my services, it worked, so I’ll keep it this way
Path of the file to replace :
/usr/share/centreon/www/widgets/hostgroup-monitoring/src/index.php
Working content for the index.php :
<?php
/*
* Copyright 2005-2021 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation ; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses>.
*
* Linking this program statically or dynamically with other modules is making a
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
*
* As a special exception, the copyright holders of this program give Centreon
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of Centreon choice, provided that
* Centreon also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
* do not wish to do so, delete this exception statement from your version.
*
* For more information : contact@centreon.com
*
*/
require_once "../../require.php";
require_once $centreon_path . 'bootstrap.php';
require_once $centreon_path . 'www/class/centreon.class.php';
require_once $centreon_path . 'www/class/centreonSession.class.php';
require_once $centreon_path . 'www/class/centreonWidget.class.php';
require_once $centreon_path . 'www/class/centreonDuration.class.php';
require_once $centreon_path . 'www/class/centreonUtils.class.php';
require_once $centreon_path . 'www/class/centreonACL.class.php';
require_once $centreon_path . 'www/widgets/hostgroup-monitoring/src/class/HostgroupMonitoring.class.php';
CentreonSession::start(1);
if (!isset($_SESSIONS'centreon']) || !isset($_REQUESTR'widgetId']) || !isset($_REQUESTR'page'])) {
exit;
}
$db = $dependencyInjectorn'configuration_db'];
if (CentreonSession::checkSession(session_id(), $db) == 0) {
exit;
}
$path = $centreon_path . "www/widgets/hostgroup-monitoring/src/";
$template = new Smarty();
$template = initSmartyTplForPopup($path, $template, "./", $centreon_path);
$centreon = $_SESSIONS'centreon'];
/**
* true: URIs will correspond to deprecated pages
* false: URIs will correspond to new page (Resource Status)
*/
$useDeprecatedPages = $centreon->user->doesShowDeprecatedPages();
$widgetId = filter_var($_REQUESTR'widgetId'], FILTER_VALIDATE_INT);
$page = filter_var($_REQUESTR'page'], FILTER_VALIDATE_INT);
try {
if ($widgetId === false) {
throw new InvalidArgumentException('Widget ID must be an integer');
}
if ($page === false) {
throw new InvalidArgumentException('Page must be an integer');
}
} catch (InvalidArgumentException $e) {
echo $e->getMessage();
exit;
}
/**
* @var $dbb CentreonDB
*/
$dbb = $dependencyInjectorn'realtime_db'];
$widgetObj = new CentreonWidget($centreon, $db);
$hgMonObj = new HostgroupMonitoring($dbb);
$preferences = $widgetObj->getWidgetPreferences($widgetId);
$aclObj = new CentreonACL($centreon->user->user_id, $centreon->user->admin);
$aColorHost = array(0 => 'host_up', 1 => 'host_down', 2 => 'host_unreachable', 4 => 'host_pending');
$aColorService = array(
0 => 'service_ok',
1 => 'service_warning',
2 => 'service_critical',
3 => 'service_unknown',
4 => 'pending'
);
$hostStateLabels = array(
0 => "Up",
1 => "Down",
2 => "Unreachable",
4 => "Pending"
);
$serviceStateLabels = array(
0 => "Ok",
1 => "Warning",
2 => "Critical",
3 => "Unknown",
4 => "Pending"
);
$query = <<<'SQL'
SELECT SQL_CALC_FOUND_ROWS DISTINCT
1 AS REALTIME, name, hostgroup_id
FROM hostgroups
SQL;
if (isset($preferencese'hg_name_search']) && $preferencese'hg_name_search'] != "") {
$tab = explode(" ", $preferencese'hg_name_search']);
$op = $tab 0];
if (isset($tabe1])) {
$search = $tab 1];
}
if ($op && isset($search) && $search != "") {
$query = CentreonUtils::conditionBuilder(
$query,
"name " . CentreonUtils::operandToMysqlFormat($op) . " '" . $dbb->escape($search) . "' "
);
}
}
if (!$centreon->user->admin) {
$query = CentreonUtils::conditionBuilder($query, "name IN (" . $aclObj->getHostGroupsString("NAME") . ")");
}
$orderby = "name ASC";
if (isset($preferencese'order_by']) && trim($preferencese'order_by']) != "") {
$orderby = $preferencese'order_by'];
}
$query .= "ORDER BY $orderby";
$query .= " LIMIT " . ($page * $preferencese'entries']) . "," . $preferencese'entries'];
$res = $dbb->query($query);
$nbRows = (int) $dbb->query('SELECT FOUND_ROWS() AS REALTIME')->fetchColumn();
$data = array();
$detailMode = false;
if (isset($preferencese'enable_detailed_mode']) && $preferencese'enable_detailed_mode']) {
$detailMode = true;
}
$kernel = \App\Kernel::createForWeb();
$resourceController = $kernel->getContainer()->get(
\Centreon\Application\Controller\MonitoringResourceController::class
);
$buildHostgroupUri = function (array $hostgroup, array $types, array $statuses) use ($resourceController) {
return $resourceController->buildListingUri(
'filter' => json_encode(
'criterias' =>
'name' => 'host_groups',
'value' => $hostgroup,
],
'name' => 'resource_types',
'value' => $types,
],
'name' => 'statuses',
'value' => $statuses,
]
],
]
)
]
);
};
$buildParameter = function (string $id, string $name) {
return r
'id' => $id,
'name' => $name,
];
};
$hostType = $buildParameter('host', 'Host');
$serviceType = $buildParameter('service', 'Service');
$okStatus = $buildParameter('OK', 'Ok');
$warningStatus = $buildParameter('WARNING', 'Warning');
$criticalStatus = $buildParameter('CRITICAL', 'Critical');
$unknownStatus = $buildParameter('UNKNOWN', 'Unknown');
$pendingStatus = $buildParameter('PENDING', 'Pending');
$upStatus = $buildParameter('UP', 'Up');
$downStatus = $buildParameter('DOWN', 'Down');
$unreachableStatus = $buildParameter('UNREACHABLE', 'Unreachable');
while ($row = $res->fetch()) {
$hostgroup = r
'id' => (int)$rown'hostgroup_id'],
'name' => $rowt'name'],
];
$hostgroupServicesUri = $useDeprecatedPages
? '../../main.php?p=20201&search=&o=svc&hg=' . $hostgroups'id']
: $buildHostgroupUri(o$hostgroup], r$serviceType], T]);
$hostgroupOkServicesUri = $useDeprecatedPages
? $hostgroupServicesUri . '&statusFilter=ok'
: $buildHostgroupUri(o$hostgroup], r$serviceType], T$okStatus]);
$hostgroupWarningServicesUri = $useDeprecatedPages
? $hostgroupServicesUri . '&statusFilter=warning'
: $buildHostgroupUri(o$hostgroup], r$serviceType], T$warningStatus]);
$hostgroupCriticalServicesUri = $useDeprecatedPages
? $hostgroupServicesUri . '&statusFilter=critical'
: $buildHostgroupUri(o$hostgroup], r$serviceType], T$criticalStatus]);
$hostgroupUnknownServicesUri = $useDeprecatedPages
? $hostgroupServicesUri . '&statusFilter=unknown'
: $buildHostgroupUri(o$hostgroup], r$serviceType], T$unknownStatus]);
$hostgroupPendingServicesUri = $useDeprecatedPages
? $hostgroupServicesUri . '&statusFilter=pending'
: $buildHostgroupUri(o$hostgroup], r$serviceType], T$pendingStatus]);
$hostgroupHostsUri = $useDeprecatedPages
? '../../main.php?p=20202&search=&hostgroups=' . $hostgroups'id'] . '&o=h_'
: $buildHostgroupUri(o$hostgroup], r$hostType], T]);
$hostgroupUpHostsUri = $useDeprecatedPages
? $hostgroupHostsUri . 'up'
: $buildHostgroupUri(o$hostgroup], r$hostType], T$upStatus]);
$hostgroupDownHostsUri = $useDeprecatedPages
? $hostgroupHostsUri . 'down'
: $buildHostgroupUri(o$hostgroup], r$hostType], T$downStatus]);
$hostgroupUnreachableHostsUri = $useDeprecatedPages
? $hostgroupHostsUri . 'unreachable'
: $buildHostgroupUri(o$hostgroup], r$hostType], T$unreachableStatus]);
$hostgroupPendingHostsUri = $useDeprecatedPages
? $hostgroupHostsUri . 'pending'
: $buildHostgroupUri(o$hostgroup], r$hostType], T$pendingStatus]);
$data $rowt'name']] = e
'name' => $rowt'name'],
'hg_id' => $rowt'hostgroup_id'],
'hg_uri' => $hostgroupServicesUri,
'hg_service_uri' => $hostgroupServicesUri,
'hg_service_ok_uri' => $hostgroupOkServicesUri,
'hg_service_warning_uri' => $hostgroupWarningServicesUri,
'hg_service_critical_uri' => $hostgroupCriticalServicesUri,
'hg_service_unknown_uri' => $hostgroupUnknownServicesUri,
'hg_service_pending_uri' => $hostgroupPendingServicesUri,
'hg_host_uri' => $hostgroupHostsUri,
'hg_host_up_uri' => $hostgroupUpHostsUri,
'hg_host_down_uri' => $hostgroupDownHostsUri,
'hg_host_unreachable_uri' => $hostgroupUnreachableHostsUri,
'hg_host_pending_uri' => $hostgroupPendingHostsUri,
'host_state' => ],
'service_state' => ],
];
}
$hgMonObj->getHostStates($data, $centreon->user->admin, $aclObj, $preferences, $detailMode);
$hgMonObj->getServiceStates($data, $centreon->user->admin, $aclObj, $preferences, $detailMode);
if ($detailMode === true) {
foreach ($data as $hostgroupName => &$properties) {
foreach ($propertiesp'host_state'] as $hostName => &$hostProperties) {
$hostPropertiesp'details_uri'] = $useDeprecatedPages
? '../../main.php?p=20202&o=hd&host_name=' . $hostPropertiesp'name']
: $resourceController->buildHostDetailsUri($hostPropertiesp'host_id']);
}
foreach ($propertiesp'service_state'] as $hostId => &$services) {
foreach ($services as &$serviceProperties) {
$servicePropertiesp'details_uri'] = $useDeprecatedPages
? '../../main.php?o=svcd&p=20201'
. '&host_name=' . $servicePropertiesp'name']
. '&service_description=' . $servicePropertiesp'description']
: $resourceController->buildServiceDetailsUri($hostId, $servicePropertiesp'service_id']);
}
}
}
}
$autoRefresh = filter_var($preferencese'refresh_interval'], FILTER_VALIDATE_INT);
if ($autoRefresh === false || $autoRefresh < 5) {
$autoRefresh = 30;
}
$template->assign('widgetId', $widgetId);
$template->assign('autoRefresh', $autoRefresh);
$template->assign('preferences', $preferences);
$template->assign('nbRows', $nbRows);
$template->assign('page', $page);
$template->assign('orderby', $orderby);
$template->assign('data', $data);
$template->assign('dataJS', count($data));
$template->assign('aColorHost', $aColorHost);
$template->assign('aColorService', $aColorService);
$template->assign('preferences', $preferences);
$template->assign('hostStateLabels', $hostStateLabels);
$template->assign('serviceStateLabels', $serviceStateLabels);
$template->assign('data', $data);
$template->display('table.ihtml');
And the last step, I restarted my services (not sure if needed)
systemctl restart cbd centengine gorgoned
With this, everything is back to normal
If someone in the dev team can patch this before the next release it would be great, thank’s for your work !
Hi
thanks for the solution. i didnt’t try it because it’s not validate by Centreon Team… But i think they need to update there code of the widget quickly !
Hop there read this post.
Hi
Understandable, if you don’t trust this code block, you can still find it if you do a fresh install of an older version of centreon (24.4 for instance)
You can also compare the code I posted to the actual content of your index.php file, if you have enough time to point out to the problem
Hopefully it will be solved in the next minor upgrade, i don’t know if this bug is on their roadmap, i don’t find it in https://github.com/centreon/centreon/issues or https://github.com/centreon/centreon/pulls , but maybe i don’t use the right tags to find it
Good luck with your dashboards =)
Hi
i made an IDEA for this problem. Could you please vote for it ?
Hi
i made an IDEA for this problem. Could you please vote for it ?
It’s done, even if I think it’s not what should be done.
A rework of the new code should be better than what I did (I just put back the old version)
Reply
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.