From be87127fd58ca5bbdfd6ff6abbd831dcfbe867ab Mon Sep 17 00:00:00 2001 From: hugetoad Date: Fri, 21 Apr 2006 15:39:05 +0000 Subject: Minor changes. git-svn-id: svn://svn.zabbix.com/trunk@2764 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- src/zabbix_server/poller/checks_aggregate.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/zabbix_server/poller/checks_aggregate.c b/src/zabbix_server/poller/checks_aggregate.c index 0a8c2b61..8fc46a18 100644 --- a/src/zabbix_server/poller/checks_aggregate.c +++ b/src/zabbix_server/poller/checks_aggregate.c @@ -27,16 +27,21 @@ static int evaluate_aggregate(AGENT_RESULT *res,char *grpfunc, char *hostgroup, char *itemkey, char *itemfunc, char *param) { char sql[MAX_STRING_LEN]; + char hostgroup_esc[MAX_STRING_LEN],itemkey_esc[MAX_STRING_LEN]; DB_RESULT *result; - int i; + int i,valuetype; + double d = 0, value; zabbix_log( LOG_LEVEL_WARNING, "In evaluate_aggregate('%s','%s','%s','%s','%s')",grpfunc,hostgroup,itemkey,itemfunc,param); + DBescape_string(itemkey,itemkey_esc,MAX_STRING_LEN); + DBescape_string(hostgroup,hostgroup_esc,MAX_STRING_LEN); + if(strcmp(itemfunc,"last") == 0) { - snprintf(sql,sizeof(sql)-1,"select items.lastvalue,items.value_type from items,hosts_groups,hosts,groups where groups.groupid=1 and hosts_groups.groupid=groups.groupid and items.hostid=hosts.hostid and hosts_groups.hostid=hosts.hostid and items.lastvalue!=NULL and groups.name='%s'",hostgroup); + snprintf(sql,sizeof(sql)-1,"select items.lastvalue,items.value_type from items,hosts_groups,hosts,groups where hosts_groups.groupid=groups.groupid and items.hostid=hosts.hostid and hosts_groups.hostid=hosts.hostid and items.lastvalue is not NULL and groups.name='%s' and items.key_='%s'",hostgroup_esc, itemkey_esc); } zabbix_log( LOG_LEVEL_WARNING, "SQL [%s]",sql); @@ -44,11 +49,29 @@ static int evaluate_aggregate(AGENT_RESULT *res,char *grpfunc, char *hostgroup, for(i=0;i