icinga-powershell-framework/lib/core/tools/Get-IcingaNetworkInterfaceUnits.psm1

25 lines
537 B
PowerShell
Raw Normal View History

function Get-IcingaNetworkInterfaceUnits()
{
param (
[long]$Value
);
[hashtable]$InterfaceData = @{
'RawValue' = $Value;
'LinkSpeed' = 0;
'Unit' = 'Mbit'
};
[decimal]$result = ($Value / [Math]::Pow(10, 6));
if ($result -ge 1000) {
$InterfaceData.LinkSpeed = [decimal]($result / 1000);
$InterfaceData.Unit = 'Gbit';
} else {
$InterfaceData.LinkSpeed = $result;
$InterfaceData.Unit = 'Mbit';
}
return $InterfaceData;
}