Project

General

Profile

How to get server statistics?

Keren Meir
Added over 5 years ago

Hi,

In the link: http://www.tigase.org/content/component-implementation-lesson-5-statistics

I see that I can get statistics for every component I want. But the question is:

How do I get those statistics? for example, I want to know how many presence the user sets. I saw that there is a groovy script which I can get users-stats by the node: http://jabber.org/protocol/admin#user-stats

The only stats I got is number of packet:

@

There is 1 active user's user1@mydomain.com sessions, packets: 11

user connections:

Connections: user_jid=user1@mydomain.com/Try, packets=13, connectionId=c2s@isr021732703.aaa.aaa.com/127.0.0.1_5222_127.0.0.1_62426, domain=mydomain.com, authState=AUTHORIZED, isAnon=false###

@

Thanks for the help


Replies (20)

Added by Wojciech Kapcia TigaseTeam over 5 years ago

Please see following documens:

If you want to access those statistics via XMPP and adhoc commands then execute those for the node stats and jid stats@domain

<iq type="set" to="stats@domain" id="stats-1">
<command xmlns="http://jabber.org/protocol/commands" node="stats"/>
</iq>

Added by Steffen Larsen over 5 years ago

Sorry for interrupting, but what about statistics from the the HTTP (REST) interface? is that possible?

Right now I can't compile the component and use it, but that is a another issue. :-)

Added by Wojciech Kapcia TigaseTeam over 5 years ago

Do you want statistics related to REST component or to access them through REST? The latter is possible as you can access any ad-hoc through rest. As for particular statistics for the component - what would you be interested most?

You can grab REST component either from maven repository or latest nightly :)

Added by Steffen Larsen over 5 years ago

Hi,

I actually meant ad-hoc queries statistics through REST. So cool that it seems to work.

I've downloaded the jar from the repo, but the jar does not contain all the runtime dependencies (and nor should it).

I would like to build it my self, but it seems like your pom can't download the tigase-server 5.2 even though it is in the repo in the pom.xml??

I keep getting:

@

[ERROR] Failed to execute goal on project tigase-http-api: Could not resolve dependencies for project tigase:tigase-http-api:bundle:1.0.0-SNAPSHOT: Failed to collect dependencies for [org.osgi:org.osgi.core:jar:4.1.0 (compile), org.eclipse.jetty:jetty-server:jar:8.1.9.v20130131 (compile), org.codehaus.groovy:groovy-all:jar:2.1.0 (compile), javax.servlet:servlet-api:jar:2.5 (compile), tigase:tigase-server:jar:5.2.0-SNAPSHOT (compile), org.eclipse.jetty:jetty-servlet:jar:8.1.9.v20130131 (compile)]: Failed to read artifact descriptor for tigase:tigase-server:jar:5.2.0-SNAPSHOT: Failure to find tigase:tigase-server-master:pom:5.2.0-SNAPSHOT in http://maven.tigase.org was cached in the local repository, resolution will not be reattempted until the update interval of tigase has elapsed or updates are forced -> [Help 1]

@

BTW: You are including tigase-server 5.2 in the pom as a compile target, should it not be "provided" instead? It gets injected into the tigase server anyways.

/Steffen

Added by Keren Meir over 5 years ago

Steffen,

I tried to compile to REST component 2 weeks ago. After a lot of JARs on the way, it works!

The main problem was JAR's versions, I can give you a list of jars with their version, check it out if it works.

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 5 years ago

Hm, this is not good. Maven should pull all required libraries in correct versions automatically. Thank you for letting me know about the problem. We will look at it.

Added by Steffen Larsen over 5 years ago

No, indeed not good.

