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);
}
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;
}
Aggregations