for (@tmp)
{
my ($plugin, $instance) = split (m/-/, $_, 2);
- $plugins{$plugin} = [] if (!$plugins{$plugin});
- push (@{$plugins{$plugin}}, $instance) if (defined ($instance));
+ $plugins{$plugin} = [] if (!exists $plugins{$plugin});
+ push (@{$plugins{$plugin}}, $instance);
}
} # for (@DataDirs)
for (@$plugin_instances)
{
- my $plugin_instance = $_;
+ my $plugin_instance = defined ($_) ? $_ : '-';
my %types = _find_types ($host, $plugin,
- ($plugin_instance ne '-') ? $plugin_instance : undef);
+ ($plugin_instance ne '-')
+ ? $plugin_instance
+ : undef);
$ret->{$plugin}{$plugin_instance} = {};
my @hosts = _get_param_host ();
@hosts = sort (@hosts);
- my $all_plugins = {};
- my $plugins_per_host = {};
+ my $timespan = _get_param_timespan ();
+ my $all_plugins = _find_files_for_hosts (@hosts);
+
+ my $url_prefix = script_name () . '?action=show_plugin'
+ . join ('', map { ';host=' . uri_escape ($_) } (@hosts))
+ . ';timespan=' . uri_escape ($timespan);
+
+ print qq( <div><a href="${\script_name ()}?action=overview">Back to list of hosts</a></div>\n);
+
+ print " <p>Available plugins:</p>\n"
+ . " <ul>\n";
+ for (sort (keys %$all_plugins))
+ {
+ my $plugin = $_;
+ my $plugin_html = encode_entities ($plugin);
+ my $url_plugin = $url_prefix . ';plugin=' . uri_escape ($plugin);
+ print qq( <li><a href="$url_plugin">$plugin_html</a></li>\n);
+ }
+ print " </ul>\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 $url_prefix = script_name () . "?$hosts_url";
+
+ my $all_plugins = {};
+ my $plugins_per_host = {};
+ my $selected_plugins = {};
+
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 $param_host = join (";", map { "host=" . encode_entities ($_) } (@hosts));
-
- print '<!-- ', Data::Dumper->Dump ([$all_plugins], ['all_plugins']), " -->\n";
-
- my @plugins = sort (keys %$all_plugins);
+ for (param ('plugin'))
+ {
+ if (defined ($all_plugins->{$_}))
+ {
+ $selected_plugins->{$_} = 1;
+ }
+ }
- print qq( <div><a href="${\script_name ()}?action=overview">Back to list of hosts</a></div>\n);
+ print qq( <div><a href="${\script_name ()}?action=show_host;$hosts_url">Back to list of plugins</a></div>\n);
+ # Print table header
print <<HTML;
<table class="graphs">
<tr>
- <th>Plugin</th>
+ <th>Plugins</th>
HTML
- for (my $i = 0; $i < @hosts; $i++)
+ for (@hosts)
{
- print "\t<th>", encode_entities ($hosts[$i]), "</th>\n";
+ print "\t<th>", encode_entities ($_), "</th>\n";
}
print " </tr>\n";
- for (my $i = 0; $i < @plugins; $i++)
- {
- my $plugin = $plugins[$i];
- my $plugin_esc = encode_entities ($plugins[$i]);
- my @pinsts = sort (keys %{$all_plugins->{$plugin}});
+ for (sort (keys %$selected_plugins))
+ {
+ my $plugin = $_;
+ my $plugin_html = encode_entities ($plugin);
+ my $plugin_url = "$url_prefix;plugin=" . uri_escape ($plugin);
+ my $all_pinst = $all_plugins->{$plugin};
- for (my $j = 0; $j < @pinsts; $j++)
+ for (sort (keys %$all_pinst))
{
- my $pinst = $pinsts[$j];
- my $pinst_esc = encode_entities ($pinst);
- my $title = $plugin . ($pinst ne '-' ? " ($pinst)" : '');
- my $title_esc = encode_entities ($title);
+ my $pinst = $_;
+ my $pinst_html = '';
+ my $pinst_url = $plugin_url;
- my $param_plugin = "plugin=$plugin_esc";
if ($pinst ne '-')
{
- $param_plugin .= ";plugin_instance=$pinst_esc";
+ $pinst_html = encode_entities ($pinst);
+ $pinst_url .= ';plugin_instance=' . uri_escape ($pinst);
}
my $files_printed = 0;
- my $files_num = _files_plugin_inst_count ($all_plugins->{$plugin}{$pinst});
- next if (!$files_num);
-
+ my $files_num = _files_plugin_inst_count ($all_pinst->{$pinst});
+ if ($files_num < 1)
+ {
+ next;
+ }
my $rowspan = ($files_num == 1) ? '' : qq( rowspan="$files_num");
for (sort (keys %{$all_plugins->{$plugin}{$pinst}}))
{
my $type = $_;
- my $type_esc = encode_entities ($type);
+ my $type_html = encode_entities ($type);
+ my $type_url = "$pinst_url;type=" . uri_escape ($type);
+
+ if ($files_printed == 0)
+ {
+ my $title = $plugin_html;
+ if ($pinst ne '-')
+ {
+ $title .= " ($pinst_html)";
+ }
+ print " <tr>\n";
+ print "\t<td$rowspan>$title</td>\n";
+ }
if (exists ($MetaGraphDefs->{$type}))
{
- my $param_type = "type=$type_esc";
+ my $graph_url = script_name () . '?action=show_graph'
+ . ';plugin=' . uri_escape ($plugin)
+ . ';type=' . uri_escape ($type)
+ . ';timespan=' . uri_escape ($timespan);
+ if ($pinst ne '-')
+ {
+ $graph_url .= ';plugin_instance=' . uri_escape ($pinst);
+ }
- print " <tr>\n";
- if ($files_printed == 0)
+ if ($files_printed != 0)
{
- print "\t<td$rowspan>$title_esc</td>\n";
+ print " <tr>\n";
}
- for (my $k = 0; $k < @hosts; $k++)
+ for (@hosts)
{
- my $host = $hosts[$k];
- my $host_esc = encode_entities ($host);
+ my $host = $_;
+ my $host_graph_url = $graph_url . ';host=' . uri_escape ($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 qq(<img src="$host_graph_url" />);
+ #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++)
$files_printed++;
next; # pinst
- }
+ } # if (exists ($MetaGraphDefs->{$type}))
for (sort (keys %{$all_plugins->{$plugin}{$pinst}{$type}}))
{
my $tinst = $_;
my $tinst_esc = encode_entities ($tinst);
-
- my $param_type = "type=$type_esc";
+ my $graph_url = script_name () . '?action=show_graph'
+ . ';plugin=' . uri_escape ($plugin)
+ . ';type=' . uri_escape ($type)
+ . ';timespan=' . uri_escape ($timespan);
+ if ($pinst ne '-')
+ {
+ $graph_url .= ';plugin_instance=' . uri_escape ($pinst);
+ }
if ($tinst ne '-')
{
- $param_type .= ";type_instance=$tinst_esc";
+ $graph_url .= ';type_instance=' . uri_escape ($tinst);
}
- print " <tr>\n";
- if ($files_printed == 0)
+ if ($files_printed != 0)
{
- print "\t<td$rowspan>$title_esc</td>\n";
+ print " <tr>\n";
}
for (my $k = 0; $k < @hosts; $k++)
{
my $host = $hosts[$k];
- my $host_esc = encode_entities ($host);
+ my $host_graph_url = $graph_url . ';host=' . uri_escape ($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 qq(<img src="$host_graph_url" />);
+ #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++)
$files_printed++;
} # for ($tinst)
} # for ($type)
- } # 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++)
+ } # for ($pinst)
+ } # for ($plugin)
print " </table>\n";
} # action_show_plugin
if (keys %selected_hosts)
{
- my $all_plugins = _find_files_for_hosts (@hosts);
+ my $all_plugins = _find_files_for_hosts (keys %selected_hosts);
my %selected_plugins = map { $_ => 1 } (param ('plugin'));
print qq(\t<select name="plugin" multiple="multiple" size="10">\n);
'GPRINT:max:MAX:%5.1lf%s Max,',
'GPRINT:avg:LAST:%5.1lf%s Last\l'
],
- charge => [
- 'DEF:avg={file}:charge:AVERAGE',
- 'DEF:min={file}:charge:MIN',
- 'DEF:max={file}:charge:MAX',
+ charge => ['-v', 'Ah',
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
"AREA:max#$HalfBlue",
"AREA:min#$Canvas",
"LINE1:avg#$FullBlue:Charge",
'GPRINT:max:MAX:%5.1lf%sAh Max,',
'GPRINT:avg:LAST:%5.1lf%sAh Last\l'
],
- charge_percent => [
- 'DEF:avg={file}:percent:AVERAGE',
- 'DEF:min={file}:percent:MIN',
- 'DEF:max={file}:percent:MAX',
- "AREA:max#$HalfBlue",
- "AREA:min#$Canvas",
- "LINE1:avg#$FullBlue:Charge",
- 'GPRINT:min:MIN:%5.1lf%s%% Min,',
- 'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
- 'GPRINT:max:MAX:%5.1lf%s%% Max,',
- 'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
- ],
cpu => ['-v', 'CPU load',
'DEF:avg={file}:value:AVERAGE',
'DEF:min={file}:value:MIN',
'GPRINT:max:MAX:%6.2lf%% Max,',
'GPRINT:avg:LAST:%6.2lf%% Last\l'
],
- current => [
- 'DEF:avg={file}:current:AVERAGE',
- 'DEF:min={file}:current:MIN',
- 'DEF:max={file}:current:MAX',
+ current => ['-v', 'Ampere',
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
"AREA:max#$HalfBlue",
"AREA:min#$Canvas",
"LINE1:avg#$FullBlue:Current",
'GPRINT:temp_max:MAX:%4.1lf Max,',
'GPRINT:temp_avg:LAST:%4.1lf Last\l'
],
+ humidity => ['-v', 'Percent',
+ 'DEF:temp_avg={file}:value:AVERAGE',
+ 'DEF:temp_min={file}:value:MIN',
+ 'DEF:temp_max={file}:value:MAX',
+ "AREA:temp_max#$HalfGreen",
+ "AREA:temp_min#$Canvas",
+ "LINE1:temp_avg#$FullGreen:Temperature",
+ 'GPRINT:temp_min:MIN:%4.1lf%% Min,',
+ 'GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,',
+ 'GPRINT:temp_max:MAX:%4.1lf%% Max,',
+ 'GPRINT:temp_avg:LAST:%4.1lf%% Last\l'
+ ],
if_errors => ['-v', 'Errors/s',
'DEF:tx_min={file}:tx:MIN',
'DEF:tx_avg={file}:tx:AVERAGE',
"DEF:val_max={file}:value:MAX",
"AREA:val_max#$HalfBlue",
"AREA:val_min#$Canvas",
- "LINE1:val_avg#$FullBlue:{inst}",
+ "LINE1:val_avg#$FullBlue:Issues/s",
'GPRINT:val_min:MIN:%5.2lf Min,',
'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
'GPRINT:val_max:MAX:%5.2lf Max,',
"DEF:val_max={file}:value:MAX",
"AREA:val_max#$HalfBlue",
"AREA:val_min#$Canvas",
- "LINE1:val_avg#$FullBlue:{inst}",
+ "LINE1:val_avg#$FullBlue:Issues/s",
'GPRINT:val_min:MIN:%5.2lf Min,',
'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
'GPRINT:val_max:MAX:%5.2lf Max,',
'GPRINT:val_avg:LAST:%5.2lf Last'
],
- mysql_octets => ['-v', 'Bytes/s',
+ mysql_octets => ['-v', 'Bits/s',
'DEF:out_min={file}:tx:MIN',
'DEF:out_avg={file}:tx:AVERAGE',
'DEF:out_max={file}:tx:MAX',
'DEF:inc_min={file}:rx:MIN',
'DEF:inc_avg={file}:rx:AVERAGE',
'DEF:inc_max={file}:rx:MAX',
- 'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
'CDEF:mytime=out_avg,TIME,TIME,IF',
'CDEF:sample_len_raw=mytime,PREV(mytime),-',
'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
'CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*',
'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
- "AREA:out_avg#$HalfGreen",
- "AREA:inc_avg#$HalfBlue",
+ 'CDEF:out_bit_min=out_min,8,*',
+ 'CDEF:out_bit_avg=out_avg,8,*',
+ 'CDEF:out_bit_max=out_max,8,*',
+ 'CDEF:inc_bit_min=inc_min,8,*',
+ 'CDEF:inc_bit_avg=inc_avg,8,*',
+ 'CDEF:inc_bit_max=inc_max,8,*',
+ 'CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF',
+ "AREA:out_bit_avg#$HalfGreen",
+ "AREA:inc_bit_avg#$HalfBlue",
"AREA:overlap#$HalfBlueGreen",
- "LINE1:out_avg#$FullGreen:Written",
- 'GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,',
- 'GPRINT:out_max:MAX:%5.1lf%s Max,',
- 'GPRINT:out_avg:LAST:%5.1lf%s Last',
+ "LINE1:out_bit_avg#$FullGreen:Written",
+ 'GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,',
+ 'GPRINT:out_bit_max:MAX:%5.1lf%s Max,',
+ 'GPRINT:out_bit_avg:LAST:%5.1lf%s Last',
'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
- "LINE1:inc_avg#$FullBlue:Read ",
- 'GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,',
- 'GPRINT:inc_max:MAX:%5.1lf%s Max,',
- 'GPRINT:inc_avg:LAST:%5.1lf%s Last',
+ "LINE1:inc_bit_avg#$FullBlue:Read ",
+ 'GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,',
+ 'GPRINT:inc_bit_max:MAX:%5.1lf%s Max,',
+ 'GPRINT:inc_bit_avg:LAST:%5.1lf%s Last',
'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
],
mysql_qcache => ['-v', 'Queries/s',
'GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,',
'GPRINT:ping_max:MAX:%4.1lf ms Max,',
'GPRINT:ping_avg:LAST:%4.1lf ms Last'],
+ power => ['-v', 'Watt',
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
+ "AREA:max#$HalfBlue",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullBlue:Watt",
+ 'GPRINT:min:MIN:%5.1lf%sW Min,',
+ 'GPRINT:avg:AVERAGE:%5.1lf%sW Avg,',
+ 'GPRINT:max:MAX:%5.1lf%sW Max,',
+ 'GPRINT:avg:LAST:%5.1lf%sW Last\l'
+ ],
processes => [
"DEF:running_avg={file}:running:AVERAGE",
"DEF:running_min={file}:running:MIN",
'GPRINT:sleeping_max:MAX:%5.1lf Max,',
'GPRINT:sleeping_avg:LAST:%5.1lf Last\l'
],
- ps_rss => [
- 'DEF:avg={file}:byte:AVERAGE',
- 'DEF:min={file}:byte:MIN',
- 'DEF:max={file}:byte:MAX',
- "AREA:avg#$HalfBlue",
- "LINE1:avg#$FullBlue:RSS",
- 'GPRINT:min:MIN:%5.1lf%s Min,',
- 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
- 'GPRINT:max:MAX:%5.1lf%s Max,',
- 'GPRINT:avg:LAST:%5.1lf%s Last\l'
+ ps_count => ['-v', 'Processes',
+ 'DEF:procs_avg={file}:processes:AVERAGE',
+ 'DEF:procs_min={file}:processes:MIN',
+ 'DEF:procs_max={file}:processes:MAX',
+ 'DEF:thrds_avg={file}:threads:AVERAGE',
+ 'DEF:thrds_min={file}:threads:MIN',
+ 'DEF:thrds_max={file}:threads:MAX',
+ "AREA:thrds_avg#$HalfBlue",
+ "AREA:procs_avg#$HalfRed",
+ "LINE1:thrds_avg#$FullBlue:Threads ",
+ 'GPRINT:thrds_min:MIN:%5.1lf Min,',
+ 'GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,',
+ 'GPRINT:thrds_max:MAX:%5.1lf Max,',
+ 'GPRINT:thrds_avg:LAST:%5.1lf Last\l',
+ "LINE1:procs_avg#$FullRed:Processes",
+ 'GPRINT:procs_min:MIN:%5.1lf Min,',
+ 'GPRINT:procs_avg:AVERAGE:%5.1lf Avg,',
+ 'GPRINT:procs_max:MAX:%5.1lf Max,',
+ 'GPRINT:procs_avg:LAST:%5.1lf Last\l'
],
- ps_cputime => [
+ ps_cputime => ['-v', 'Jiffies',
'DEF:user_avg_raw={file}:user:AVERAGE',
'DEF:user_min_raw={file}:user:MIN',
'DEF:user_max_raw={file}:user:MAX',
'GPRINT:syst_max:MAX:%5.1lf%s Max,',
'GPRINT:syst_avg:LAST:%5.1lf%s Last\l'
],
- ps_count => [
- 'DEF:procs_avg={file}:processes:AVERAGE',
- 'DEF:procs_min={file}:processes:MIN',
- 'DEF:procs_max={file}:processes:MAX',
- 'DEF:thrds_avg={file}:threads:AVERAGE',
- 'DEF:thrds_min={file}:threads:MIN',
- 'DEF:thrds_max={file}:threads:MAX',
- "AREA:thrds_avg#$HalfBlue",
- "AREA:procs_avg#$HalfRed",
- "LINE1:thrds_avg#$FullBlue:Threads ",
- 'GPRINT:thrds_min:MIN:%5.1lf Min,',
- 'GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,',
- 'GPRINT:thrds_max:MAX:%5.1lf Max,',
- 'GPRINT:thrds_avg:LAST:%5.1lf Last\l',
- "LINE1:procs_avg#$FullRed:Processes",
- 'GPRINT:procs_min:MIN:%5.1lf Min,',
- 'GPRINT:procs_avg:AVERAGE:%5.1lf Avg,',
- 'GPRINT:procs_max:MAX:%5.1lf Max,',
- 'GPRINT:procs_avg:LAST:%5.1lf Last\l'
- ],
- ps_pagefaults => [
+ ps_pagefaults => ['-v', 'Pagefaults/s',
'DEF:minor_avg={file}:minflt:AVERAGE',
'DEF:minor_min={file}:minflt:MIN',
'DEF:minor_max={file}:minflt:MAX',
'GPRINT:major_max:MAX:%5.1lf%s Max,',
'GPRINT:major_avg:LAST:%5.1lf%s Last\l'
],
+ ps_rss => ['-v', 'Bytes',
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
+ "AREA:avg#$HalfBlue",
+ "LINE1:avg#$FullBlue:RSS",
+ 'GPRINT:min:MIN:%5.1lf%s Min,',
+ 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
+ 'GPRINT:max:MAX:%5.1lf%s Max,',
+ 'GPRINT:avg:LAST:%5.1lf%s Last\l'
+ ],
ps_state => ['-v', 'Processes',
'DEF:avg={file}:value:AVERAGE',
'DEF:min={file}:value:MIN',
'GPRINT:max:MAX:%6.2lf%sByte Max,',
'GPRINT:avg:LAST:%6.2lf%sByte Last\l'
],
- ols_swap => [
+ old_swap => [
'DEF:used_avg={file}:used:AVERAGE',
'DEF:used_min={file}:used:MIN',
'DEF:used_max={file}:used:MAX',
'GPRINT:used_max:MAX:%5.1lf%s Max,',
'GPRINT:used_avg:LAST:%5.1lf%s Last\l'
],
+ tcp_connections => ['-v', 'Connections',
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
+ "AREA:max#$HalfBlue",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullBlue:Connections",
+ 'GPRINT:min:MIN:%4.1lf Min,',
+ 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
+ 'GPRINT:max:MAX:%4.1lf Max,',
+ 'GPRINT:avg:LAST:%4.1lf Last\l'
+ ],
temperature => ['-v', 'Celsius',
'DEF:temp_avg={file}:value:AVERAGE',
'DEF:temp_min={file}:value:MIN',
'DEF:temp_max={file}:value:MAX',
'CDEF:average=temp_avg,0.2,*,PREV,UN,temp_avg,PREV,IF,0.8,*,+',
- 'CDEF:derivative=PREV(average),average,-',
- 'CDEF:rising=derivative,-0.01,LT,INF,UNKN,IF',
- 'CDEF:falling=derivative,0.01,GT,INF,UNKN,IF',
- "AREA:rising#f0fff0",
- "AREA:falling#fff0f0",
"AREA:temp_max#$HalfRed",
"AREA:temp_min#$Canvas",
- #"LINE1:average#000000",
"LINE1:temp_avg#$FullRed:Temperature",
'GPRINT:temp_min:MIN:%4.1lf Min,',
'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
'GPRINT:temp_max:MAX:%4.1lf Max,',
'GPRINT:temp_avg:LAST:%4.1lf Last\l'
],
- timeleft => [
+ timeleft => ['-v', 'Minutes',
'DEF:avg={file}:timeleft:AVERAGE',
'DEF:min={file}:timeleft:MIN',
'DEF:max={file}:timeleft:MAX',
'GPRINT:multimeter_max:MAX:%4.1lf Max,',
'GPRINT:multimeter_avg:LAST:%4.1lf Last\l'
],
- users => [
+ users => ['-v', 'Users',
'DEF:users_avg={file}:users:AVERAGE',
'DEF:users_min={file}:users:MIN',
'DEF:users_max={file}:users:MAX',
$GraphDefs->{'if_tx_errors'} = $GraphDefs->{'if_rx_errors'};
$MetaGraphDefs->{'cpu'} = \&meta_graph_cpu;
+ $MetaGraphDefs->{'if_rx_errors'} = \&meta_graph_if_rx_errors;
+ $MetaGraphDefs->{'if_tx_errors'} = \&meta_graph_if_rx_errors;
$MetaGraphDefs->{'memory'} = \&meta_graph_memory;
+ $MetaGraphDefs->{'nfs_procedure'} = \&meta_graph_nfs_procedure;
+ $MetaGraphDefs->{'ps_state'} = \&meta_graph_ps_state;
+ $MetaGraphDefs->{'swap'} = \&meta_graph_swap;
+ $MetaGraphDefs->{'mysql_commands'} = \&meta_graph_mysql_commands;
+ $MetaGraphDefs->{'mysql_handler'} = \&meta_graph_mysql_commands;
+ $MetaGraphDefs->{'tcp_connections'} = \&meta_graph_tcp_connections;
} # load_graph_definitions
sub meta_graph_generic_stack
qq#CDEF:${inst_name}_nnl=${inst_name}_avg,UN,0,${inst_name}_avg,IF#);
}
- for (my $i = 0; $i < @$sources; $i++)
{
- my $inst_data0 = $sources->[@$sources - (1 + $i)];
- my $inst_data1 = $sources->[@$sources - (($i == 0) ? 1 : $i)];
+ my $inst_data = $sources->[@$sources - 1];
+ my $inst_name = $inst_data->{'name'};
+
+ push (@cmd, qq#CDEF:${inst_name}_stk=${inst_name}_nnl#);
+ }
+ for (my $i = 1; $i < @$sources; $i++)
+ {
+ my $inst_data0 = $sources->[@$sources - ($i + 1)];
+ my $inst_data1 = $sources->[@$sources - $i];
my $inst_name0 = $inst_data0->{'name'};
my $inst_name1 = $inst_data1->{'name'};
- my $cdef_name = ($i == 0) ? 'nnl' : 'stk';
-
- push (@cmd, qq#CDEF:${inst_name0}_stk=${inst_name0}_nnl,${inst_name1}_${cdef_name},+#);
+ push (@cmd, qq#CDEF:${inst_name0}_stk=${inst_name0}_nnl,${inst_name1}_stk,+#);
}
for (my $i = 0; $i < @$sources; $i++)
qq(GPRINT:${inst_name}_min:MIN:$number_format Min,),
qq(GPRINT:${inst_name}_avg:AVERAGE:$number_format Avg,),
qq(GPRINT:${inst_name}_max:MAX:$number_format Max,),
- qq(GPRINT:${inst_name}_avg:LAST:$number_format Last\l),
+ qq(GPRINT:${inst_name}_avg:LAST:$number_format Last\\l),
);
}
$opts->{'title'} = "$host/$plugin"
. (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+ $opts->{'rrd_opts'} = ['-v', 'Percent'];
+
my @files = ();
$opts->{'colors'} =
. (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
$opts->{'number_format'} = '%5.1lf%s';
- $opts->{'rrd_opts'} = ['-b', '1024'];
+ $opts->{'rrd_opts'} = ['-b', '1024', '-v', 'Bytes'];
my @files = ();
return (meta_graph_generic_stack ($opts, $sources));
} # meta_graph_cpu
+sub meta_graph_if_rx_errors
+{
+ confess ("Wrong number of arguments") if (@_ != 5);
+
+ my $host = shift;
+ my $plugin = shift;
+ my $plugin_instance = shift;
+ my $type = shift;
+ my $type_instances = shift;
+
+ my $opts = {};
+ my $sources = [];
+
+ $opts->{'title'} = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+ $opts->{'number_format'} = '%5.2lf';
+ $opts->{'rrd_opts'} = ['-v', 'Errors/s'];
+
+ my @files = ();
+
+ for (sort @$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+ my $title = $opts->{'title'};
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$title-$inst.rrd")
+ {
+ $file = "$_/$title-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $title") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => $inst,
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_if_rx_errors
+
+sub meta_graph_mysql_commands
+{
+ confess ("Wrong number of arguments") if (@_ != 5);
+
+ my $host = shift;
+ my $plugin = shift;
+ my $plugin_instance = shift;
+ my $type = shift;
+ my $type_instances = shift;
+
+ my $opts = {};
+ my $sources = [];
+
+ $opts->{'title'} = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+ $opts->{'number_format'} = '%5.2lf';
+
+ my @files = ();
+
+ for (sort @$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+ my $title = $opts->{'title'};
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$title-$inst.rrd")
+ {
+ $file = "$_/$title-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $title") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => $inst,
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_mysql_commands
+
+sub meta_graph_nfs_procedure
+{
+ confess ("Wrong number of arguments") if (@_ != 5);
+
+ my $host = shift;
+ my $plugin = shift;
+ my $plugin_instance = shift;
+ my $type = shift;
+ my $type_instances = shift;
+
+ my $opts = {};
+ my $sources = [];
+
+ $opts->{'title'} = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+ $opts->{'number_format'} = '%5.1lf%s';
+
+ my @files = ();
+
+ for (sort @$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+ my $title = $opts->{'title'};
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$title-$inst.rrd")
+ {
+ $file = "$_/$title-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $title") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => $inst,
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_nfs_procedure
+
+sub meta_graph_ps_state
+{
+ confess ("Wrong number of arguments") if (@_ != 5);
+
+ my $host = shift;
+ my $plugin = shift;
+ my $plugin_instance = shift;
+ my $type = shift;
+ my $type_instances = shift;
+
+ my $opts = {};
+ my $sources = [];
+
+ $opts->{'title'} = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+ $opts->{'rrd_opts'} = ['-v', 'Processes'];
+
+ my @files = ();
+
+ $opts->{'colors'} =
+ {
+ 'Running' => '00e000',
+ 'Sleeping' => '0000ff',
+ 'Paging' => 'ffb000',
+ 'Zombies' => 'ff0000',
+ 'Blocked' => 'ff00ff',
+ 'Stopped' => 'a000a0'
+ };
+
+ _custom_sort_arrayref ($type_instances,
+ [qw(paging blocked zombies stopped running sleeping)]);
+
+ for (@$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+ my $title = $opts->{'title'};
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$title-$inst.rrd")
+ {
+ $file = "$_/$title-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $title") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => ucfirst ($inst),
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_ps_state
+
+sub meta_graph_swap
+{
+ confess ("Wrong number of arguments") if (@_ != 5);
+
+ my $host = shift;
+ my $plugin = shift;
+ my $plugin_instance = shift;
+ my $type = shift;
+ my $type_instances = shift;
+
+ my $opts = {};
+ my $sources = [];
+
+ $opts->{'title'} = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+ $opts->{'number_format'} = '%5.1lf%s';
+ $opts->{'rrd_opts'} = ['-v', 'Bytes'];
+
+ my @files = ();
+
+ $opts->{'colors'} =
+ {
+ 'Free' => '00e000',
+ 'Cached' => '0000ff',
+ 'Reserved' => 'ffb000',
+ 'Used' => 'ff0000'
+ };
+
+ _custom_sort_arrayref ($type_instances,
+ [qw(free cached reserved used)]);
+
+ for (@$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+ my $title = $opts->{'title'};
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$title-$inst.rrd")
+ {
+ $file = "$_/$title-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $title") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => ucfirst ($inst),
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_swap
+
+sub meta_graph_tcp_connections
+{
+ confess ("Wrong number of arguments") if (@_ != 5);
+
+ my $host = shift;
+ my $plugin = shift;
+ my $plugin_instance = shift;
+ my $type = shift;
+ my $type_instances = shift;
+
+ my $opts = {};
+ my $sources = [];
+
+ $opts->{'title'} = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+ $opts->{'number_format'} = '%6.2lf';
+
+ $opts->{'rrd_opts'} = ['-v', 'Connections'];
+
+ my @files = ();
+
+ $opts->{'colors'} =
+ {
+ ESTABLISHED => '00e000',
+ SYN_SENT => '00e0ff',
+ SYN_RECV => '00e0a0',
+ FIN_WAIT1 => 'f000f0',
+ FIN_WAIT2 => 'f000a0',
+ TIME_WAIT => 'ffb000',
+ CLOSE => '0000f0',
+ CLOSE_WAIT => '0000a0',
+ LAST_ACK => '000080',
+ LISTEN => 'ff0000',
+ CLOSING => '000000'
+ };
+
+ _custom_sort_arrayref ($type_instances,
+ [reverse qw(ESTABLISHED SYN_SENT SYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSE
+ CLOSE_WAIT LAST_ACK CLOSING LISTEN)]);
+
+ for (@$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+ my $title = $opts->{'title'};
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$title-$inst.rrd")
+ {
+ $file = "$_/$title-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $title") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => $inst,
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_tcp_connections
# vim: shiftwidth=2:softtabstop=2:tabstop=8