Hi everyone. I have read many posts about this, but I haven't had much success. I'm not very familiar with using SNMP on the Raspberry.
Following some posts I have managed to enable basic communication between my PC (mybrownser) and my Raspberry through SNMP.
As of today, I have managed to perform the query of an OID based on viewtopic.php?t=83286 with a basic script (data_request.sh).
--> data_request.sh--> snmpd.conf:
pass .1.3.6.1.4.1.45281.1.2.1.5 /bin/sh /ruta/data_request.sh
--> Shell & MibBrownser (successful execution, both)
$ snmpget -v 2c -c private IP .1.3.6.1.4.1.45281.1.2.1.5
.1.3.6.1.4.1.45281.1.2.1.5 = Gauge32: 255
The problem arises when I want to read a csv or a database in SQlite:
--> data_request.sh
Running directly in the console, the result is correct:
$sh data_request.sh
.1.3.6.1.4.1.45281.1.2.1.5
Unsigned32
255
BUT when requesting the snmpget -v 2c -c private IP .1.3.6.1.4.1.45281.1.2.1.5 The return value does not match the terminal value: .1.3.6.1.4.1.45281.1.2.1.5 = Gauge32: 0 (instead of 255)
I have tried several ways and followed different posts without success. I tried a .py instead of a .sh without success.
I have tried to read a .csv instead of a .db without success. The result is the same, the shell terminal gives me a correct value but my getsnmp request does not have access to those values or at some point they get lost.
I couldn't answer or ask in the aforementioned posts because they are blocked so I made a new one. I apologize in advance if this is not the right way but I hope you can advise me please.
Thanks in advance
Following some posts I have managed to enable basic communication between my PC (mybrownser) and my Raspberry through SNMP.
As of today, I have managed to perform the query of an OID based on viewtopic.php?t=83286 with a basic script (data_request.sh).
--> data_request.sh
Code:
#!/bin/bashecho .1.3.6.1.4.1.45281.1.2.1.5echo Unsigned32echo 255exit 0
pass .1.3.6.1.4.1.45281.1.2.1.5 /bin/sh /ruta/data_request.sh
--> Shell & MibBrownser (successful execution, both)
$ snmpget -v 2c -c private IP .1.3.6.1.4.1.45281.1.2.1.5
.1.3.6.1.4.1.45281.1.2.1.5 = Gauge32: 255
The problem arises when I want to read a csv or a database in SQlite:
--> data_request.sh
Code:
#!/bin/bashDB_FILE="dataLog.db"echo .1.3.6.1.4.1.45281.1.2.1.5echo Unsigned32value=$(sqlite3 "$DB_FILE" <<EOFSELECT * FROM registros ORDER BY ID DESC LIMIT 1;EOF)echo "$value" | cut -d"|" -f8 > temp.txtexit 0
$sh data_request.sh
.1.3.6.1.4.1.45281.1.2.1.5
Unsigned32
255
BUT when requesting the snmpget -v 2c -c private IP .1.3.6.1.4.1.45281.1.2.1.5 The return value does not match the terminal value: .1.3.6.1.4.1.45281.1.2.1.5 = Gauge32: 0 (instead of 255)
I have tried several ways and followed different posts without success. I tried a .py instead of a .sh without success.
I have tried to read a .csv instead of a .db without success. The result is the same, the shell terminal gives me a correct value but my getsnmp request does not have access to those values or at some point they get lost.
I couldn't answer or ask in the aforementioned posts because they are blocked so I made a new one. I apologize in advance if this is not the right way but I hope you can advise me please.
Thanks in advance
Statistics: Posted by Schatten — Fri Oct 25, 2024 10:38 pm