lukecyca/pyzabbix

The average value from zapi.trend.get is different from GUI

ella87 opened this issue · 3 comments

ella87 commented

Hi, just meet this issue recently, we found that with the same duration (2hours), the average of traffic from zapi.trend.get is quite different from what we can see in the Zabbix GUI.
zabbix_gui
The traffic average value from zapi.trend.get is smaller than the value from Zabbix GUI.
zapi_trend_get
Does anyone know why?

def get_utilization_avg(item_ids, item_name, time_from, time_till):
    # Query item's trend (float) data (all should be float value)
    history = zapi.trend.get(itemids=item_ids, time_from=time_from, time_till=time_till,
                             output=["itemid", "value_avg"], limit="1", history=0)
    avg_value = float(history[0].get('value_avg'))
    if 'bond' in item_name:
        avg = round(avg_value / (1024 * 1024), 2)
    elif 'idle' in item_name:
        avg = round(100 - avg_value, 2)
    else:
        avg = round(avg_value, 2)
    return avg

Moreover, the value after 2 hour is always the same, as shown in below snapshot during performance testing.
avg_same

ella87 commented

Hi, sorry for this, it is the value convert not correct, after I checked, the bps -> Mbps should divide 1,000,000, not 1024*1024.
avg = round(avg_value / (1024 * 1024), 2) => avg = round(avg_value / 1000000, 2)
But for why the value is always the same after that time, I didn't know

jooola commented

Hi, I am gonna close this as this seem unrelated to the pyzabbix library.

ella87 commented

Okay, thanks, I'll keep investigating this issue myself.