Yun and SNMP

opkg update
opkg install snmp-utils
opkg install snmpd 

/etc/init.d/snmpd enable
/etc/init.d/snmpd stop
/etc/init.d/snmpd start
nano /mnt/sda1/snmp.sh
#!/bin/ash
snmpset -v 2c -c private 127.0.0.1 iso.3.6.1.2.1.31.1.1.1.18.1 s $1 2>/dev/null
chmod 755 /mnt/sda1/snmp.sh

Test snmpset:

root@Arduino:/mnt/sda1# /mnt/sda1/snmp.sh 70
iso.3.6.1.2.1.31.1.1.1.18.1 = STRING: "70"

Confirm snmpget:

snmpget -v 2c -c public 127.0.0.1 iso.3.6.1.2.1.31.1.1.1.18.1  2>/dev/null

Arduino code:

#include <Process.h>
int temperature;
void setup() {
  Bridge.begin();  // Initialize Bridge
}
void loop() {
  temperature = 70 + random(0, 10);
  Process p;
  p.begin("/mnt/sda1/snmp.sh");
  p.addParameter(String(temperature));
  p.run();
  delay(5000);
}

Confirm:

root@Arduino:/mnt/sda1# snmpget -v 2c -c public 127.0.0.1 iso.3.6.1.2.1.31.1.1.1
.18.1  2>/dev/null
iso.3.6.1.2.1.31.1.1.1.18.1 = STRING: "77"
root@Arduino:/mnt/sda1# snmpget -v 2c -c public 127.0.0.1 iso.3.6.1.2.1.31.1.1.1
.18.1  2>/dev/null
iso.3.6.1.2.1.31.1.1.1.18.1 = STRING: "79"

Hello,

Is it also possible to add a second snmp OID for example : simulation random humidity?

(iso.3.6.1.2.1.31.1.1.1.18.2)

How should i implement this in the code and snmp.sh ?

Regards

nano /mnt/sda1/snmp.sh
#!/bin/ash
snmpset -v 2c -c private 127.0.0.1 iso.3.6.1.2.1.31.1.1.1.18.1 s $1 2>/dev/null
snmpset -v 2c -c private 127.0.0.1 iso.3.6.1.2.1.31.1.1.1.18.2 s $2 2>/dev/null
chmod 755 /mnt/sda1/snmp.sh

Test snmpset:

/mnt/sda1/snmp.sh 70 90

Confirm snmpget:

snmpget -v 2c -c public 127.0.0.1 iso.3.6.1.2.1.31.1.1.1.18.1  2>/dev/null
snmpget -v 2c -c public 127.0.0.1 iso.3.6.1.2.1.31.1.1.1.18.2  2>/dev/null

Arduino code:

#include <Process.h>
int temperature;
int humidity;
void setup() {
  Bridge.begin();  // Initialize Bridge
}
void loop() {
  temperature = 70 + random(0, 10);
  humidity = 50+ random(0, 50);
  Process p;
  p.begin("/mnt/sda1/snmp.sh");
  p.addParameter(String(temperature));
  p.addParameter(String(humidity));
  p.run();
  delay(5000);
}

Greetings to Brandon, Feedback, and sonnyyu
I would like to join this conversation.

I would like to deploy SNMP with the YUN
1st I would like to read Yun MIB with Getif
And then I would like to monitor my Yun with cloud supported Cacti

I think exactly as you. Can you please bring me up to speed? Part of the early forum material seems to be lost or in another topic.

thank you and warm regards

Hi cybrk,

For a cacti/yun implementation you do not need any MIB file. My cacti is a little bit rusty, but you can just add the OID to cacti and it will do a SNMP get to the arduino yun.

Goodluck!

Hi
I installed snmp-utils and snmpd daemon packages in arduino yun and I manged to make snmp set and get calls to arduino yun and so far i am successful in it. I am setting and getting the data on a predefined MIB iso.3.6.1.2.1.31.1.1.1.18.1 ... I can only use 4 MIBS iso.3.6.1.2.1.31.1.1.1.18.1 iso.3.6.1.2.1.31.1.1.1.18.2, iso.3.6.1.2.1.31.1.1.1.18.3, iso.3.6.1.2.1.31.1.1.1.18.5 .

My system requires 93 Mibs... So i planned to go with experimental mib series .1.3.6.1.3(experimental series)... But how can i define these mibs in the system is a question?
net-snmp has good tutorial on defining your own mibs but net-snmp is not available as a package for Yun...... For Yun I cant even find the predefined mibs files location-definition etc nothing....
Can any body please help me how can i use experimental series?
My snmp configuration file is at location
/etc/config/snmpd
and
/etc/snmp/snmpd.config

hola, muy bueno el ejemplo lo he logrado. por favor me podrían ayudar como hacer lo mismo pero para un sensor de humo específicamente el MQ-2.

Hello, very good example achieved. Please help me do the same but for a specifically MQ-2 smoke sensor.