123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.IO;
- using System.Net;
- using System.Reflection;
- using System.Text;
- using log4net;
- using Nini.Config;
- using OpenMetaverse;
- using OpenMetaverse.StructuredData;
- using OpenSim.Framework;
- using OpenSim.Framework.Communications;
- using OpenSim.Framework.Communications.Services;
- using OpenSim.Framework.Communications.Cache;
- using OpenSim.Framework.Console;
- using OpenSim.Framework.Servers;
- using OpenSim.Framework.Servers.HttpServer;
- using OpenSim.Framework.Statistics;
- using OpenSim.Region.Framework;
- using OpenSim.Region.Framework.Interfaces;
- using OpenSim.Region.Framework.Scenes;
- namespace OpenSim.Region.Framework.Scenes
- {
-
-
- public class RegionStatsHandler : IStreamedRequestHandler
- {
- private string osRXStatsURI = String.Empty;
- private string osXStatsURI = String.Empty;
-
- private OpenSim.Framework.RegionInfo regionInfo;
- public string localZone = TimeZone.CurrentTimeZone.StandardName;
- public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
-
-
- public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info)
- {
- regionInfo = region_info;
- osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
- osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
-
- }
-
- public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
- {
- return Encoding.UTF8.GetBytes(Report());
- }
- public string ContentType
- {
- get { return "text/plain"; }
- }
- public string HttpMethod
- {
- get { return "GET"; }
- }
- public string Path
- {
-
- get { return "/" + osRXStatsURI + "/"; }
- }
-
- private string Report()
- {
- OSDMap args = new OSDMap(30);
-
- args["OSStatsURI"] = OSD.FromString("http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "/" + osXStatsURI + "/");
- args["TimeZoneName"] = OSD.FromString(localZone);
- args["TimeZoneOffs"] = OSD.FromReal(utcOffset.TotalHours);
- args["UxTime"] = OSD.FromInteger(Util.ToUnixTime(DateTime.Now));
- args["Memory"] = OSD.FromReal(Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
- args["Version"] = OSD.FromString(VersionInfo.Version);
-
- string strBuffer = "";
- strBuffer = OSDParser.SerializeJsonString(args);
- return strBuffer;
-
- }
- }
- }
|