mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 12:19:29 -05:00
32 lines
751 B
PowerShell
32 lines
751 B
PowerShell
function Get-IcingaNetworkInterfaceUnits()
|
|
{
|
|
param (
|
|
[decimal]$Value = 0,
|
|
[string]$Unit = ''
|
|
);
|
|
|
|
[hashtable]$InterfaceData = @{
|
|
'RawValue' = $Value;
|
|
'LinkSpeed' = 0;
|
|
'Unit' = 'Mbit'
|
|
};
|
|
|
|
if ([string]::IsNullOrEmpty($Unit) -eq $FALSE) {
|
|
$InterfaceData.LinkSpeed = $Value;
|
|
$InterfaceData.Unit = $Unit;
|
|
|
|
return $InterfaceData;
|
|
}
|
|
|
|
[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;
|
|
}
|