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.0.7.6-extended
parent
4e86674a3a
commit
50c163ae6c
|
@ -26,10 +26,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Monitoring
|
namespace OpenSim.Framework.Monitoring
|
||||||
|
@ -262,6 +264,35 @@ namespace OpenSim.Framework.Monitoring
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Hashtable HandleStatsRequest(Hashtable request)
|
||||||
|
{
|
||||||
|
Hashtable responsedata = new Hashtable();
|
||||||
|
string regpath = request["uri"].ToString();
|
||||||
|
int response_code = 200;
|
||||||
|
string contenttype = "text/json";
|
||||||
|
|
||||||
|
string pCategoryName = StatsManager.AllSubCommand;
|
||||||
|
string pContainerName = StatsManager.AllSubCommand;
|
||||||
|
string pStatName = StatsManager.AllSubCommand;
|
||||||
|
|
||||||
|
if (request.ContainsKey("cat")) pCategoryName = request["cat"].ToString();
|
||||||
|
if (request.ContainsKey("cont")) pContainerName = request["cat"].ToString();
|
||||||
|
if (request.ContainsKey("stat")) pStatName = request["cat"].ToString();
|
||||||
|
|
||||||
|
string strOut = StatsManager.GetStatsAsOSDMap(pCategoryName, pContainerName, pStatName).ToString();
|
||||||
|
|
||||||
|
// m_log.DebugFormat("{0} StatFetch: uri={1}, cat={2}, cont={3}, stat={4}, resp={5}",
|
||||||
|
// LogHeader, regpath, pCategoryName, pContainerName, pStatName, strOut);
|
||||||
|
|
||||||
|
responsedata["int_response_code"] = response_code;
|
||||||
|
responsedata["content_type"] = contenttype;
|
||||||
|
responsedata["keepalive"] = false;
|
||||||
|
responsedata["str_response_string"] = strOut;
|
||||||
|
responsedata["access_control_allow_origin"] = "*";
|
||||||
|
|
||||||
|
return responsedata;
|
||||||
|
}
|
||||||
|
|
||||||
// /// <summary>
|
// /// <summary>
|
||||||
// /// Start collecting statistics related to assets.
|
// /// Start collecting statistics related to assets.
|
||||||
// /// Should only be called once.
|
// /// Should only be called once.
|
||||||
|
|
|
@ -172,6 +172,13 @@ namespace OpenSim
|
||||||
if (userStatsURI != String.Empty)
|
if (userStatsURI != String.Empty)
|
||||||
MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this));
|
MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this));
|
||||||
|
|
||||||
|
if (managedStatsURI != String.Empty)
|
||||||
|
{
|
||||||
|
string urlBase = String.Format("/{0}/", managedStatsURI);
|
||||||
|
MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest);
|
||||||
|
m_log.WarnFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_console is RemoteConsole)
|
if (m_console is RemoteConsole)
|
||||||
{
|
{
|
||||||
if (m_consolePort == 0)
|
if (m_consolePort == 0)
|
||||||
|
|
|
@ -75,6 +75,7 @@ namespace OpenSim
|
||||||
protected int proxyOffset = 0;
|
protected int proxyOffset = 0;
|
||||||
|
|
||||||
public string userStatsURI = String.Empty;
|
public string userStatsURI = String.Empty;
|
||||||
|
public string managedStatsURI = String.Empty;
|
||||||
|
|
||||||
protected bool m_autoCreateClientStack = true;
|
protected bool m_autoCreateClientStack = true;
|
||||||
|
|
||||||
|
@ -188,6 +189,7 @@ namespace OpenSim
|
||||||
CreatePIDFile(pidFile);
|
CreatePIDFile(pidFile);
|
||||||
|
|
||||||
userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
|
userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
|
||||||
|
managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the simulation data service
|
// Load the simulation data service
|
||||||
|
|
Loading…
Reference in New Issue