mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
Show rate values in Byte/s instead of Bps, Show network traffic in Bit/s
This commit is contained in:
parent
ec374afabf
commit
0f8008e482
@ -95,6 +95,8 @@ namespace XenAdmin.Controls.CustomDataGraph
|
||||
{
|
||||
case Unit.Bytes:
|
||||
return Util.MemorySizeStringVariousUnits(constrVal);
|
||||
case Unit.BitsPerSecond:
|
||||
return Util.DataRateString(constrVal, true);
|
||||
case Unit.BytesPerSecond:
|
||||
return Util.DataRateString(constrVal);
|
||||
case Unit.Percentage:
|
||||
@ -128,6 +130,9 @@ namespace XenAdmin.Controls.CustomDataGraph
|
||||
case Unit.Bytes:
|
||||
Util.MemorySizeValueVariousUnits(Max, out unit);
|
||||
return unit;
|
||||
case Unit.BitsPerSecond:
|
||||
Util.DataRateValue(Max, out unit, true);
|
||||
return unit;
|
||||
case Unit.BytesPerSecond:
|
||||
Util.DataRateValue(Max, out unit);
|
||||
return unit;
|
||||
@ -164,6 +169,8 @@ namespace XenAdmin.Controls.CustomDataGraph
|
||||
{
|
||||
case Unit.Bytes:
|
||||
return Util.MemorySizeValueVariousUnits(constrVal, out unit);
|
||||
case Unit.BitsPerSecond:
|
||||
return Util.DataRateValue(constrVal, out unit, true);
|
||||
case Unit.BytesPerSecond:
|
||||
return Util.DataRateValue(constrVal, out unit);
|
||||
case Unit.NanoSeconds:
|
||||
@ -229,6 +236,7 @@ namespace XenAdmin.Controls.CustomDataGraph
|
||||
Resolution = Max > 10 ? Max / 10d : 1;
|
||||
break;
|
||||
case Unit.Bytes:
|
||||
case Unit.BitsPerSecond:
|
||||
case Unit.BytesPerSecond:
|
||||
default:
|
||||
{
|
||||
@ -260,5 +268,5 @@ namespace XenAdmin.Controls.CustomDataGraph
|
||||
|
||||
public enum RangeScaleMode { Fixed, Auto, Delegate }
|
||||
|
||||
public enum Unit { None, Percentage, BytesPerSecond, Bytes, NanoSeconds, CountsPerSecond, MilliWatt, Centigrade, MegaHertz }
|
||||
public enum Unit { None, Percentage, BitsPerSecond, BytesPerSecond, Bytes, NanoSeconds, CountsPerSecond, MilliWatt, Centigrade, MegaHertz }
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ namespace XenAdmin.Controls.CustomDataGraph
|
||||
else if (settype.StartsWith("vif") || settype.StartsWith("pif"))
|
||||
{
|
||||
//xapi units are in bytes/sec or errors/sec
|
||||
Unit unit = settype.EndsWith("errors") ? Unit.CountsPerSecond : Unit.BytesPerSecond;
|
||||
Unit unit = settype.EndsWith("errors") ? Unit.CountsPerSecond : Unit.BitsPerSecond;
|
||||
|
||||
dataSet.CustomYRange = new DataRange(1, 0, 1, unit, RangeScaleMode.Auto);
|
||||
dataSet.Type = DataType.Network;
|
||||
|
55
XenModel/Messages.Designer.cs
generated
55
XenModel/Messages.Designer.cs
generated
@ -36511,7 +36511,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die GBps ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die GByte/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_GIGRATE {
|
||||
get {
|
||||
@ -36519,6 +36519,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die GBit/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_GIGRATE_BIT_S {
|
||||
get {
|
||||
return ResourceManager.GetString("VAL_GIGRATE_BIT_S", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die {0} kB ähnelt.
|
||||
/// </summary>
|
||||
@ -36547,7 +36556,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die kBps ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die kByte/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_KILRATE {
|
||||
get {
|
||||
@ -36555,6 +36564,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die KBit/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_KILRATE_BIT_S {
|
||||
get {
|
||||
return ResourceManager.GetString("VAL_KILRATE_BIT_S", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die {0} MB ähnelt.
|
||||
/// </summary>
|
||||
@ -36583,7 +36601,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die MBps ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die MByte/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_MEGRATE {
|
||||
get {
|
||||
@ -36591,6 +36609,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die MBit/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_MEGRATE_BIT_S {
|
||||
get {
|
||||
return ResourceManager.GetString("VAL_MEGRATE_BIT_S", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die μs ähnelt.
|
||||
/// </summary>
|
||||
@ -36637,7 +36664,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Bps ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Byte/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_RATE {
|
||||
get {
|
||||
@ -36645,6 +36672,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Bit/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_RATE_BIT_S {
|
||||
get {
|
||||
return ResourceManager.GetString("VAL_RATE_BIT_S", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die 0.0 ähnelt.
|
||||
/// </summary>
|
||||
@ -36673,7 +36709,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die TiBps ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die TiByte/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_TERRATE {
|
||||
get {
|
||||
@ -36681,6 +36717,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die TBit/s ähnelt.
|
||||
/// </summary>
|
||||
public static string VAL_TERRATE_BIT_S {
|
||||
get {
|
||||
return ResourceManager.GetString("VAL_TERRATE_BIT_S", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die W ähnelt.
|
||||
/// </summary>
|
||||
|
@ -12643,7 +12643,10 @@ To start a [XenServer] trial, click the button below.</value>
|
||||
<value>GHz</value>
|
||||
</data>
|
||||
<data name="VAL_GIGRATE" xml:space="preserve">
|
||||
<value>GBps</value>
|
||||
<value>GByte/s</value>
|
||||
</data>
|
||||
<data name="VAL_GIGRATE_BIT_S" xml:space="preserve">
|
||||
<value>GBit/s</value>
|
||||
</data>
|
||||
<data name="VAL_KB" xml:space="preserve">
|
||||
<value>{0} kB</value>
|
||||
@ -12655,7 +12658,10 @@ To start a [XenServer] trial, click the button below.</value>
|
||||
<value>kW</value>
|
||||
</data>
|
||||
<data name="VAL_KILRATE" xml:space="preserve">
|
||||
<value>kBps</value>
|
||||
<value>kByte/s</value>
|
||||
</data>
|
||||
<data name="VAL_KILRATE_BIT_S" xml:space="preserve">
|
||||
<value>KBit/s</value>
|
||||
</data>
|
||||
<data name="VAL_MB" xml:space="preserve">
|
||||
<value>{0} MB</value>
|
||||
@ -12667,7 +12673,10 @@ To start a [XenServer] trial, click the button below.</value>
|
||||
<value>MHz</value>
|
||||
</data>
|
||||
<data name="VAL_MEGRATE" xml:space="preserve">
|
||||
<value>MBps</value>
|
||||
<value>MByte/s</value>
|
||||
</data>
|
||||
<data name="VAL_MEGRATE_BIT_S" xml:space="preserve">
|
||||
<value>MBit/s</value>
|
||||
</data>
|
||||
<data name="VAL_MICSEC" xml:space="preserve">
|
||||
<value>μs</value>
|
||||
@ -12685,7 +12694,10 @@ To start a [XenServer] trial, click the button below.</value>
|
||||
<value>ns</value>
|
||||
</data>
|
||||
<data name="VAL_RATE" xml:space="preserve">
|
||||
<value>Bps</value>
|
||||
<value>Byte/s</value>
|
||||
</data>
|
||||
<data name="VAL_RATE_BIT_S" xml:space="preserve">
|
||||
<value>Bit/s</value>
|
||||
</data>
|
||||
<data name="VAL_RATE_NUM_FORMAT" xml:space="preserve">
|
||||
<value>0.0</value>
|
||||
@ -12697,7 +12709,10 @@ To start a [XenServer] trial, click the button below.</value>
|
||||
<value>TiB</value>
|
||||
</data>
|
||||
<data name="VAL_TERRATE" xml:space="preserve">
|
||||
<value>TiBps</value>
|
||||
<value>TiByte/s</value>
|
||||
</data>
|
||||
<data name="VAL_TERRATE_BIT_S" xml:space="preserve">
|
||||
<value>TBit/s</value>
|
||||
</data>
|
||||
<data name="VAL_WATT" xml:space="preserve">
|
||||
<value>W</value>
|
||||
|
@ -120,16 +120,16 @@ namespace XenAdmin
|
||||
}
|
||||
}
|
||||
|
||||
public static string DataRateString(double bytesPerSec)
|
||||
public static string DataRateString(double bytesPerSec, bool resultInBits = false)
|
||||
{
|
||||
string unit;
|
||||
string value = ByteSizeString(bytesPerSec, 1, true, out unit);
|
||||
string value = !resultInBits ? ByteSizeString(bytesPerSec, 1, true, out unit) : BitSizeStringRate(bytesPerSec, 1, out unit);
|
||||
return string.Format(Messages.VAL_FORMAT, value, unit);
|
||||
}
|
||||
|
||||
public static string DataRateValue(double bytesPerSec, out string unit)
|
||||
public static string DataRateValue(double bytesPerSec, out string unit, bool resultInBits = false)
|
||||
{
|
||||
return ByteSizeString(bytesPerSec, 1, true, out unit);
|
||||
return !resultInBits ? ByteSizeString(bytesPerSec, 1, true, out unit) : BitSizeStringRate(bytesPerSec, 1, out unit);
|
||||
}
|
||||
|
||||
public static string DiskSizeString(ulong bytes)
|
||||
@ -170,6 +170,39 @@ namespace XenAdmin
|
||||
return ByteSizeString(bytes, 0, false, out unit);
|
||||
}
|
||||
|
||||
private static string BitSizeStringRate(double bytes, int decPlaces, out string unit, string format = null)
|
||||
{
|
||||
if (bytes >= BINARY_TERA)
|
||||
{
|
||||
unit = Messages.VAL_TERRATE_BIT_S;
|
||||
var result = Math.Round(bytes * 8 / BINARY_TERA, decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
if (bytes >= BINARY_GIGA)
|
||||
{
|
||||
unit = Messages.VAL_GIGRATE_BIT_S;
|
||||
var result = Math.Round(bytes * 8 / (BINARY_GIGA), decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
if (bytes >= BINARY_MEGA)
|
||||
{
|
||||
unit = Messages.VAL_MEGRATE_BIT_S;
|
||||
var result = Math.Round(bytes * 8 / (BINARY_MEGA), decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
if (bytes >= BINARY_KILO)
|
||||
{
|
||||
unit = Messages.VAL_KILRATE_BIT_S;
|
||||
var result = Math.Round(bytes / BINARY_KILO, decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
unit = Messages.VAL_RATE_BIT_S;
|
||||
return bytes.ToString();
|
||||
}
|
||||
|
||||
private static string ByteSizeString(double bytes, int decPlaces, bool isRate, out string unit, string format = null)
|
||||
{
|
||||
if (bytes >= BINARY_TERA)
|
||||
@ -180,15 +213,15 @@ namespace XenAdmin
|
||||
}
|
||||
if (bytes >= BINARY_GIGA)
|
||||
{
|
||||
unit = isRate ? "GBit/s" /*Messages.VAL_GIGRATE*/ : Messages.VAL_GIGB;
|
||||
var result = isRate ? Math.Round((bytes*8) / (BINARY_GIGA), decPlaces) : Math.Round(bytes / BINARY_GIGA, decPlaces);
|
||||
unit = isRate ? Messages.VAL_GIGRATE : Messages.VAL_GIGB;
|
||||
var result = isRate ? Math.Round(bytes / (BINARY_GIGA), decPlaces) : Math.Round(bytes / BINARY_GIGA, decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
if (bytes >= BINARY_MEGA)
|
||||
{
|
||||
unit = isRate ? "MBit/s" /*Messages.VAL_MEGRATE*/ : Messages.VAL_MEGB;
|
||||
var result = isRate ? Math.Round((bytes*8) / (BINARY_MEGA), decPlaces) : Math.Round(bytes / BINARY_MEGA, decPlaces);
|
||||
unit = isRate ? Messages.VAL_MEGRATE : Messages.VAL_MEGB;
|
||||
var result = isRate ? Math.Round(bytes / (BINARY_MEGA), decPlaces) : Math.Round(bytes / BINARY_MEGA, decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user