'xpath' => '//Status/MachineInfo/Storage',
'protocol_version' => [ "<= 31" ],
'attrs' => [ qw/_total_total _total_used/ ],
- 'commify' => [ qw/_total_total _total_used/ ],
+ 'commify' => [ qw/si__total_total si__total_used/ ],
'human_readable_sizes' => [ qw/_total_total _total_used/ ],
- 'template' => "Total space is ___total_total__ ___total_total_unit__, with ___total_used__ ___total_used_unit__ used (__percent__)",
+ 'template' => "Total space is __si__total_total__ __si__total_total_unit__, with __si__total_used__ __si__total_used_unit__ used (__percent__)",
'format' => 'one line',
'optional' => 1,
'subs' => {
'percent' => sub {
- calc_disk_space_percentage("$_[0]->{'_total_used'} $_[0]->{'_total_used_unit'}", "$_[0]->{'_total_total'} $_[0]->{'_total_total_unit'}")
+ calc_disk_space_percentage($_[0]->{'_total_used'}, $_[0]->{'_total_total'})
},
},
},
'protocol_version' => [ ">= 32" ],
'xml_version' => [ "== 0" ],
'attrs' => [ qw/drive_total_total drive_total_used/ ],
- 'commify' => [ qw/drive_total_total drive_total_used/ ],
+ 'commify' => [ qw/si_drive_total_total si_drive_total_used/ ],
'human_readable_sizes' => [ qw/drive_total_total drive_total_used/ ],
- 'template' => "Total space is __drive_total_total__ __drive_total_total_unit__, with __drive_total_used__ __drive_total_used_unit__ used (__percent__)",
+ 'template' => "Total space is __si_drive_total_total__ __si_drive_total_total_unit__, with __si_drive_total_used__ __si_drive_total_used_unit__ used (__percent__)",
'format' => 'one line',
'optional' => 1,
'subs' => {
'percent' => sub {
- calc_disk_space_percentage("$_[0]->{'drive_total_used'} $_[0]->{'drive_total_used_unit'}", "$_[0]->{'drive_total_total'} $_[0]->{'drive_total_total_unit'}")
+ calc_disk_space_percentage($_[0]->{'drive_total_used'}, $_[0]->{'drive_total_total'})
},
},
},
'xpath' => '//Status/MachineInfo/Storage/Group[@id="total"]',
'protocol_version' => [ ">= 39" ],
'attrs' => [ qw/total used/ ],
- 'commify' => [ qw/total used/ ],
+ 'commify' => [ qw/si_total used/ ],
'human_readable_sizes' => [ qw/total used/ ],
- 'template' => "Total space is __total__ __total_unit__, with __used__ __used_unit__ used (__percent__)",
+ 'template' => "Total space is __si_total__ __si_total_unit__, with __si_used__ __si_used_unit__ used (__percent__)",
'format' => 'one line',
'optional' => 1,
'subs' => {
'percent' => sub {
- calc_disk_space_percentage("$_[0]->{'used'} $_[0]->{'used_unit'}", "$_[0]->{'total'} $_[0]->{'total_unit'}")
+ calc_disk_space_percentage($_[0]->{'used'}, $_[0]->{'total'})
},
},
},
'xpath' => '//Status/MachineInfo/Storage/Group',
'protocol_version' => [ ">= 39" ],
'attrs' => [ qw/id total used/ ],
- 'commify' => [ qw/total used/ ],
+ 'commify' => [ qw/si_total used/ ],
'human_readable_sizes' => [ qw/total used/ ],
- 'template' => "Total space for group __id__ is __total__ __total_unit__, with __used__ __used_unit__ used (__percent__)",
+ 'template' => "Total space for group __id__ is __si_total__ __si_total_unit__, with __si_used__ __si_used_unit__ used (__percent__)",
'filter' => {
'id' => sub { return $_[0] eq 'total' },
'used' => sub {
},
'subs' => {
'percent' => sub {
- calc_disk_space_percentage("$_[0]->{'used'} $_[0]->{'used_unit'}", "$_[0]->{'total'} $_[0]->{'total_unit'}")
+ calc_disk_space_percentage($_[0]->{'used'}, $_[0]->{'total'})
},
},
},
for my $unit (@size_thresholds) {
if (defined $vars->{$key} && defined $unit->{'threshold'}) {
if ($vars->{$key} > $unit->{'threshold'}) {
- $vars->{$key} = sprintf("%.1f", $vars->{$key} / $unit->{'conversion'});
- $vars->{$key} =~ s/\.0//;
- $vars->{"${key}_unit"} = $unit->{'unit'};
+ $vars->{"si_$key"} = sprintf("%.1f", $vars->{$key} / $unit->{'conversion'});
+ $vars->{"si_$key"} =~ s/\.0//;
+ $vars->{"si_${key}_unit"} = $unit->{'unit'};
last;
}
} else {
- $vars->{"${key}_unit"} = $unit->{'unit'};
+ $vars->{"si_${key}"} = $vars->{$key};
+ $vars->{"si_${key}_unit"} = $unit->{'unit'};
}
}
}
# Make sure that the disk space is in a common unit.
# Currently that is MB.
sub normalise_disk_space {
- if ($_[0] =~ /^([.0-9]+) (\w+)$/) {
+ if ($_[0] =~ /^[.0-9]+$/) {
+ return $_[0];
+ } elsif ($_[0] =~ /^([.0-9]+) (\w+)$/) {
my $space = $1;
my $unit = $2;