* Updates the sim stats module. Cleans out some of the rot.

* Adds a prototype web stats module which is disabled by default.  It's functional with one report right now, however, the database structure may change, so I don't recommend enabling this to keep actual stats right now.  I'll let you know when it's safe.
* Adds Prototype for ajaxy web content
* removed a warning or two.
0.6.2-post-fixes
Teravus Ovares 2009-01-03 03:30:03 +00:00
parent 4144fd0eb2
commit e9cef70f89
20 changed files with 6360 additions and 66 deletions

View File

@ -113,6 +113,7 @@ This software uses components from the following developers:
* Prebuild (http://sourceforge.net/projects/dnpb/)
* LibSecondLife (http://www.libsecondlife.org/wiki/Main_Page)
* DotNetOpenMail v0.5.8b (http://dotnetopenmail.sourceforge.net)
* Prototype JavaScript Framework ajax (http://www.prototypejs.org/)
In addition, we would like to thank:

View File

@ -1091,6 +1091,7 @@ namespace OpenSim.Framework.Servers
{
host = (string)headervals["Host"];
}
keysvals.Add("headers",headervals);
if (keysvals.Contains("method"))
{
@ -1238,7 +1239,7 @@ namespace OpenSim.Framework.Servers
byte[] buffer;
if (!contentType.Contains("image"))
if (!(contentType.Contains("image") || contentType.Contains("x-shockwave-flash")))
{
buffer = Encoding.UTF8.GetBytes(responseString);
}

View File

@ -72,11 +72,18 @@ namespace OpenSim.Framework
get { return m_objectCapacity; }
}
private uint m_objectCapacity;
public OpenMetaverse.UUID RegionUUID
{
get { return regionUUID;}
}
private OpenMetaverse.UUID regionUUID;
public SimStats(
uint regionX, uint regionY, uint regionFlags, uint objectCapacity,
SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock)
SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, OpenMetaverse.UUID pRUUID)
{
regionUUID = pRUUID;
m_regionX = regionX;
m_regionY = regionY;
m_regionFlags = regionFlags;

View File

@ -51,27 +51,27 @@ namespace OpenSim.Framework.Statistics
private long assetServiceRequestFailures;
private long inventoryServiceRetrievalFailures;
private float timeDilation;
private float simFps;
private float physicsFps;
private float agentUpdates;
private float rootAgents;
private float childAgents;
private float totalPrims;
private float activePrims;
private float totalFrameTime;
private float netFrameTime;
private float physicsFrameTime;
private float otherFrameTime;
private float imageFrameTime;
private float inPacketsPerSecond;
private float outPacketsPerSecond;
private float unackedBytes;
private float agentFrameTime;
private float pendingDownloads;
private float pendingUploads;
private float activeScripts;
private float scriptLinesPerSecond;
private volatile float timeDilation;
private volatile float simFps;
private volatile float physicsFps;
private volatile float agentUpdates;
private volatile float rootAgents;
private volatile float childAgents;
private volatile float totalPrims;
private volatile float activePrims;
private volatile float totalFrameTime;
private volatile float netFrameTime;
private volatile float physicsFrameTime;
private volatile float otherFrameTime;
private volatile float imageFrameTime;
private volatile float inPacketsPerSecond;
private volatile float outPacketsPerSecond;
private volatile float unackedBytes;
private volatile float agentFrameTime;
private volatile float pendingDownloads;
private volatile float pendingUploads;
private volatile float activeScripts;
private volatile float scriptLinesPerSecond;
/// <summary>
/// Number of times that a client thread terminated because of an exception
@ -87,7 +87,28 @@ namespace OpenSim.Framework.Statistics
public long TexturesInCache { get { return texturesInCache; } }
public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } }
public float TimeDilation { get { return timeDilation; } }
public float SimFps { get { return simFps; } }
public float PhysicsFps { get { return physicsFps; } }
public float AgentUpdates { get { return agentUpdates; } }
public float RootAgents { get { return rootAgents; } }
public float ChildAgents { get { return childAgents; } }
public float TotalPrims { get { return totalPrims; } }
public float ActivePrims { get { return activePrims; } }
public float TotalFrameTime { get { return totalFrameTime; } }
public float NetFrameTime { get { return netFrameTime; } }
public float PhysicsFrameTime { get { return physicsFrameTime; } }
public float OtherFrameTime { get { return otherFrameTime; } }
public float ImageFrameTime { get { return imageFrameTime; } }
public float InPacketsPerSecond { get { return inPacketsPerSecond; } }
public float OutPacketsPerSecond { get { return outPacketsPerSecond; } }
public float UnackedBytes { get { return unackedBytes; } }
public float AgentFrameTime { get { return agentFrameTime; } }
public float PendingDownloads { get { return pendingDownloads; } }
public float PendingUploads { get { return pendingUploads; } }
public float ActiveScripts { get { return activeScripts; } }
public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } }
/// <summary>
/// This is the time it took for the last asset request made in response to a cache miss.
/// </summary>

