Ad Widget

Collapse

Using Zabcon to retrieve graph (images)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #1

    Using Zabcon to retrieve graph (images)

    It's a topic that often comes up, how can you retrieve a Zabbix graph using a command line utility? Often before this would require a custom script which called wget or a similar program.

    Now you don't need to write your own script, but rather you can use Zabcon to retrieve the graphs.

    During the conference I talked about creating your own custom commands for Zabcon, I figure the best way to show people the power of this approach would be to release this as a Zabcon custom command. Meaning if you already have Zabcon installed you don't need to update your Zabcon install, but rather download the command file and update your zabcon.conf file.

    The file can be downloaded here:


    Otherwise it can be browsed here:


    When installed the command allows the following syntax:
    Code:
    zabbix get graph itemid=1234 start=now-5h end=now-4h filename=graph_out
    Which will download the graph for item 1234 to the file graph_out.png. If no path is specified the directory in which zabxon was executed is used. The extension is set by mime time returned by Zabbix server, if you need to convert the image to another format ImageMagic is recommended.

    width is also an option should you prefer to have the graph have a specified width in pixels.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

  • LeoCombes
    Member
    • Mar 2011
    • 32

    #2
    I will try!

    Comment

    • 0siris
      Member
      Zabbix Certified Specialist
      • Nov 2010
      • 76

      #3
      Hi Nelson,
      I'm trying to figure out how I can use this: for a large number of items we have to manually create graphs of the previous month, every month, so thats a lot of clicking and slider adjustments.

      I've looked into the .rb file, but I'm not sure to understand if the syntax allows for that. So typically we (I say "we" but I'm not actually doing this manual labour thank goodness) start clicking away and produce the graphs in the first couple of days of every month (so from first day of the previous month 00:00 am to last day of the previous month 23:59:59 pm).

      Is an adaptation to easily procuce previous-month-graphs possible/feasible or should I try and rape^W adapt your scripts myself?

      Comment

      • nelsonab
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2006
        • 1233

        #4
        Sounds like you just need to be able to feed the command a date range, vs a relative start/stop time? That shouldn't be too difficult to add.
        RHCE, author of zbxapi
        Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
        Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

        Comment

        Working...