Hello,
Please find below the change I made on file SnmpAttribute.java (package
org.opennms.netmgt.collectd):
Imports:
========
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Constant:
=========
private static Pattern NUMBER_PATTERN =
Pattern.compile("[^\\d\\-\\+]*([\\+\\-]?\\d+(\\.\\d+)?).*");
Replace function getNumericalValue by this one:
===============================================
public String getNumericValue() {
if (getValue() == null) {
log().debug("No data collected for attribute "+this+". Skipping");
return null;
} else if (getValue().isNumeric()) {
return Long.toString(getValue().toLong());
} else {
Matcher m = NUMBER_PATTERN.matcher(getValue().toString());
if (m.matches()) {
String value = m.group(1);
return value;
}
else {
try {
return Double.valueOf(getValue().toString()).toString();
} catch(NumberFormatException e) {
log().trace("Unable to process data received for
attribute " + this + " maybe this is not a number? See bug 1473 for more
information. Skipping.");
return null;
}
}
}
}
This peace of code could be integrated into the next release, what do you think
about that ?
Regards,
Samuel Mutel.
----- Mail original -----
De: "Samuel Mutel" <[email protected]>
À: [email protected]
Envoyé: Mercredi 27 Juin 2012 16:27:24
Objet: [opennms-devel] Capability to convert string into integer or gauge
in datacollection
Hello,
I wanted to create a patch for this feature:
http://issues.opennms.org/browse/NMS-5405
To make a great patch, what is the best solution:
- Change the source code of collectd
- Change the source code of core/snmp/api ?
Changing function storeResult in SNMPCollectorEntry is a good option ?
I already installed maven/eclipse/opennms source.
Regards,
Samuel Mutel.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ
opennms-devel mailing list
To *unsubscribe* or change your subscription options, see the bottom of this
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ
opennms-devel mailing list
To *unsubscribe* or change your subscription options, see the bottom of this
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel