function renderObjectMuninGraphs($object_id) { function printNewItem($options) { echo "<table cellspacing=\"0\" align=\"center\" width=\"50%\">"; echo "<tr><td> </td><th>Server</th><th>Graph</th><th>Caption</th><td> </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 " {$graph['caption']}"; echo "</td></tr>"; } echo '</table>'; if (getConfigVar('ADDNEW_AT_TOP') != 'yes') { printNewItem($options); } finishPortlet(); }
function renderObjectMuninGraphs($object_id) { function printNewItem($options) { echo "<table cellspacing=\"0\" align=\"center\" width=\"50%\">"; echo "<tr><td> </td><th>Server</th><th>Graph</th><th>Caption</th><td> </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 " {$graph['caption']}"; echo "</td></tr>"; } echo '</table>'; if (getConfigVar('ADDNEW_AT_TOP') != 'yes') { printNewItem($options); } finishPortlet(); }