View File

@ -603,10 +603,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void Flush()
{
m_PacketQueue.Flush();
m_UnackedBytes = (-1 * m_UnackedBytes);
SendPacketStats();
}
public void Clear()
{
m_UnackedBytes = (-1 * m_UnackedBytes);
SendPacketStats();
m_NeedAck.Clear();
m_PendingAcks.Clear();
m_Sequence += 1000000;

View File

@ -69,7 +69,7 @@ namespace OpenSim.Region.Environment.Scenes
protected Timer m_restartWaitTimer = new Timer();
protected SimStatsReporter m_statsReporter;
public SimStatsReporter StatsReporter;
protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
@ -244,7 +244,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public float SimulatorFPS
{
get { return m_statsReporter.getLastReportedSimFPS(); }
get { return StatsReporter.getLastReportedSimFPS(); }
}
public int TimePhase
@ -358,10 +358,10 @@ namespace OpenSim.Region.Environment.Scenes
m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics;
m_statsReporter = new SimStatsReporter(this);
m_statsReporter.OnSendStatsResult += SendSimStatsPackets;
StatsReporter = new SimStatsReporter(this);
StatsReporter.OnSendStatsResult += SendSimStatsPackets;
m_statsReporter.SetObjectCapacity(objectCapacity);
StatsReporter.SetObjectCapacity(objectCapacity);
m_simulatorVersion = simulatorVersion
+ " (OS " + Util.GetOperatingSystemInformation() + ")"
@ -814,7 +814,7 @@ namespace OpenSim.Region.Environment.Scenes
if (m_update_entities == 1)
{
m_update_entities = 5;
m_statsReporter.SetUpdateMS(6000);
StatsReporter.SetUpdateMS(6000);
}
}
else
@ -822,7 +822,7 @@ namespace OpenSim.Region.Environment.Scenes
if (m_update_entities == 5)
{
m_update_entities = 1;
m_statsReporter.SetUpdateMS(3000);
StatsReporter.SetUpdateMS(3000);
}
}
@ -891,20 +891,20 @@ namespace OpenSim.Region.Environment.Scenes
otherMS = System.Environment.TickCount - otherMS;
// if (m_frame%m_update_avatars == 0)
// UpdateInWorldTime();
m_statsReporter.AddPhysicsFPS(physicsFPS);
m_statsReporter.AddTimeDilation(m_timedilation);
m_statsReporter.AddFPS(1);
m_statsReporter.AddInPackets(0);
m_statsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
m_statsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
m_statsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
m_statsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
StatsReporter.AddPhysicsFPS(physicsFPS);
StatsReporter.AddTimeDilation(m_timedilation);
StatsReporter.AddFPS(1);
StatsReporter.AddInPackets(0);
StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
frameMS = System.Environment.TickCount - frameMS;
m_statsReporter.addFrameMS(frameMS);
m_statsReporter.addPhysicsMS(physicsMS);
m_statsReporter.addOtherMS(otherMS);
m_statsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
m_statsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
StatsReporter.addFrameMS(frameMS);
StatsReporter.addPhysicsMS(physicsMS);
StatsReporter.addOtherMS(otherMS);
StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
}
}
catch (NotImplementedException)
@ -2380,8 +2380,8 @@ namespace OpenSim.Region.Environment.Scenes
client.OnObjectOwner += ObjectOwner;
if (m_statsReporter != null)
client.OnNetworkStatsUpdate += m_statsReporter.AddPacketsFromClientStats;
if (StatsReporter != null)
client.OnNetworkStatsUpdate += StatsReporter.AddPacketsFromClientStats;
// EventManager.TriggerOnNewClient(client);
}
@ -3027,14 +3027,14 @@ namespace OpenSim.Region.Environment.Scenes
if (presence != null)
{
// Nothing is removed here, so down count it as such
// if (presence.IsChildAgent)
// {
// m_sceneGraph.removeUserCount(false);
// }
// else
// {
// m_sceneGraph.removeUserCount(true);
// }
if (presence.IsChildAgent)
{
m_sceneGraph.removeUserCount(false);
}
else
{
m_sceneGraph.removeUserCount(true);
}
// Don't do this to root agents on logout, it's not nice for the viewer
if (presence.IsChildAgent)
@ -3322,9 +3322,9 @@ namespace OpenSim.Region.Environment.Scenes
if (RegionInfo.ObjectCapacity != 0)
objects = RegionInfo.ObjectCapacity;
if (m_statsReporter != null)
if (StatsReporter != null)
{
m_statsReporter.SetObjectCapacity(objects);
StatsReporter.SetObjectCapacity(objects);
}
objectCapacity = objects;
}
@ -3430,25 +3430,25 @@ namespace OpenSim.Region.Environment.Scenes
public void AddPacketStats(int inPackets, int outPackets, int unAckedBytes)
{
m_statsReporter.AddInPackets(inPackets);
m_statsReporter.AddOutPackets(outPackets);
m_statsReporter.AddunAckedBytes(unAckedBytes);
StatsReporter.AddInPackets(inPackets);
StatsReporter.AddOutPackets(outPackets);
StatsReporter.AddunAckedBytes(unAckedBytes);
}
public void AddAgentTime(int ms)
{
m_statsReporter.addFrameMS(ms);
m_statsReporter.addAgentMS(ms);
StatsReporter.addFrameMS(ms);
StatsReporter.addAgentMS(ms);
}
public void AddAgentUpdates(int count)
{
m_statsReporter.AddAgentUpdates(count);
StatsReporter.AddAgentUpdates(count);
}
public void AddPendingDownloads(int count)
{
m_statsReporter.addPendingDownload(count);
StatsReporter.addPendingDownload(count);
}
#endregion

