use of org.netxms.client.datacollection.ThresholdViolationSummary in project netxms by netxms.
the class NXCSession method getThresholdSummary.
/**
* Get threshold violation summary for all nodes under given parent object. Parent object could
* be container, subnet, zone, entire network, or infrastructure service root.
*
* @param objectId parent object ID
* @return list of threshold violation summary objects for all nodes below given root
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<ThresholdViolationSummary> getThresholdSummary(final long objectId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_THRESHOLD_SUMMARY);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
List<ThresholdViolationSummary> list = new ArrayList<ThresholdViolationSummary>();
long varId = NXCPCodes.VID_THRESHOLD_BASE;
while (response.getFieldAsInt64(varId) != 0) {
final ThresholdViolationSummary t = new ThresholdViolationSummary(response, varId);
list.add(t);
varId += 50 * t.getDciList().size() + 2;
}
return list;
}
use of org.netxms.client.datacollection.ThresholdViolationSummary in project netxms by netxms.
the class DataCollectionTest method testGetThresholdSummary.
public void testGetThresholdSummary() throws Exception {
final NXCSession session = connect();
session.syncObjects();
final List<ThresholdViolationSummary> list = session.getThresholdSummary(1);
for (ThresholdViolationSummary s : list) {
DataCollectionTarget target = (DataCollectionTarget) session.findObjectById(s.getNodeId(), DataCollectionTarget.class);
System.out.println("* " + target.getObjectName());
if (s.getDciList().size() > 0) {
for (DciValue v : s.getDciList()) {
System.out.println(" + " + v.getDescription());
}
} else {
System.out.println(" --- no threshold violations");
}
}
session.disconnect();
}
use of org.netxms.client.datacollection.ThresholdViolationSummary in project netxms by netxms.
the class ThresholdSummaryWidget method refresh.
/**
* Refresh widget
*/
public void refresh() {
if (visibilityValidator != null && !visibilityValidator.isVisible())
return;
if (object == null) {
viewer.setInput(new ArrayList<ThresholdViolationSummary>(0));
return;
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final long rootId = object.getObjectId();
ConsoleJob job = new ConsoleJob(Messages.get().ThresholdSummaryWidget_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<ThresholdViolationSummary> data = session.getThresholdSummary(rootId);
runInUIThread(new Runnable() {
@Override
public void run() {
if (isDisposed() || (object == null) || (rootId != object.getObjectId()))
return;
viewer.setInput(data);
viewer.expandAll();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ThresholdSummaryWidget_JobError;
}
};
job.setUser(false);
job.start();
}
Aggregations