TheBigOne - 2012-04-03

Hi All,

I know it`s not really a clean or nice solution but it works (even after upgrades of cacti as long as they don`t not change the cli version)

The only problem is at the moment that you need to login (in the iframe) once to be able to view the graphs.

redirector.php

$ref=$_SERVER["HTTP_REFERER"];
if(!preg_match('/localdomain.com/Uis', $ref)){
        echo "<h1>Direct Access to this site is now allowed!</h1>";
        return false;
}
$host_name=$_GET["host_name"];
$host=trim(`php cli/add_tree.php --list-hosts |grep -i $host_name`,"\n");
$hosts = explode("\n",$host);
if(empty($hosts[0])){
        echo "<h1>Sorry! This host does not exist in cacti</h1>";
}elseif(count($hosts)> 1){
        echo "<h1>This hostname is not unique!</h1>";
        echo "<h2>Please select the host from the list below!</h2>";
        foreach($hosts as $key => $host){
                $hostArr=explode("\t",$host);
                $id = $hostArr[0];
                $name = $hostArr[1];
                echo '<a href="http://cactiserver.localdomain.com/graph_view.php?action=preview&host_id='.$id.'">'.$name.'</a></br>';
        }
}else{
        $host=explode("\t",$hosts[0]);
        header("Location: http://cactiserver.localdomain.com/graph_view.php?action=preview&host_id=".$host[0] );
}
?>

Put this file just to your cacti htdocs path. Edit the lines where you find "localdomain.com"

In iTop change the following:

1. Go in directory "<iTop path>/modules/itop-config-mgmt-1.0.0/" and edit file "model.itop-config-mgmt.php".
2. Search for the section "class InfrastructureCI"
3. Add the following function within this class. This will add a Tab Cacti for all InfrastuctureCI on production, when you are not in edit mode.

function DisplayBareRelations(WebPage $oPage, $bEditMode = false) 
{ 
    parent::DisplayBareRelations($oPage, $bEditMode); 
    if (!$bEditMode) 
    { 
        $sStatus = $this->Get('status'); 
        $sName = $this->Get('name'); 
        if ($sStatus == 'production') 
        { 
            $oPage->SetCurrentTab(Dict::S('Cacti')); 
            $oPage->add("<iframe width=\"100%\" height=\"400\" src=\"http://<cacti_path>/redirector.php?host_name=$sName\"></iframe>"); 
        } 
    } 
}