View File

@ -306,8 +306,19 @@ namespace OpenSim.Region.Environment.Scenes
if (!resultOfObjectLinked)
{
m_numPrim -= ((SceneObjectGroup) Entities[uuid]).Children.Count;
if ((((SceneObjectGroup)Entities[uuid]).RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
{
RemovePhysicalPrim(((SceneObjectGroup)Entities[uuid]).Children.Count);
}
}
Entities.Remove(uuid);
//SceneObjectGroup part;
//((part.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
return true;
}

View File

@ -26,6 +26,7 @@
*/
using System;
//using System.Collections.Generic;
using System.Timers;
using OpenMetaverse.Packets;
using OpenSim.Framework;
@ -189,7 +190,7 @@ namespace OpenSim.Region.Environment.Scenes
}
sb[0].StatID = (uint) Stats.TimeDilation;
sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
sb[1].StatID = (uint) Stats.SimFPS;
sb[1].StatValue = simfps/statsUpdateFactor;
@ -253,7 +254,7 @@ namespace OpenSim.Region.Environment.Scenes
SimStats simStats
= new SimStats(
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb);
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID);
handlerSendStatResult = OnSendStatsResult;
if (handlerSendStatResult != null)
@ -309,7 +310,11 @@ namespace OpenSim.Region.Environment.Scenes
public void SetChildAgents(int childAgents)
{
m_childAgents = childAgents;
m_childAgents = (childAgents > 0) ? childAgents : 0;
if (childAgents < 0)
{
//List<ScenePresence> avs= m_scene.GetScenePresences();
}
}
public void SetObjects(int objects)
@ -350,6 +355,7 @@ namespace OpenSim.Region.Environment.Scenes
public void AddunAckedBytes(int numBytes)
{
m_unAckedBytes += numBytes;
if (m_unAckedBytes < 0) m_unAckedBytes = 0;
}
public void addFrameMS(int ms)
@ -383,6 +389,7 @@ namespace OpenSim.Region.Environment.Scenes
public void addPendingDownload(int count)
{
m_pendingDownloads += count;
if (m_pendingDownloads < 0) m_pendingDownloads = 0;
//m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads);
}

