public void updateDb()
{
try
{
RrdDb rrdDb = _rrdPool.requestRrdDb(_rrdPath);
Sample sample = rrdDb.createSample();
if (_connection.isRegistered(_sessionManger))
sample.setValue("calls", (Integer) _connection.getAttribute(_sessionManger, "callSessions"));
long totalMemory = __runtime.totalMemory();
sample.setValue("maxMemory", __runtime.maxMemory());
sample.setValue("totalMemory", totalMemory);
sample.setValue("usedMemory", totalMemory - __runtime.freeMemory());
if (_connection.isRegistered(ConsoleFilter.CONNECTOR_MANAGER))
{
sample.setValue("incomingMessages",
(Long) _connection.getAttribute(ConsoleFilter.CONNECTOR_MANAGER, "messagesReceived"));
sample.setValue("outgoingMessages",
(Long) _connection.getAttribute(ConsoleFilter.CONNECTOR_MANAGER, "messagesSent"));
}
int nbCpu = (Integer) _connection.getAttribute(OPERATING_SYSTEM, "AvailableProcessors");
if (_cpuStatAvailable)
{
long processCpuTime = (Long) _connection.getAttribute(OPERATING_SYSTEM, "ProcessCpuTime");
sample.setValue("cpu", processCpuTime / nbCpu);
}
long timeInGc = 0;
Set<ObjectName> garbageCollections = _connection.queryNames(GARBAGE_COLLECTORS, null);
for (ObjectName objectName : garbageCollections)
{
timeInGc += (Long) _connection.getAttribute(objectName, "CollectionTime");
}
sample.setValue("timeInGc", timeInGc / nbCpu);
sample.update();
_rrdPool.release(rrdDb);
}
catch (Exception e)
{
_logger.warn("Unable to set statistics", e);