aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-08-06 08:21:16 -0700
committerRobert Adams2013-08-08 09:45:01 -0700
commit50c163ae6ca734610694f4edcc109ff0bdc65ba1 (patch)
tree10ed643a31a62ac2014e6e1c2022a51af6b53ade /OpenSim
parent* Added set water height <height> [<x>] [<y>] console command following the s... (diff)
downloadopensim-SC_OLD-50c163ae6ca734610694f4edcc109ff0bdc65ba1.zip
opensim-SC_OLD-50c163ae6ca734610694f4edcc109ff0bdc65ba1.tar.gz
opensim-SC_OLD-50c163ae6ca734610694f4edcc109ff0bdc65ba1.tar.bz2
opensim-SC_OLD-50c163ae6ca734610694f4edcc109ff0bdc65ba1.tar.xz
Add a JSON web fetch of the statististics managed by StatsManager.
Disabled by default. Enable by setting [Startup]ManagedStatsRemoteFetchURI="Something" and thereafter "http://ServerHTTPPort/Something/" will return all the managed stats (equivilent to "show stats all" console command). Accepts queries "cat=", "cont=" and "stat=" to specify statistic category, container and statistic names. The special name "all" is the default and returns all values in that group.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs31
-rw-r--r--OpenSim/Region/Application/OpenSim.cs7
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs2
3 files changed, 40 insertions, 0 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index c8e838c..23c6f18 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -26,10 +26,12 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Linq; 31using System.Linq;
31using System.Text; 32using System.Text;
32 33
34using OpenSim.Framework;
33using OpenMetaverse.StructuredData; 35using OpenMetaverse.StructuredData;
34 36
35namespace OpenSim.Framework.Monitoring 37namespace OpenSim.Framework.Monitoring
@@ -262,6 +264,35 @@ namespace OpenSim.Framework.Monitoring
262 return map; 264 return map;
263 } 265 }
264 266
267 public static Hashtable HandleStatsRequest(Hashtable request)
268 {
269 Hashtable responsedata = new Hashtable();
270 string regpath = request["uri"].ToString();
271 int response_code = 200;
272 string contenttype = "text/json";
273
274 string pCategoryName = StatsManager.AllSubCommand;
275 string pContainerName = StatsManager.AllSubCommand;
276 string pStatName = StatsManager.AllSubCommand;
277
278 if (request.ContainsKey("cat")) pCategoryName = request["cat"].ToString();
279 if (request.ContainsKey("cont")) pContainerName = request["cat"].ToString();
280 if (request.ContainsKey("stat")) pStatName = request["cat"].ToString();
281
282 string strOut = StatsManager.GetStatsAsOSDMap(pCategoryName, pContainerName, pStatName).ToString();
283
284 // m_log.DebugFormat("{0} StatFetch: uri={1}, cat={2}, cont={3}, stat={4}, resp={5}",
285 // LogHeader, regpath, pCategoryName, pContainerName, pStatName, strOut);
286
287 responsedata["int_response_code"] = response_code;
288 responsedata["content_type"] = contenttype;
289 responsedata["keepalive"] = false;
290 responsedata["str_response_string"] = strOut;
291 responsedata["access_control_allow_origin"] = "*";
292
293 return responsedata;
294 }
295
265// /// <summary> 296// /// <summary>
266// /// Start collecting statistics related to assets. 297// /// Start collecting statistics related to assets.
267// /// Should only be called once. 298// /// Should only be called once.
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 58f9368..13fdb3b 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -172,6 +172,13 @@ namespace OpenSim
172 if (userStatsURI != String.Empty) 172 if (userStatsURI != String.Empty)
173 MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this)); 173 MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this));
174 174
175 if (managedStatsURI != String.Empty)
176 {
177 string urlBase = String.Format("/{0}/", managedStatsURI);
178 MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest);
179 m_log.WarnFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
180 }
181
175 if (m_console is RemoteConsole) 182 if (m_console is RemoteConsole)
176 { 183 {
177 if (m_consolePort == 0) 184 if (m_consolePort == 0)
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index f0c088a..b032e7f 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -75,6 +75,7 @@ namespace OpenSim
75 protected int proxyOffset = 0; 75 protected int proxyOffset = 0;
76 76
77 public string userStatsURI = String.Empty; 77 public string userStatsURI = String.Empty;
78 public string managedStatsURI = String.Empty;
78 79
79 protected bool m_autoCreateClientStack = true; 80 protected bool m_autoCreateClientStack = true;
80 81
@@ -188,6 +189,7 @@ namespace OpenSim
188 CreatePIDFile(pidFile); 189 CreatePIDFile(pidFile);
189 190
190 userStatsURI = startupConfig.GetString("Stats_URI", String.Empty); 191 userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
192 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
191 } 193 }
192 194
193 // Load the simulation data service 195 // Load the simulation data service