View File

@ -0,0 +1,185 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Mono.Data.SqliteClient;
using OpenMetaverse;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Statistics;
namespace OpenSim.Region.UserStatistics
{
public class ActiveConnectionsAJAX : IStatsController
{
#region IStatsController Members
public Hashtable ProcessModel(Hashtable pParams)
{
List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
Hashtable nh = new Hashtable();
nh.Add("hdata", m_scene);
return nh;
}
public string RenderView(Hashtable pModelResult)
{
List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
StringBuilder output = new StringBuilder();
HTMLUtil.OL_O(ref output, "");
foreach (Scene scene in all_scenes)
{
List<ScenePresence> avatarInScene = scene.GetScenePresences();
HTMLUtil.LI_O(ref output, "");
output.Append(scene.RegionInfo.RegionName);
HTMLUtil.OL_O(ref output, "");
foreach (ScenePresence av in avatarInScene)
{
Dictionary<string,string> queues = new Dictionary<string, string>();
if (av.ControllingClient is IStatsCollector)
{
IStatsCollector isClient = (IStatsCollector) av.ControllingClient;
queues = decodeQueueReport(isClient.Report());
}
HTMLUtil.LI_O(ref output, "");
output.Append(av.Name);
output.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
output.Append((av.IsChildAgent ? "Child" : "Root"));
Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
HTMLUtil.UL_O(ref output, "");
foreach (string throttlename in throttles.Keys)
{
HTMLUtil.LI_O(ref output, "");
output.Append(throttlename);
output.Append(":");
output.Append(throttles[throttlename].ToString());
if (queues.ContainsKey(throttlename))
{
output.Append("/");
output.Append(queues[throttlename]);
}
HTMLUtil.LI_C(ref output);
}
if (queues.ContainsKey("Incoming") && queues.ContainsKey("Outgoing"))
{
HTMLUtil.LI_O(ref output, "red");
output.Append("SEND:");
output.Append(queues["Outgoing"]);
output.Append("/");
output.Append(queues["Incoming"]);
HTMLUtil.LI_C(ref output);
}
HTMLUtil.UL_C(ref output);
HTMLUtil.LI_C(ref output);
}
HTMLUtil.OL_C(ref output);
}
HTMLUtil.OL_C(ref output);
return output.ToString();
}
public Dictionary<string, int> DecodeClientThrottles(byte[] throttle)
{
Dictionary<string, int> returndict = new Dictionary<string, int>();
// From mantis http://opensimulator.org/mantis/view.php?id=1374
// it appears that sometimes we are receiving empty throttle byte arrays.
// TODO: Investigate this behaviour
if (throttle.Length == 0)
{
return new Dictionary<string, int>();
}
int tResend = -1;
int tLand = -1;
int tWind = -1;
int tCloud = -1;
int tTask = -1;
int tTexture = -1;
int tAsset = -1;
int tall = -1;
const int singlefloat = 4;
//Agent Throttle Block contains 7 single floatingpoint values.
int j = 0;
// Some Systems may be big endian...
// it might be smart to do this check more often...
if (!BitConverter.IsLittleEndian)
for (int i = 0; i < 7; i++)
Array.Reverse(throttle, j + i * singlefloat, singlefloat);
// values gotten from OpenMetaverse.org/wiki/Throttle. Thanks MW_
// bytes
// Convert to integer, since.. the full fp space isn't used.
tResend = (int)BitConverter.ToSingle(throttle, j);
returndict.Add("Resend", tResend);
j += singlefloat;
tLand = (int)BitConverter.ToSingle(throttle, j);
returndict.Add("Land", tLand);
j += singlefloat;
tWind = (int)BitConverter.ToSingle(throttle, j);
returndict.Add("Wind", tWind);
j += singlefloat;
tCloud = (int)BitConverter.ToSingle(throttle, j);
returndict.Add("Cloud", tCloud);
j += singlefloat;
tTask = (int)BitConverter.ToSingle(throttle, j);
returndict.Add("Task", tTask);
j += singlefloat;
tTexture = (int)BitConverter.ToSingle(throttle, j);
returndict.Add("Texture", tTexture);
j += singlefloat;
tAsset = (int)BitConverter.ToSingle(throttle, j);
returndict.Add("Asset", tAsset);
tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
returndict.Add("All", tall);
return returndict;
}
public Dictionary<string,string> decodeQueueReport(string rep)
{
Dictionary<string, string> returndic = new Dictionary<string, string>();
if (rep.Length == 79)
{
int pos = 1;
returndic.Add("All", rep.Substring((6 * pos), 8)); pos++;
returndic.Add("Incoming", rep.Substring((7 * pos), 8)); pos++;
returndic.Add("Outgoing", rep.Substring((7 * pos) , 8)); pos++;
returndic.Add("Resend", rep.Substring((7 * pos) , 8)); pos++;
returndic.Add("Land", rep.Substring((7 * pos) , 8)); pos++;
returndic.Add("Wind", rep.Substring((7 * pos) , 8)); pos++;
returndic.Add("Cloud", rep.Substring((7 * pos) , 8)); pos++;
returndic.Add("Task", rep.Substring((7 * pos) , 8)); pos++;
returndic.Add("Texture", rep.Substring((7 * pos), 8)); pos++;
returndic.Add("Asset", rep.Substring((7 * pos), 8));
/*
* return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
SendQueue.Count(),
IncomingPacketQueue.Count,
OutgoingPacketQueue.Count,
ResendOutgoingPacketQueue.Count,
LandOutgoingPacketQueue.Count,
WindOutgoingPacketQueue.Count,
CloudOutgoingPacketQueue.Count,
TaskOutgoingPacketQueue.Count,
TextureOutgoingPacketQueue.Count,
AssetOutgoingPacketQueue.Count);
*/
}
return returndic;
}
#endregion
}
}

