Ad Widget

Collapse

Logging data from web page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danodemano
    Junior Member
    • Jun 2014
    • 21

    #1

    Logging data from web page

    Hello everyone,

    I have been working with Zabbix for some time now but have a really stupid question that I can't seem to find the answer to. I have some temperature sensors in my house logging to a MySQL database (not on the same server as Zabbix) that I would like to query. I have written a simple PHP page that returns ONLY the value of a specied sensor but I cannot figure out how to log/graph/trigger on this data. The web monitoring doesn't seem to do this (unless I'm missing something) and I didn't find anything useful in the external scripts. Any help would be greatly appreciated. Thanks!!

    --
    Dan
  • aib
    Senior Member
    • Jan 2014
    • 1615

    #2
    Zabbix server widely uses curl to get any data from http:// links.

    Do you mind to try something like:
    Code:
    curl http://sensor_page.html | grep "Temperature:" | awk '{print $2;}'
    It will works if you have a simple page like
    Temperature: 32.9 °C


    If your command works, you can add it to UserParameter= in /etc/zabbix/zabbix_agent.conf file and then you can create Item/Triggers/Graphs with that Item in use.

    OK?
    Sincerely yours,
    Aleksey

    Comment

    • danodemano
      Junior Member
      • Jun 2014
      • 21

      #3
      Aleksey,

      Than k you very much for your reply! I think we are on the right track however when I attempt to query the custom parameter Zabbix is giving a not supported. Here is what I have done. Running the curl manually works correctly as expected:

      Code:
      [root@zabbix zabbix_agentd.d]# curl http://arduino1.danodemano.com/get_data.php?sensor=1 | grep "Temperature:" | awk '{print $2;}'
      
        % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                       Dload  Upload   Total   Spent    Left  Speed
        0    18    0    18    0     0      3      0 --:--:--  0:00:05 --:--:--   189
      86.00
      [root@zabbix zabbix_agentd.d]#
      So I created a new .conf file in /etc/zabbix/zabbix_agent.d and called it userparameters_temps.conf and it contains:

      Code:
      #Arduino temperature monitoring
      UserParameter=arduino.temp1,curl http://arduino1.danodemano.com/get_data.php?sensor=1 | grep "Temperature:" | awk '{print $2;}'
      I restarted the agent but when I attempt to query the parameter I get a not supported error:

      Code:
      [root@zabbix zabbix_agentd.d]# zabbix_agentd -t arduino.temp1
      arduino.temp1                                 [m|ZBX_NOTSUPPORTED]
      [root@zabbix zabbix_agentd.d]#
      Is there something else I'm missing here? Thanks again, I really appreciate it!

      --
      Dan

      Comment

      • danodemano
        Junior Member
        • Jun 2014
        • 21

        #4
        Nevermind, I can't edit the reply I made since it hasn't been posted yet. I set UnsafeUserParameters to a 1 and also increased my timeout value to 15 and it's working correctly now. Thanks again for the help, it's greatly appreciated!!

        --
        Dan

        Comment

        • aib
          Senior Member
          • Jan 2014
          • 1615

          #5
          Anytime!

          Just for future use - curl has an option -s (silent)
          When you use that option, you will never seen the extra lines like
          Code:
            % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                           Dload  Upload   Total   Spent    Left  Speed
            0    18    0    18    0     0      3      0 --:--:--  0:00:05 --:--:--   189
          Sincerely yours,
          Aleksey

          Comment

          • danodemano
            Junior Member
            • Jun 2014
            • 21

            #6
            Sweet! Didn't know that. It's been working perfectly though since I got everything up and running. I think I wan't to move the agent that's running the requests to my web server but that's another issue. I think I'm still getting some timeouts but the graph is looking awesome:



            Thanks again, I really do appreciate it!!!

            Comment

            • aib
              Senior Member
              • Jan 2014
              • 1615

              #7
              wow.
              it's really hot in your home.
              did you try to open windows?
              Sincerely yours,
              Aleksey

              Comment

              • danodemano
                Junior Member
                • Jun 2014
                • 21

                #8
                Haha, we don't run the AC much but the windows are always open.

                Comment

                Working...