Ad Widget

Collapse

Errors running Adafruit_Python_DHT script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • The-Tech
    Junior Member
    • Jan 2022
    • 29

    #1

    Errors running Adafruit_Python_DHT script

    I am attempting to setup Temp monitors in my data rooms using Rasp Pi. I found a few articles that make it look easy enough, such as the following https://zabbix.tips/monitor-temperat...midity-zabbix/ but it is dated because with Bookworm and the newer 64 bit OS versions now require virtual environments. I even tried some of the steps from https://www.zabbix.com/forum/zabbix-...-python-script with no luck

    I setup a /opt/TempMonitoring/ directory and assigned chmod -R ugo+rw permissions just to started

    in the zabbix_agentd.conf I added the following

    AllowKey=system.run[*]
    UserParameter=dht.pull[*],/opt/TempMonitoring/venv/bin/python3 /opt/TempMonitoring/Adafruit_Python_DHT/examples/AdafruitDHT.py | awk -F[=*%] '{print $$$1}


    Click image for larger version

Name:	Item1.jpg
Views:	140
Size:	42.1 KB
ID:	498301

    In the Zabbix Server for the host I created a new Item with the key system.run[python3 /opt/TempMonitoring/Adafruit_Python_DHT/examples/AdafruitDHT.py 11 4] but when I test/run the Item python errors that it's looking for library files from /usr/local/lib/python3.9/dist-packages/Adafruit_DHT/



    Click image for larger version

Name:	image.png
Views:	76
Size:	50.3 KB
ID:	498302Click image for larger version

Name:	Item2.gif
Views:	46
Size:	342.7 KB
ID:	498303
    I added ( at least I thought it is correct) the zabbix user with privileged access as well as the includedir variable

    Click image for larger version

Name:	Item4.gif
Views:	46
Size:	40.0 KB
ID:	498304

    I can run the the script from CLI python3 /opt/TempMonitoring/Adafruit_Python_DHT/examples/AdafruitDHT.py 11 4| awk -F[=*%] '{print $$$1}' without issue and without the sudo command

    Click image for larger version

Name:	image.png
Views:	56
Size:	14.5 KB
ID:	498305


    ​​​Clearly I am missing something but if anyone can help me out I would me most great full
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    You are using user "pi" to test and run the command... but your zabbix agent does not run as user "pi". It is running as user "zabbix". So you should be testing under that user. Your environments are probably not same for those users. You can miss paths etc...
    With sudo rules you shoudl add full command there.. not just path to script. And then also your Userparameter should contain "sudo"...

    Comment

    • The-Tech
      Junior Member
      • Jan 2022
      • 29

      #3
      thanks for the sugestion

      Comment

      Working...