NEXJAST: remove legacy WebStats module
This commit is contained in:
1 parent
02869ec47a
commit
97ac79052f
17 files changed
-7946
No files matched your search
@@ -164,39 +164,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\Default_Report.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\SimStatsAJAX.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\Updater_distributor.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\WebStatsModule.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\IStatsReport.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\LogLinesAJAX.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\Clients_report.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\Prototype_distributor.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\HTMLUtil.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\ActiveConnectionsAJAX.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserStatistics\Sessions_Report.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="World\NPC\NPCAvatar.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -1,308 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class ActiveConnectionsAJAX : IStatsController
|
||||
{
|
||||
private Vector3 DefaultNeighborPosition = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 70);
|
||||
|
||||
#region IStatsController Members
|
||||
|
||||
public string ReportName
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
HTMLUtil.LI_O(ref output, String.Empty);
|
||||
output.Append(scene.RegionInfo.RegionName);
|
||||
HTMLUtil.OL_O(ref output, String.Empty);
|
||||
scene.ForEachScenePresence(delegate(ScenePresence av)
|
||||
{
|
||||
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, String.Empty);
|
||||
output.Append(av.Name);
|
||||
output.Append(" ");
|
||||
output.Append((av.IsChildAgent ? "Child" : "Root"));
|
||||
if (av.AbsolutePosition == DefaultNeighborPosition)
|
||||
{
|
||||
output.Append("<br />Position: ?");
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X,
|
||||
(int)av.AbsolutePosition.Y,
|
||||
(int)av.AbsolutePosition.Z));
|
||||
}
|
||||
Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
|
||||
|
||||
HTMLUtil.UL_O(ref output, String.Empty);
|
||||
|
||||
foreach (string throttlename in throttles.Keys)
|
||||
{
|
||||
HTMLUtil.LI_O(ref output, String.Empty);
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert active connections information to JSON string. Returns a structure:
|
||||
/// <pre>
|
||||
/// {"regionName": {
|
||||
/// "presenceName": {
|
||||
/// "name": "presenceName",
|
||||
/// "position": "<x,y,z>",
|
||||
/// "isRoot": "false",
|
||||
/// "throttle": {
|
||||
/// },
|
||||
/// "queue": {
|
||||
/// }
|
||||
/// },
|
||||
/// ... // multiple presences in the scene
|
||||
/// },
|
||||
/// ... // multiple regions in the sim
|
||||
/// }
|
||||
///
|
||||
/// </pre>
|
||||
/// </summary>
|
||||
/// <param name="pModelResult"></param>
|
||||
/// <returns></returns>
|
||||
public string RenderJson(Hashtable pModelResult)
|
||||
{
|
||||
List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
|
||||
|
||||
OSDMap regionInfo = new OSDMap();
|
||||
foreach (Scene scene in all_scenes)
|
||||
{
|
||||
OSDMap sceneInfo = new OpenMetaverse.StructuredData.OSDMap();
|
||||
List<ScenePresence> avatarInScene = scene.GetScenePresences();
|
||||
foreach (ScenePresence av in avatarInScene)
|
||||
{
|
||||
OSDMap presenceInfo = new OSDMap();
|
||||
presenceInfo.Add("Name", new OSDString(av.Name));
|
||||
|
||||
Dictionary<string,string> queues = new Dictionary<string, string>();
|
||||
if (av.ControllingClient is IStatsCollector)
|
||||
{
|
||||
IStatsCollector isClient = (IStatsCollector) av.ControllingClient;
|
||||
queues = decodeQueueReport(isClient.Report());
|
||||
}
|
||||
OSDMap queueInfo = new OpenMetaverse.StructuredData.OSDMap();
|
||||
foreach (KeyValuePair<string, string> kvp in queues) {
|
||||
queueInfo.Add(kvp.Key, new OSDString(kvp.Value));
|
||||
}
|
||||
sceneInfo.Add("queues", queueInfo);
|
||||
|
||||
if (av.IsChildAgent)
|
||||
presenceInfo.Add("isRoot", new OSDString("false"));
|
||||
else
|
||||
presenceInfo.Add("isRoot", new OSDString("true"));
|
||||
|
||||
if (av.AbsolutePosition == DefaultNeighborPosition)
|
||||
{
|
||||
presenceInfo.Add("position", new OSDString("<0, 0, 0>"));
|
||||
}
|
||||
else
|
||||
{
|
||||
presenceInfo.Add("position", new OSDString(string.Format("<{0},{1},{2}>",
|
||||
(int)av.AbsolutePosition.X,
|
||||
(int) av.AbsolutePosition.Y,
|
||||
(int) av.AbsolutePosition.Z)) );
|
||||
}
|
||||
|
||||
Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
|
||||
OSDMap throttleInfo = new OpenMetaverse.StructuredData.OSDMap();
|
||||
foreach (string throttlename in throttles.Keys)
|
||||
{
|
||||
throttleInfo.Add(throttlename, new OSDString(throttles[throttlename].ToString()));
|
||||
}
|
||||
presenceInfo.Add("throttle", throttleInfo);
|
||||
|
||||
sceneInfo.Add(av.Name, presenceInfo);
|
||||
}
|
||||
regionInfo.Add(scene.RegionInfo.RegionName, sceneInfo);
|
||||
}
|
||||
return regionInfo.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
|
||||
}
|
||||
}
|
||||
@@ -1,322 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class Clients_report : IStatsController
|
||||
{
|
||||
#region IStatsController Members
|
||||
|
||||
public string ReportName
|
||||
{
|
||||
get { return "Client"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return summar information in the form:
|
||||
/// <pre>
|
||||
/// {"totalUsers": "34",
|
||||
/// "totalSessions": "233",
|
||||
/// ...
|
||||
/// }
|
||||
/// </pre>
|
||||
/// </summary>
|
||||
/// <param name="pModelResult"></param>
|
||||
/// <returns></returns>
|
||||
public string RenderJson(Hashtable pModelResult) {
|
||||
stats_default_page_values values = (stats_default_page_values) pModelResult["hdata"];
|
||||
|
||||
OSDMap summaryInfo = new OpenMetaverse.StructuredData.OSDMap();
|
||||
summaryInfo.Add("totalUsers", new OSDString(values.total_num_users.ToString()));
|
||||
summaryInfo.Add("totalSessions", new OSDString(values.total_num_sessions.ToString()));
|
||||
summaryInfo.Add("averageClientFPS", new OSDString(values.avg_client_fps.ToString()));
|
||||
summaryInfo.Add("averageClientMem", new OSDString(values.avg_client_mem_use.ToString()));
|
||||
summaryInfo.Add("averageSimFPS", new OSDString(values.avg_sim_fps.ToString()));
|
||||
summaryInfo.Add("averagePingTime", new OSDString(values.avg_ping.ToString()));
|
||||
summaryInfo.Add("totalKBOut", new OSDString(values.total_kb_out.ToString()));
|
||||
summaryInfo.Add("totalKBIn", new OSDString(values.total_kb_in.ToString()));
|
||||
return summaryInfo.ToString();
|
||||
}
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"];
|
||||
|
||||
|
||||
List<ClientVersionData> clidata = new List<ClientVersionData>();
|
||||
List<ClientVersionData> cliRegData = new List<ClientVersionData>();
|
||||
Hashtable regionTotals = new Hashtable();
|
||||
|
||||
Hashtable modeldata = new Hashtable();
|
||||
modeldata.Add("Scenes", pParams["Scenes"]);
|
||||
modeldata.Add("Reports", pParams["Reports"]);
|
||||
int totalclients = 0;
|
||||
int totalregions = 0;
|
||||
|
||||
lock (dbConn)
|
||||
{
|
||||
string sql = "select count(distinct region_id) as regcnt from stats_session_data";
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand(sql, dbConn);
|
||||
SqliteDataReader sdr = cmd.ExecuteReader();
|
||||
if (sdr.HasRows)
|
||||
{
|
||||
sdr.Read();
|
||||
totalregions = Convert.ToInt32(sdr["regcnt"]);
|
||||
}
|
||||
sdr.Close();
|
||||
cmd.Dispose();
|
||||
|
||||
sql =
|
||||
"select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;";
|
||||
|
||||
cmd = new SqliteCommand(sql, dbConn);
|
||||
sdr = cmd.ExecuteReader();
|
||||
if (sdr.HasRows)
|
||||
{
|
||||
while (sdr.Read())
|
||||
{
|
||||
ClientVersionData udata = new ClientVersionData();
|
||||
udata.version = sdr["client_version"].ToString();
|
||||
udata.count = Convert.ToInt32(sdr["cnt"]);
|
||||
udata.fps = Convert.ToSingle(sdr["simfps"]);
|
||||
clidata.Add(udata);
|
||||
totalclients += udata.count;
|
||||
|
||||
}
|
||||
}
|
||||
sdr.Close();
|
||||
cmd.Dispose();
|
||||
|
||||
if (totalregions > 1)
|
||||
{
|
||||
sql =
|
||||
"select region_id, client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by region_id, client_version order by region_id, count(*) desc;";
|
||||
cmd = new SqliteCommand(sql, dbConn);
|
||||
|
||||
sdr = cmd.ExecuteReader();
|
||||
|
||||
if (sdr.HasRows)
|
||||
{
|
||||
while (sdr.Read())
|
||||
{
|
||||
ClientVersionData udata = new ClientVersionData();
|
||||
udata.version = sdr["client_version"].ToString();
|
||||
udata.count = Convert.ToInt32(sdr["cnt"]);
|
||||
udata.fps = Convert.ToSingle(sdr["simfps"]);
|
||||
udata.region_id = UUID.Parse(sdr["region_id"].ToString());
|
||||
cliRegData.Add(udata);
|
||||
}
|
||||
}
|
||||
sdr.Close();
|
||||
cmd.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ClientVersionData cvd in cliRegData)
|
||||
{
|
||||
|
||||
if (regionTotals.ContainsKey(cvd.region_id))
|
||||
{
|
||||
int regiontotal = (int)regionTotals[cvd.region_id];
|
||||
regiontotal += cvd.count;
|
||||
regionTotals[cvd.region_id] = regiontotal;
|
||||
}
|
||||
else
|
||||
{
|
||||
regionTotals.Add(cvd.region_id, cvd.count);
|
||||
}
|
||||
}
|
||||
|
||||
modeldata["ClientData"] = clidata;
|
||||
modeldata["ClientRegionData"] = cliRegData;
|
||||
modeldata["RegionTotals"] = regionTotals;
|
||||
modeldata["Total"] = totalclients;
|
||||
|
||||
return modeldata;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
List<ClientVersionData> clidata = (List<ClientVersionData>) pModelResult["ClientData"];
|
||||
int totalclients = (int)pModelResult["Total"];
|
||||
Hashtable regionTotals = (Hashtable) pModelResult["RegionTotals"];
|
||||
List<ClientVersionData> cliRegData = (List<ClientVersionData>) pModelResult["ClientRegionData"];
|
||||
List<Scene> m_scenes = (List<Scene>)pModelResult["Scenes"];
|
||||
Dictionary<string, IStatsController> reports = (Dictionary<string, IStatsController>)pModelResult["Reports"];
|
||||
|
||||
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>
|
||||
";
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
HTMLUtil.HtmlHeaders_O(ref output);
|
||||
output.Append(STYLESHEET);
|
||||
HTMLUtil.HtmlHeaders_C(ref output);
|
||||
|
||||
HTMLUtil.AddReportLinks(ref output, reports, "");
|
||||
|
||||
HTMLUtil.TABLE_O(ref output, "defaultr");
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("ClientVersion");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("Count/%");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("SimFPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
|
||||
foreach (ClientVersionData cvd in clidata)
|
||||
{
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
string linkhref = "sessions.report?VersionString=" + cvd.version;
|
||||
HTMLUtil.A(ref output, cvd.version, linkhref, "");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(cvd.count);
|
||||
output.Append("/");
|
||||
if (totalclients > 0)
|
||||
output.Append((((float)cvd.count / (float)totalclients)*100).ToString());
|
||||
else
|
||||
output.Append(0);
|
||||
|
||||
output.Append("%");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(cvd.fps);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
}
|
||||
HTMLUtil.TABLE_C(ref output);
|
||||
|
||||
if (cliRegData.Count > 0)
|
||||
{
|
||||
HTMLUtil.TABLE_O(ref output, "defaultr");
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("Region");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("ClientVersion");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("Count/%");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("SimFPS");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
|
||||
foreach (ClientVersionData cvd in cliRegData)
|
||||
{
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(regionNamefromUUID(m_scenes, cvd.region_id));
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(cvd.version);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(cvd.count);
|
||||
output.Append("/");
|
||||
if ((int)regionTotals[cvd.region_id] > 0)
|
||||
output.Append((((float)cvd.count / (float)((int)regionTotals[cvd.region_id])) * 100).ToString());
|
||||
else
|
||||
output.Append(0);
|
||||
|
||||
output.Append("%");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(cvd.fps);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
}
|
||||
HTMLUtil.TABLE_C(ref output);
|
||||
|
||||
}
|
||||
|
||||
output.Append("</BODY>");
|
||||
output.Append("</HTML>");
|
||||
return output.ToString();
|
||||
}
|
||||
public string regionNamefromUUID(List<Scene> scenes, UUID region_id)
|
||||
{
|
||||
string returnstring = string.Empty;
|
||||
foreach (Scene sn in scenes)
|
||||
{
|
||||
if (region_id == sn.RegionInfo.originRegionID)
|
||||
{
|
||||
returnstring = sn.RegionInfo.RegionName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnstring.Length == 0)
|
||||
{
|
||||
returnstring = region_id.ToString();
|
||||
}
|
||||
|
||||
return returnstring;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public struct ClientVersionData
|
||||
{
|
||||
public UUID region_id;
|
||||
public string version;
|
||||
public int count;
|
||||
public float fps;
|
||||
}
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class Default_Report : IStatsController
|
||||
{
|
||||
|
||||
public string ReportName
|
||||
{
|
||||
get { return "Home"; }
|
||||
}
|
||||
|
||||
#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"];
|
||||
mData.stats_reports = (Dictionary<string, IStatsController>) pParams["Reports"];
|
||||
|
||||
Hashtable nh = new Hashtable();
|
||||
nh.Add("hdata", mData);
|
||||
nh.Add("Reports", pParams["Reports"]);
|
||||
|
||||
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[3];
|
||||
int[] ajaxUpdaterSeconds = new int[3];
|
||||
string[] ajaxUpdaterReportFragments = new string[3];
|
||||
|
||||
ajaxUpdaterDivs[0] = "activeconnections";
|
||||
ajaxUpdaterSeconds[0] = 10;
|
||||
ajaxUpdaterReportFragments[0] = "activeconnectionsajax.html";
|
||||
|
||||
ajaxUpdaterDivs[1] = "activesimstats";
|
||||
ajaxUpdaterSeconds[1] = 20;
|
||||
ajaxUpdaterReportFragments[1] = "simstatsajax.html";
|
||||
|
||||
ajaxUpdaterDivs[2] = "activelog";
|
||||
ajaxUpdaterSeconds[2] = 5;
|
||||
ajaxUpdaterReportFragments[2] = "activelogajax.html";
|
||||
|
||||
HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);
|
||||
|
||||
output.Append(STYLESHEET);
|
||||
HTMLUtil.HtmlHeaders_C(ref output);
|
||||
HTMLUtil.AddReportLinks(ref output, values.stats_reports, "");
|
||||
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\">Active Connections loading...</DIV>");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "align_top");
|
||||
output.Append("<DIV id=\"activesimstats\">SimStats loading...</DIV>");
|
||||
output.Append("<DIV id=\"activelog\">ActiveLog 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"]);
|
||||
|
||||
}
|
||||
sdr.Close();
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
return returnstruct;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return summar information in the form:
|
||||
/// <pre>
|
||||
/// {"totalUsers": "34",
|
||||
/// "totalSessions": "233",
|
||||
/// ...
|
||||
/// }
|
||||
/// </pre>
|
||||
/// </summary>
|
||||
/// <param name="pModelResult"></param>
|
||||
/// <returns></returns>
|
||||
public string RenderJson(Hashtable pModelResult) {
|
||||
stats_default_page_values values = (stats_default_page_values) pModelResult["hdata"];
|
||||
|
||||
OSDMap summaryInfo = new OSDMap();
|
||||
summaryInfo.Add("totalUsers", new OSDString(values.total_num_users.ToString()));
|
||||
summaryInfo.Add("totalSessions", new OSDString(values.total_num_sessions.ToString()));
|
||||
summaryInfo.Add("averageClientFPS", new OSDString(values.avg_client_fps.ToString()));
|
||||
summaryInfo.Add("averageClientMem", new OSDString(values.avg_client_mem_use.ToString()));
|
||||
summaryInfo.Add("averageSimFPS", new OSDString(values.avg_sim_fps.ToString()));
|
||||
summaryInfo.Add("averagePingTime", new OSDString(values.avg_ping.ToString()));
|
||||
summaryInfo.Add("totalKBOut", new OSDString(values.total_kb_out.ToString()));
|
||||
summaryInfo.Add("totalKBIn", new OSDString(values.total_kb_in.ToString()));
|
||||
return summaryInfo.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
public Dictionary<string, IStatsController> stats_reports;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
TD_O(ref o, pclass, 0, 0);
|
||||
}
|
||||
|
||||
public static void TD_O(ref StringBuilder o, string pclass, int rowspan, int colspan)
|
||||
{
|
||||
o.Append("<td");
|
||||
if (pclass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pclass);
|
||||
}
|
||||
if (rowspan > 1)
|
||||
{
|
||||
o.Append(" rowspan=\"");
|
||||
o.Append(rowspan);
|
||||
o.Append("\"");
|
||||
}
|
||||
if (colspan > 1)
|
||||
{
|
||||
o.Append(" colspan=\"");
|
||||
o.Append(colspan);
|
||||
o.Append("\"");
|
||||
}
|
||||
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>");
|
||||
}
|
||||
|
||||
public static void AddReportLinks(ref StringBuilder o, Dictionary<string, IStatsController> reports, string pClass)
|
||||
{
|
||||
int repcount = 0;
|
||||
foreach (string str in reports.Keys)
|
||||
{
|
||||
if (reports[str].ReportName.Length > 0)
|
||||
{
|
||||
if (repcount > 0)
|
||||
{
|
||||
o.Append("| ");
|
||||
}
|
||||
A(ref o, reports[str].ReportName, str, pClass);
|
||||
o.Append(" ");
|
||||
repcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void A(ref StringBuilder o, string linktext, string linkhref, string pClass)
|
||||
{
|
||||
o.Append("<A");
|
||||
if (pClass.Length > 0)
|
||||
{
|
||||
GenericClass(ref o, pClass);
|
||||
}
|
||||
o.Append(" href=\"");
|
||||
o.Append(linkhref);
|
||||
o.Append("\">");
|
||||
o.Append(linktext);
|
||||
o.Append("</A>");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public interface IStatsController
|
||||
{
|
||||
string ReportName { get; }
|
||||
Hashtable ProcessModel(Hashtable pParams);
|
||||
string RenderView(Hashtable pModelResult);
|
||||
string RenderJson(Hashtable pModelResult);
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class LogLinesAJAX : IStatsController
|
||||
{
|
||||
private Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
|
||||
|
||||
private Regex webFormat = new Regex(@"[^\s]*\s([^,]*),[^\s]*\s([A-Z]*)[^\s-][^\[]*\[([^\]]*)\]([^\n]*)",
|
||||
RegexOptions.Singleline | RegexOptions.Compiled);
|
||||
private Regex TitleColor = new Regex(@"[^\s]*\s(?:[^,]*),[^\s]*\s(?:[A-Z]*)[^\s-][^\[]*\[([^\]]*)\](?:[^\n]*)",
|
||||
RegexOptions.Singleline | RegexOptions.Compiled);
|
||||
|
||||
|
||||
#region IStatsController Members
|
||||
|
||||
public string ReportName
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
Hashtable nh = new Hashtable();
|
||||
nh.Add("loglines", pParams["LogLines"]);
|
||||
return nh;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
HTMLUtil.HR(ref output, "");
|
||||
output.Append("<H3>ActiveLog</H3>\n");
|
||||
|
||||
string tmp = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n");
|
||||
|
||||
string[] result = Regex.Split(tmp, "\n");
|
||||
|
||||
string formatopen = "";
|
||||
string formatclose = "";
|
||||
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
{
|
||||
if (result[i].Length >= 30)
|
||||
{
|
||||
string logtype = result[i].Substring(24, 6);
|
||||
switch (logtype)
|
||||
{
|
||||
case "WARN ":
|
||||
formatopen = "<font color=\"#7D7C00\">";
|
||||
formatclose = "</font>";
|
||||
break;
|
||||
|
||||
case "ERROR ":
|
||||
formatopen = "<font color=\"#FF0000\">";
|
||||
formatclose = "</font>";
|
||||
break;
|
||||
|
||||
default:
|
||||
formatopen = "";
|
||||
formatclose = "";
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
StringBuilder replaceStr = new StringBuilder();
|
||||
//string titlecolorresults =
|
||||
|
||||
string formatresult = Regex.Replace(TitleColor.Replace(result[i], "$1"), "[^ABCDEFabcdef0-9]", "");
|
||||
if (formatresult.Length > 6)
|
||||
{
|
||||
formatresult = formatresult.Substring(0, 6);
|
||||
|
||||
}
|
||||
for (int j = formatresult.Length; j <= 5; j++)
|
||||
formatresult += "0";
|
||||
replaceStr.Append("$1 - [<font color=\"#");
|
||||
replaceStr.Append(formatresult);
|
||||
replaceStr.Append("\">$3</font>] $4<br />");
|
||||
string repstr = replaceStr.ToString();
|
||||
|
||||
output.Append(formatopen);
|
||||
output.Append(webFormat.Replace(result[i], repstr));
|
||||
output.Append(formatclose);
|
||||
}
|
||||
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the last log lines. Output in the format:
|
||||
/// <pre>
|
||||
/// {"logLines": [
|
||||
/// "line1",
|
||||
/// "line2",
|
||||
/// ...
|
||||
/// ]
|
||||
/// }
|
||||
/// </pre>
|
||||
/// </summary>
|
||||
/// <param name="pModelResult"></param>
|
||||
/// <returns></returns>
|
||||
public string RenderJson(Hashtable pModelResult)
|
||||
{
|
||||
OSDMap logInfo = new OpenMetaverse.StructuredData.OSDMap();
|
||||
|
||||
OSDArray logLines = new OpenMetaverse.StructuredData.OSDArray();
|
||||
string tmp = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n");
|
||||
string[] result = Regex.Split(tmp, "\n");
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
{
|
||||
logLines.Add(new OSDString(result[i]));
|
||||
}
|
||||
logInfo.Add("logLines", logLines);
|
||||
return logInfo.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
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 jsFileName = "prototype.js";
|
||||
private string prototypejs = string.Empty;
|
||||
|
||||
public Prototype_distributor()
|
||||
{
|
||||
jsFileName = "prototype.js";
|
||||
}
|
||||
|
||||
public Prototype_distributor(string jsName)
|
||||
{
|
||||
jsFileName = jsName;
|
||||
}
|
||||
|
||||
public string ReportName
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
Hashtable pResult = new Hashtable();
|
||||
pResult["js"] = jsFileName;
|
||||
return pResult;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
string fileName = (string)pModelResult["js"];
|
||||
using (StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/" + fileName, FileMode.Open)))
|
||||
{
|
||||
prototypejs = fs.ReadToEnd();
|
||||
fs.Close();
|
||||
}
|
||||
return prototypejs;
|
||||
}
|
||||
|
||||
public string RenderJson(Hashtable pModelResult)
|
||||
{
|
||||
return "{}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class Sessions_Report : IStatsController
|
||||
{
|
||||
#region IStatsController Members
|
||||
|
||||
public string ReportName
|
||||
{
|
||||
get { return "Sessions"; }
|
||||
}
|
||||
|
||||
public Hashtable ProcessModel(Hashtable pParams)
|
||||
{
|
||||
Hashtable modeldata = new Hashtable();
|
||||
modeldata.Add("Scenes", pParams["Scenes"]);
|
||||
modeldata.Add("Reports", pParams["Reports"]);
|
||||
SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"];
|
||||
List<SessionList> lstSessions = new List<SessionList>();
|
||||
Hashtable requestvars = (Hashtable) pParams["RequestVars"];
|
||||
|
||||
|
||||
string puserUUID = string.Empty;
|
||||
string clientVersionString = string.Empty;
|
||||
int queryparams = 0;
|
||||
|
||||
if (requestvars != null)
|
||||
{
|
||||
if (requestvars.ContainsKey("UserID"))
|
||||
{
|
||||
UUID testUUID = UUID.Zero;
|
||||
if (UUID.TryParse(requestvars["UserID"].ToString(), out testUUID))
|
||||
{
|
||||
puserUUID = requestvars["UserID"].ToString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (requestvars.ContainsKey("VersionString"))
|
||||
{
|
||||
clientVersionString = requestvars["VersionString"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
lock (dbConn)
|
||||
{
|
||||
string sql =
|
||||
"SELECT distinct a.name_f, a.name_l, a.Agent_ID, b.Session_ID, b.client_version, b.last_updated, b.start_time FROM stats_session_data a LEFT OUTER JOIN stats_session_data b ON a.Agent_ID = b.Agent_ID";
|
||||
|
||||
if (puserUUID.Length > 0)
|
||||
{
|
||||
if (queryparams == 0)
|
||||
sql += " WHERE";
|
||||
else
|
||||
sql += " AND";
|
||||
|
||||
sql += " b.agent_id=:agent_id";
|
||||
queryparams++;
|
||||
}
|
||||
|
||||
if (clientVersionString.Length > 0)
|
||||
{
|
||||
if (queryparams == 0)
|
||||
sql += " WHERE";
|
||||
else
|
||||
sql += " AND";
|
||||
|
||||
sql += " b.client_version=:client_version";
|
||||
queryparams++;
|
||||
}
|
||||
|
||||
sql += " ORDER BY a.name_f, a.name_l, b.last_updated;";
|
||||
|
||||
SqliteCommand cmd = new SqliteCommand(sql, dbConn);
|
||||
|
||||
if (puserUUID.Length > 0)
|
||||
cmd.Parameters.Add(new SqliteParameter(":agent_id", puserUUID));
|
||||
if (clientVersionString.Length > 0)
|
||||
cmd.Parameters.Add(new SqliteParameter(":client_version", clientVersionString));
|
||||
|
||||
SqliteDataReader sdr = cmd.ExecuteReader();
|
||||
|
||||
if (sdr.HasRows)
|
||||
{
|
||||
UUID userUUID = UUID.Zero;
|
||||
|
||||
SessionList activeSessionList = new SessionList();
|
||||
activeSessionList.user_id=UUID.Random();
|
||||
while (sdr.Read())
|
||||
{
|
||||
UUID readUUID = UUID.Parse(sdr["agent_id"].ToString());
|
||||
if (readUUID != userUUID)
|
||||
{
|
||||
activeSessionList = new SessionList();
|
||||
activeSessionList.user_id = readUUID;
|
||||
activeSessionList.firstname = sdr["name_f"].ToString();
|
||||
activeSessionList.lastname = sdr["name_l"].ToString();
|
||||
activeSessionList.sessions = new List<ShortSessionData>();
|
||||
lstSessions.Add(activeSessionList);
|
||||
}
|
||||
|
||||
ShortSessionData ssd = new ShortSessionData();
|
||||
|
||||
ssd.last_update = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["last_updated"]));
|
||||
ssd.start_time = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["start_time"]));
|
||||
ssd.session_id = UUID.Parse(sdr["session_id"].ToString());
|
||||
ssd.client_version = sdr["client_version"].ToString();
|
||||
activeSessionList.sessions.Add(ssd);
|
||||
|
||||
userUUID = activeSessionList.user_id;
|
||||
}
|
||||
}
|
||||
sdr.Close();
|
||||
cmd.Dispose();
|
||||
}
|
||||
modeldata["SessionData"] = lstSessions;
|
||||
return modeldata;
|
||||
}
|
||||
|
||||
public string RenderView(Hashtable pModelResult)
|
||||
{
|
||||
List<SessionList> lstSession = (List<SessionList>) pModelResult["SessionData"];
|
||||
Dictionary<string, IStatsController> reports = (Dictionary<string, IStatsController>)pModelResult["Reports"];
|
||||
|
||||
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>
|
||||
";
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
HTMLUtil.HtmlHeaders_O(ref output);
|
||||
output.Append(STYLESHEET);
|
||||
HTMLUtil.HtmlHeaders_C(ref output);
|
||||
|
||||
HTMLUtil.AddReportLinks(ref output, reports, "");
|
||||
|
||||
HTMLUtil.TABLE_O(ref output, "defaultr");
|
||||
HTMLUtil.TR_O(ref output, "defaultr");
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("FirstName");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("LastName");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("SessionEnd");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("SessionLength");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "header");
|
||||
output.Append("Client");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
if (lstSession.Count == 0)
|
||||
{
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
HTMLUtil.TD_O(ref output, "align_top", 1, 5);
|
||||
output.Append("No results for that query");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
}
|
||||
foreach (SessionList ssnlst in lstSession)
|
||||
{
|
||||
int cnt = 0;
|
||||
foreach (ShortSessionData sesdata in ssnlst.sessions)
|
||||
{
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
if (cnt++ == 0)
|
||||
{
|
||||
HTMLUtil.TD_O(ref output, "align_top", ssnlst.sessions.Count, 1);
|
||||
output.Append(ssnlst.firstname);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "align_top", ssnlst.sessions.Count, 1);
|
||||
output.Append(ssnlst.lastname);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
}
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(sesdata.last_update.ToShortDateString());
|
||||
output.Append(" - ");
|
||||
output.Append(sesdata.last_update.ToShortTimeString());
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
TimeSpan dtlength = sesdata.last_update.Subtract(sesdata.start_time);
|
||||
if (dtlength.Days > 0)
|
||||
{
|
||||
output.Append(dtlength.Days);
|
||||
output.Append(" Days ");
|
||||
}
|
||||
if (dtlength.Hours > 0)
|
||||
{
|
||||
output.Append(dtlength.Hours);
|
||||
output.Append(" Hours ");
|
||||
}
|
||||
if (dtlength.Minutes > 0)
|
||||
{
|
||||
output.Append(dtlength.Minutes);
|
||||
output.Append(" Minutes");
|
||||
}
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TD_O(ref output, "content");
|
||||
output.Append(sesdata.client_version);
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
|
||||
}
|
||||
HTMLUtil.TR_O(ref output, "");
|
||||
HTMLUtil.TD_O(ref output, "align_top", 1, 5);
|
||||
HTMLUtil.HR(ref output, "");
|
||||
HTMLUtil.TD_C(ref output);
|
||||
HTMLUtil.TR_C(ref output);
|
||||
}
|
||||
HTMLUtil.TABLE_C(ref output);
|
||||
output.Append("</BODY>\n</HTML>");
|
||||
return output.ToString();
|
||||
}
|
||||
|
||||
public class SessionList
|
||||
{
|
||||
public string firstname;
|
||||
public string lastname;
|
||||
public UUID user_id;
|
||||
public List<ShortSessionData> sessions;
|
||||
}
|
||||
|
||||
public struct ShortSessionData
|
||||
{
|
||||
public UUID session_id;
|
||||
public string client_version;
|
||||
public DateTime last_update;
|
||||
public DateTime start_time;
|
||||
}
|
||||
|
||||
public string RenderJson(Hashtable pModelResult)
|
||||
{
|
||||
return "{}";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Region.UserStatistics
|
||||
{
|
||||
public class SimStatsAJAX : IStatsController
|
||||
{
|
||||
#region IStatsController Members
|
||||
|
||||
public string ReportName
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
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("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.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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return stat information for all regions in the sim. Returns data of the form:
|
||||
/// <pre>
|
||||
/// {"REGIONNAME": {
|
||||
/// "region": "REGIONNAME",
|
||||
/// "timeDilation": "101",
|
||||
/// ... // the rest of the stat info
|
||||
/// },
|
||||
/// ... // entries for each region
|
||||
/// }
|
||||
/// </pre>
|
||||
/// </summary>
|
||||
/// <param name="pModelResult"></param>
|
||||
/// <returns></returns>
|
||||
public string RenderJson(Hashtable pModelResult)
|
||||
{
|
||||
List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
|
||||
Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
|
||||
|
||||
OSDMap allStatsInfo = new OpenMetaverse.StructuredData.OSDMap();
|
||||
foreach (USimStatsData sdata in sdatadic.Values)
|
||||
{
|
||||
OSDMap statsInfo = new OpenMetaverse.StructuredData.OSDMap();
|
||||
string regionName = "unknown";
|
||||
foreach (Scene sn in all_scenes)
|
||||
{
|
||||
if (sn.RegionInfo.RegionID == sdata.RegionId)
|
||||
{
|
||||
regionName = sn.RegionInfo.RegionName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
statsInfo.Add("region", new OSDString(regionName));
|
||||
statsInfo.Add("timeDilation", new OSDString(sdata.TimeDilation.ToString()));
|
||||
statsInfo.Add("simFPS", new OSDString(sdata.SimFps.ToString()));
|
||||
statsInfo.Add("physicsFPS", new OSDString(sdata.PhysicsFps.ToString()));
|
||||
statsInfo.Add("agentUpdates", new OSDString(sdata.AgentUpdates.ToString()));
|
||||
statsInfo.Add("rootAgents", new OSDString(sdata.RootAgents.ToString()));
|
||||
statsInfo.Add("childAgents", new OSDString(sdata.ChildAgents.ToString()));
|
||||
statsInfo.Add("totalPrims", new OSDString(sdata.TotalPrims.ToString()));
|
||||
statsInfo.Add("activePrims", new OSDString(sdata.ActivePrims.ToString()));
|
||||
statsInfo.Add("activeScripts", new OSDString(sdata.ActiveScripts.ToString()));
|
||||
statsInfo.Add("scriptLinesPerSec", new OSDString(sdata.ScriptLinesPerSecond.ToString()));
|
||||
statsInfo.Add("totalFrameTime", new OSDString(sdata.TotalFrameTime.ToString()));
|
||||
statsInfo.Add("agentFrameTime", new OSDString(sdata.AgentFrameTime.ToString()));
|
||||
statsInfo.Add("physicsFrameTime", new OSDString(sdata.PhysicsFrameTime.ToString()));
|
||||
statsInfo.Add("otherFrameTime", new OSDString(sdata.OtherFrameTime.ToString()));
|
||||
statsInfo.Add("outPacketsPerSec", new OSDString(sdata.OutPacketsPerSecond.ToString()));
|
||||
statsInfo.Add("inPacketsPerSec", new OSDString(sdata.InPacketsPerSecond.ToString()));
|
||||
statsInfo.Add("unackedByptes", new OSDString(sdata.UnackedBytes.ToString()));
|
||||
statsInfo.Add("pendingDownloads", new OSDString(sdata.PendingDownloads.ToString()));
|
||||
statsInfo.Add("pendingUploads", new OSDString(sdata.PendingUploads.ToString()));
|
||||
|
||||
allStatsInfo.Add(regionName, statsInfo);
|
||||
}
|
||||
return allStatsInfo.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
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 string ReportName
|
||||
{
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public string RenderJson(Hashtable pModelResult) {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1841,13 +1841,6 @@
|
||||
; next option may still use framework performance monitors designed for debug only, so avoid it
|
||||
;ServerStatsEnabled = false
|
||||
|
||||
[WebStats]
|
||||
; View region statistics via a web page
|
||||
; See http://opensimulator.org/wiki/FAQ#Region_Statistics_on_a_Web_Page
|
||||
; Use a web browser and type in the "Login URI" + "/SStats/"
|
||||
; For example- http://127.0.0.1:9000/SStats/
|
||||
; enabled=false
|
||||
|
||||
[Statistics]
|
||||
; NumberOfFrames is used in a moving average calculation, where NumberOfFrames is the number of frames
|
||||
; to include in the averaging calculations
|
||||
|
||||
Vendored
-4222
File diff suppressed because it is too large.
Load diff
@@ -1,85 +0,0 @@
|
||||
body {
|
||||
font-family: Veranda,Arial,Helvetica,sans-serif;
|
||||
font-size: 12px;
|
||||
background: #4A5F6D;
|
||||
color: #EEEAD6;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
.footer {
|
||||
font-family: Veranda,Arial,Helvetica,sans-serif;
|
||||
font-size: 10px;
|
||||
}
|
||||
td {
|
||||
font-family: Veranda,Arial,Helvetica,sans-serif;
|
||||
font-size: 12px;
|
||||
padding: 4px;
|
||||
margin: 4px;
|
||||
}
|
||||
blockquote {
|
||||
font-family: Veranda,Arial,Helvetica,sans-serif;
|
||||
font-style: italic;
|
||||
font-size: 12px;
|
||||
}
|
||||
pre {
|
||||
padding: 5px;
|
||||
background-color: #8080B0;
|
||||
color: #000000;
|
||||
margin-left: 20px;
|
||||
font-size: 11px;
|
||||
}
|
||||
:link {
|
||||
color: #ffffff;
|
||||
}
|
||||
:visited {
|
||||
color: #d0d0d0;
|
||||
}
|
||||
.SimSectionHeader {
|
||||
font-size: 120%;
|
||||
}
|
||||
div.SimSectionContainer {
|
||||
padding: 10px 0px 0px 20px;
|
||||
}
|
||||
/* SimStats ===================================== */
|
||||
#SimSimStats div {
|
||||
margin-left: 20px;
|
||||
background: #3A4F5D;
|
||||
}
|
||||
#SimSimStats table td {
|
||||
text-align: right;
|
||||
padding: 0px 0px 0px 5px;
|
||||
margin: 0px 0px 0px 0px;
|
||||
}
|
||||
/* Region Stats ===================================== */
|
||||
#SimRegionStats div {
|
||||
margin-left: 20px;
|
||||
background: #3A4F5D;
|
||||
}
|
||||
#SimRegionStats table {
|
||||
border: 1px;
|
||||
border-style: solid;
|
||||
}
|
||||
#SimRegionStats table td {
|
||||
text-align: right;
|
||||
padding: 0px 0px 0px 5px;
|
||||
margin: 0px 0px 0px 0px;
|
||||
}
|
||||
/* Session Stats ===================================== */
|
||||
#SimSessionStats div {
|
||||
margin-left: 20px;
|
||||
background: #3A4F5D;
|
||||
}
|
||||
#SimSessionStats table td {
|
||||
text-align: right;
|
||||
padding: 0px 0px 0px 5px;
|
||||
margin: 0px 0px 0px 0px;
|
||||
}
|
||||
/* LogFile ===================================== */
|
||||
#SimLogFile div {
|
||||
margin-left: 20px;
|
||||
}
|
||||
#SimLogFile table td {
|
||||
text-align: right;
|
||||
padding: 0px 0px 0px 5px;
|
||||
margin: 0px 0px 0px 0px;
|
||||
}
|
||||
@@ -1,291 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Simulator statistics</title>
|
||||
<link rel="stylesheet" href="sim.css" type="text/css"/>
|
||||
<!-- <script type="text/javascript" src="jquery.js"></script> -->
|
||||
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.0.min.js"></script> -->
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
|
||||
<!-- <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/libs/jQuery/jquery-1.9.0.min.js"></script> -->
|
||||
<noscript>
|
||||
<p color="red">
|
||||
Your browser does not support Javascript. This won't work for you.
|
||||
</p>
|
||||
</noscript>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
// Major divisions in the content accordioning
|
||||
$('.SimSection').show('slow');
|
||||
$('.SimSectionHeader').click(function() {
|
||||
$(this).next().slideToggle('slow');
|
||||
return false;
|
||||
});
|
||||
|
||||
// Start the timed functions
|
||||
TimerDataStuff();
|
||||
});
|
||||
|
||||
// One of the sections is viewer statistics. Poll for the data.
|
||||
var statTimerHandle;
|
||||
var graphFPS;
|
||||
var lastFPS = 10;
|
||||
var xxThru = 0;
|
||||
function TimerDataStuff() {
|
||||
statTimerHandle = setInterval('TimerStatDisplay()', 5000);
|
||||
}
|
||||
|
||||
// called by timer to fetch and display statistic information
|
||||
var doingStatDisplay = false;
|
||||
function TimerStatDisplay() {
|
||||
if (doingStatDisplay) return;
|
||||
doingStatDisplay = true;
|
||||
if ($('#SimSimStats').is(':visible')) {
|
||||
DisplaySimStats();
|
||||
}
|
||||
if ($('#SimRegionStats').is(':visible')) {
|
||||
DisplayPerRegionStats();
|
||||
}
|
||||
if ($('#SimSessionStats').is(':visible')) {
|
||||
DisplaySessionStats();
|
||||
}
|
||||
if ($('#SimLogFile').is(':visible')) {
|
||||
DisplayLogFile();
|
||||
}
|
||||
doingStatDisplay = false;
|
||||
}
|
||||
|
||||
var simName = "127.0.0.1";
|
||||
var simPort = "9000";
|
||||
function DisplaySimStats() {
|
||||
var statURL = "http://" + simName + ":" + simPort + "/SStats/?json=1";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: statURL,
|
||||
dataType: 'json',
|
||||
timeout: 1000,
|
||||
success: function(data, status) {
|
||||
if (status == 'success') {
|
||||
DisplaySimStatDetails(data);
|
||||
}
|
||||
},
|
||||
error: function(xmlHTTPRequest, errorType) {
|
||||
// DebugLog('Failed fetch');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function DisplayPerRegionStats() {
|
||||
var statURL = "http://" + simName + ":" + simPort + "/SStats/simstatsajax.html?json=1";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: statURL,
|
||||
dataType: 'json',
|
||||
timeout: 1000,
|
||||
success: function(data, status) {
|
||||
if (status == 'success') {
|
||||
DisplayRegionStatDetails(data);
|
||||
}
|
||||
},
|
||||
error: function(xmlHTTPRequest, errorType) {
|
||||
// DebugLog('Failed fetch');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function DisplayLogFile() {
|
||||
var statURL = "http://" + simName + ":" + simPort + "/SStats/activelogajax.html?json=1";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: statURL,
|
||||
dataType: 'json',
|
||||
timeout: 1000,
|
||||
success: function(data, status) {
|
||||
if (status == 'success') {
|
||||
DisplayLogFileDetails(data);
|
||||
}
|
||||
},
|
||||
error: function(xmlHTTPRequest, errorType) {
|
||||
// DebugLog('Failed fetch');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function DisplaySessionStats() {
|
||||
var statURL = "http://" + simName + ":" + simPort + "/SStats/activeconnectionsajax.html?json=1";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: statURL,
|
||||
dataType: 'json',
|
||||
timeout: 1000,
|
||||
success: function(data, status) {
|
||||
if (status == 'success') {
|
||||
DisplaySessionStatsDetails(data);
|
||||
}
|
||||
},
|
||||
error: function(xmlHTTPRequest, errorType) {
|
||||
// DebugLog('Failed fetch');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function DisplaySimStatDetails(data) {
|
||||
var simInfo = new StringBuffer();
|
||||
simInfo.append('<table id="RegionStatsTable">');
|
||||
simInfo.append('<tr>');
|
||||
simInfo.append('<th>Total Users</th>');
|
||||
simInfo.append('<th>Total Sessions</th>');
|
||||
simInfo.append('<th>Avg client FPS</th>');
|
||||
simInfo.append('<th>Avg client Mem</th>');
|
||||
simInfo.append('<th>Avg ping time</th>');
|
||||
simInfo.append('<th>KB out</th>');
|
||||
simInfo.append('<th>KB in</th>');
|
||||
simInfo.append('</tr>');
|
||||
simInfo.append('<tr>');
|
||||
simInfo.append('<td>' + data.totalUsers + '</td>');
|
||||
simInfo.append('<td>' + data.totalSessions + '</td>');
|
||||
simInfo.append('<td>' + data.averageClientFPS + '</td>');
|
||||
simInfo.append('<td>' + data.averageClientMem + '</td>');
|
||||
simInfo.append('<td>' + data.averagePingTime + '</td>');
|
||||
simInfo.append('<td>' + data.totalKBOut + '</td>');
|
||||
simInfo.append('<td>' + data.totalKBIn + '</td>');
|
||||
simInfo.append('</tr>');
|
||||
simInfo.append('</table>');
|
||||
$('#SimSimStats').empty();
|
||||
$('#SimSimStats').append(simInfo.toString());
|
||||
}
|
||||
|
||||
function DisplayRegionStatDetails(data) {
|
||||
var regionInfo = new StringBuffer();
|
||||
regionInfo.append('<table id="RegionStatsTable">');
|
||||
regionInfo.append('<tr>');
|
||||
regionInfo.append('<th>Region</th>');
|
||||
regionInfo.append('<th>Agents</th>');
|
||||
regionInfo.append('<th>Child</th>');
|
||||
regionInfo.append('<th>FPS</th>');
|
||||
regionInfo.append('<th>Frame Time</th>');
|
||||
regionInfo.append('<th>Phys Time</th>');
|
||||
regionInfo.append('<th>Prims</th>');
|
||||
regionInfo.append('</tr>');
|
||||
for (region in data) {
|
||||
regionInfo.append('<tr>');
|
||||
regionInfo.append('<td>' + data[region].region + '</td>');
|
||||
regionInfo.append('<td>' + data[region].rootAgents + '</td>');
|
||||
regionInfo.append('<td>' + data[region].childAgents + '</td>');
|
||||
regionInfo.append('<td>' + data[region].simFPS + '</td>');
|
||||
regionInfo.append('<td>' + data[region].totalFrameTime + '</td>');
|
||||
regionInfo.append('<td>' + data[region].physicsFrameTime + '</td>');
|
||||
regionInfo.append('<td>' + data[region].totalPrims + '</td>');
|
||||
regionInfo.append('</tr>');
|
||||
}
|
||||
regionInfo.append('</table>');
|
||||
$('#SimRegionStats').empty();
|
||||
$('#SimRegionStats').append(regionInfo.toString());
|
||||
}
|
||||
|
||||
function DisplayLogFileDetails(data) {
|
||||
var logInfo = new StringBuffer();
|
||||
var logPattern = /^(.+),\d\d\d .* \[(.+)\]: (.+)$/;
|
||||
for (logLine in data['logLines']) {
|
||||
logInfo.append('<div>');
|
||||
var logPieces = logPattern.exec(data['logLines'][logLine]);
|
||||
if (logPieces) {
|
||||
logInfo.append(logPieces[1] + ' [' + logPieces[2]
|
||||
+ '] ' + logPieces[3]);
|
||||
}
|
||||
else {
|
||||
logInfo.append(data['logLines'][logLine]);
|
||||
}
|
||||
|
||||
logInfo.append('</div>');
|
||||
}
|
||||
$('#SimLogFile').empty();
|
||||
$('#SimLogFile').append(logInfo.toString());
|
||||
}
|
||||
|
||||
function DisplaySessionStatsDetails(data) {
|
||||
var userInfo = new StringBuffer();
|
||||
userInfo.append('<table>');
|
||||
userInfo.append('<tr>');
|
||||
userInfo.append('<th>region</th>');
|
||||
userInfo.append('<th>user</th>');
|
||||
userInfo.append('<th></th>');
|
||||
userInfo.append('<th>position</th>');
|
||||
userInfo.append('</tr>');
|
||||
for (region in data) {
|
||||
for (user in data[region]) {
|
||||
if (user != 'queues') {
|
||||
userInfo.append('<tr>');
|
||||
userInfo.append('<td>' + region + '</td>');
|
||||
userInfo.append('<td>' + data[region][user].Name + '</td>');
|
||||
if (data[region][user].isRoot == 'true') {
|
||||
userInfo.append('<td>root</td>');
|
||||
}
|
||||
else {
|
||||
userInfo.append('<td>child</td>');
|
||||
}
|
||||
userInfo.append('<td>' + data[region][user].position + '</td>');
|
||||
userInfo.append('</tr>');
|
||||
}
|
||||
}
|
||||
}
|
||||
userInfo.append('</table>');
|
||||
$('#SimSessionStats').empty();
|
||||
$('#SimSessionStats').append(userInfo.toString());
|
||||
}
|
||||
|
||||
function DebugLog(msg) {
|
||||
$("#DEBUG").append('<div>' + msg + '</div>');
|
||||
$("#DEBUG").show();
|
||||
}
|
||||
|
||||
function StringBuffer() {
|
||||
this.__strings__ = new Array;
|
||||
}
|
||||
StringBuffer.prototype.append = function(str) {
|
||||
this.__strings__.push(str);
|
||||
}
|
||||
StringBuffer.prototype.toString = function() {
|
||||
return this.__strings__.join("");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body id="SimBody">
|
||||
<div id="SimHeader"></div>
|
||||
<div id="SimContent">
|
||||
|
||||
<!-- ============================================== -->
|
||||
<div class="SimSectionContainer">
|
||||
<a class="SimSectionHeader" href="#">Simulator Stats</a>
|
||||
<div id="SimSimStats" class="SimSection">
|
||||
</div> <!-- SimSimStats -->
|
||||
</div> <!-- SimSectionContainer -->
|
||||
|
||||
<!-- ============================================== -->
|
||||
<div class="SimSectionContainer">
|
||||
<a class="SimSectionHeader" href="#">Region Stats</a>
|
||||
<div id="SimRegionStats" class="SimSection">
|
||||
</div> <!-- SimRegionStats -->
|
||||
</div> <!-- SimSectionContainer -->
|
||||
|
||||
<!-- ============================================== -->
|
||||
<div class="SimSectionContainer">
|
||||
<a class="SimSectionHeader" href="#">Sessions</a>
|
||||
<div id="SimSessionStats" class="SimSection">
|
||||
</div> <!-- SimSessionStats -->
|
||||
</div> <!-- SimSectionContainer -->
|
||||
|
||||
<!-- ============================================== -->
|
||||
<div class="SimSectionContainer">
|
||||
<a class="SimSectionHeader" href="#">Log File</a>
|
||||
<div id="SimLogFile" class="SimSection">
|
||||
</div> <!-- SimLogFile -->
|
||||
</div> <!-- SimSectionContainer -->
|
||||
|
||||
<!-- ============================================== -->
|
||||
</div> <!-- SimContent -->
|
||||
<div id="DEBUG"></div>
|
||||
<div id="SimFooter"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,20 +0,0 @@
|
||||
var updater = Class.create({
|
||||
initialize: function(divToUpdate, interval, file) {
|
||||
this.divToUpdate = divToUpdate;
|
||||
this.interval = interval;
|
||||
this.file = file;
|
||||
new PeriodicalExecuter(this.getUpdate.bind(this), this.interval);
|
||||
},
|
||||
|
||||
getUpdate: function() {
|
||||
var oOptions = {
|
||||
method: "POST",
|
||||
parameters: "intervalPeriod="+this.interval,
|
||||
asynchronous: true,
|
||||
onComplete: function (oXHR, Json) {
|
||||
$(this.divToUpdate).innerHTML = oXHR.responseText;
|
||||
}
|
||||
};
|
||||
var oRequest = new Ajax.Updater(this.divToUpdate, this.file, oOptions);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user