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