Ad Widget

Collapse

Create an item key from python script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bekem
    Junior Member
    • Oct 2018
    • 10

    #1

    Create an item key from python script

    Hello there,

    I am using a MAX6675 for monitoring temperature and I want to create an item for this. I tried to write this 'UserParameter=max6675.pull, /usr/local/bin/max6675-1.py' to /zabbix_agentd.conf but it said 'ZBX_NOTSUPPORTED'

    The attached file is python script, please take a look for helping me.

    Thank you.
    Attached Files
  • Olli
    Junior Member
    • Nov 2017
    • 17

    #2
    Did you restart agent after changing configuration?

    Comment

    • bekem
      Junior Member
      • Oct 2018
      • 10

      #3
      Originally posted by Olli
      Did you restart agent after changing configuration?
      Yes, i did but unlucky.

      Comment

      • bekem
        Junior Member
        • Oct 2018
        • 10

        #4
        can someone help to settle this?

        thanks,

        Comment

        • brunohl
          Senior Member
          Zabbix Certified Specialist
          • Mar 2019
          • 215

          #5
          Could you upload your zabbix_agentd.conf and you userparameter.conf?

          Comment

          • bekem
            Junior Member
            • Oct 2018
            • 10

            #6
            Originally posted by brunohl
            Could you upload your zabbix_agentd.conf and you userparameter.conf?
            Hi burunohl,

            Please find the attachment for zabbix_agentd.

            I ran zabbix_agentd -t max6675.pull and got the answer was "max6675.pull [m|ZBX_NOTSUPPORTED] [Timeout while executing a shell script.]"
            Attached Files

            Comment

            • max.ch.88
              Senior Member
              • Oct 2018
              • 206

              #7
              How long does your script take to be executed? The timeout for zabbix is 30 seconds maximum.
              Last edited by max.ch.88; 20-03-2019, 18:58.

              Comment

              • brunohl
                Senior Member
                Zabbix Certified Specialist
                • Mar 2019
                • 215

                #8
                max.ch.88 is correct, I guess that your script is taking longer than 30s to return

                Comment

                • bekem
                  Junior Member
                  • Oct 2018
                  • 10

                  #9
                  I ran zabbix_agentd for many times and it took exact 30s.

                  Comment

                  • brunohl
                    Senior Member
                    Zabbix Certified Specialist
                    • Mar 2019
                    • 215

                    #10
                    Yeah, I guess the cance of not working is big. I would suggest you to ise the script with zabbix sender and schedule on crontab. Because I dont yhink its good practice to use 30s timeout, it can overweight your pollers.

                    Comment

                    • bekem
                      Junior Member
                      • Oct 2018
                      • 10

                      #11
                      Originally posted by brunohl
                      Yeah, I guess the cance of not working is big. I would suggest you to ise the script with zabbix sender and schedule on crontab. Because I dont yhink its good practice to use 30s timeout, it can overweight your pollers.
                      Brunohl, can you help to write me the script?

                      Comment

                      • brunohl
                        Senior Member
                        Zabbix Certified Specialist
                        • Mar 2019
                        • 215

                        #12
                        Other thing you could do is schedule a task in your cron to run, then write the results in a txt file and then on your agent check you could just read the file created:

                        Cron (to run every 10 minutes):
                        Code:
                        */10 * * * * /usr/local/bin/max6675-1.py > /tmp/result.txt
                        Check:
                        Code:
                        UserParameter=check_max,cat /tmp/result.txt
                        Of course you will always be sometime behind, but I guess it's better than timeout.

                        Comment


                        • Mairold
                          Mairold commented
                          Editing a comment
                          Hello

                          i have a different script but want to do the same thing however i get a error : "Invalid key "UserParameter=check_max,cat /tmp/dbsize.json" for item "postgre monitoorimine" on "Zabbix server": incorrect syntax near "=check_max,cat /tmp/dbsize.json"." while trying to a a key in zabbix. Any assist you could give in creating this key would be wonderful!
                      • max.ch.88
                        Senior Member
                        • Oct 2018
                        • 206

                        #13
                        Originally posted by bekem
                        Hello there,

                        I am using a MAX6675 for monitoring temperature and I want to create an item for this. I tried to write this 'UserParameter=max6675.pull, /usr/local/bin/max6675-1.py' to /zabbix_agentd.conf but it said 'ZBX_NOTSUPPORTED'

                        The attached file is python script, please take a look for helping me.

                        Thank you.
                        Hi. Could you show the output of /usr/local/bin/max6675-1.py ?

                        Comment

                        • bekem
                          Junior Member
                          • Oct 2018
                          • 10

                          #14
                          Originally posted by max.ch.88

                          Hi. Could you show the output of /usr/local/bin/max6675-1.py ?
                          Here is the output of the script.

                          pi@raspberrypi:/tmp $ /usr/local/bin/max6675-1.py
                          20.50
                          20.25
                          20.50
                          20.50
                          20.55
                          20.50
                          20.50
                          20.50
                          19.75
                          20.50
                          20.20
                          20.50
                          20.25
                          20.50
                          20.50
                          20.50
                          ^CTraceback (most recent call last):
                          File "/usr/local/bin/max6675-1.py", line 60, in <module>
                          time.sleep(0.25) # Don't try to read more often than 4 times a second.
                          KeyboardInterrupt

                          Comment

                          • bekem
                            Junior Member
                            • Oct 2018
                            • 10

                            #15
                            Originally posted by brunohl
                            Other thing you could do is schedule a task in your cron to run, then write the results in a txt file and then on your agent check you could just read the file created:

                            Cron (to run every 10 minutes):
                            Code:
                            */10 * * * * /usr/local/bin/max6675-1.py > /tmp/result.txt
                            Check:
                            Code:
                            UserParameter=check_max,cat /tmp/result.txt
                            Of course you will always be sometime behind, but I guess it's better than timeout.
                            Hi, I did this and the result was not expected, I think the timeout was better more..

                            I think there is something in python script needs to be considered to work with zabbix...

                            Comment

                            Working...