View File

@ -0,0 +1,215 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Mono.Data.SqliteClient;
using OpenMetaverse;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Statistics;
namespace OpenSim.Region.UserStatistics
{
public class Default_Report : IStatsController
{
public Default_Report()
{
}
#region IStatsController Members
public Hashtable ProcessModel(Hashtable pParams)
{
SqliteConnection conn = (SqliteConnection)pParams["DatabaseConnection"];
List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
stats_default_page_values mData = rep_DefaultReport_data(conn, m_scene);
mData.sim_stat_data = (Dictionary<UUID,USimStatsData>)pParams["SimStats"];
Hashtable nh = new Hashtable();
nh.Add("hdata", mData);
return nh;
}
public string RenderView(Hashtable pModelResult)
{
stats_default_page_values mData = (stats_default_page_values) pModelResult["hdata"];
return rep_Default_report_view(mData);
}
#endregion
public string rep_Default_report_view(stats_default_page_values values)
{
StringBuilder output = new StringBuilder();
const string TableClass = "defaultr";
const string TRClass = "defaultr";
const string TDHeaderClass = "header";
const string TDDataClass = "content";
//const string TDDataClassRight = "contentright";
const string TDDataClassCenter = "contentcenter";
const string STYLESHEET =
@"
<STYLE>
body
{
font-size:15px; font-family:Helvetica, Verdana; color:Black;
}
TABLE.defaultr { }
TR.defaultr { padding: 5px; }
TD.header { font-weight:bold; padding:5px; }
TD.content {}
TD.contentright { text-align: right; }
TD.contentcenter { text-align: center; }
TD.align_top { vertical-align: top; }
</STYLE>
";
HTMLUtil.HtmlHeaders_O(ref output);
HTMLUtil.InsertProtoTypeAJAX(ref output);
string[] ajaxUpdaterDivs = new string[2];
int[] ajaxUpdaterSeconds = new int[2];
string[] ajaxUpdaterReportFragments = new string[2];
ajaxUpdaterDivs[0] = "activeconnections";
ajaxUpdaterSeconds[0] = 10;
ajaxUpdaterReportFragments[0] = "activeconnectionsajax.ajax";
ajaxUpdaterDivs[1] = "activesimstats";
ajaxUpdaterSeconds[1] = 20;
ajaxUpdaterReportFragments[1] = "simstatsajax.ajax";
HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);
output.Append(STYLESHEET);
HTMLUtil.HtmlHeaders_C(ref output);
HTMLUtil.TABLE_O(ref output, TableClass);
HTMLUtil.TR_O(ref output, TRClass);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("# Users Total");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("# Sessions Total");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("Avg Client FPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("Avg Client Mem Use");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("Avg Sim FPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("Avg Ping");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("KB Out Total");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("KB In Total");
HTMLUtil.TD_C(ref output);
HTMLUtil.TR_C(ref output);
HTMLUtil.TR_O(ref output, TRClass);
HTMLUtil.TD_O(ref output, TDDataClass);
output.Append(values.total_num_users);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClass);
output.Append(values.total_num_sessions);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(values.avg_client_fps);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(values.avg_client_mem_use);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(values.avg_sim_fps);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(values.avg_ping);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(values.total_kb_out);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(values.total_kb_in);
HTMLUtil.TD_C(ref output);
HTMLUtil.TR_C(ref output);
HTMLUtil.TABLE_C(ref output);
HTMLUtil.HR(ref output, "");
HTMLUtil.TABLE_O(ref output, "");
HTMLUtil.TR_O(ref output, "");
HTMLUtil.TD_O(ref output, "align_top");
output.Append("<DIV id=\"activeconnections\">loading...</DIV>");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, "align_top");
output.Append("<DIV id=\"activesimstats\">loading...</DIV>");
HTMLUtil.TD_C(ref output);
HTMLUtil.TR_C(ref output);
HTMLUtil.TABLE_C(ref output);
output.Append("</BODY></HTML>");
// TODO: FIXME: template
return output.ToString();
}
public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene)
{
stats_default_page_values returnstruct = new stats_default_page_values();
returnstruct.all_scenes = m_scene.ToArray();
lock (db)
{
string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps,
AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb,
SUM(n_out_pk) as num_in_packets, SUM(n_in_kb) as num_out_kb, SUM(n_in_pk) as num_out_packets, AVG(mem_use) as sav_mem_use
FROM stats_session_data;";
SqliteCommand cmd = new SqliteCommand(SQL, db);
SqliteDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
sdr.Read();
returnstruct.total_num_users = Convert.ToInt32(sdr["agents"]);
returnstruct.total_num_sessions = Convert.ToInt32(sdr["sessions"]);
returnstruct.avg_client_fps = Convert.ToSingle(sdr["client_fps"]);
returnstruct.avg_sim_fps = Convert.ToSingle(sdr["savg_sim_fps"]);
returnstruct.avg_ping = Convert.ToSingle(sdr["sav_ping"]);
returnstruct.total_kb_out = Convert.ToSingle(sdr["num_out_kb"]);
returnstruct.total_kb_in = Convert.ToSingle(sdr["num_in_kb"]);
returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
}
}
return returnstruct;
}
}
public struct stats_default_page_values
{
public int total_num_users;
public int total_num_sessions;
public float avg_client_fps;
public float avg_client_mem_use;
public float avg_sim_fps;
public float avg_ping;
public float total_kb_out;
public float total_kb_in;
public float avg_client_resends;
public Scene[] all_scenes;
public Dictionary<UUID, USimStatsData> sim_stat_data;
}
}

