Project

General

Profile

Script to access Tigase statistics

Igor Khomenko
Added over 4 years ago

Is it possible to write a script which gets Tigase statistics ?

like:

  • PresencesNumber

  • MessagesNumber

and maybe other parameters


Replies (9)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

Yes, but there are many ways to get these metrics. Please tell us how you want to retrieve these metrics. Possible options are:

  1. Write a simple, command line client (maybe tclmt can do it already?) that connects via XMPP and retrieves metrics

  2. Simple command line tool which connects via JMX and downloads metrics - this would be the easiest and more flexible, so this is my top recommendation

  3. You can dump Tigase's metric to a text file from within Tigase at given time intervals

  4. You can dump Tigase's metrics to a DB at given time intervals

I guess, there are other ways too..... Let me know which one you would like to use and I can give you more details.

I am attaching StatsDumper.groovy script which has been already attached hundreds of times to the forums. It connects to Tigase via JMX and dumps Tigase stats to a text file. It would be very easy to adjust the script for custom needs.

Added by Igor Khomenko over 4 years ago

Thanks,

I'm thinking about unified HTTP API for system administrator, so admin can manage all Chat things

and one of them is retrieving statistics via HTTP API

As I understand from your answer, I can write custom HTTP API script and incorporate the stats dumper inside it. Will it work this way?

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

REST/HTTP API is already available and I think retrieving statistics is possible out of the box. Basically all the admin ad-hoc commands normally executable over XMPP can be also executed over HTTP API (REST API). We are also working on the kind of HTTP front-end for administrator for the coming version.

Added by Igor Khomenko over 4 years ago

Yes, it supports lots of commands http://xmpp.org/extensions/xep-0133.html

like

  • Get Number of Online Users

  • Get Number of Active Users

but no info about

  • PresencesNumber

  • MessagesNumber

Added by Wojciech Kapcia TigaseTeam over 4 years ago

When using the REST component (tigase-http-api) you can query the statistics component (above commands are from session manager, stats has it own commands) which can provide you more detailed statistics.

Added by Igor Khomenko over 4 years ago

How to retrieve a list of available stats command?

Should I use something like this?

http://tigasestage.mycompany.com:8080/rest/adhoc/stats@tigasestage.mycompany.com

It returns me just an empty array

{
  "items": [

  ]
}

Added by Wojciech Kapcia TigaseTeam over 4 years ago

You simply send:

<command>
  <node>stats</node>
  <fields>
    <item>
      <var>Stats level</var>
      <value>FINEST</value>
    </item>
  </fields>
</command>

to the above URI. You can control amount of information by adjusting level (Java logger levels are used).

Added by Igor Khomenko over 4 years ago

Not sure which url I should use

this

http://tigasestage.mycompany.com:8080/rest/adhoc/stats@tigasestage.mycompany.com

or

http://tigasestage.mycompany.com:8080/rest/adhoc/sess-man@tigasestage.mycompany.com

but both return 500 Server Error and next log

2014-09-30 19:32:02.243 [qtp654082169-64]  java_util_logging_Logger$log.call()  SEVERE: exception processing request
groovy.lang.MissingPropertyException: No such property: command for class: org.eclipse.jetty.server.Request
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
    at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
    at tigase.rest.adhoc.AdHocHandler$_closure2.doCall(AdHoc.groovy:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at org.codehaus.groovy.runtime.metaclass.TransformMetaMethod.invoke(TransformMetaMethod.java:55)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass$1.invoke(ClosureMetaClass.java:259)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at tigase.http.rest.RestSerlvet.execute(RestServlet.groovy:281)
    at tigase.http.rest.RestSerlvet$execute.callCurrent(Unknown Source)
    at tigase.http.rest.RestSerlvet.executeAsync(RestServlet.groovy:174)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:361)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
    at tigase.http.rest.RestSerlvet$_processRequest_closure3.doCall(RestServlet.groovy:143)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at groovy.lang.Closure.call(Closure.java:411)
    at groovy.lang.Closure.call(Closure.java:427)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1326)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1298)
    at org.codehaus.groovy.runtime.dgm$148.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at tigase.http.rest.RestSerlvet.processRequest(RestServlet.groovy:116)
    at tigase.http.rest.RestSerlvet$processRequest.callCurrent(Unknown Source)
    at tigase.http.rest.RestSerlvet.service(RestServlet.groovy:79)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1077)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:368)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:488)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:943)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1004)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:744)

Added by Wojciech Kapcia TigaseTeam over 4 years ago

It should be:

http://tigasestage.mycompany.com:8088/rest/adhoc/stats@tigasestage.mycompany.com

Which version do you use? I've checked it on the latest snapshot and it works without a problem. There were some changes to the REST component a few weeks ago.

    (1-9/9)