Skip to content

Commit

Permalink
Added checks for null/blank sysName before updating node label with the
Browse files Browse the repository at this point in the history
sysName value. Fixes bug NMS-2580.
  • Loading branch information
soleger authored and Benjamin Reed committed Nov 26, 2014
1 parent 80b686d commit 74ffe56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Expand Up @@ -101,11 +101,15 @@ public void setAttribute(String key, String value) {
m_node.setSysObjectId(value);
} else if (key.equals("sysName")) {
m_node.setSysName(value);
// If the node is labeled as just the IP address from the newSuspect that created it,
// use the SNMP sysName value instead and update the label source to indicate this
if (m_node.getLabelSource() == NodeLabelSource.ADDRESS) {
m_node.setLabel(value);
m_node.setLabelSource(NodeLabelSource.SYSNAME);

// If the sysName isn't null or empty...
if (value != null && !"".equals(value.trim())) {
// If the node is labeled as just the IP address from the newSuspect that created it,
// use the SNMP sysName value instead and update the label source to indicate this
if (m_node.getLabelSource() == NodeLabelSource.ADDRESS) {
m_node.setLabel(value);
m_node.setLabelSource(NodeLabelSource.SYSNAME);
}
}
}

Expand Down
Expand Up @@ -378,7 +378,7 @@ private DbNodeEntry createNode(Connection dbc, InetAddress ifaddr,
String str = sysgrp.getSysName();
LOG.debug("SuspectEventProcessor: {} has sysName: {}", str(ifaddr), str);

if (str != null && str.length() > 0) {
if (str != null && !"".equals(str.trim())) {
entryNode.setSystemName(str);

// Hostname takes precedence over sysName so only replace
Expand Down

0 comments on commit 74ffe56

Please sign in to comment.