X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fphp-collection%2Findex.php;h=5953fbd354c96a05d0c91eed34d41023caee4e59;hb=126d448bce2ab48300c05f13ee7eb0a75b214d81;hp=1f788fc968098a46b2514a54f8d6ee39715f0ab2;hpb=6597f3a6584704f92f824f3cf7bac3369102e8a0;p=collectd.git diff --git a/contrib/php-collection/index.php b/contrib/php-collection/index.php index 1f788fc9..5953fbd3 100644 --- a/contrib/php-collection/index.php +++ b/contrib/php-collection/index.php @@ -39,6 +39,22 @@ function dhtml_response_list(&$items, $method) { print(""); } +function dhtml_response_graphs(&$graphs, $method) { + header("Content-Type: text/xml"); + + print(''."\n"); + print("\n"); + printf(" %s\n", htmlspecialchars($method)); + print(" \n"); + foreach ($graphs as &$graph) + printf(' '."\n", + htmlspecialchars($graph['host']), htmlspecialchars($graph['plugin']), htmlspecialchars($graph['pinst']), + htmlspecialchars($graph['type']), htmlspecialchars($graph['tinst']), htmlspecialchars($graph['timespan']), + htmlspecialchars($graph['logarithmic']), htmlspecialchars($graph['tinyLegend'])); + print(" \n"); + print(""); +} + /** * Product page body with selection fields */ @@ -66,7 +82,7 @@ function build_page() { -
+

Collectd browser for system statistics graphs

Hide graph selection tool
@@ -137,9 +154,18 @@ var graph_url = ''; + + + + + + + + + +
- - -
Graph list favorites:S
LD
@@ -184,6 +210,24 @@ var graph_url = ''; echo '

Config error: RRDTOOL ('.htmlspecialchars(RRDTOOL).') is not executable

'; ?>
+ + + + + + + + + + + + + 1) + array_unshift($hosts, '@all'); return dhtml_response_list($hosts, 'ListOfHost'); case 'list_plugins': // Generate list of plugins for selected hosts - $arg_hosts = read_var('host', $_POST, array()); - if (!is_array($arg_hosts)) - $arg_hosts = array($arg_hosts); - $plugins = collectd_list_plugins(reset($arg_hosts)); + $arg_hosts = read_var('host', $_POST, ''); + if (is_array($arg_hosts)) + $arg_hosts = reset($arg_hosts); + $plugins = collectd_list_plugins($arg_hosts); + if (count($plugins) > 1) + array_unshift($plugins, '@all'); return dhtml_response_list($plugins, 'ListOfPlugin'); case 'list_pinsts': // Generate list of plugin_instances for selected hosts and plugin - $arg_hosts = read_var('host', $_POST, array()); - if (!is_array($arg_hosts)) - $arg_hosts = array($arg_hosts); + $arg_hosts = read_var('host', $_POST, ''); + if (is_array($arg_hosts)) + $arg_hosts = reset($arg_hosts); $arg_plugin = read_var('plugin', $_POST, ''); - $pinsts = collectd_list_pinsts(reset($arg_hosts), $arg_plugin); + $pinsts = collectd_list_plugins($arg_hosts, $arg_plugin); + if (count($pinsts) > 1) + array_unshift($pinsts, '@all' /* , '@merge_sum', '@merge_avg', '@merge_stack', '@merge_line' */); return dhtml_response_list($pinsts, 'ListOfPluginInstance'); case 'list_types': // 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_hosts = read_var('host', $_POST, ''); + if (is_array($arg_hosts)) + $arg_hosts = reset($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); + $types = collectd_list_types($arg_hosts, $arg_plugin, $arg_pinst); + if (count($types) > 1) + array_unshift($types, '@all'); 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_hosts = read_var('host', $_POST, ''); + if (is_array($arg_hosts)) + $arg_hosts = reset($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'); + $tinsts = collectd_list_types($arg_hosts, $arg_plugin, $arg_pinst, $arg_type); + if (count($tinsts)) + if ($arg_type != '@all') { + require('definitions.php'); + load_graph_definitions(); + if (isset($MetaGraphDefs[$arg_type])) + array_unshift($tinsts, '@merge'); + if (count($tinsts) > 1) + array_unshift($tinsts, '@all'); + } else { + array_unshift($tinsts, /* '@merge_sum', '@merge_avg', '@merge_stack', '@merge_line', */ '@merge'); + if (count($tinsts) > 1) + array_unshift($tinsts, '@all'); } - } return dhtml_response_list($tinsts, 'ListOfTypeInstance'); + case 'list_graphs': + // Generate list of types for selected hosts, plugin and plugin-instance + $arg_hosts = read_var('host', $_POST, ''); + if (is_array($arg_hosts)) + $arg_hosts = reset($arg_hosts); + $arg_plugin = read_var('plugin', $_POST, ''); + $arg_pinst = read_var('plugin_instance', $_POST, ''); + $arg_type = read_var('type', $_POST, ''); + $arg_tinst = read_var('type_instance', $_POST, ''); + $arg_log = (int)read_var('logarithmic', $_POST, '0'); + $arg_legend = (int)read_var('tinyLegend', $_POST, '0'); + $arg_period = read_var('timespan', $_POST, ''); + $graphs = collectd_list_graphs($arg_hosts, $arg_plugin, $arg_pinst, $arg_type, $arg_tinst); + foreach ($graphs as &$graph) { + $graph['logarithmic'] = $arg_log; + $graph['tinyLegend'] = $arg_legend; + $graph['timespan'] = $arg_period; + } + return dhtml_response_graphs($graphs, 'ListOfGraph'); + case 'overview': default: return build_page();