Exemple #1
0
        $vars['plugin'] = $plugin;
    }
    if ($vars['plugin'] == $plugin) {
        $navbar['options'][$plugin]['class'] = "active";
    }
    $navbar['options'][$plugin]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'collectd', 'plugin' => $plugin));
    $navbar['options'][$plugin]['text'] = htmlspecialchars(ucwords($plugin));
}
print_navbar($navbar);
echo '<table class="table table-bordered table-condensed table-striped table-hover">';
$i = 0;
$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']);
foreach ($pinsts as &$instance) {
    $types = collectd_list_types($device['hostname'], $vars['plugin'], $instance);
    foreach ($types as &$type) {
        $typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
        if ($MetaGraphDefs[$type]) {
            $typeinstances = array($MetaGraphDefs[$type]);
        }
        foreach ($typeinstances as &$tinst) {
            $i++;
            if (!is_integer($i / 2)) {
                $row_colour = $list_colour_a;
            } else {
                $row_colour = $list_colour_b;
            }
            echo '<tr><td>';
            echo '<h4>' . $graph_title;
            if ($tinst) {
                echo $vars['plugin'] . " {$instance} - {$type} - {$tinst}";
            } else {
		if (!is_array($arg_hosts))
			$arg_hosts = array($arg_hosts);
		$arg_plugin = read_var('plugin', $_POST, '');
		$arg_pinst  = read_var('plugin_instance', $_POST, '');
		$types = collectd_list_types(reset($arg_hosts), $arg_plugin, $arg_pinst);
		return dhtml_response_list($types, 'ListOfType');

	case 'list_tinsts':
		// Generate list of types for selected hosts, plugin and plugin-instance
		$arg_hosts  = read_var('host', $_POST, array());
		if (!is_array($arg_hosts))
			$arg_hosts = array($arg_hosts);
		$arg_plugin = read_var('plugin', $_POST, '');
		$arg_pinst  = read_var('plugin_instance', $_POST, '');
		$arg_type   = read_var('type', $_POST, '');
		$tinsts = collectd_list_tinsts(reset($arg_hosts), $arg_plugin, $arg_pinst, $arg_type);
		if (count($tinsts)) {
			require('definitions.php');
			load_graph_definitions();
			if (isset($MetaGraphDefs[$arg_type])) {
				$meta_tinsts = array('@');
				return dhtml_response_list($meta_tinsts, 'ListOfTypeInstance');
			}
		}
		return dhtml_response_list($tinsts, 'ListOfTypeInstance');

	case 'overview':
	default:
		return build_page();
		break;
}
Exemple #3
0
$tinst = read_var('c_type_instance', $vars, '');
$graph_identifier = $host . '/' . $plugin . (strlen($pinst) ? '-' . $pinst : '') . '/' . $type . (strlen($tinst) ? '-' . $tinst : '-*');
$timespan = read_var('timespan', $vars, $config['timespan'][0]['name']);
$timespan_ok = false;
foreach ($config['timespan'] as &$ts) {
    if ($ts['name'] == $timespan) {
        $timespan_ok = true;
    }
}
if (!$timespan_ok) {
    return error400($graph_identifier, "Unknown timespan requested");
}
$logscale = (bool) read_var('logarithmic', $vars, false);
$tinylegend = (bool) read_var('tinylegend', $vars, false);
// Check that at least 1 RRD exists for the specified request
$all_tinst = collectd_list_tinsts($host, $plugin, $pinst, $type);
if (count($all_tinst) == 0) {
    return error404($graph_identifier, "No rrd file found for graphing");
}
// Now that we are read, do the bulk work
load_graph_definitions($logscale, $tinylegend);
$pinst = strlen($pinst) == 0 ? null : $pinst;
$tinst = strlen($tinst) == 0 ? null : $tinst;
$opts = array();
$opts['timespan'] = $timespan;
if ($logscale) {
    $opts['logarithmic'] = 1;
}
if ($tinylegend) {
    $opts['tinylegend'] = 1;
}
Exemple #4
0
        echo "<strong>";
    }
    echo "<a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/collectd/" . $plugin . "/'>" . htmlspecialchars($plugin) . "</a>\n";
    if ($_GET['opta'] == $plugin) {
        echo "</strong>";
    }
    $sep = ' | ';
}
unset($sep);
print_optionbar_end();
$i = 0;
$pinsts = collectd_list_pinsts($device['hostname'], $_GET['opta']);
foreach ($pinsts as &$instance) {
    $types = collectd_list_types($device['hostname'], $_GET['opta'], $instance);
    foreach ($types as &$type) {
        $typeinstances = collectd_list_tinsts($device['hostname'], $_GET['opta'], $instance, $type);
        if ($MetaGraphDefs[$type]) {
            $typeinstances = array($MetaGraphDefs[$type]);
        }
        foreach ($typeinstances as &$tinst) {
            $i++;
            if (!is_integer($i / 2)) {
                $row_colour = $list_colour_a;
            } else {
                $row_colour = $list_colour_b;
            }
            echo '<div style="background-color: ' . $row_colour . ';">';
            echo '<div class="graphhead" style="padding:4px 0px 0px 8px;">';
            if ($tinst) {
                echo $_GET['opta'] . " {$instance} - {$type} - {$tinst}";
            } else {