View File

@ -0,0 +1,185 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.UserStatistics
{
public static class HTMLUtil
{
public static void TR_O(ref StringBuilder o, string pclass)
{
o.Append("<tr");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(">\n\t");
}
public static void TR_C(ref StringBuilder o)
{
o.Append("</tr>\n");
}
public static void TD_O(ref StringBuilder o, string pclass)
{
o.Append("<td");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(">");
}
public static void TD_C(ref StringBuilder o)
{
o.Append("</td>");
}
public static void TABLE_O(ref StringBuilder o, string pclass)
{
o.Append("<table");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(">\n\t");
}
public static void TABLE_C(ref StringBuilder o)
{
o.Append("</table>\n");
}
public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass)
{
o.Append("<blockquote");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(" />\n");
}
public static void BLOCKQUOTE_C(ref StringBuilder o)
{
o.Append("</blockquote>\n");
}
public static void BR(ref StringBuilder o)
{
o.Append("<br />\n");
}
public static void HR(ref StringBuilder o, string pclass)
{
o.Append("<hr");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(" />\n");
}
public static void UL_O(ref StringBuilder o, string pclass)
{
o.Append("<ul");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(" />\n");
}
public static void UL_C(ref StringBuilder o)
{
o.Append("</ul>\n");
}
public static void OL_O(ref StringBuilder o, string pclass)
{
o.Append("<ol");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(" />\n");
}
public static void OL_C(ref StringBuilder o)
{
o.Append("</ol>\n");
}
public static void LI_O(ref StringBuilder o, string pclass)
{
o.Append("<li");
if (pclass.Length > 0)
{
GenericClass(ref o, pclass);
}
o.Append(" />\n");
}
public static void LI_C(ref StringBuilder o)
{
o.Append("</li>\n");
}
public static void GenericClass(ref StringBuilder o, string pclass)
{
o.Append(" class=\"");
o.Append(pclass);
o.Append("\"");
}
public static void InsertProtoTypeAJAX(ref StringBuilder o)
{
o.Append("<script type=\"text/javascript\" src=\"prototype.js\"></script>\n");
o.Append("<script type=\"text/javascript\" src=\"updater.js\"></script>\n");
}
public static void InsertPeriodicUpdaters(ref StringBuilder o, string[] divID, int[] seconds, string[] reportfrag)
{
o.Append("<script type=\"text/javascript\">\n");
o.Append(
@"
// <![CDATA[
document.observe('dom:loaded', function() {
/*
first arg : div to update
second arg : interval to poll in seconds
third arg : file to get data
*/
");
for (int i = 0; i < divID.Length; i++)
{
o.Append("new updater('");
o.Append(divID[i]);
o.Append("', ");
o.Append(seconds[i]);
o.Append(", '");
o.Append(reportfrag[i]);
o.Append("');\n");
}
o.Append(@"
});
// ]]>
</script>");
}
public static void HtmlHeaders_O ( ref StringBuilder o)
{
o.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
o.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"nl\">");
o.Append("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");
}
public static void HtmlHeaders_C ( ref StringBuilder o)
{
o.Append("</HEAD>");
o.Append("<BODY>");
}
}
}

