- } # for (my $j = 0; $j < @pinsts; $j++)
- } # for (my $i = 0; $i < @plugins; $i++)
- print " </table>\n";
-} # action_show_host
-
-sub action_show_plugin
-{
- my @hosts = _get_param_host ();
- my $plugin = shift;
- my $plugin_instance = shift;
- my $timespan = _get_param_timespan ();
-
- my $hosts_url = join (';', map { 'host=' . uri_escape ($_) } (@hosts));
- my $plugin_esc = encode_entities ($plugin);
- my $plugin_url = uri_escape ($plugin);
- my $plugin_instance_url = defined ($plugin_instance) ? uri_escape ($plugin_instance) : undef;
-
- my $all_plugins = {};
- my $plugins_per_host = {};
-
- for (my $i = 0; $i < @hosts; $i++)
- {
- $plugins_per_host->{$hosts[$i]} = _find_files_for_host ($hosts[$i]);
- _files_union ($all_plugins, $plugins_per_host->{$hosts[$i]});
- }
-
- my $url_prefix = script_name () . "?$hosts_url;plugin=$plugin_url";
- $url_prefix .= ";plugin_instance=$plugin_instance_url" if (defined ($plugin_instance));
-
- print qq( <div><a href="${\script_name ()}?action=show_host;$hosts_url">Back to list of plugins</a></div>\n);
-
- if (!defined ($all_plugins->{$plugin}))
- {
- print qq( <div class="error">Plugin "${\encode_entities ($plugin)}" not found for host "${\encode_entities (@hosts)}".</div>\n);
- return;
- }
-
- my @pinsts = sort (keys %{$all_plugins->{$plugin}});
-
- print <<HTML;
- <table class="graphs">
- <tr>
- <th>Plugin</th>
-HTML
- for (my $i = 0; $i < @hosts; $i++)
- {
- print "\t<th>", encode_entities ($hosts[$i]), "</th>\n";
- }
- print " </tr>\n";
-
- for (my $j = 0; $j < @pinsts; $j++)
- {
- my $pinst = $pinsts[$j];
- my $pinst_esc = encode_entities ($pinst);
- my $title = $plugin . ($pinst ne '-' ? " ($pinst)" : '');
- my $title_esc = encode_entities ($title);
-
- my $param_plugin = "plugin=$plugin_esc";
- if ($pinst ne '-')
- {
- $param_plugin .= ";plugin_instance=$pinst_esc";
- }
-
- my $files_printed = 0;
- my $files_num = _files_plugin_inst_count ($all_plugins->{$plugin}{$pinst});
- next if (!$files_num);
-
- my $rowspan = ($files_num == 1) ? '' : qq( rowspan="$files_num");
-
- for (sort (keys %{$all_plugins->{$plugin}{$pinst}}))
- {
- my $type = $_;
- my $type_esc = encode_entities ($type);
-
- if (exists ($MetaGraphDefs->{$type}))
- {
- my $param_type = "type=$type_esc";
-
- print " <tr>\n";
- if ($files_printed == 0)
- {
- print "\t<td$rowspan>$title_esc</td>\n";
- }
-
- for (my $k = 0; $k < @hosts; $k++)
- {
- my $host = $hosts[$k];
- my $host_esc = encode_entities ($host);
-
- print "\t<td>";
- if (exists $plugins_per_host->{$host}{$plugin}{$pinst}{$type})
- {
- print qq(<img src="${\script_name ()}?action=show_graph;host=$host_esc;$param_plugin;$param_type;timespan=$timespan" />);
- #print encode_entities (qq(<img src="${\script_name ()}?action=show_graph;host=$host_esc;$param_plugin;$param_type;timespan=$timespan" />));
- }
- print "</td>\n";
- } # for (my $k = 0; $k < @hosts; $k++)
-
- print " </tr>\n";
-
- $files_printed++;
- next; # pinst
- }
-
- for (sort (keys %{$all_plugins->{$plugin}{$pinst}{$type}}))
- {
- my $tinst = $_;
- my $tinst_esc = encode_entities ($tinst);
-
- my $param_type = "type=$type_esc";
- if ($tinst ne '-')
- {
- $param_type .= ";type_instance=$tinst_esc";
- }
-
- print " <tr>\n";
- if ($files_printed == 0)
- {
- print "\t<td$rowspan>$title_esc</td>\n";
- }
-
- for (my $k = 0; $k < @hosts; $k++)
- {
- my $host = $hosts[$k];
- my $host_esc = encode_entities ($host);
-
- print "\t<td>";
- if ($plugins_per_host->{$host}{$plugin}{$pinst}{$type}{$tinst})
- {
- print qq(<img src="${\script_name ()}?action=show_graph;host=$host_esc;$param_plugin;$param_type;timespan=$timespan" />);
- #print encode_entities (qq(<img src="${\script_name ()}?action=show_graph;host=$host_esc;$param_plugin;$param_type;timespan=$timespan" />));
- }
- print "</td>\n";
- } # for (my $k = 0; $k < @hosts; $k++)
-
- print " </tr>\n";
-
- $files_printed++;
- } # for ($tinst)
- } # for ($type)
- } # for (my $j = 0; $j < @pinsts; $j++)