Search in sources :

Example 16 with Statistic

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

the class StatisticsModule method addPacketStatistic.

/**
     * Tracks the total number of packets both incoming and outgoing in the server.
     */
private void addPacketStatistic() {
    // Register a statistic.
    Statistic packetTrafficStatistic = new i18nStatistic(TRAFFIC_KEY, MonitoringConstants.NAME, Statistic.Type.rate) {

        public double sample() {
            return packetCount.getAndSet(0);
        }

        public boolean isPartialSample() {
            return true;
        }
    };
    statisticsManager.addStatistic(TRAFFIC_KEY, packetTrafficStatistic);
}
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 17 with Statistic

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

the class StatsEngine method createDefintion.

private StatDefinition createDefintion(String key) {
    StatDefinition def = definitionMap.get(key);
    if (def == null) {
        Statistic statistic = statsManager.getStatistic(key);
        String statGroup = statsManager.getMultistatGroup(key);
        try {
            def = new DefaultStatDefinition(statGroup != null ? statGroup : key, key, statistic);
            // If the definition is a part of a group check to see all defiintions have been
            // made for that group
            StatDefinition[] definitions;
            if (statGroup != null) {
                definitions = checkAndCreateGroup(statGroup, def, true);
            } else {
                definitions = new StatDefinition[] { def };
                multiMap.put(key, Arrays.asList(definitions));
            }
            if (definitions != null) {
                checkDatabase(definitions);
            }
            definitionMap.put(key, def);
        } catch (RrdException e) {
            Log.error("Error creating database definition", e);
        } catch (IOException e) {
            Log.error("Error creating database definition", e);
        }
    }
    return def;
}
Also used : Statistic(org.jivesoftware.openfire.stats.Statistic) RrdException(org.jrobin.core.RrdException) IOException(java.io.IOException)

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