mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
* Updates the sim stats module. Cleans out some of the rot.
* Adds a prototype web stats module which is disabled by default. It's functional with one report right now, however, the database structure may change, so I don't recommend enabling this to keep actual stats right now. I'll let you know when it's safe. * Adds Prototype for ajaxy web content * removed a warning or two.
This commit is contained in:
185
OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
Normal file
185
OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework.Statistics;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class ActiveConnectionsAJAX : IStatsController
|
||||
{
|
||||
#region IStatsController Members
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
|
||||
List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
|
||||
|
||||
Hashtable nh = new Hashtable();
|
||||
nh.Add("hdata", m_scene);
|
||||
|
||||
return nh;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
HTMLUtil.OL_O(ref output, "");
|
||||
foreach (Scene scene in all_scenes)
|
||||
{
|
||||
List<ScenePresence> avatarInScene = scene.GetScenePresences();
|
||||
|
||||
HTMLUtil.LI_O(ref output, "");
|
||||
output.Append(scene.RegionInfo.RegionName);
|
||||
HTMLUtil.OL_O(ref output, "");
|
||||
foreach (ScenePresence av in avatarInScene)
|
||||
{
|
||||
Dictionary<string,string> queues = new Dictionary<string, string>();
|
||||
if (av.ControllingClient is IStatsCollector)
|
||||
{
|
||||
IStatsCollector isClient = (IStatsCollector) av.ControllingClient;
|
||||
queues = decodeQueueReport(isClient.Report());
|
||||
}
|
||||
HTMLUtil.LI_O(ref output, "");
|
||||
output.Append(av.Name);
|
||||
output.Append(" ");
|
||||
output.Append((av.IsChildAgent ? "Child" : "Root"));
|
||||
|
||||
Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
|
||||
|
||||
HTMLUtil.UL_O(ref output, "");
|
||||
foreach (string throttlename in throttles.Keys)
|
||||
{
|
||||
HTMLUtil.LI_O(ref output, "");
|
||||
output.Append(throttlename);
|
||||
output.Append(":");
|
||||
output.Append(throttles[throttlename].ToString());
|
||||
if (queues.ContainsKey(throttlename))
|
||||
{
|
||||
output.Append("/");
|
||||
output.Append(queues[throttlename]);
|
||||
}
|
||||
HTMLUtil.LI_C(ref output);
|
||||
}
|
||||
if (queues.ContainsKey("Incoming") && queues.ContainsKey("Outgoing"))
|
||||
{
|
||||
HTMLUtil.LI_O(ref output, "red");
|
||||
output.Append("SEND:");
|
||||
output.Append(queues["Outgoing"]);
|
||||
output.Append("/");
|
||||
output.Append(queues["Incoming"]);
|
||||
HTMLUtil.LI_C(ref output);
|
||||
}
|
||||
|
||||
HTMLUtil.UL_C(ref output);
|
||||
HTMLUtil.LI_C(ref output);
|
||||
}
|
||||
HTMLUtil.OL_C(ref output);
|
||||
}
|
||||
HTMLUtil.OL_C(ref output);
|
||||
return output.ToString();
|
||||
}
|
||||
|
||||
public Dictionary<string, int> DecodeClientThrottles(byte[] throttle)
|
||||
{
|
||||
Dictionary<string, int> returndict = new Dictionary<string, int>();
|
||||
// From mantis http://opensimulator.org/mantis/view.php?id=1374
|
||||
// it appears that sometimes we are receiving empty throttle byte arrays.
|
||||
// TODO: Investigate this behaviour
|
||||
if (throttle.Length == 0)
|
||||
{
|
||||
return new Dictionary<string, int>();
|
||||
}
|
||||
|
||||
int tResend = -1;
|
||||
int tLand = -1;
|
||||
int tWind = -1;
|
||||
int tCloud = -1;
|
||||
int tTask = -1;
|
||||
int tTexture = -1;
|
||||
int tAsset = -1;
|
||||
int tall = -1;
|
||||
const int singlefloat = 4;
|
||||
|
||||
//Agent Throttle Block contains 7 single floatingpoint values.
|
||||
int j = 0;
|
||||
|
||||
// Some Systems may be big endian...
|
||||
// it might be smart to do this check more often...
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
for (int i = 0; i < 7; i++)
|
||||
Array.Reverse(throttle, j + i * singlefloat, singlefloat);
|
||||
|
||||
// values gotten from OpenMetaverse.org/wiki/Throttle. Thanks MW_
|
||||
// bytes
|
||||
// Convert to integer, since.. the full fp space isn't used.
|
||||
tResend = (int)BitConverter.ToSingle(throttle, j);
|
||||
returndict.Add("Resend", tResend);
|
||||
j += singlefloat;
|
||||
tLand = (int)BitConverter.ToSingle(throttle, j);
|
||||
returndict.Add("Land", tLand);
|
||||
j += singlefloat;
|
||||
tWind = (int)BitConverter.ToSingle(throttle, j);
|
||||
returndict.Add("Wind", tWind);
|
||||
j += singlefloat;
|
||||
tCloud = (int)BitConverter.ToSingle(throttle, j);
|
||||
returndict.Add("Cloud", tCloud);
|
||||
j += singlefloat;
|
||||
tTask = (int)BitConverter.ToSingle(throttle, j);
|
||||
returndict.Add("Task", tTask);
|
||||
j += singlefloat;
|
||||
tTexture = (int)BitConverter.ToSingle(throttle, j);
|
||||
returndict.Add("Texture", tTexture);
|
||||
j += singlefloat;
|
||||
tAsset = (int)BitConverter.ToSingle(throttle, j);
|
||||
returndict.Add("Asset", tAsset);
|
||||
|
||||
tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
|
||||
returndict.Add("All", tall);
|
||||
|
||||
return returndict;
|
||||
}
|
||||
public Dictionary<string,string> decodeQueueReport(string rep)
|
||||
{
|
||||
Dictionary<string, string> returndic = new Dictionary<string, string>();
|
||||
if (rep.Length == 79)
|
||||
{
|
||||
int pos = 1;
|
||||
returndic.Add("All", rep.Substring((6 * pos), 8)); pos++;
|
||||
returndic.Add("Incoming", rep.Substring((7 * pos), 8)); pos++;
|
||||
returndic.Add("Outgoing", rep.Substring((7 * pos) , 8)); pos++;
|
||||
returndic.Add("Resend", rep.Substring((7 * pos) , 8)); pos++;
|
||||
returndic.Add("Land", rep.Substring((7 * pos) , 8)); pos++;
|
||||
returndic.Add("Wind", rep.Substring((7 * pos) , 8)); pos++;
|
||||
returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++;
|
||||
returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++;
|
||||
returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++;
|
||||
returndic.Add("Asset", rep.Substring((7 * pos), 8));
|
||||
/*
|
||||
* return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
|
||||
SendQueue.Count(),
|
||||
IncomingPacketQueue.Count,
|
||||
OutgoingPacketQueue.Count,
|
||||
ResendOutgoingPacketQueue.Count,
|
||||
LandOutgoingPacketQueue.Count,
|
||||
WindOutgoingPacketQueue.Count,
|
||||
CloudOutgoingPacketQueue.Count,
|
||||
TaskOutgoingPacketQueue.Count,
|
||||
TextureOutgoingPacketQueue.Count,
|
||||
AssetOutgoingPacketQueue.Count);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
return returndic;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
215
OpenSim/Region/UserStatistics/Default_Report.cs
Normal file
215
OpenSim/Region/UserStatistics/Default_Report.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework.Statistics;
|
||||
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class Default_Report : IStatsController
|
||||
{
|
||||
|
||||
public Default_Report()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region IStatsController Members
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
SqliteConnection conn = (SqliteConnection)pParams["DatabaseConnection"];
|
||||
List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
|
||||
|
||||
stats_default_page_values mData = rep_DefaultReport_data(conn, m_scene);
|
||||
mData.sim_stat_data = (Dictionary<UUID,USimStatsData>)pParams["SimStats"];
|
||||
|
||||
Hashtable nh = new Hashtable();
|
||||
nh.Add("hdata", mData);
|
||||
|
||||
return nh;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
stats_default_page_values mData = (stats_default_page_values) pModelResult["hdata"];
|
||||
return rep_Default_report_view(mData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public string rep_Default_report_view(stats_default_page_values values)
|
||||
{
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
|
||||
|
||||
const string TableClass = "defaultr";
|
||||
const string TRClass = "defaultr";
|
||||
const string TDHeaderClass = "header";
|
||||
const string TDDataClass = "content";
|
||||
//const string TDDataClassRight = "contentright";
|
||||
const string TDDataClassCenter = "contentcenter";
|
||||
|
||||
const string STYLESHEET =
|
||||
@"
|
||||
<STYLE>
|
||||
body
|
||||
{
|
||||
font-size:15px; font-family:Helvetica, Verdana; color:Black;
|
||||
}
|
||||
TABLE.defaultr { }
|
||||
TR.defaultr { padding: 5px; }
|
||||
TD.header { font-weight:bold; padding:5px; }
|
||||
TD.content {}
|
||||
TD.contentright { text-align: right; }
|
||||
TD.contentcenter { text-align: center; }
|
||||
TD.align_top { vertical-align: top; }
|
||||
</STYLE>
|
||||
";
|
||||
HTMLUtil.HtmlHeaders_O(ref output);
|
||||
|
||||
HTMLUtil.InsertProtoTypeAJAX(ref output);
|
||||
string[] ajaxUpdaterDivs = new string[2];
|
||||
int[] ajaxUpdaterSeconds = new int[2];
|
||||
string[] ajaxUpdaterReportFragments = new string[2];
|
||||
|
||||
ajaxUpdaterDivs[0] = "activeconnections";
|
||||
ajaxUpdaterSeconds[0] = 10;
|
||||
ajaxUpdaterReportFragments[0] = "activeconnectionsajax.ajax";
|
||||
|
||||
ajaxUpdaterDivs[1] = "activesimstats";
|
||||
ajaxUpdaterSeconds[1] = 20;
|
||||
ajaxUpdaterReportFragments[1] = "simstatsajax.ajax";
|
||||
|
||||
HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);
|
||||
|
||||
output.Append(STYLESHEET);
|
||||
HTMLUtil.HtmlHeaders_C(ref output);
|
||||
|
||||
HTMLUtil.TABLE_O(ref output, TableClass);
|
||||
HTMLUtil.TR_O(ref output, TRClass);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("# Users Total");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("# Sessions Total");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("Avg Client FPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("Avg Client Mem Use");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("Avg Sim FPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("Avg Ping");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("KB Out Total");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("KB In Total");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
HTMLUtil.TR_O(ref output, TRClass);
|
||||
HTMLUtil.TD_O(ref output, TDDataClass);
|
||||
output.Append(values.total_num_users);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClass);
|
||||
output.Append(values.total_num_sessions);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(values.avg_client_fps);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(values.avg_client_mem_use);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(values.avg_sim_fps);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(values.avg_ping);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(values.total_kb_out);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(values.total_kb_in);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
HTMLUtil.TABLE_C(ref output);
|
||||
|
||||
HTMLUtil.HR(ref output, "");
|
||||
HTMLUtil.TABLE_O(ref output, "");
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
HTMLUtil.TD_O(ref output, "align_top");
|
||||
output.Append("<DIV id=\"activeconnections\">loading...</DIV>");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "align_top");
|
||||
output.Append("<DIV id=\"activesimstats\">loading...</DIV>");
|
||||
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
HTMLUtil.TABLE_C(ref output);
|
||||
output.Append("</BODY></HTML>");
|
||||
// TODO: FIXME: template
|
||||
return output.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene)
|
||||
{
|
||||
stats_default_page_values returnstruct = new stats_default_page_values();
|
||||
returnstruct.all_scenes = m_scene.ToArray();
|
||||
lock (db)
|
||||
{
|
||||
string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps,
|
||||
AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb,
|
||||
SUM(n_out_pk) as num_in_packets, SUM(n_in_kb) as num_out_kb, SUM(n_in_pk) as num_out_packets, AVG(mem_use) as sav_mem_use
|
||||
FROM stats_session_data;";
|
||||
SqliteCommand cmd = new SqliteCommand(SQL, db);
|
||||
SqliteDataReader sdr = cmd.ExecuteReader();
|
||||
if (sdr.HasRows)
|
||||
{
|
||||
sdr.Read();
|
||||
returnstruct.total_num_users = Convert.ToInt32(sdr["agents"]);
|
||||
returnstruct.total_num_sessions = Convert.ToInt32(sdr["sessions"]);
|
||||
returnstruct.avg_client_fps = Convert.ToSingle(sdr["client_fps"]);
|
||||
returnstruct.avg_sim_fps = Convert.ToSingle(sdr["savg_sim_fps"]);
|
||||
returnstruct.avg_ping = Convert.ToSingle(sdr["sav_ping"]);
|
||||
returnstruct.total_kb_out = Convert.ToSingle(sdr["num_out_kb"]);
|
||||
returnstruct.total_kb_in = Convert.ToSingle(sdr["num_in_kb"]);
|
||||
returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
|
||||
|
||||
}
|
||||
}
|
||||
return returnstruct;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct stats_default_page_values
|
||||
{
|
||||
public int total_num_users;
|
||||
public int total_num_sessions;
|
||||
public float avg_client_fps;
|
||||
public float avg_client_mem_use;
|
||||
public float avg_sim_fps;
|
||||
public float avg_ping;
|
||||
public float total_kb_out;
|
||||
public float total_kb_in;
|
||||
public float avg_client_resends;
|
||||
public Scene[] all_scenes;
|
||||
public Dictionary<UUID, USimStatsData> sim_stat_data;
|
||||
}
|
||||
}
|
||||
185
OpenSim/Region/UserStatistics/HTMLUtil.cs
Normal file
185
OpenSim/Region/UserStatistics/HTMLUtil.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public static class HTMLUtil
|
||||
{
|
||||
|
||||
public static void TR_O(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<tr");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(">\n\t");
|
||||
}
|
||||
public static void TR_C(ref StringBuilder o)
|
||||
{
|
||||
o.Append("</tr>\n");
|
||||
}
|
||||
|
||||
public static void TD_O(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<td");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(">");
|
||||
}
|
||||
public static void TD_C(ref StringBuilder o)
|
||||
{
|
||||
o.Append("</td>");
|
||||
}
|
||||
public static void TABLE_O(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<table");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(">\n\t");
|
||||
}
|
||||
public static void TABLE_C(ref StringBuilder o)
|
||||
{
|
||||
o.Append("</table>\n");
|
||||
}
|
||||
|
||||
public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<blockquote");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(" />\n");
|
||||
}
|
||||
|
||||
public static void BLOCKQUOTE_C(ref StringBuilder o)
|
||||
{
|
||||
o.Append("</blockquote>\n");
|
||||
}
|
||||
|
||||
public static void BR(ref StringBuilder o)
|
||||
{
|
||||
o.Append("<br />\n");
|
||||
}
|
||||
|
||||
public static void HR(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<hr");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(" />\n");
|
||||
}
|
||||
|
||||
public static void UL_O(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<ul");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(" />\n");
|
||||
}
|
||||
|
||||
public static void UL_C(ref StringBuilder o)
|
||||
{
|
||||
o.Append("</ul>\n");
|
||||
}
|
||||
|
||||
public static void OL_O(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<ol");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(" />\n");
|
||||
}
|
||||
|
||||
public static void OL_C(ref StringBuilder o)
|
||||
{
|
||||
o.Append("</ol>\n");
|
||||
}
|
||||
|
||||
public static void LI_O(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append("<li");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
o.Append(" />\n");
|
||||
}
|
||||
|
||||
public static void LI_C(ref StringBuilder o)
|
||||
{
|
||||
o.Append("</li>\n");
|
||||
}
|
||||
|
||||
public static void GenericClass(ref StringBuilder o, string pclass)
|
||||
{
|
||||
o.Append(" class=\"");
|
||||
o.Append(pclass);
|
||||
o.Append("\"");
|
||||
}
|
||||
|
||||
public static void InsertProtoTypeAJAX(ref StringBuilder o)
|
||||
{
|
||||
o.Append("<script type=\"text/javascript\" src=\"prototype.js\"></script>\n");
|
||||
o.Append("<script type=\"text/javascript\" src=\"updater.js\"></script>\n");
|
||||
}
|
||||
|
||||
public static void InsertPeriodicUpdaters(ref StringBuilder o, string[] divID, int[] seconds, string[] reportfrag)
|
||||
{
|
||||
o.Append("<script type=\"text/javascript\">\n");
|
||||
o.Append(
|
||||
@"
|
||||
// <![CDATA[
|
||||
document.observe('dom:loaded', function() {
|
||||
/*
|
||||
first arg : div to update
|
||||
second arg : interval to poll in seconds
|
||||
third arg : file to get data
|
||||
*/
|
||||
");
|
||||
for (int i = 0; i < divID.Length; i++)
|
||||
{
|
||||
|
||||
o.Append("new updater('");
|
||||
o.Append(divID[i]);
|
||||
o.Append("', ");
|
||||
o.Append(seconds[i]);
|
||||
o.Append(", '");
|
||||
o.Append(reportfrag[i]);
|
||||
o.Append("');\n");
|
||||
}
|
||||
|
||||
o.Append(@"
|
||||
});
|
||||
// ]]>
|
||||
</script>");
|
||||
|
||||
}
|
||||
|
||||
public static void HtmlHeaders_O ( ref StringBuilder o)
|
||||
{
|
||||
o.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
|
||||
o.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"nl\">");
|
||||
o.Append("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");
|
||||
|
||||
|
||||
}
|
||||
public static void HtmlHeaders_C ( ref StringBuilder o)
|
||||
{
|
||||
o.Append("</HEAD>");
|
||||
o.Append("<BODY>");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
OpenSim/Region/UserStatistics/IStatsReport.cs
Normal file
10
OpenSim/Region/UserStatistics/IStatsReport.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public interface IStatsController
|
||||
{
|
||||
Hashtable ProcessModel(Hashtable pParams);
|
||||
string RenderView(Hashtable pModelResult);
|
||||
}
|
||||
}
|
||||
33
OpenSim/Region/UserStatistics/Prototype_distributor.cs
Normal file
33
OpenSim/Region/UserStatistics/Prototype_distributor.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class Prototype_distributor : IStatsController
|
||||
{
|
||||
private string prototypejs=string.Empty;
|
||||
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
Hashtable pResult = new Hashtable();
|
||||
if (prototypejs.Length == 0)
|
||||
{
|
||||
StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open));
|
||||
prototypejs = fs.ReadToEnd();
|
||||
}
|
||||
pResult["js"] = prototypejs;
|
||||
return pResult;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
return pModelResult["js"].ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
190
OpenSim/Region/UserStatistics/SimStatsAJAX.cs
Normal file
190
OpenSim/Region/UserStatistics/SimStatsAJAX.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Framework.Statistics;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class SimStatsAJAX : IStatsController
|
||||
{
|
||||
#region IStatsController Members
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
|
||||
|
||||
Hashtable nh = new Hashtable();
|
||||
nh.Add("hdata", m_scene);
|
||||
nh.Add("simstats", pParams["SimStats"]);
|
||||
|
||||
return nh;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
|
||||
Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
|
||||
|
||||
const string TableClass = "defaultr";
|
||||
const string TRClass = "defaultr";
|
||||
const string TDHeaderClass = "header";
|
||||
const string TDDataClass = "content";
|
||||
//const string TDDataClassRight = "contentright";
|
||||
const string TDDataClassCenter = "contentcenter";
|
||||
|
||||
foreach (USimStatsData sdata in sdatadic.Values)
|
||||
{
|
||||
|
||||
|
||||
foreach (Scene sn in all_scenes)
|
||||
{
|
||||
if (sn.RegionInfo.RegionID == sdata.RegionId)
|
||||
{
|
||||
output.Append("<H2>");
|
||||
output.Append(sn.RegionInfo.RegionName);
|
||||
output.Append("</H2>");
|
||||
}
|
||||
}
|
||||
HTMLUtil.TABLE_O(ref output, TableClass);
|
||||
HTMLUtil.TR_O(ref output, TRClass);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("Dilatn");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("SimFPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("PhysFPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("AgntUp");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("RootAg");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("ChldAg");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("Prims");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("ATvPrm");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("AtvScr");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("ScrLPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
HTMLUtil.TR_O(ref output, TRClass);
|
||||
HTMLUtil.TD_O(ref output, TDDataClass);
|
||||
output.Append(sdata.TimeDilation);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClass);
|
||||
output.Append(sdata.SimFps);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.PhysicsFps);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.AgentUpdates);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.RootAgents);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.ChildAgents);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.TotalPrims);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.ActivePrims);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.ActiveScripts);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.ScriptLinesPerSecond);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
HTMLUtil.TR_O(ref output, TRClass);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("FrmMS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("AgtMS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("PhysMS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("OthrMS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("ScrLPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("OutPPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("InPPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("NoAckKB");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("PndDWN");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDHeaderClass);
|
||||
output.Append("PndUP");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
HTMLUtil.TR_O(ref output, TRClass);
|
||||
HTMLUtil.TD_O(ref output, TDDataClass);
|
||||
output.Append(sdata.TotalFrameTime);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClass);
|
||||
output.Append(sdata.AgentFrameTime);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.PhysicsFrameTime);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.OtherFrameTime);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.ScriptLinesPerSecond);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.OutPacketsPerSecond);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.InPacketsPerSecond);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.UnackedBytes);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.PendingDownloads);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, TDDataClassCenter);
|
||||
output.Append(sdata.PendingUploads);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
HTMLUtil.TABLE_C(ref output);
|
||||
}
|
||||
return output.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
35
OpenSim/Region/UserStatistics/Updater_distributor.cs
Normal file
35
OpenSim/Region/UserStatistics/Updater_distributor.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class Updater_distributor : IStatsController
|
||||
{
|
||||
private string updaterjs = string.Empty;
|
||||
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
Hashtable pResult = new Hashtable();
|
||||
if (updaterjs.Length == 0)
|
||||
{
|
||||
StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/updater.js", FileMode.Open));
|
||||
updaterjs = fs.ReadToEnd();
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
}
|
||||
pResult["js"] = updaterjs;
|
||||
return pResult;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
return pModelResult["js"].ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
1083
OpenSim/Region/UserStatistics/WebStatsModule.cs
Normal file
1083
OpenSim/Region/UserStatistics/WebStatsModule.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user