Search in sources :

Example 6 with Statistic

use of org.jivesoftware.openfire.stats.Statistic in project Openfire by igniterealtime.

the class GetStatistics method run.

public void run() {
    samples = new HashMap<String, Double>();
    for (Map.Entry<String, Statistic> statisticEntry : StatisticsManager.getInstance().getAllStatistics()) {
        String key = statisticEntry.getKey();
        Statistic statistic = statisticEntry.getValue();
        // Only sample statistics that keep info of the cluster node and not the entire cluster
        if (statistic.isPartialSample()) {
            double statSample = sampleStat(key, statistic);
            // Store sample result
            samples.put(key, statSample);
        }
    }
}
Also used : Statistic(org.jivesoftware.openfire.stats.Statistic) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with Statistic

use of org.jivesoftware.openfire.stats.Statistic in project Openfire by igniterealtime.

the class MultiUserChatManager method addTotalConnectedUsers.

private void addTotalConnectedUsers() {
    // Register a statistic.
    Statistic statistic = new Statistic() {

        @Override
        public String getName() {
            return LocaleUtils.getLocalizedString("muc.stats.users.name");
        }

        @Override
        public Type getStatType() {
            return Type.count;
        }

        @Override
        public String getDescription() {
            return LocaleUtils.getLocalizedString("muc.stats.users.description");
        }

        @Override
        public String getUnits() {
            return LocaleUtils.getLocalizedString("muc.stats.users.label");
        }

        @Override
        public double sample() {
            double users = 0;
            for (MultiUserChatService service : getMultiUserChatServices()) {
                users += service.getNumberConnectedUsers(false);
            }
            return users;
        }

        @Override
        public boolean isPartialSample() {
            return false;
        }
    };
    StatisticsManager.getInstance().addStatistic(usersStatKey, statistic);
}
Also used : Statistic(org.jivesoftware.openfire.stats.Statistic)

Example 8 with Statistic

use of org.jivesoftware.openfire.stats.Statistic in project Openfire by igniterealtime.

the class MultiUserChatManager method addNumberOutgoingMessages.

private void addNumberOutgoingMessages() {
    // Register a statistic.
    Statistic statistic = new Statistic() {

        @Override
        public String getName() {
            return LocaleUtils.getLocalizedString("muc.stats.outgoing.name");
        }

        @Override
        public Type getStatType() {
            return Type.rate;
        }

        @Override
        public String getDescription() {
            return LocaleUtils.getLocalizedString("muc.stats.outgoing.description");
        }

        @Override
        public String getUnits() {
            return LocaleUtils.getLocalizedString("muc.stats.outgoing.label");
        }

        @Override
        public double sample() {
            double msgcnt = 0;
            for (MultiUserChatService service : getMultiUserChatServices()) {
                msgcnt += service.getOutgoingMessageCount(true);
            }
            return msgcnt;
        }

        @Override
        public boolean isPartialSample() {
            // Each cluster node knows the total across the cluster
            return false;
        }
    };
    StatisticsManager.getInstance().addMultiStatistic(outgoingStatKey, trafficStatGroup, statistic);
}
Also used : Statistic(org.jivesoftware.openfire.stats.Statistic)

Example 9 with Statistic

use of org.jivesoftware.openfire.stats.Statistic in project Openfire by igniterealtime.

the class StatisticsModule method addServerToServerStatistic.

/**
     * Tracks the number of Server To Server connections taking place in the server at anyone time.
     * This includes both incoming and outgoing connections.
     */
private void addServerToServerStatistic() {
    // Register a statistic.
    Statistic serverToServerStatistic = new i18nStatistic(SERVER_2_SERVER_SESSIONS_KEY, MonitoringConstants.NAME, Statistic.Type.count) {

        public double sample() {
            return (SessionManager.getInstance().getIncomingServers().size() + SessionManager.getInstance().getOutgoingServers().size());
        }

        public boolean isPartialSample() {
            return false;
        }
    };
    // Add to StatisticsManager
    statisticsManager.addStatistic(SERVER_2_SERVER_SESSIONS_KEY, serverToServerStatistic);
}
Also used : Statistic(org.jivesoftware.openfire.stats.Statistic) org.jivesoftware.openfire.stats.i18nStatistic(org.jivesoftware.openfire.stats.i18nStatistic) org.jivesoftware.openfire.stats.i18nStatistic(org.jivesoftware.openfire.stats.i18nStatistic)

Example 10 with Statistic

use of org.jivesoftware.openfire.stats.Statistic in project Openfire by igniterealtime.

the class StatisticsModule method addActiveSessionsStatistic.

/**
     * Tracks the number of Active Sessions with the server at any point in time.
     * Active Sessions are defined as one client connection.
     */
private void addActiveSessionsStatistic() {
    // Register a statistic.
    Statistic activeSessionStatistic = new i18nStatistic(SESSIONS_KEY, MonitoringConstants.NAME, Statistic.Type.count) {

        public double sample() {
            return SessionManager.getInstance().getUserSessionsCount(false);
        }

        public boolean isPartialSample() {
            return false;
        }
    };
    statisticsManager.addStatistic(SESSIONS_KEY, activeSessionStatistic);
}
Also used : Statistic(org.jivesoftware.openfire.stats.Statistic) org.jivesoftware.openfire.stats.i18nStatistic(org.jivesoftware.openfire.stats.i18nStatistic) org.jivesoftware.openfire.stats.i18nStatistic(org.jivesoftware.openfire.stats.i18nStatistic)

Aggregations

Statistic (org.jivesoftware.openfire.stats.Statistic)17 org.jivesoftware.openfire.stats.i18nStatistic (org.jivesoftware.openfire.stats.i18nStatistic)3 Date (java.util.Date)2 JFreeChart (org.jfree.chart.JFreeChart)2 MonitoringPlugin (org.jivesoftware.openfire.plugin.MonitoringPlugin)2 Document (com.lowagie.text.Document)1 DocumentException (com.lowagie.text.DocumentException)1 Paragraph (com.lowagie.text.Paragraph)1 DefaultFontMapper (com.lowagie.text.pdf.DefaultFontMapper)1 PdfContentByte (com.lowagie.text.pdf.PdfContentByte)1 PdfTemplate (com.lowagie.text.pdf.PdfTemplate)1 PdfWriter (com.lowagie.text.pdf.PdfWriter)1 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 NumberFormat (java.text.NumberFormat)1