{
my $array_ref = shift;
my $array_sort = shift;
+ my $unknown_first = shift || 0;
my %elements = map { $_ => 1 } (@$array_ref);
splice (@$array_ref, 0);
push (@$array_ref, $_);
delete ($elements{$_});
}
- push (@$array_ref, sort (keys %elements));
+ if ($unknown_first) {
+ unshift (@$array_ref, sort (keys %elements));
+ }
+ else {
+ push (@$array_ref, sort (keys %elements));
+ }
} # _custom_sort_arrayref
sub action_show_host
$GraphDefs->{'virt_cpu_total'} = $GraphDefs->{'virt_cpu_total'};
$MetaGraphDefs->{'cpu'} = \&meta_graph_cpu;
+ $MetaGraphDefs->{'df_complex'} = \&meta_graph_df;
$MetaGraphDefs->{'dns_qtype'} = \&meta_graph_dns;
$MetaGraphDefs->{'dns_rcode'} = \&meta_graph_dns;
$MetaGraphDefs->{'if_rx_errors'} = \&meta_graph_if_rx_errors;
return (meta_graph_generic_stack ($opts, $sources));
} # meta_graph_cpu
+sub meta_graph_df
+{
+ 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 = [];
+
+ my $prefix = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+
+ $opts->{'title'} = "Disk usage $prefix";
+
+ $opts->{'number_format'} = '%5.1lf%s';
+ $opts->{'rrd_opts'} = ['-b', '1024', '-v', 'Bytes'];
+
+ my @files = ();
+
+ $opts->{'colors'} =
+ {
+ 'used' => 'ff0000',
+ 'snap_normal_used' => 'c10640',
+ 'snap_reserve_used' => '820c81',
+ 'snap_reserved' => 'f15aef',
+ 'reserved' => 'ffb000',
+ 'free' => '00ff00',
+ 'sis_saved' => '00e0e0',
+ 'dedup_saved' => '00c1c1',
+ 'compression_saved' => '00a2a2'
+ };
+
+ # LVM uses LV names as type-instance; they should sort first
+ _custom_sort_arrayref ($type_instances,
+ [qw(compression_saved dedup_saved sis_saved free reserved snap_reserved
+ snap_reserve_used snap_normal_used used)], 1);
+
+ for (@$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$prefix-$inst.rrd")
+ {
+ $file = "$_/$prefix-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $prefix") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => $inst,
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_df
+
sub meta_graph_dns
{
confess ("Wrong number of arguments") if (@_ != 5);