Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add View for Groups #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

require_once 'conf/common.inc.php';
require_once 'inc/html.inc.php';
require_once 'inc/collectd.inc.php';

header("Content-Type: text/html");

$category = GET('h');
$plugin = GET('p');

$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);

html_start();

echo "<h1>$category</h1>";

$host = $CONFIG['cat'][$category][0];

printf("<fieldset id=\"%s\">", htmlentities($host));
printf("<legend>%s</legend>", htmlentities($host));

echo <<<EOT
<input type="checkbox" id="navicon" class="navicon" />
<label for="navicon"></label>

EOT;

if (!strlen($host) || !$plugins = collectd_plugins($host)) {
echo "Unknown host\n";
return false;
}

plugins_list_group($category, $selected_plugins);

echo $CONFIG['cat'][$category];

echo '<div class="graphs">';
foreach ($selected_plugins as $selected_plugin) {
plugin_header($host, $selected_plugin);
if (in_array($selected_plugin, $plugins)) {
foreach ($CONFIG['cat'][$category] as $host) {
graphs_from_plugin($host, $selected_plugin, empty($plugin));
}
}
}
echo '</div>';
printf("</fieldset>");

html_end();
50 changes: 49 additions & 1 deletion inc/html.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,51 @@ function plugin_header($host, $plugin) {
htmlentities($plugin));
}

function plugins_list_group($group, $selected_plugins = array()) {
global $CONFIG;

$plugins = collectd_plugins( $CONFIG['cat'][$group][0]);

echo '<div class="plugins">';
echo '<h2>Plugins</h2>';
echo '<ul>';

printf("<li><a %shref=\"%sgroup.php?h=%s\">overview</a></li>\n",
selected_overview($selected_plugins),
htmlentities($CONFIG['weburl']),
urlencode($group)
);

# first the ones defined as ordered
foreach($CONFIG['overview'] as $plugin) {
if (in_array($plugin, $plugins)) {
printf("<li><a %shref=\"%sgroup.php?h=%s&amp;p=%s\">%s</a></li>\n",
selected_plugin($plugin, $selected_plugins),
htmlentities($CONFIG['weburl']),
urlencode($group),
urlencode($plugin),
htmlentities($plugin)
);
}
}

# other plugins
foreach($plugins as $plugin) {
if (!in_array($plugin, $CONFIG['overview'])) {
printf("<li><a %shref=\"%sgroup.php?h=%s&amp;p=%s\">%s</a></li>\n",
selected_plugin($plugin, $selected_plugins),
htmlentities($CONFIG['weburl']),
urlencode($group),
urlencode($plugin),
htmlentities($plugin)
);
}
}

echo '</ul>';
echo '</div>';
}

function plugins_list($host, $selected_plugins = array()) {
global $CONFIG;

Expand Down Expand Up @@ -223,7 +268,10 @@ function host_summary($cat, $hosts) {
$rrd = new RRDTool($CONFIG['rrdtool']);

printf('<fieldset id="%s">', htmlentities($cat));
printf('<legend>%s</legend>', htmlentities($cat));
printf('<legend><a href="%sgroup.php?h=%s">%s</a></legend>',
htmlentities($CONFIG['weburl']),
htmlentities($cat),
htmlentities($cat));
echo "<div class=\"summary\">\n";

$row_style = array(0 => "even", 1 => "odd");
Expand Down