DataSets data;
TimeSeriesContext context;
DataGraph graphFrame;
int processorIndex;
String processorString;
Device currentDevice;
ProcessorUCDSNMP processorUCDSNMP;
ProcessorCiscoSNMP processorCiscoSNMP;
int pollInterval;
//pollInterval = Integer.parseInt(pollField.getText()) * 1000;
pollInterval = Integer.parseInt(pollField.getText());
if ( collectorTypeComboBox.getSelectedIndex() == COLLECTOR_TYPE_HR ) {
try {
processorIndex = processorHRSNMP.getProcessorsIndex()[((JList)(processorsPane.getViewport().getView())).getSelectedIndex()];
processorString = (String)((JList)processorsPane.getViewport().getView()).getSelectedValue();
collector = new ProcessorHRCollector(processorHRSNMP, pollInterval, processorIndex);
data = new DataSets(DataType.PROCESSOR, collector, device, pollInterval, processorString, DataSets.DIRECTION_NONE, null, storeDataCheckBox.isSelected());
context = new TimeSeriesContext(data);
graphFrame = new DataGraph(context);
} catch (NullPointerException e) {
ErrorHandler.modalError(this, "Please enumerate resources on a device and select a processor",
"No processor selected");
} catch (ArrayIndexOutOfBoundsException e) {
ErrorHandler.modalError(this, "Please select a processor", "No processor selected");
} catch (DBException e) {
ErrorHandler.modalError(null, "Please ensure that database is running and accessible",
"Error opening database connection", e);
} catch (UnknownHostException e) {
ErrorHandler.modalError(null, "Please ensure that device name \"" + deviceField.getText() + "\" is valid",
"Unknown host " + deviceField.getText());
} catch (SNMPException e) {
ErrorHandler.modalError(null, "Please ensure that device name and community string are correct",
"Cannot access SNMP service on device " + deviceField.getText(), e);
} catch (ClassCastException e) {
ErrorHandler.modalError(null, "Please ensure that device supports processor usage in the Host Resources MIB",
"Cannot find processor usage information on device " + deviceField.getText(), e);
}
} else if ( collectorTypeComboBox.getSelectedIndex() == COLLECTOR_TYPE_UCD ) {
try {
currentDevice = new Device(deviceField.getText(), communityField.getText(), null, false);
processorUCDSNMP = new ProcessorUCDSNMP(currentDevice);
collector = new ProcessorUCDCollector(processorUCDSNMP, (long)pollInterval);
data = new DataSets(DataType.NETSNMP_PROCESSOR, collector, currentDevice, pollInterval, null, DataSets.DIRECTION_NONE, null, storeDataCheckBox.isSelected());
context = new TimeSeriesContext(data);
graphFrame = new DataGraph(context);
} catch (DBException e) {
ErrorHandler.modalError(null, "Please ensure that database is running and accessible",
"Error opening database connection", e);
} catch (UnknownHostException e) {
ErrorHandler.modalError(null, "Please ensure that device name \"" + deviceField.getText() + "\" is valid",
"Unknown host " + deviceField.getText());
} catch (SNMPException e) {
ErrorHandler.modalError(null, "Please ensure that device name and community string are correct",
"Cannot access SNMP service on device " + deviceField.getText(), e);
}
} else if ( collectorTypeComboBox.getSelectedIndex() == COLLECTOR_TYPE_CISCO ) {
try {
currentDevice = new Device(deviceField.getText(), communityField.getText(), null, false);
processorCiscoSNMP = new ProcessorCiscoSNMP(currentDevice);
collector = new ProcessorCiscoCollector(processorCiscoSNMP, pollInterval);
data = new DataSets(DataType.PROCESSOR, collector, currentDevice, pollInterval, null, DataSets.DIRECTION_NONE, null, storeDataCheckBox.isSelected());
context = new TimeSeriesContext(data);
graphFrame = new DataGraph(context);