コード例 #1
0
ファイル: solutions.php プロジェクト: ehironymous/racktables
function dispatchImageRequest()
{
    genericAssertion('img', 'string');
    global $pageno, $tabno;
    switch ($_REQUEST['img']) {
        case 'minirack':
            // rack security context
            $pageno = 'rack';
            $tabno = 'default';
            fixContext();
            assertPermission();
            dispatchMiniRackThumbRequest(getBypassValue());
            break;
        case 'midirack':
            // rack security context
            $pageno = 'rack';
            $tabno = 'default';
            fixContext();
            assertPermission();
            genericAssertion('scale', 'uint');
            # Scaling implies no caching, there is no special dispatching.
            header('Content-type: image/png');
            printRackThumbImage(getBypassValue(), $_REQUEST['scale']);
            break;
        case 'preview':
            // file security context
            $pageno = 'file';
            $tabno = 'download';
            fixContext();
            assertPermission();
            renderImagePreview(getBypassValue());
            break;
        case 'cactigraph':
            $pageno = 'object';
            $tabno = 'cacti';
            fixContext();
            assertPermission();
            genericAssertion('server_id', 'uint');
            genericAssertion('graph_id', 'uint');
            if (!array_key_exists($_REQUEST['graph_id'], getCactiGraphsForObject(getBypassValue()))) {
                throw new InvalidRequestArgException('graph_id', $_REQUEST['graph_id']);
            }
            proxyCactiRequest($_REQUEST['server_id'], $_REQUEST['graph_id']);
            break;
        case 'muningraph':
            $pageno = 'object';
            $tabno = 'munin';
            fixContext();
            assertPermission();
            genericAssertion('server_id', 'uint');
            genericAssertion('graph', 'string');
            if (!array_key_exists($_REQUEST['graph'], getMuninGraphsForObject(getBypassValue()))) {
                throw new InvalidRequestArgException('graph', $_REQUEST['graph']);
            }
            proxyMuninRequest($_REQUEST['server_id'], $_REQUEST['graph']);
            break;
        default:
            renderErrorImage();
    }
}
コード例 #2
0
ファイル: interface.php プロジェクト: xtha/salt
function renderObjectMuninGraphs($object_id)
{
    function printNewItem($options)
    {
        echo "<table cellspacing=\"0\" align=\"center\" width=\"50%\">";
        echo "<tr><td>&nbsp;</td><th>Server</th><th>Graph</th><th>Caption</th><td>&nbsp;</td></tr>\n";
        printOpFormIntro('add');
        echo "<tr><td>";
        printImageHREF('Attach', 'Link new graph', TRUE);
        echo '</td><td>' . getSelect($options, array('name' => 'server_id'));
        echo "</td><td><input type=text name=graph tabindex=100></td><td><input type=text name=caption tabindex=101></td><td>";
        printImageHREF('Attach', 'Link new graph', TRUE, 101);
        echo "</td></tr></form>";
        echo "</table>";
        echo "<br/><br/>";
    }
    if (!extension_loaded('curl')) {
        throw new RackTablesError("The PHP cURL extension is not loaded.", RackTablesError::MISCONFIGURED);
    }
    $servers = getMuninServers();
    $options = array();
    foreach ($servers as $server) {
        $options[$server['id']] = "{$server['id']}: {$server['base_url']}";
    }
    startPortlet('Munin Graphs');
    if (getConfigVar('ADDNEW_AT_TOP') == 'yes') {
        printNewItem($options);
    }
    echo "<table cellspacing=\"0\" cellpadding=\"10\" align=\"center\" width=\"50%\">";
    $object = spotEntity('object', $object_id);
    list($host, $domain) = preg_split("/\\./", $object['dname'], 2);
    foreach (getMuninGraphsForObject($object_id) as $graph_name => $graph) {
        $munin_url = $servers[$graph['server_id']]['base_url'];
        $text = "(graph {$graph_name} on server {$graph['server_id']})";
        echo "<tr><td>";
        echo "<a href='{$munin_url}/{$domain}/{$object['dname']}/{$graph_name}.html' target='_blank'>";
        echo "<img src='index.php?module=image&img=muningraph&object_id={$object_id}&server_id={$graph['server_id']}&graph={$graph_name}' alt='{$text}' title='{$text}'></a></td>";
        echo "<td>";
        echo getOpLink(array('op' => 'del', 'server_id' => $graph['server_id'], 'graph' => $graph_name), '', 'Cut', 'Unlink graph', 'need-confirmation');
        echo "&nbsp; &nbsp;{$graph['caption']}";
        echo "</td></tr>";
    }
    echo '</table>';
    if (getConfigVar('ADDNEW_AT_TOP') != 'yes') {
        printNewItem($options);
    }
    finishPortlet();
}
コード例 #3
0
function renderObjectMuninGraphs($object_id)
{
    function printNewItem($options)
    {
        echo "<table cellspacing=\"0\" align=\"center\" width=\"50%\">";
        echo "<tr><td>&nbsp;</td><th>Server</th><th>Graph</th><th>Caption</th><td>&nbsp;</td></tr>\n";
        printOpFormIntro('add');
        echo "<tr><td>";
        printImageHREF('Attach', 'Link new graph', TRUE);
        echo '</td><td>' . getSelect($options, array('name' => 'server_id'));
        echo "</td><td><input type=text name=graph></td><td><input type=text name=caption></td><td>";
        printImageHREF('Attach', 'Link new graph', TRUE);
        echo "</td></tr></form>";
        echo "</table>";
        echo "<br/><br/>";
    }
    if (!extension_loaded('curl')) {
        showError('The PHP cURL extension is not loaded.');
        return;
    }
    try {
        list($host, $domain) = getMuninNameAndDomain($object_id);
    } catch (InvalidArgException $e) {
        showError('This object does not have the FQDN or the common name in the host.do.ma.in format.');
        return;
    }
    $servers = getMuninServers();
    $options = array();
    foreach ($servers as $server) {
        $options[$server['id']] = "{$server['id']}: {$server['base_url']}";
    }
    startPortlet('Munin Graphs');
    if (getConfigVar('ADDNEW_AT_TOP') == 'yes') {
        printNewItem($options);
    }
    echo "<table cellspacing=\"0\" cellpadding=\"10\" align=\"center\" width=\"50%\">";
    foreach (getMuninGraphsForObject($object_id) as $graph_name => $graph) {
        $munin_url = $servers[$graph['server_id']]['base_url'];
        $text = "(graph {$graph_name} on server {$graph['server_id']})";
        echo "<tr><td>";
        echo "<a href='{$munin_url}/{$domain}/{$host}.{$domain}/{$graph_name}.html' target='_blank'>";
        echo "<img src='index.php?module=image&img=muningraph&object_id={$object_id}&server_id={$graph['server_id']}&graph={$graph_name}' alt='{$text}' title='{$text}'></a></td>";
        echo "<td>";
        echo getOpLink(array('op' => 'del', 'server_id' => $graph['server_id'], 'graph' => $graph_name), '', 'Cut', 'Unlink graph', 'need-confirmation');
        echo "&nbsp; &nbsp;{$graph['caption']}";
        echo "</td></tr>";
    }
    echo '</table>';
    if (getConfigVar('ADDNEW_AT_TOP') != 'yes') {
        printNewItem($options);
    }
    finishPortlet();
}
コード例 #4
0
ファイル: triggers.php プロジェクト: peter-volkov/RackTrack
function triggerMuninGraphs()
{
    if (!count(getMuninServers())) {
        return '';
    }
    if (count(getMuninGraphsForObject(getBypassValue())) or considerConfiguredConstraint(spotEntity('object', getBypassValue()), 'MUNIN_LISTSRC')) {
        return 'std';
    } else {
        return '';
    }
}