PDA

View Full Version : zabbix & customer multiplier


vgray
04-01-2006, 11:46
Zabbix (beta5) do no corretly support custom multiplier

I receive value 1234 from snmp, use multiplier 0.001 and want get in result 1.234

if I use Type of information = int 64 then zabbix makes result=value*int(0.001) => result =0

if( (item->value_type==ITEM_VALUE_TYPE_UINT64) && (value->type & AR_UINT64))
{
value->ui64 = value->ui64 * (zbx_uint64_t)atoll(item->formula);
}

if I use Type of information =float then zabbix do not use multiplier becouse my snmp value is not float

if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_DOUBLE ))
{
multiplier = strtod(item->formula,&e);
value->dbl = value->dbl * multiplier;
}

it should be fixed!

Alexei
04-01-2006, 13:41
Haveyou seen this:

else if((item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_UINT64))
{
if((item->prevorgvalue_null == 0) && (item->prevorgvalue <= (double)value->ui64) )
{
DBadd_history(item->itemid, ((double)value->ui64 - item->prevorgvalue), now);
}
}

It is exactly your case. Anyway, I'll retest this to see if it works correctly.

vgray
04-01-2006, 14:25
I've search trought beta5 code and found you fragment in add_history function,
but I've spoken about process_new_value function in which we use "item->formula"

I am not C programmer and I don't know C at all (i use perl) so please check your code in process_new_value

if(item->multiplier == ITEM_MULTIPLIER_USE)
{
if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_DOUBLE))
{
multiplier = strtod(item->formula,&e);
value->dbl = value->dbl * multiplier;
}
if( (item->value_type==ITEM_VALUE_TYPE_UINT64) && (value->type & AR_UINT64))
{
value->ui64 = value->ui64 * (zbx_uint64_t)atoll(item->formula);
}
}

PS: I've rolled back to beta2 becouse with beta5 my squid graph going crazy

Alexei
04-01-2006, 14:30
Add this code to the two IFs to make it work:

if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_UINT64))
{
multiplier = strtod(item->formula,&e);
value->dbl = (double)value->ui64 * multiplier;
}


Thanks for reporting this!

vgray
04-01-2006, 14:57
thank you

but why if I use Type of information = int 64 and multiplier (for example) 0.05
zabbix makes result=value*int(0.5) => result =0 , I think will be better next behavior result = int (value*0.5)

Alexei
04-01-2006, 15:32
Good idea! Use this code:

if( (item->value_type==ITEM_VALUE_TYPE_UINT64) && (value->type & AR_UINT64))
{
if(is_uint(item->formula))
{
value->ui64 = value->ui64 * (zbx_uint64_t)atoll(item->formula);
}
else
{
multiplier = strtod(item->formula,&e);
value->dbl = (zbx_uint64_t)((double)value->ui64 * multiplier);
}
}

vgray
05-01-2006, 05:10
else
{
multiplier = strtod(item->formula,&e);
value->dbl = (zbx_uint64_t)((double)value->ui64 * multiplier);


Are you right? is really should be value->dbl ?

or maybe it should be value->ui64

And, Alexei current zabbix code do not support situation with
item->value_type = ITEM_VALUE_TYPE_UINT64 and
value->type = AR_DOUBLE
could you add support for it?