A good starting point for investigating is to:

  • remove your .m2/repository/tigase/... (you can have something locally that makes your build)

  • to look through your .m2/settings.xml file (you can have a repo or something there, that the public doesn't)

-Cheers!

/Steffen

Added by Wojciech Kapcia TigaseTeam over 5 years ago

Hi,

I've deployed missing artifacts and it should work now - please confirm.

Added by Steffen Larsen over 5 years ago

Super!, It worked out fine.

Added by Steffen Larsen over 5 years ago

Compilation went fine, but.

you should really include and embed all depending jars in the taget jar file.

When I deploy the tigase-http-api in the tigase server I get:

java.lang.ClassNotFoundException: org.eclipse.jetty.security.LoginService

You can do this quite easilly in the pom.xml, but using the maven-assembly-plugin:

    <plugins>

        <plugin>

            <artifactId>maven-assembly-plugin</artifactId>

            <version>2.4</version>

            <executions>

                <execution>

                    <id>make-assembly</id>

                    <phase>package</phase>

                    <goals>

                        <goal>single</goal>

                    </goals>

                </execution>

            </executions>

            <configuration>

                <descriptorRefs>

                    <descriptorRef>jar-with-dependencies</descriptorRef>

                </descriptorRefs>

            </configuration>

        </plugin>

    </plugins>

</build>

Added by Wojciech Kapcia TigaseTeam over 5 years ago

I'm reluctant to bundle all dependencies in single jar:

  • they can be shared between multiple components

  • we provide them in the distribution packages

  • if you don't want to use distribution packages you can get them without modifying default project configuration

mvn  dependency:copy-dependencies -DoutputDirectory=jars

or better yet - create jar with bundled dependencies using command line switches.

Added by Steffen Larsen over 5 years ago

Yes I completely understand your reluctancy to this. But if you are a "normal" tigase user, then compiling the project and moving the jar should be enough.

If you are using:

@

mvn dependency:copy-dependencies -DoutputDirectory=jars

@

Then that will make you cherry pick the jar dependencies from the jars directory. I actually don't understand why tigase-server etc. is put in the output directory when it is "provided" in the pom. But maybe that can be tweaked by an option to the plugin.

My point is that maintainability is hard when doing it this way. But if http-api if going into a distributable package, it will be great. :-)

Added by Wojciech Kapcia TigaseTeam over 5 years ago

My point is that maintainability is hard when doing it this way. But if http-api if going into a distributable package, it will be great. :-)

Yes, it is, for example http://build.tigase.org/nightlies/dists/2013-08-16/tigase-server-5.2.0-SNAPSHOT-b3250-dist-max.zip :)

Added by Steffen Larsen over 5 years ago

Yes this is the full server package, what I wanted was only the necessary libs for the http-api. But no problem I've copied them from my own dependency..

So back to my orig. question. To get statistics (e.g. how many users online) from the http-api.

I've read the usage guide (https://projects.tigase.org/projects/tigase-http-api/wiki/Usage_examples), and to get the full list I query the session manager like so:

http://localhost:8080/rest/adhoc/sess-man@domain

But this just give me a 404. And yes I put my own domain and such. I can see it through IQ queries in PSI when admin.

My init.prop looks like this:

--comp-name-1=rest

--comp-class-1=tigase.http.rest.RestMessageReceiver

rest/use-local-server[B]=true

I can see that the rest service is being loaded in the log and no error messages or nothing.

/Steffen

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 5 years ago

One question: did you copied components scripts to your server directory? Process of coping those scripts is explained https://projects.tigase.org/projects/tigase-http-api/wiki/Configuration at Basic configuration section.

Added by Steffen Larsen over 5 years ago

hmmm my directory is : tigase-server/scripts/admin/rest not tigase-server/scripts/rest . Should I change this? I haven't changed anything, its 5.2.0-beta2 out of the box.

Maybe its a distribution problem again?.

Added by Wojciech Kapcia TigaseTeam over 5 years ago

It should be tigase-server/scripts/rest.

About distribution - it's interesting, because beta2 did not include REST component and neither scripts related to it. Which exact package did you use?

Added by Steffen Larsen over 5 years ago

tigase-server-5.2.0-beta2-b3223 - the tarball version as I remember.

This seems to be the newest one, so its quite strange that it should not contain the rest part. I can see that jersey responds.

/Steffen

Added by Wojciech Kapcia TigaseTeam over 5 years ago

Actually it was only included in latest nightlies after beta2, but there is an issue with packaging and archives still miss rest scripts - we will fix it in the coming release.

Added by Steffen Larsen over 5 years ago

Super!. I'll wait until the package is done. Do you have an ETA on Tigase 5.2 stable release?

    (1-20/20)