diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 51 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs | 41 |
2 files changed, 58 insertions, 34 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index a7628d2..72516cd 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -278,25 +278,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
278 | m_shouldCollectStats = false; | 278 | m_shouldCollectStats = false; |
279 | if (config != null) | 279 | if (config != null) |
280 | { | 280 | { |
281 | if (config.Contains("enabled") && config.GetBoolean("enabled")) | 281 | m_shouldCollectStats = config.GetBoolean("Enabled", false); |
282 | { | 282 | binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("packet_headers_period_seconds", 300)); |
283 | if (config.Contains("collect_packet_headers")) | 283 | binStatsDir = config.GetString("stats_dir", "."); |
284 | m_shouldCollectStats = config.GetBoolean("collect_packet_headers"); | 284 | m_aggregatedBWStats = config.GetBoolean("aggregatedBWStats", false); |
285 | if (config.Contains("packet_headers_period_seconds")) | 285 | } |
286 | { | 286 | #endregion BinaryStats |
287 | binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds")); | ||
288 | } | ||
289 | if (config.Contains("stats_dir")) | ||
290 | { | ||
291 | binStatsDir = config.GetString("stats_dir"); | ||
292 | } | ||
293 | } | ||
294 | else | ||
295 | { | ||
296 | m_shouldCollectStats = false; | ||
297 | } | ||
298 | } | ||
299 | #endregion BinaryStats | ||
300 | 287 | ||
301 | m_throttle = new TokenBucket(null, sceneThrottleBps); | 288 | m_throttle = new TokenBucket(null, sceneThrottleBps); |
302 | ThrottleRates = new ThrottleRates(configSource); | 289 | ThrottleRates = new ThrottleRates(configSource); |
@@ -1266,8 +1253,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1266 | static object binStatsLogLock = new object(); | 1253 | static object binStatsLogLock = new object(); |
1267 | static string binStatsDir = ""; | 1254 | static string binStatsDir = ""; |
1268 | 1255 | ||
1256 | //for Aggregated In/Out BW logging | ||
1257 | static bool m_aggregatedBWStats = false; | ||
1258 | static long m_aggregatedBytesIn = 0; | ||
1259 | static long m_aggregatedByestOut = 0; | ||
1260 | static object aggBWStatsLock = new object(); | ||
1261 | |||
1262 | public static long AggregatedLLUDPBytesIn | ||
1263 | { | ||
1264 | get { return m_aggregatedBytesIn; } | ||
1265 | } | ||
1266 | public static long AggregatedLLUDPBytesOut | ||
1267 | { | ||
1268 | get {return m_aggregatedByestOut;} | ||
1269 | } | ||
1270 | |||
1269 | public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size) | 1271 | public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size) |
1270 | { | 1272 | { |
1273 | if (m_aggregatedBWStats) | ||
1274 | { | ||
1275 | lock (aggBWStatsLock) | ||
1276 | { | ||
1277 | if (incoming) | ||
1278 | m_aggregatedBytesIn += size; | ||
1279 | else | ||
1280 | m_aggregatedByestOut += size; | ||
1281 | } | ||
1282 | } | ||
1283 | |||
1271 | if (!m_shouldCollectStats) return; | 1284 | if (!m_shouldCollectStats) return; |
1272 | 1285 | ||
1273 | // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size | 1286 | // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size |
diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs index a3d2436..6e74ce0 100644 --- a/OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs +++ b/OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs | |||
@@ -140,9 +140,12 @@ public class ServerStats : ISharedRegionModule | |||
140 | } | 140 | } |
141 | #endregion ISharedRegionModule | 141 | #endregion ISharedRegionModule |
142 | 142 | ||
143 | private void MakeStat(string pName, string pUnit, string pContainer, Action<Stat> act) | 143 | private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act) |
144 | { | 144 | { |
145 | Stat stat = new Stat(pName, pName, "", pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info); | 145 | string desc = pDesc; |
146 | if (desc == null) | ||
147 | desc = pName; | ||
148 | Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info); | ||
146 | StatsManager.RegisterStat(stat); | 149 | StatsManager.RegisterStat(stat); |
147 | RegisteredStats.Add(pName, stat); | 150 | RegisteredStats.Add(pName, stat); |
148 | } | 151 | } |
@@ -166,16 +169,16 @@ public class ServerStats : ISharedRegionModule | |||
166 | StatsManager.RegisterStat(tempStat); | 169 | StatsManager.RegisterStat(tempStat); |
167 | RegisteredStats.Add(tempName, tempStat); | 170 | RegisteredStats.Add(tempName, tempStat); |
168 | 171 | ||
169 | MakeStat("TotalProcessorTime", "sec", ContainerProcessor, | 172 | MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor, |
170 | (s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; }); | 173 | (s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; }); |
171 | 174 | ||
172 | MakeStat("UserProcessorTime", "sec", ContainerProcessor, | 175 | MakeStat("UserProcessorTime", null, "sec", ContainerProcessor, |
173 | (s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; }); | 176 | (s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; }); |
174 | 177 | ||
175 | MakeStat("PrivilegedProcessorTime", "sec", ContainerProcessor, | 178 | MakeStat("PrivilegedProcessorTime", null, "sec", ContainerProcessor, |
176 | (s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; }); | 179 | (s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; }); |
177 | 180 | ||
178 | MakeStat("Threads", "threads", ContainerProcessor, | 181 | MakeStat("Threads", null, "threads", ContainerProcessor, |
179 | (s) => { s.Value = Process.GetCurrentProcess().Threads.Count; }); | 182 | (s) => { s.Value = Process.GetCurrentProcess().Threads.Count; }); |
180 | } | 183 | } |
181 | catch (Exception e) | 184 | catch (Exception e) |
@@ -196,8 +199,10 @@ public class ServerStats : ISharedRegionModule | |||
196 | string nicInterfaceType = nic.NetworkInterfaceType.ToString(); | 199 | string nicInterfaceType = nic.NetworkInterfaceType.ToString(); |
197 | if (!okInterfaceTypes.Contains(nicInterfaceType)) | 200 | if (!okInterfaceTypes.Contains(nicInterfaceType)) |
198 | { | 201 | { |
199 | m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'. To include, add to [Monitoring]NetworkInterfaceTypes='Ethernet,Loopback'", | 202 | m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'.", |
200 | LogHeader, nic.Name, nicInterfaceType); | 203 | LogHeader, nic.Name, nicInterfaceType); |
204 | m_log.DebugFormat("{0} To include, add to comma separated list in [Monitoring]NetworkInterfaceTypes={1}", | ||
205 | LogHeader, NetworkInterfaceTypes); | ||
201 | continue; | 206 | continue; |
202 | } | 207 | } |
203 | 208 | ||
@@ -206,14 +211,15 @@ public class ServerStats : ISharedRegionModule | |||
206 | IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics(); | 211 | IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics(); |
207 | if (nicStats != null) | 212 | if (nicStats != null) |
208 | { | 213 | { |
209 | MakeStat("BytesRcvd/" + nic.Name, "KB", ContainerNetwork, | 214 | MakeStat("BytesRcvd/" + nic.Name, nic.Name, "KB", ContainerNetwork, |
210 | (s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); }); | 215 | (s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); }); |
211 | MakeStat("BytesSent/" + nic.Name, "KB", ContainerNetwork, | 216 | MakeStat("BytesSent/" + nic.Name, nic.Name, "KB", ContainerNetwork, |
212 | (s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); }); | 217 | (s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); }); |
213 | MakeStat("TotalBytes/" + nic.Name, "KB", ContainerNetwork, | 218 | MakeStat("TotalBytes/" + nic.Name, nic.Name, "KB", ContainerNetwork, |
214 | (s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); }); | 219 | (s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); }); |
215 | } | 220 | } |
216 | } | 221 | } |
222 | // TODO: add IPv6 (it may actually happen someday) | ||
217 | } | 223 | } |
218 | } | 224 | } |
219 | catch (Exception e) | 225 | catch (Exception e) |
@@ -221,13 +227,13 @@ public class ServerStats : ISharedRegionModule | |||
221 | m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e); | 227 | m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e); |
222 | } | 228 | } |
223 | 229 | ||
224 | MakeStat("ProcessMemory", "MB", ContainerMemory, | 230 | MakeStat("ProcessMemory", null, "MB", ContainerMemory, |
225 | (s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; }); | 231 | (s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; }); |
226 | MakeStat("ObjectMemory", "MB", ContainerMemory, | 232 | MakeStat("ObjectMemory", null, "MB", ContainerMemory, |
227 | (s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; }); | 233 | (s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; }); |
228 | MakeStat("LastMemoryChurn", "MB/sec", ContainerMemory, | 234 | MakeStat("LastMemoryChurn", null, "MB/sec", ContainerMemory, |
229 | (s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); }); | 235 | (s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); }); |
230 | MakeStat("AverageMemoryChurn", "MB/sec", ContainerMemory, | 236 | MakeStat("AverageMemoryChurn", null, "MB/sec", ContainerMemory, |
231 | (s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); }); | 237 | (s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); }); |
232 | } | 238 | } |
233 | 239 | ||
@@ -263,6 +269,8 @@ public class ServerStats : ISharedRegionModule | |||
263 | } | 269 | } |
264 | } | 270 | } |
265 | 271 | ||
272 | // Lookup the nic that goes with this stat and set the value by using a fetch action. | ||
273 | // Not sure about closure with delegates inside delegates. | ||
266 | private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat); | 274 | private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat); |
267 | private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor) | 275 | private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor) |
268 | { | 276 | { |
@@ -275,7 +283,10 @@ public class ServerStats : ISharedRegionModule | |||
275 | { | 283 | { |
276 | IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics(); | 284 | IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics(); |
277 | if (intrStats != null) | 285 | if (intrStats != null) |
278 | stat.Value = Math.Round(getter(intrStats) / factor, 3); | 286 | { |
287 | double newVal = Math.Round(getter(intrStats) / factor, 3); | ||
288 | stat.Value = newVal; | ||
289 | } | ||
279 | break; | 290 | break; |
280 | } | 291 | } |
281 | } | 292 | } |