Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)
avatar

How to use make a simple flow using SNMPSET/SNMPGET
Append A - Troubleshooting common mistakes


Pre-requisites:
- Nifi Cluster Installed (I'm using HDF 3.1.2.0 hence with Nifi 1.5)
- Centos7

With your NIFI cluster installed, you're up to initiate this step-by-step.
First of all, we'll need to install a snmp server to retrieve/set values of/to MIB's. In my case I'm using net-snmp tool, and it comes with some MIB samples to play. Here we're going to use the SNMPv2-MIB.txt under the /usr/share/snmp/mibs path

1)Install net-snmp

yum install -y net-snmp net-snmp-utils net-snmp-libs 

2)Give full access of read-write to anyone at public community (DON'T DO IT IN PROD, please)

echo > /etc/snmp/snmpd.conf 
printf "agentAddress udp:161\nrwcommunity public\nrwuser public\nrocommunity public default system\nrouser public" >> /etc/snmp/snmpd.conf 

3)Start the SNMP SERVER DAEMON - port 161

service snmpd start 

4)Test a simple snmpwalk to see if those changes at step 2 are working

snmpwalk -v2c -mALL -c public localhost system 

5)Test a simple snmpget

snmpget -v2c -mALL -c public localhost SNMPv2-MIB::sysContact.0 

6)Setting a simple value to overwrite the value above, and check again to see if the value has been replaced with the new value

snmpset -v2c -mALL -c public localhost SNMPv2-MIB::sysContact.0 = "Vinicius Higa Murakami" 
snmpget -v2c -mALL -c public localhost SNMPv2-MIB::sysContact.0 

7)Login as nifi user and take the same steps as above (just to ensure that the nifi user has access to read/write)

su - nifi 
snmpset -v2c -mALL -c public localhost SNMPv2-MIB::sysContact.0 = "Nifi it's here" 
snmpget -v2c -mALL -c public localhost SNMPv2-MIB::sysContact.0 

8)Now we're ready to use nifi and draw the simple flow, using SNMP processors.
Go to nifi UI and draw the following components:

87425-snmp-entire-flow.png

GenerateFlowFile Property

87426-generateflowfile-property.png

SetSNMP Property
87427-setsnmp-property.png

LogAttribute Property
87428-logattribute-property.png

GetSNMP Property87429-getsnmp-property.png

LogAttribute Property
87430-logattribute-property-2.png

9)Run the nifi flow (snmpset and snmpget) and check if your value is showing up in the nifi-app.log
87431-logging-getsnmp.png
Append A
To troubleshoot the snmp, you can enable the DEBUG log by adding the following line to the /etc/sysconfig/snmpd

OPTIONS="-A -p /var/run/snmpd -a -LF 7 /var/log/snmpd.log" 

And then make some snmpget (step 7) to check if it's logging the connections into the /var/log/snmpd.log. Should appear 2 lines:

Connection from UDP: [127.0.0.1]:40769->[127.0.0.1]:161 
Received SNMP packet(s) from UDP: [127.0.0.1]:40769->[127.0.0.1]:161 

If you're having issues with the SNMPSET like the below.

87424-error-setsnmp.png

Check if your snmpset it's able to reach the snmp server and send snmp packets, to do this, you can use tail -f /var/log/snmpd.log to monitor the connections and start the flow to watch the behaviour.
Other attention point is to check if your nifi has permissions to set/get values from MIB's (make sure you did the step 7).
And lastly is to check if your snmp$oid is valid.

And here's the template used:
template-kb-snmp.xml

3,838 Views