Ad Widget

Collapse

Get the graph url

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amaranth
    Junior Member
    • Mar 2013
    • 4

    #1

    Get the graph url

    I am currently using Zabbix 2.0 to monitor some machines. My hosts have graphs.

    I am in the process of creating a Python script in order to download the images of specific graphs to include them into a report. I have the host name and the graph name.

    I am not there yet, I currently only did the login, but I intend to get the host from it's name, go through the graph and find the right graph.

    Once I have that graph, is there a way to get the url of the image that is produced in the preview tab of the graph configuration page?

    I don't want to generate the url manually with the graph attributes since the image url has over 1700 characters (many items in it).
  • Amaranth
    Junior Member
    • Mar 2013
    • 4

    #2
    I was able to find the graph. I added permissions to the guest account to be able to read some info and i'm able to access the graph in the browser without login with an url like this:

    url = serverAdd + 'zabbix/chart2.php?' + 'graphid=' + graphid

    However, when I try to dowload the graph

    graphImage = urllib2.urlopen(graphUrl)
    ...

    I get an error:
    urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

    Comment

    • Amaranth
      Junior Member
      • Mar 2013
      • 4

      #3
      Finally, I was able to work around the issue, but I was wondering if there was a better way.

      # DOWNLOADS and SAVES the graph image
      r=requests.post(graphUrl)

      # SAVES the graph image
      file = open(hostname + " - " + searchedGraph + ".png", "wb")
      file.write(r.content)
      file.close()

      Comment

      Working...