Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-1537 Added SNMP processors #257

Closed
wants to merge 1 commit into from

Conversation

pvillard31
Copy link
Contributor

Processors for SNMP set/get/walk operations over SNMP v1, v2c & v3 using SNMP4J library.

Method[] methods = PDU.class.getDeclaredMethods();
Map<String, String> attributes = new HashMap<String, String>();
for (Method method : methods) {
if (Modifier.isPublic(method.getModifiers()) && (method.getParameterCount() == 0) && method.getName().startsWith("get")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pierre, I noticed this when I was researching for your OnStopped issue. I believe this method 'getParameterCount' was introduced in Java 8 while we still have to be compliant with Java 7. So consider refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Oleg, I have fixed it.

@olegz
Copy link
Contributor

olegz commented Mar 7, 2016

Pierre, so the ReflectionUtils fix is in #260. So watch the PR and once it is merged, rebase, update (remove that temp fix code) and test and let me know. I've already tested it with your branch but still extra validation would help.

@pvillard31
Copy link
Contributor Author

Oleg, yes sure, will do!

@pvillard31
Copy link
Contributor Author

Pre-requisite: NIFI-1595 has to be merged in before


if("SNMPv3".equals(context.getProperty(SNMP_VERSION).getValue())) {
USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just initiated a DISCUSS thread on the dev list. Basically while there is not much we can do at the moment, the above code will set the security model that will be applicable across all instances of SNMP processors within a single instance of NiFi.

@olegz
Copy link
Contributor

olegz commented Mar 23, 2016

Pierre

You may want to rebase (merge conflicts) and push again since it's out of sink.
Also, aside from unit tests would you mind giving some pointers on how to test it outside of unit tests? A link on how to setup an environment or a short writeup. I am not that familiar with SNMP

@michalklempa
Copy link
Contributor

@olegz there is http://snmpsim.sourceforge.net/ project, which can be used for testing purposes. Some simulation files are available with distribution, so basic testing may be done out-of-the-box

@pvillard31
Copy link
Contributor Author

@olegz I just rebased the PR.

As @michalklempa mentioned, you can use online SNMP service provided by snmpsim (http://snmpsim.sourceforge.net/public-snmp-simulator.html), otherwise it depends of your OS. Personally, I tried the processor by requesting basic SNMP data (such as uptime for example) on a CentOS machine with net-snmp agent running with various configurations in SNMP v1, v2c and v3 (MD5/DES).

As a side note, at this moment, the processor is expecting an OID in numerical format. If I try the following command on my computer:

snmpwalk -v2c -c public demo.snmplabs.com IF-MIB::interfaces

I can get numerical OID by adding the option -On:

snmpwalk -v2c -c public demo.snmplabs.com IF-MIB::interfaces -On

This way I can see that IF-MIB::interfaces is equivalent to .1.3.6.1.2.1.2.2.1

I will try to write something to help setting an environment. On a Linux-like environment, a quick setup can be:
yum install net-snmp net-snmp-utils
service snmpd start

It will allow access to basic SNMP information in v1 and v2c with 'public' as community. For SNMP v3 setup, it is possible to add users using the command net-snmp-create-v3-user.

Hope it helps, if not, let me know ;)

@olegz
Copy link
Contributor

olegz commented Mar 24, 2016

@michalklempa @pvillard31 thank you both for the input. Will be reviewing and testing.

@trixpan
Copy link
Contributor

trixpan commented Jun 5, 2016

@olegz any luck with this review? Cheers

@pvillard31
Copy link
Contributor Author

@trixpan @olegz @michalklempa
I rebased the PR against master

@olegz
Copy link
Contributor

olegz commented Jun 15, 2016

@pvillard31 could you please rebase and fix merge conflicts one last time. I am now committed to review/test it so we can have it in 0.7.

@pvillard31
Copy link
Contributor Author

@olegz half-time ;) done!

@olegz
Copy link
Contributor

olegz commented Jun 15, 2016

. . . and you almost scored ;) but. . . anyway, will try to wrap it up tomorrow

@olegz
Copy link
Contributor

olegz commented Jun 17, 2016

Ok, finally I am in this PR and no distractions ;)

@olegz
Copy link
Contributor

olegz commented Jun 19, 2016

@pvillard31 Had a merge conflict again, but fixed it myself. Nothing to do, just making comment for traceability.

@asfgit asfgit closed this in 86bba1b Jun 19, 2016
asfgit pushed a commit that referenced this pull request Jun 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants