Ad Widget

Collapse

delta(#n) not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vince2
    Member
    • Oct 2006
    • 40

    #1

    delta(#n) not working

    Hi !

    delta(#n) function is not working in 1.1.2.

    Here is the following snippet of code from evalfunc.c

    Code:
    	else if(flag == ZBX_FLAG_VALUES)
    	{
    		snprintf(sql,sizeof(sql)-1,"select value from history where itemid=%d order by clock desc",item->itemid);
    		result = DBselectN(sql,parameter);
    		rows=0;
    		while((row=DBfetch(result)))
    		{
    			f=atof(row[0]);
    			if(rows==0)
    			{
    				min=f;
    				max=f;
    			}
    			else
    			{
    				if(f>max)	max=f;
    				if(f<min)	min=f;
    			}
    		}
    		if(rows==0)
    		{
    			zabbix_log(LOG_LEVEL_DEBUG, "Result for DELTA is empty" );
    			res = FAIL;
    		}
    		else
    		{
    			snprintf(value,MAX_STRING_LEN-1,"%f", max-min);
    		}
    	}
    rows seem to be never incremented. First test on rows should be 'rows++==0'.

    Another problem with delta is that the templates given out with zabbix call delta with parameter 0. Therefore, the condition in the SQL select if clock>now (now-parameter=now with parameter to 0). Then, delta is always empty.
Working...