diff options
author | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-03-12 11:48:06 +0000 |
---|---|---|
committer | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-03-12 11:48:06 +0000 |
commit | a898c94111e6c0932c49f8af20570a473da5be21 (patch) | |
tree | 367715a9e0f1376ca6794258e453261a2dcce711 | |
parent | 8d6cd503a08f956059438f34c33758de943af48a (diff) | |
download | zabbix-a898c94111e6c0932c49f8af20570a473da5be21.tar.gz zabbix-a898c94111e6c0932c49f8af20570a473da5be21.tar.xz zabbix-a898c94111e6c0932c49f8af20570a473da5be21.zip |
- added support of avg() for items having integer type (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@3881 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/zabbix_server/evalfunc.c | 47 |
2 files changed, 28 insertions, 20 deletions
@@ -1,5 +1,6 @@ Changes for 1.3.4: + - added support of avg() for items having integer type (Alexei) - added user group for database down messages (Alexei/Eugene) - removed support of action repeats (Alexei) - fixed upgrade of rights,sysmaps,sysmaps_elements (Alexei) diff --git a/src/zabbix_server/evalfunc.c b/src/zabbix_server/evalfunc.c index 82f2c00f..ee6574e8 100644 --- a/src/zabbix_server/evalfunc.c +++ b/src/zabbix_server/evalfunc.c @@ -357,17 +357,30 @@ static int evaluate_AVG(char *value,DB_ITEM *item,int parameter,int flag) int rows; double sum=0; - if(item->value_type != ITEM_VALUE_TYPE_FLOAT) + char table[MAX_STRING_LEN]; + + if( (item->value_type != ITEM_VALUE_TYPE_FLOAT) && (item->value_type != ITEM_VALUE_TYPE_UINT64)) { return FAIL; } now=time(NULL); + if(item->value_type == ITEM_VALUE_TYPE_UINT64) + { + strscpy(table,"history_uint"); + } + else + { + strscpy(table,"history"); + } + if(flag == ZBX_FLAG_SEC) { - result = DBselect("select avg(value) from history where clock>%d and itemid=" ZBX_FS_UI64, - now-parameter,item->itemid); + result = DBselect("select avg(value) from %s where clock>%d and itemid=" ZBX_FS_UI64, + table, + now-parameter, + item->itemid); row = DBfetch(result); @@ -384,7 +397,8 @@ static int evaluate_AVG(char *value,DB_ITEM *item,int parameter,int flag) } else if(flag == ZBX_FLAG_VALUES) { - zbx_snprintf(sql,sizeof(sql),"select value from history where itemid=" ZBX_FS_UI64 " order by clock desc", + zbx_snprintf(sql,sizeof(sql),"select value from %s where itemid=" ZBX_FS_UI64 " order by clock desc", + table, item->itemid); result = DBselectN(sql, parameter); rows=0; @@ -455,16 +469,17 @@ static int evaluate_MIN(char *value,DB_ITEM *item,int parameter, int flag) now=time(NULL); + if(item->value_type == ITEM_VALUE_TYPE_UINT64) + { + strscpy(table,"history_uint"); + } + else + { + strscpy(table,"history"); + } + if(flag == ZBX_FLAG_SEC) { - if(item->value_type == ITEM_VALUE_TYPE_UINT64) - { - strscpy(table,"history_uint"); - } - else - { - strscpy(table,"history"); - } result = DBselect("select min(value) from %s where clock>%d and itemid=" ZBX_FS_UI64, table, now-parameter,item->itemid); row = DBfetch(result); @@ -481,14 +496,6 @@ static int evaluate_MIN(char *value,DB_ITEM *item,int parameter, int flag) } else if(flag == ZBX_FLAG_VALUES) { - if(item->value_type == ITEM_VALUE_TYPE_UINT64) - { - strscpy(table,"history_uint"); - } - else - { - strscpy(table,"history"); - } zbx_snprintf(sql,sizeof(sql),"select value from %s where itemid=" ZBX_FS_UI64 " order by clock desc", table,item->itemid); result = DBselectN(sql,parameter); |