View File

@ -0,0 +1,10 @@
using System.Collections;
namespace OpenSim.Region.UserStatistics
{
public interface IStatsController
{
Hashtable ProcessModel(Hashtable pParams);
string RenderView(Hashtable pModelResult);
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
namespace OpenSim.Region.UserStatistics
{
public class Prototype_distributor : IStatsController
{
private string prototypejs=string.Empty;
public Hashtable ProcessModel(Hashtable pParams)
{
Hashtable pResult = new Hashtable();
if (prototypejs.Length == 0)
{
StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open));
prototypejs = fs.ReadToEnd();
}
pResult["js"] = prototypejs;
return pResult;
}
public string RenderView(Hashtable pModelResult)
{
return pModelResult["js"].ToString();
}
}
}

View File

@ -0,0 +1,190 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Mono.Data.SqliteClient;
using OpenMetaverse;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Statistics;
namespace OpenSim.Region.UserStatistics
{
public class SimStatsAJAX : IStatsController
{
#region IStatsController Members
public Hashtable ProcessModel(Hashtable pParams)
{
List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
Hashtable nh = new Hashtable();
nh.Add("hdata", m_scene);
nh.Add("simstats", pParams["SimStats"]);
return nh;
}
public string RenderView(Hashtable pModelResult)
{
StringBuilder output = new StringBuilder();
List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];
Dictionary<UUID, USimStatsData> sdatadic = (Dictionary<UUID,USimStatsData>)pModelResult["simstats"];
const string TableClass = "defaultr";
const string TRClass = "defaultr";
const string TDHeaderClass = "header";
const string TDDataClass = "content";
//const string TDDataClassRight = "contentright";
const string TDDataClassCenter = "contentcenter";
foreach (USimStatsData sdata in sdatadic.Values)
{
foreach (Scene sn in all_scenes)
{
if (sn.RegionInfo.RegionID == sdata.RegionId)
{
output.Append("<H2>");
output.Append(sn.RegionInfo.RegionName);
output.Append("</H2>");
}
}
HTMLUtil.TABLE_O(ref output, TableClass);
HTMLUtil.TR_O(ref output, TRClass);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("Dilatn");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("SimFPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("PhysFPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("AgntUp");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("RootAg");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("ChldAg");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("Prims");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("ATvPrm");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("AtvScr");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("ScrLPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TR_C(ref output);
HTMLUtil.TR_O(ref output, TRClass);
HTMLUtil.TD_O(ref output, TDDataClass);
output.Append(sdata.TimeDilation);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClass);
output.Append(sdata.SimFps);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.PhysicsFps);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.AgentUpdates);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.RootAgents);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.ChildAgents);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.TotalPrims);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.ActivePrims);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.ActiveScripts);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.ScriptLinesPerSecond);
HTMLUtil.TD_C(ref output);
HTMLUtil.TR_C(ref output);
HTMLUtil.TR_O(ref output, TRClass);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("FrmMS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("AgtMS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("PhysMS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("OthrMS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("ScrLPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("OutPPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("InPPS");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("NoAckKB");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("PndDWN");
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDHeaderClass);
output.Append("PndUP");
HTMLUtil.TD_C(ref output);
HTMLUtil.TR_C(ref output);
HTMLUtil.TR_O(ref output, TRClass);
HTMLUtil.TD_O(ref output, TDDataClass);
output.Append(sdata.TotalFrameTime);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClass);
output.Append(sdata.AgentFrameTime);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.PhysicsFrameTime);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.OtherFrameTime);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.ScriptLinesPerSecond);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.OutPacketsPerSecond);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.InPacketsPerSecond);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.UnackedBytes);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.PendingDownloads);
HTMLUtil.TD_C(ref output);
HTMLUtil.TD_O(ref output, TDDataClassCenter);
output.Append(sdata.PendingUploads);
HTMLUtil.TD_C(ref output);
HTMLUtil.TR_C(ref output);
HTMLUtil.TABLE_C(ref output);
}
return output.ToString();
}
#endregion
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
namespace OpenSim.Region.UserStatistics
{
public class Updater_distributor : IStatsController
{
private string updaterjs = string.Empty;
public Hashtable ProcessModel(Hashtable pParams)
{
Hashtable pResult = new Hashtable();
if (updaterjs.Length == 0)
{
StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/updater.js", FileMode.Open));
updaterjs = fs.ReadToEnd();
fs.Close();
fs.Dispose();
}
pResult["js"] = updaterjs;
return pResult;
}
public string RenderView(Hashtable pModelResult)
{
return pModelResult["js"].ToString();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
Copyright (c) 2005-2008 Sam Stephenson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

4222
bin/data/prototype.js vendored Normal file

File diff suppressed because it is too large Load Diff

20
bin/data/updater.js Normal file
View File

@ -0,0 +1,20 @@
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);
}
});

View File

@ -2267,6 +2267,54 @@
</Match>
</Files>
</Project>
<Project name="OpenSim.Region.UserStatistics" path="OpenSim/Region/UserStatistics" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System" localCopy="false"/>
<Reference name="System.Data"/>
<Reference name="System.Xml"/>
<Reference name="System.Drawing"/>
<Reference name="System.Runtime.Remoting"/>
<Reference name="System.Web"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Data" />
<Reference name="OpenSim.Region.Interfaces" />
<Reference name="OpenSim.Region.Environment" />
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Grid.AssetServer"/>
<Reference name="Mono.Data.SqliteClient"/>
<!-- For scripting in funny languages by default -->
<Reference name="Microsoft.JScript"/>
<Reference name="XMLRPC.dll"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Data.Base"/>
<Reference name="Nini.dll" />
<Reference name="log4net.dll"/>
<Reference name="DotNetOpenMail.dll"/>
<Files>
<Match pattern="*.cs" recurse="true">
<Exclude name="Tests" pattern="Tests" />
</Match>
</Files>
</Project>
<!-- Tools -->