Skip to content

Instantly share code, notes, and snippets.

@BlueSkyDetector
Created February 14, 2013 02:09
Show Gist options
  • Select an option

  • Save BlueSkyDetector/4950116 to your computer and use it in GitHub Desktop.

Select an option

Save BlueSkyDetector/4950116 to your computer and use it in GitHub Desktop.

Revisions

  1. BlueSkyDetector created this gist Feb 14, 2013.
    22 changes: 22 additions & 0 deletions get_zabbix_graph.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/usr/bin/env python

    ### setting start ###
    import urllib2, cookielib
    login_url = 'http://192.168.0.16/zabbix/index.php'
    graph_url = 'http://192.168.0.16/zabbix/chart2.php'
    name = 'Admin'
    password = 'zabbix'
    graphid = 388
    output_file = 'out_graph.jpg'
    ### setting end ###


    c = cookielib.CookieJar()
    ch = urllib2.HTTPCookieProcessor(c)
    op = urllib2.build_opener(ch)
    r = op.open(login_url,"form_refresh=1&name;=%s&password;=%s&enter=Enter" % (name, password))
    r = op.open(graph_url + "?graphid=" + str(graphid))
    f = open(output_file,'wb')
    f.write(r.read())
    f.close()
    r.close()