gpio snmp

Hello friends. I'm having a problem that's making me sleepy for days. I am new to linux and raspberry, and have the need to monitor the status of raspberryPI GP3s with raspbian. I used as a base the instructions of our friend David Taylor on the site:

formatting link

The problem is that I can not read the status of a GPIO configured as input even with the snmpget command.

I created a python script to get the info and it worked. I created a Bash script to link the status with an OID and it worked. I edited the snmpd.conf file and created a PASS to read the scrpts and it does not work.

I do not know how to give access or who to give access to allow to read the GPIOs via SNMP.

Can someone help me?

Sorry for English, I'm Brazilian using google translator.

Reply to
José Vieira
Loading thread data ...

You haven't given enough information. Which function or system call fails, and what error does it return?

You need to be uid=root, or gid=gpio.

If you want another user to be able to access the filesystem device nodes, make them a member of group gpio. For example, this is so I can access gpio as andrew:

grep andrew /etc/group gpio:x:1000:pi,andrew andrew:x:10001:

Similarly, there's an i2c and an spi group, if you are using those interfaces.

I just looked at the web page you mentioned, and it does cover this partly. Look at the section "A problem ..."

There is also a bug with accessing gpio as a non-root user. After you have exported the gpio you want to use, it can take a few hundred milliseconds before the open() call will succeed without returning EACCESS. I retry in a loop with a 20ms delay until it works (or until I have looped 50 times). This is not a problem if you access it as uid=root.

--
Andrew Gabriel 
[email address is not usable -- followup in the newsgroup]
Reply to
Andrew Gabriel

screveu:

of raspberryPI GP3s with raspbian.

formatting link

ut even with the snmpget command.

does not work.

he GPIOs via SNMP.

Thanks for the quick response. Following is the scripts. As can be seen in the results, the two initial scripts work fine but when s nmp does the request does not work.

Following are scripts below.

/home/pi > gpio_23.py

import RPi.GPIO as gpio import time

gpio.setmode(gpio.BCM)

# Com pull-up interno gpio.setup(23, gpio.IN, pull_up_down = gpio.PUD_UP)

print (gpio.input(23))

time.sleep(1) gpio.cleanup()

/usr/local/bin > input23

#!/bin/bash if [ "$1" = "-g" ] then echo .1.3.6.1.2.1.25.1.222 echo gauge python /home/pi/gpio_23.py fi exit 0

/etc/snmp/snmpd.conf ... # "Pass-through" MIB extension command # #pass .1.3.6.1.4.1.8072.2.255 /bin/sh PREFIX/local/passtest #pass .1.3.6.1.4.1.8072.2.255 /usr/bin/perl PREFIX/local/passtest.pl

pass .1.3.6.1.2.1.25.1.8 /bin/sh /usr/local/bin/snmp-cpu-temp pass .1.3.6.1.2.1.25.1.222 /bin/sh /usr/local/bin/input23

# Note that this requires one of the two 'passtest' scripts to be installed fir$ # before the appropriate line is uncommented. # These scripts can be found in the 'local' directory of the source distrib utio$ # and are not installed automatically.

?

Results:

root@raspberrypi:/home/pi# snmpget -v 2c localhost -c public .1.3.6.1.2.1.2

5.1.222 iso.3.6.1.2.1.25.1.222 = Gauge32: 0

root@raspberrypi:/home/pi# python gpio_23.py

1

root@raspberrypi:/usr/local/bin# ./input23 -g .1.3.6.1.2.1.25.1.222 gauge

1
Reply to
José Vieira

Hi Jose,

Did you ever get a reply for this. I have the same problem.

Tom

of raspberryPI GP3s with raspbian.

formatting link

ut even with the snmpget command.

does not work.

he GPIOs via SNMP.

Reply to
voguehomeauto

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.