Ad Widget

Collapse

[chart.php] Allow user defined order

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gammuts
    Junior Member
    • Feb 2016
    • 6

    #1

    [chart.php] Allow user defined order

    I would like to see chart.php modified to allow for a user defined order (dictated by itemIds). My workaround/hack is in the background information below.



    Background and/or use case:

    I'm trying to write a program that e-mails graphs that are defined in a screen, somewhat like https://www.zabbix.com/forum/showthread.php?t=15316

    The screen has 2 colums:
    1) Simple graph prototype for disk used (in bytes, not percent)
    2) Simple graph prototype for disk free (in bytes, not percent)

    In my report, I ask Zabbix for a stacked graph, as it will give the receiver of the report also the total disk space. The URL for getting the PNG is http://localhost/zabbix/chart.php?st...emids[1]=87950

    But no matter which item ID I put first, I always get disk free first. That screwes up my graph. So, some sort of sorting is done in chart.php or its helpers. And I do not want Zabbix to sort it for me, since I depend on my order for correct graphs.

    My quickfix was to force the order I specified via itemids parameter:
    Code:
    [root@zbx01 ~]# rpm -qi zabbix-server | awk '/^Version/ {print $3}'
    2.4.7
    [root@zbx01 ~]# 
    [root@zbx01 ~]# diff -u /usr/share/zabbix/chart.php{-dd20160203BD-original-order-please,}
    --- /usr/share/zabbix/chart.php-dd20160203BD-original-order-please	2015-11-12 11:12:37.000000000 +0100
    +++ /usr/share/zabbix/chart.php	2016-02-03 11:34:27.785941705 +0100
    @@ -116,7 +116,8 @@
     	$graph->setBorder(0);
     }
     
    -foreach ($items as $item) {
    +foreach ($itemIds as $itemId) {
    +	$item = $items[$itemId];
     	$graph->addItem($item['itemid'], GRAPH_YAXIS_SIDE_DEFAULT, (getRequest('batch')) ? CALC_FNC_AVG : CALC_FNC_ALL,
     		rgb2hex(get_next_color(1))
     	);
    [root@zbx01 ~]#
    But I agree that this may break existing graphs or user experience. So, an extra option would more likely be a more general solution.
Working...