Ad Widget

Collapse

Download Graph in png

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Niolith
    Junior Member
    • May 2018
    • 3

    #1

    Download Graph in png

    Hello everyone,

    I check a couple of post in the Zabbix Forum and others sites to find a solution to download a graph using a curl command.
    The function zablogin is

    Hello everyone,

    I check a couple of post in the Zabbix Forum and others sites to find a solution to download a graph using a curl command.
    Code:
    curl -X GET -v -o chart.png --cookie 'zbx_sessionid=#{zablogin}' "[URL="http://10.100.5.46/zabbix/chart.php?from=now-1M&to=now&itemids=72351&profileIdx=web.item.graph.filter&width=1733"]http://192.168.0.10/zabbix/chart.php?from=now-1M&to=now&itemids=72351&profileIdx=web.item.graph.filter&width=1733[/URL]"

    The function zablogin is
    Code:
    def zabpost(payload)
      req = Net::HTTP::Post.new("/zabbix/api_jsonrpc.php", initheader = {'Content-Type' =>'application/json'})
      req.basic_auth "script", "scr1pt"
      req.body = payload
      response = Net::HTTP.new("[URL="http://10.100.5.46/zabbix/chart.php?from=now-1M&to=now&itemids=72351&profileIdx=web.item.graph.filter&width=1733"]192.168.0.10[/URL]", "80").start {|http| http.request(req) }
      puts "Response #{response.code} #{response.message}: #{response.body}"
      return JSON.parse(response.body)
      #return JSON.parse(response.body, object_class: OpenStruct)
    end
    
    def zablogin
      payload = '
        {
          "jsonrpc":"2.0",
          "method": "user.login",
          "params": {
            "user": "script",
            "password":"scr1pt"
          },
          "id": 0
        }'
      temp = zabpost(payload)
      return temp["result"]
    end
    Unfortunately, when I run this, I get an empty graph :

    Click image for larger version  Name:	chart.png Views:	0 Size:	15.5 KB ID:	392414

    Could you help me to find a solution ?

    Thanks,
Working...