aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics/WebStatsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/UserStatistics/WebStatsModule.cs')
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs63
1 files changed, 18 insertions, 45 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index 3139b8a..9d87c45 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.UserStatistics
58 58
59 private static SqliteConnection dbConn; 59 private static SqliteConnection dbConn;
60 private Dictionary<UUID, UserSessionID> m_sessions = new Dictionary<UUID, UserSessionID>(); 60 private Dictionary<UUID, UserSessionID> m_sessions = new Dictionary<UUID, UserSessionID>();
61 private List<Scene> m_scene = new List<Scene>(); 61 private List<Scene> m_scenes = new List<Scene>();
62 private Dictionary<string, IStatsController> reports = new Dictionary<string, IStatsController>(); 62 private Dictionary<string, IStatsController> reports = new Dictionary<string, IStatsController>();
63 private Dictionary<UUID, USimStatsData> m_simstatsCounters = new Dictionary<UUID, USimStatsData>(); 63 private Dictionary<UUID, USimStatsData> m_simstatsCounters = new Dictionary<UUID, USimStatsData>();
64 private const int updateStatsMod = 6; 64 private const int updateStatsMod = 6;
@@ -71,25 +71,17 @@ namespace OpenSim.Region.UserStatistics
71 71
72 public virtual void Initialise(Scene scene, IConfigSource config) 72 public virtual void Initialise(Scene scene, IConfigSource config)
73 { 73 {
74 IConfig cnfg; 74 IConfig cnfg = config.Configs["WebStats"];
75 try 75
76 { 76 if (cnfg != null)
77 cnfg = config.Configs["WebStats"];
78 enabled = cnfg.GetBoolean("enabled", false); 77 enabled = cnfg.GetBoolean("enabled", false);
79 }
80 catch (Exception)
81 {
82 enabled = false;
83 }
84 78
85 if (!enabled) 79 if (!enabled)
86 {
87 return; 80 return;
88 }
89 81
90 lock (m_scene) 82 lock (m_scenes)
91 { 83 {
92 if (m_scene.Count == 0) 84 if (m_scenes.Count == 0)
93 { 85 {
94 //IConfig startupConfig = config.Configs["Startup"]; 86 //IConfig startupConfig = config.Configs["Startup"];
95 87
@@ -115,22 +107,19 @@ namespace OpenSim.Region.UserStatistics
115 reports.Add("clients.report", clientReport); 107 reports.Add("clients.report", clientReport);
116 reports.Add("sessions.report", sessionsReport); 108 reports.Add("sessions.report", sessionsReport);
117 109
118
119
120 //// 110 ////
121 // Add Your own Reports here (Do Not Modify Lines here Devs!) 111 // Add Your own Reports here (Do Not Modify Lines here Devs!)
122 //// 112 ////
123 113
124 //// 114 ////
125 // End Own reports section 115 // End Own reports section
126 //// 116 ////
127
128 117
129 MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest); 118 MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest);
130 MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); 119 MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
131 } 120 }
132 121
133 m_scene.Add(scene); 122 m_scenes.Add(scene);
134 if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID)) 123 if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID))
135 m_simstatsCounters.Remove(scene.RegionInfo.RegionID); 124 m_simstatsCounters.Remove(scene.RegionInfo.RegionID);
136 125
@@ -214,7 +203,7 @@ namespace OpenSim.Region.UserStatistics
214 203
215 204
216 repParams["DatabaseConnection"] = dbConn; 205 repParams["DatabaseConnection"] = dbConn;
217 repParams["Scenes"] = m_scene; 206 repParams["Scenes"] = m_scenes;
218 repParams["SimStats"] = m_simstatsCounters; 207 repParams["SimStats"] = m_simstatsCounters;
219 repParams["LogLines"] = m_loglines; 208 repParams["LogLines"] = m_loglines;
220 repParams["Reports"] = reports; 209 repParams["Reports"] = reports;
@@ -265,7 +254,6 @@ namespace OpenSim.Region.UserStatistics
265 CreateTables(db); 254 CreateTables(db);
266 } 255 }
267 } 256 }
268
269 } 257 }
270 258
271 public void CreateTables(SqliteConnection db) 259 public void CreateTables(SqliteConnection db)
@@ -277,8 +265,6 @@ namespace OpenSim.Region.UserStatistics
277 createcmd.ExecuteNonQuery(); 265 createcmd.ExecuteNonQuery();
278 } 266 }
279 267
280
281
282 public virtual void PostInitialise() 268 public virtual void PostInitialise()
283 { 269 {
284 if (!enabled) 270 if (!enabled)
@@ -297,7 +283,7 @@ namespace OpenSim.Region.UserStatistics
297 dbConn.Close(); 283 dbConn.Close();
298 dbConn.Dispose(); 284 dbConn.Dispose();
299 m_sessions.Clear(); 285 m_sessions.Clear();
300 m_scene.Clear(); 286 m_scenes.Clear();
301 reports.Clear(); 287 reports.Clear();
302 m_simstatsCounters.Clear(); 288 m_simstatsCounters.Clear();
303 } 289 }
@@ -333,10 +319,10 @@ namespace OpenSim.Region.UserStatistics
333 319
334 protected virtual void AddHandlers() 320 protected virtual void AddHandlers()
335 { 321 {
336 lock (m_scene) 322 lock (m_scenes)
337 { 323 {
338 updateLogMod = m_scene.Count * 2; 324 updateLogMod = m_scenes.Count * 2;
339 foreach (Scene scene in m_scene) 325 foreach (Scene scene in m_scenes)
340 { 326 {
341 scene.EventManager.OnRegisterCaps += OnRegisterCaps; 327 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
342 scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps; 328 scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps;
@@ -376,15 +362,11 @@ namespace OpenSim.Region.UserStatistics
376 } 362 }
377 } 363 }
378 364
379
380
381
382 public void OnMakeChildAgent(ScenePresence agent) 365 public void OnMakeChildAgent(ScenePresence agent)
383 { 366 {
384 367
385 } 368 }
386 369
387
388 public void OnClientClosed(UUID agentID, Scene scene) 370 public void OnClientClosed(UUID agentID, Scene scene)
389 { 371 {
390 lock (m_sessions) 372 lock (m_sessions)
@@ -394,7 +376,6 @@ namespace OpenSim.Region.UserStatistics
394 m_sessions.Remove(agentID); 376 m_sessions.Remove(agentID);
395 } 377 }
396 } 378 }
397
398 } 379 }
399 380
400 public string readLogLines(int amount) 381 public string readLogLines(int amount)
@@ -433,14 +414,13 @@ namespace OpenSim.Region.UserStatistics
433 fs.Close(); 414 fs.Close();
434 fs.Dispose(); 415 fs.Dispose();
435 return encoding.GetString(buffer); 416 return encoding.GetString(buffer);
436
437 } 417 }
438 418
439 public UUID GetRegionUUIDFromHandle(ulong regionhandle) 419 public UUID GetRegionUUIDFromHandle(ulong regionhandle)
440 { 420 {
441 lock (m_scene) 421 lock (m_scenes)
442 { 422 {
443 foreach (Scene scene in m_scene) 423 foreach (Scene scene in m_scenes)
444 { 424 {
445 if (scene.RegionInfo.RegionHandle == regionhandle) 425 if (scene.RegionInfo.RegionHandle == regionhandle)
446 return scene.RegionInfo.RegionID; 426 return scene.RegionInfo.RegionID;
@@ -448,6 +428,7 @@ namespace OpenSim.Region.UserStatistics
448 } 428 }
449 return UUID.Zero; 429 return UUID.Zero;
450 } 430 }
431
451 /// <summary> 432 /// <summary>
452 /// Callback for a viewerstats cap 433 /// Callback for a viewerstats cap
453 /// </summary> 434 /// </summary>
@@ -523,8 +504,6 @@ namespace OpenSim.Region.UserStatistics
523 504
524 usd = uid.session_data; 505 usd = uid.session_data;
525 506
526
527
528 if (message.Type != OSDType.Map) 507 if (message.Type != OSDType.Map)
529 return new UserSessionID(); 508 return new UserSessionID();
530 509
@@ -699,7 +678,6 @@ namespace OpenSim.Region.UserStatistics
699 678
700 } 679 }
701 } 680 }
702
703 } 681 }
704 682
705 #region SQL 683 #region SQL
@@ -824,6 +802,7 @@ set session_id=:session_id,
824WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"; 802WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key";
825 #endregion 803 #endregion
826 } 804 }
805
827 public static class UserSessionUtil 806 public static class UserSessionUtil
828 { 807 {
829 public static UserSessionData newUserSessionData() 808 public static UserSessionData newUserSessionData()
@@ -941,7 +920,6 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
941 return result / cnt; 920 return result / cnt;
942 } 921 }
943 922
944
945 public static float ArrayMode_f(float[] arr) 923 public static float ArrayMode_f(float[] arr)
946 { 924 {
947 List<float> mode = new List<float>(); 925 List<float> mode = new List<float>();
@@ -995,10 +973,8 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
995 } 973 }
996 974
997 return mode.ToArray()[0]; 975 return mode.ToArray()[0];
998
999 } 976 }
1000 977
1001
1002 public static int ArrayMode_i(int[] arr) 978 public static int ArrayMode_i(int[] arr)
1003 { 979 {
1004 List<int> mode = new List<int>(); 980 List<int> mode = new List<int>();
@@ -1052,7 +1028,6 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
1052 } 1028 }
1053 1029
1054 return mode.ToArray()[0]; 1030 return mode.ToArray()[0];
1055
1056 } 1031 }
1057 1032
1058 #endregion 1033 #endregion
@@ -1178,7 +1153,6 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
1178 public List<float> _sim_fps; 1153 public List<float> _sim_fps;
1179 public List<int> _agents_in_view; 1154 public List<int> _agents_in_view;
1180 } 1155 }
1181
1182 1156
1183 #endregion 1157 #endregion
1184 1158
@@ -1263,5 +1237,4 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
1263 m_scriptLinesPerSecond = stats.StatsBlock[20].StatValue; 1237 m_scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
1264 } 1238 }
1265 } 1239 }
1266 1240} \ No newline at end of file
1267}