Zabbix is a very nice tool but I won't talk about it. If you don't know, check it at: www.zabbix.com.
Using Zabbix in a multi tenant server, feel the lack of avoiding one user to see the Services of each other. It won't see any trigger from other group, but top level SLA is still visible.
Check this post for the complete problem description:
https://www.zabbix.com/forum/showthread.php?t=23482
Someone sugested a solution, but it didn't work for 2.2.1 version I'm using.
With a bit of hack, I managed to get it working with 2.2.1 easily. Sorry for the messy code. At last it works nice for me.
Steps:
1) In the include/services.inc.php, locate and change the "if" block bellow. This is the one right after the comment:
// hard dependencies and dependencies for the "root" node
if (!$dependency || $dependency['soft'] == 0) { $tree[$serviceNode['id']] = $serviceNode; foreach ($service['dependencies'] as $dependency) { $childService = $services[$dependency['servicedownid']]; createServiceMonitoringTree($services, $slaData, $period, $tree, $service, $childService, $dependency); } }Change it to:
if (!$dependency || $dependency['soft'] == 0) { // Show logic if( checkServiceVisibility($serviceNode['id'],$services)){ $tree[$serviceNode['id']] = $serviceNode; foreach ($service['dependencies'] as $dependency) { $childService = $services[$dependency['servicedownid']]; createServiceMonitoringTree($services, $slaData, $period, $tree, $service, $childService, $dependency); } } }
Keep the else block as it is.
2) Include the following function somewhere in the same file.
/**
* Check if a service should be visible or not.
* If it do not have a last one children service that is a trigger, do not show
* It's recursive function to go deep into the tree.
*
* @param array $services an array of services to display in the tree
* @param $serviceid
*
* @return bool
*/
function checkServiceVisibility($id,$services){
$r = false;
// root is always shown
if($id == 0 ){
return true;
}
// If $service has a trigger, it should be show
if(count($services[$id]['trigger']) > 0){
return true;
}
// It doesn't have a trigger, let's check at last one of the children have
else{
foreach( $services[$id]['dependencies'] as $children ){
print_r($children['servicedownid']);
if( checkServiceVisibility($children['servicedownid'],$services)){
return true;
}
}
return false;
}
}
Probably there's a better way to do it, but I'm too lazy to go deep on how the code works. It would be nice if Zabbix guys could implement this on future versions, so I can upgrade easily.
Olá Jonathan!
ResponderExcluirObrigado por compartilhar e sua excelente solução!
Depois de muito pesquisar e buscar uma forma de contornar esse bug do Zabbix, foi somente o seu artigo que trouxe a solução.
Já estamos na versão 3.0.1 e até hoje o pessoal da Zabbix não resolveu isso.
Parabéns e muito sucesso para você!
Grato,
Leandro Rocha
Que bom que foi util Leandro! Estou pra migrar pro 3, e achei que eles já tinham resolvido isso... Sucesso ai!
ExcluirJonathan just my thanks for this fix... much appreciated!
ResponderExcluirYou're welcome! I'm glad to help!
Excluir