Ad Widget

Collapse

API: Retrieve Graph image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mojah
    Member
    • Apr 2010
    • 60

    #1

    API: Retrieve Graph image

    Is there currently a way to retrieve the graph of a host as a full image from the API?

    The current "graph.get" retrieves actual data (name, graphid, values), but I'm trying to integrate Zabbix Graphs using this API, so I don't have to render them myself by querying all the data.

    If it's not possible, would it be considered for addition later?

    And if not, is there a way to retrieve the data from the "chart2.php?graphid=[id]" directly, without logging in to the webfrontend (so I can fetch the data on that page from my appliance & present it to the user, without logging in to the "real" zabbix web frontend first)? I don't like to give the guest account read privileges on these graphs, I prefer to keep it secured by using the authentication mechanisme in the API.
    Last edited by Mojah; 06-09-2010, 00:36.
  • Aly
    ZABBIX developer
    • May 2007
    • 1126

    #2
    Hi, as you mentioned currently it's not possible, but in future such feature definitely will be added.
    Zabbix | ex GUI developer

    Comment

    • Mojah
      Member
      • Apr 2010
      • 60

      #3
      Hi,

      Ok, are there proper guidelines on "forging" sessions/cookies to retrieve it directly from the graph2.php page? By "forging", I of course mean using valid credentials, but setting up the sessions/cookies in a way that is accepted by the Zabbix Frontend.

      If not, I'll have to deepdive into the code and track it down ...

      Regards,
      Mattias

      Comment

      • Aly
        ZABBIX developer
        • May 2007
        • 1126

        #4
        Try searching the forum there are some ways to get images by curl.
        Zabbix | ex GUI developer

        Comment

        • Mojah
          Member
          • Apr 2010
          • 60

          #5
          The forum search did indeed yield some results. For the PHP implementers among us, here's how.

          PHP Code:
          // Get the login-cookie
          $strWgetLogin           "wget --save-cookies=cookies.txt --keep-session-cookies --post-data \"name={zabbixuser}&password={zabbixpass}&enter=Enter\" -O - -q \"http://url/index.php?login=1\"";
          exec($strWgetLogin);

          // Wget our graph!
          $strWget        "wget --load-cookies=cookies.txt -O graph.png -q \"http://url/chart2.php?graphid={graphid}&width=400\"";
          exec($strWget); 
          To be expanded to include security etc!

          Thanks!

          Comment

          • azislo
            Junior Member
            • Mar 2011
            • 2

            #6
            Is it now possible to get graph as .png file via API (without any php stuff) ? All I get are graphid's and similar things. I need it for my experimental Zabbix android app, can't use cURL or something similar ...

            Thanks for help.

            Comment

            • Mojah
              Member
              • Apr 2010
              • 60

              #7
              Originally posted by azislo
              Is it now possible to get graph as .png file via API (without any php stuff) ? All I get are graphid's and similar things. I need it for my experimental Zabbix android app, can't use cURL or something similar ...

              Thanks for help.
              For now: no. We worked around this via curl, or by using system calls to retrieve the graph. Have a look at the source: https://github.com/mattiasgeniar/MoZ...ass_zabbix.php

              It's in the function getGraphImageById().

              Comment

              • simon123
                Junior Member
                • Oct 2010
                • 22

                #8
                Originally posted by Mojah
                For now: no. We worked around this via curl, or by using system calls to retrieve the graph. Have a look at the source: https://github.com/mattiasgeniar/MoZ...ass_zabbix.php

                It's in the function getGraphImageById().
                Is there already a feature request for this? This would be a major improvement!

                EDIT:

                Nevermind, found it:

                Last edited by simon123; 12-08-2011, 10:13.

                Comment

                • Mojah
                  Member
                  • Apr 2010
                  • 60

                  #9
                  Originally posted by simon123
                  Is there already a feature request for this? This would be a major improvement!
                  None that I'm aware of, so feel free to add it. But actually, curl is available for many languages, so just using that to retrieve your graphs is a viable way of getting it done.

                  Comment

                  Working...