diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 139 |
1 files changed, 95 insertions, 44 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 12e1a78..f11987e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -26,14 +26,15 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
30 | using System.Threading; | ||
31 | using System.Collections; | 29 | using System.Collections; |
32 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Globalization; | ||
32 | using System.IO; | ||
33 | using System.Reflection; | ||
33 | using System.Security; | 34 | using System.Security; |
34 | using System.Security.Policy; | 35 | using System.Security.Policy; |
35 | using System.Reflection; | 36 | using System.Text; |
36 | using System.Globalization; | 37 | using System.Threading; |
37 | using System.Xml; | 38 | using System.Xml; |
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | using OpenMetaverse.StructuredData; | 40 | using OpenMetaverse.StructuredData; |
@@ -273,11 +274,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
273 | } | 274 | } |
274 | 275 | ||
275 | MainConsole.Instance.Commands.AddCommand( | 276 | MainConsole.Instance.Commands.AddCommand( |
276 | "scripts", false, "scripts show", "scripts show", "Show script information", | 277 | "scripts", false, "xengine status", "xengine status", "Show status information", |
277 | "Show information on all scripts known to the script engine", HandleShowScripts); | 278 | "Show status information on the script engine.", |
279 | HandleShowStatus); | ||
280 | |||
281 | MainConsole.Instance.Commands.AddCommand( | ||
282 | "scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information", | ||
283 | "Show information on all scripts known to the script engine." | ||
284 | + "If a <script-item-uuid> is given then only information on that script will be shown.", | ||
285 | HandleShowScripts); | ||
278 | 286 | ||
279 | MainConsole.Instance.Commands.AddCommand( | 287 | MainConsole.Instance.Commands.AddCommand( |
280 | "scripts", false, "show scripts", "show scripts", "Show script information", | 288 | "scripts", false, "show scripts", "show scripts [<script-item-uuid>]", "Show script information", |
281 | "Synonym for scripts show command", HandleShowScripts); | 289 | "Synonym for scripts show command", HandleShowScripts); |
282 | 290 | ||
283 | MainConsole.Instance.Commands.AddCommand( | 291 | MainConsole.Instance.Commands.AddCommand( |
@@ -308,43 +316,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
308 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); | 316 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); |
309 | } | 317 | } |
310 | 318 | ||
311 | public void HandleShowScripts(string module, string[] cmdparams) | ||
312 | { | ||
313 | lock (m_Scripts) | ||
314 | { | ||
315 | MainConsole.Instance.OutputFormat( | ||
316 | "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); | ||
317 | |||
318 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
319 | { | ||
320 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); | ||
321 | string status; | ||
322 | |||
323 | if (instance.ShuttingDown) | ||
324 | { | ||
325 | status = "shutting down"; | ||
326 | } | ||
327 | else if (instance.Suspended) | ||
328 | { | ||
329 | status = "suspended"; | ||
330 | } | ||
331 | else if (!instance.Running) | ||
332 | { | ||
333 | status = "stopped"; | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | status = "running"; | ||
338 | } | ||
339 | |||
340 | MainConsole.Instance.OutputFormat( | ||
341 | "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", | ||
342 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, | ||
343 | sop.AbsolutePosition, status); | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | |||
348 | /// <summary> | 319 | /// <summary> |
349 | /// Parse the raw item id into a script instance from the command params if it's present. | 320 | /// Parse the raw item id into a script instance from the command params if it's present. |
350 | /// </summary> | 321 | /// </summary> |
@@ -353,6 +324,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
353 | /// <returns>true if we're okay to proceed, false if not.</returns> | 324 | /// <returns>true if we're okay to proceed, false if not.</returns> |
354 | private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) | 325 | private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) |
355 | { | 326 | { |
327 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) | ||
328 | return; | ||
329 | |||
356 | lock (m_Scripts) | 330 | lock (m_Scripts) |
357 | { | 331 | { |
358 | string rawItemId; | 332 | string rawItemId; |
@@ -394,6 +368,83 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
394 | } | 368 | } |
395 | } | 369 | } |
396 | 370 | ||
371 | private void HandleShowStatus(string module, string[] cmdparams) | ||
372 | { | ||
373 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) | ||
374 | return; | ||
375 | |||
376 | StringBuilder sb = new StringBuilder(); | ||
377 | sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); | ||
378 | |||
379 | lock (m_Scripts) | ||
380 | sb.AppendFormat("Scripts loaded : {0}\n", m_Scripts.Count); | ||
381 | |||
382 | sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); | ||
383 | sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); | ||
384 | sb.AppendFormat("Allocated threads : {0}\n", m_ThreadPool.ActiveThreads); | ||
385 | sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); | ||
386 | sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); | ||
387 | // sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); | ||
388 | |||
389 | MainConsole.Instance.OutputFormat(sb.ToString()); | ||
390 | } | ||
391 | |||
392 | public void HandleShowScripts(string module, string[] cmdparams) | ||
393 | { | ||
394 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) | ||
395 | return; | ||
396 | |||
397 | if (cmdparams.Length == 2) | ||
398 | { | ||
399 | lock (m_Scripts) | ||
400 | { | ||
401 | MainConsole.Instance.OutputFormat( | ||
402 | "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); | ||
403 | } | ||
404 | } | ||
405 | |||
406 | HandleScriptsAction(cmdparams, HandleShowScript); | ||
407 | } | ||
408 | |||
409 | private void HandleShowScript(IScriptInstance instance) | ||
410 | { | ||
411 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); | ||
412 | string status; | ||
413 | |||
414 | if (instance.ShuttingDown) | ||
415 | { | ||
416 | status = "shutting down"; | ||
417 | } | ||
418 | else if (instance.Suspended) | ||
419 | { | ||
420 | status = "suspended"; | ||
421 | } | ||
422 | else if (!instance.Running) | ||
423 | { | ||
424 | status = "stopped"; | ||
425 | } | ||
426 | else | ||
427 | { | ||
428 | status = "running"; | ||
429 | } | ||
430 | |||
431 | StringBuilder sb = new StringBuilder(); | ||
432 | Queue eq = instance.EventQueue; | ||
433 | |||
434 | sb.AppendFormat("Script name : {0}\n", instance.ScriptName); | ||
435 | sb.AppendFormat("Status : {0}\n", status); | ||
436 | |||
437 | lock (eq) | ||
438 | sb.AppendFormat("Queued events : {0}\n", eq.Count); | ||
439 | |||
440 | sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); | ||
441 | sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); | ||
442 | sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); | ||
443 | sb.AppendFormat("Position : {0}\n", sop.AbsolutePosition); | ||
444 | |||
445 | MainConsole.Instance.OutputFormat(sb.ToString()); | ||
446 | } | ||
447 | |||
397 | private void HandleSuspendScript(IScriptInstance instance) | 448 | private void HandleSuspendScript(IScriptInstance instance) |
398 | { | 449 | { |
399 | if (!instance.Suspended) | 450 | if (!instance.Suspended) |