Add a method to IStatsCollector for returning stats as an OSDMap.

Extend implementors of IStatsCollector to return an OSDMap of stats.
Update UserStatsCollector and AssetStatsCollector to return both
string and OSDMap data (as well as console format).
0.7.4-extended
Robert Adams 2013-02-20 14:11:02 -08:00 committed by Justin Clark-Casey (justincc)
parent a46b02a3ae
commit dee74834be
6 changed files with 82 additions and 4 deletions

View File

@ -28,6 +28,8 @@
using System;
using System.Timers;
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework.Monitoring
{
/// <summary>
@ -100,5 +102,29 @@ Asset requests yesterday : {3} ({4} per hour) of which {5} were not found",
AssetRequestsToday, assetRequestsTodayPerHour, AssetRequestsNotFoundToday,
AssetRequestsYesterday, assetRequestsYesterdayPerHour, AssetRequestsNotFoundYesterday);
}
public override string XReport(string uptime, string version)
{
return OSDParser.SerializeJsonString(OReport(uptime, version));
}
public override OSDMap OReport(string uptime, string version)
{
double elapsedHours = (DateTime.Now - startTime).TotalHours;
if (elapsedHours <= 0) { elapsedHours = 1; } // prevent divide by zero
long assetRequestsTodayPerHour = (long)Math.Round(AssetRequestsToday / elapsedHours);
long assetRequestsYesterdayPerHour = (long)Math.Round(AssetRequestsYesterday / 24.0);
OSDMap ret = new OSDMap();
ret.Add("AssetRequestsToday", OSD.FromLong(AssetRequestsToday));
ret.Add("AssetRequestsTodayPerHour", OSD.FromLong(assetRequestsTodayPerHour));
ret.Add("AssetRequestsNotFoundToday", OSD.FromLong(AssetRequestsNotFoundToday));
ret.Add("AssetRequestsYesterday", OSD.FromLong(AssetRequestsYesterday));
ret.Add("AssetRequestsYesterdayPerHour", OSD.FromLong(assetRequestsYesterdayPerHour));
ret.Add("AssetRequestsNotFoundYesterday", OSD.FromLong(assetRequestsNotFoundYesterday));
return ret;
}
}
}

View File

@ -67,5 +67,12 @@ namespace OpenSim.Framework.Monitoring
{
return (string) Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0).ToString() ;
}
public virtual OSDMap OReport(string uptime, string version)
{
OSDMap ret = new OSDMap();
ret.Add("TotalMemory", new OSDReal(Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)));
return ret;
}
}
}

View File

@ -25,6 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework.Monitoring
{
/// <summary>
@ -45,5 +47,12 @@ namespace OpenSim.Framework.Monitoring
/// A <see cref="System.String"/>
/// </returns>
string XReport(string uptime, string version);
/// <summary>
/// Report back collected statistical information as an OSDMap of key/values
/// </summary>
/// <returns>
/// </returns>
OSDMap OReport(string uptime, string version);
}
}

View File

@ -404,6 +404,15 @@ Asset service request failures: {3}" + Environment.NewLine,
/// </summary>
/// <returns></returns>
public override string XReport(string uptime, string version)
{
return OSDParser.SerializeJsonString(OReport(uptime, version));
}
/// <summary>
/// Report back collected statistical information as an OSDMap
/// </summary>
/// <returns></returns>
public override OSDMap OReport(string uptime, string version)
{
OSDMap args = new OSDMap(30);
// args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache));
@ -442,12 +451,10 @@ Asset service request failures: {3}" + Environment.NewLine,
args["Uptime"] = OSD.FromString (uptime);
args["Version"] = OSD.FromString (version);
string strBuffer = "";
strBuffer = OSDParser.SerializeJsonString(args);
return args;
}
}
return strBuffer;
}
}
/// <summary>
/// Pull packet queue stats from packet queues and report
@ -474,5 +481,11 @@ Asset service request failures: {3}" + Environment.NewLine,
{
return "";
}
public OSDMap OReport(string uptime, string version)
{
OSDMap ret = new OSDMap();
return ret;
}
}
}

View File

@ -27,6 +27,8 @@
using System.Timers;
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework.Monitoring
{
/// <summary>
@ -88,5 +90,21 @@ namespace OpenSim.Framework.Monitoring
Logouts total : {3}",
SuccessfulLogins, SuccessfulLoginsToday, SuccessfulLoginsYesterday, Logouts);
}
public override string XReport(string uptime, string version)
{
return OSDParser.SerializeJsonString(OReport(uptime, version));
}
public override OSDMap OReport(string uptime, string version)
{
OSDMap ret = new OSDMap();
ret.Add("SuccessfulLogins", OSD.FromInteger(SuccessfulLogins));
ret.Add("SuccessfulLoginsToday", OSD.FromInteger(SuccessfulLoginsToday));
ret.Add("SuccessfulLoginsYesterday", OSD.FromInteger(SuccessfulLoginsYesterday));
ret.Add("Logouts", OSD.FromInteger(Logouts));
return ret;
}
}
}

View File

@ -12084,6 +12084,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return String.Empty;
}
public OSDMap OReport(string uptime, string version)
{
return new OSDMap();
}
/// <summary>
/// Make an asset request to the asset service in response to a client request.
/// </summary>