Fix server statistics always reporting zero for total network bytes in/out.
Clean up some parameter code in Statistics.Binary.user_profiles
parent
d3e76730bd
commit
c10c43d6f6
|
@ -278,25 +278,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_shouldCollectStats = false;
|
m_shouldCollectStats = false;
|
||||||
if (config != null)
|
if (config != null)
|
||||||
{
|
{
|
||||||
if (config.Contains("enabled") && config.GetBoolean("enabled"))
|
m_shouldCollectStats = config.GetBoolean("Enabled", false);
|
||||||
{
|
binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("packet_headers_period_seconds", 300));
|
||||||
if (config.Contains("collect_packet_headers"))
|
binStatsDir = config.GetString("stats_dir", ".");
|
||||||
m_shouldCollectStats = config.GetBoolean("collect_packet_headers");
|
m_aggregatedBWStats = config.GetBoolean("aggregatedBWStats", false);
|
||||||
if (config.Contains("packet_headers_period_seconds"))
|
}
|
||||||
{
|
#endregion BinaryStats
|
||||||
binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds"));
|
|
||||||
}
|
|
||||||
if (config.Contains("stats_dir"))
|
|
||||||
{
|
|
||||||
binStatsDir = config.GetString("stats_dir");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_shouldCollectStats = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion BinaryStats
|
|
||||||
|
|
||||||
m_throttle = new TokenBucket(null, sceneThrottleBps);
|
m_throttle = new TokenBucket(null, sceneThrottleBps);
|
||||||
ThrottleRates = new ThrottleRates(configSource);
|
ThrottleRates = new ThrottleRates(configSource);
|
||||||
|
@ -1266,8 +1253,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
static object binStatsLogLock = new object();
|
static object binStatsLogLock = new object();
|
||||||
static string binStatsDir = "";
|
static string binStatsDir = "";
|
||||||
|
|
||||||
|
//for Aggregated In/Out BW logging
|
||||||
|
static bool m_aggregatedBWStats = false;
|
||||||
|
static long m_aggregatedBytesIn = 0;
|
||||||
|
static long m_aggregatedByestOut = 0;
|
||||||
|
static object aggBWStatsLock = new object();
|
||||||
|
|
||||||
|
public static long AggregatedLLUDPBytesIn
|
||||||
|
{
|
||||||
|
get { return m_aggregatedBytesIn; }
|
||||||
|
}
|
||||||
|
public static long AggregatedLLUDPBytesOut
|
||||||
|
{
|
||||||
|
get {return m_aggregatedByestOut;}
|
||||||
|
}
|
||||||
|
|
||||||
public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size)
|
public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size)
|
||||||
{
|
{
|
||||||
|
if (m_aggregatedBWStats)
|
||||||
|
{
|
||||||
|
lock (aggBWStatsLock)
|
||||||
|
{
|
||||||
|
if (incoming)
|
||||||
|
m_aggregatedBytesIn += size;
|
||||||
|
else
|
||||||
|
m_aggregatedByestOut += size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_shouldCollectStats) return;
|
if (!m_shouldCollectStats) return;
|
||||||
|
|
||||||
// Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size
|
// Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size
|
||||||
|
|
|
@ -140,9 +140,12 @@ public class ServerStats : ISharedRegionModule
|
||||||
}
|
}
|
||||||
#endregion ISharedRegionModule
|
#endregion ISharedRegionModule
|
||||||
|
|
||||||
private void MakeStat(string pName, string pUnit, string pContainer, Action<Stat> act)
|
private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act)
|
||||||
{
|
{
|
||||||
Stat stat = new Stat(pName, pName, "", pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info);
|
string desc = pDesc;
|
||||||
|
if (desc == null)
|
||||||
|
desc = pName;
|
||||||
|
Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info);
|
||||||
StatsManager.RegisterStat(stat);
|
StatsManager.RegisterStat(stat);
|
||||||
RegisteredStats.Add(pName, stat);
|
RegisteredStats.Add(pName, stat);
|
||||||
}
|
}
|
||||||
|
@ -166,16 +169,16 @@ public class ServerStats : ISharedRegionModule
|
||||||
StatsManager.RegisterStat(tempStat);
|
StatsManager.RegisterStat(tempStat);
|
||||||
RegisteredStats.Add(tempName, tempStat);
|
RegisteredStats.Add(tempName, tempStat);
|
||||||
|
|
||||||
MakeStat("TotalProcessorTime", "sec", ContainerProcessor,
|
MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor,
|
||||||
(s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; });
|
(s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; });
|
||||||
|
|
||||||
MakeStat("UserProcessorTime", "sec", ContainerProcessor,
|
MakeStat("UserProcessorTime", null, "sec", ContainerProcessor,
|
||||||
(s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; });
|
(s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; });
|
||||||
|
|
||||||
MakeStat("PrivilegedProcessorTime", "sec", ContainerProcessor,
|
MakeStat("PrivilegedProcessorTime", null, "sec", ContainerProcessor,
|
||||||
(s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; });
|
(s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; });
|
||||||
|
|
||||||
MakeStat("Threads", "threads", ContainerProcessor,
|
MakeStat("Threads", null, "threads", ContainerProcessor,
|
||||||
(s) => { s.Value = Process.GetCurrentProcess().Threads.Count; });
|
(s) => { s.Value = Process.GetCurrentProcess().Threads.Count; });
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -196,8 +199,10 @@ public class ServerStats : ISharedRegionModule
|
||||||
string nicInterfaceType = nic.NetworkInterfaceType.ToString();
|
string nicInterfaceType = nic.NetworkInterfaceType.ToString();
|
||||||
if (!okInterfaceTypes.Contains(nicInterfaceType))
|
if (!okInterfaceTypes.Contains(nicInterfaceType))
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'. To include, add to [Monitoring]NetworkInterfaceTypes='Ethernet,Loopback'",
|
m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'.",
|
||||||
LogHeader, nic.Name, nicInterfaceType);
|
LogHeader, nic.Name, nicInterfaceType);
|
||||||
|
m_log.DebugFormat("{0} To include, add to comma separated list in [Monitoring]NetworkInterfaceTypes={1}",
|
||||||
|
LogHeader, NetworkInterfaceTypes);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,14 +211,15 @@ public class ServerStats : ISharedRegionModule
|
||||||
IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics();
|
IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics();
|
||||||
if (nicStats != null)
|
if (nicStats != null)
|
||||||
{
|
{
|
||||||
MakeStat("BytesRcvd/" + nic.Name, "KB", ContainerNetwork,
|
MakeStat("BytesRcvd/" + nic.Name, nic.Name, "KB", ContainerNetwork,
|
||||||
(s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); });
|
(s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); });
|
||||||
MakeStat("BytesSent/" + nic.Name, "KB", ContainerNetwork,
|
MakeStat("BytesSent/" + nic.Name, nic.Name, "KB", ContainerNetwork,
|
||||||
(s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); });
|
(s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); });
|
||||||
MakeStat("TotalBytes/" + nic.Name, "KB", ContainerNetwork,
|
MakeStat("TotalBytes/" + nic.Name, nic.Name, "KB", ContainerNetwork,
|
||||||
(s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); });
|
(s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: add IPv6 (it may actually happen someday)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -221,13 +227,13 @@ public class ServerStats : ISharedRegionModule
|
||||||
m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e);
|
m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeStat("ProcessMemory", "MB", ContainerMemory,
|
MakeStat("ProcessMemory", null, "MB", ContainerMemory,
|
||||||
(s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; });
|
(s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; });
|
||||||
MakeStat("ObjectMemory", "MB", ContainerMemory,
|
MakeStat("ObjectMemory", null, "MB", ContainerMemory,
|
||||||
(s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; });
|
(s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; });
|
||||||
MakeStat("LastMemoryChurn", "MB/sec", ContainerMemory,
|
MakeStat("LastMemoryChurn", null, "MB/sec", ContainerMemory,
|
||||||
(s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); });
|
(s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); });
|
||||||
MakeStat("AverageMemoryChurn", "MB/sec", ContainerMemory,
|
MakeStat("AverageMemoryChurn", null, "MB/sec", ContainerMemory,
|
||||||
(s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); });
|
(s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +269,8 @@ public class ServerStats : ISharedRegionModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lookup the nic that goes with this stat and set the value by using a fetch action.
|
||||||
|
// Not sure about closure with delegates inside delegates.
|
||||||
private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat);
|
private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat);
|
||||||
private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor)
|
private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor)
|
||||||
{
|
{
|
||||||
|
@ -275,7 +283,10 @@ public class ServerStats : ISharedRegionModule
|
||||||
{
|
{
|
||||||
IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics();
|
IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics();
|
||||||
if (intrStats != null)
|
if (intrStats != null)
|
||||||
stat.Value = Math.Round(getter(intrStats) / factor, 3);
|
{
|
||||||
|
double newVal = Math.Round(getter(intrStats) / factor, 3);
|
||||||
|
stat.Value = newVal;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue