mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-20 12:14:54 +02:00
add convert misc function
This commit is contained in:
parent
f672ade530
commit
03e874c75b
@ -389,6 +389,19 @@ sub change_seconds {
|
||||
return $str;
|
||||
}
|
||||
|
||||
sub convert_bytes {
|
||||
my (%options) = @_;
|
||||
my %expo = (k => 1, m => 2, g => 3, t => 4);
|
||||
my $value = $options{value};
|
||||
my $base = defined($options{network}) ? 1000 : 1020;
|
||||
|
||||
if ($options{unit} =~ /([kmgt])b/i) {
|
||||
$value = $value * ($base ** $expo{lc($1)});
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
Loading…
x
Reference in New Issue
Block a user