aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Framework
diff options
context:
space:
mode:
authorRobert Adams2013-03-15 13:59:34 -0700
committerRobert Adams2013-03-15 13:59:34 -0700
commitc10c43d6f6b0a79848b9a655533c27ab58cd2993 (patch)
tree43816d297304a155a2815ae48cc1b7452a94f62e /OpenSim/Region/OptionalModules/Framework
parentAdd example code to DOExampleModule to pull data from that previously saved b... (diff)
downloadopensim-SC_OLD-c10c43d6f6b0a79848b9a655533c27ab58cd2993.zip
opensim-SC_OLD-c10c43d6f6b0a79848b9a655533c27ab58cd2993.tar.gz
opensim-SC_OLD-c10c43d6f6b0a79848b9a655533c27ab58cd2993.tar.bz2
opensim-SC_OLD-c10c43d6f6b0a79848b9a655533c27ab58cd2993.tar.xz
Fix server statistics always reporting zero for total network bytes in/out.
Clean up some parameter code in Statistics.Binary.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Framework')
-rw-r--r--OpenSim/Region/OptionalModules/Framework/Monitoring/ServerStats.cs41
1 files changed, 26 insertions, 15 deletions
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 }