summaryrefslogtreecommitdiffstats
path: root/src/zabbix_server
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-06 23:55:23 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-06 23:55:23 +0000
commitd3df28b936d259b8d3e91deeeba2104e87dffc8c (patch)
treef80e86dbe44d37c015bb5c58d5ed08fc859f57be /src/zabbix_server
parentdf815285d27dc77733398d14db0bfbc27a7a3c3e (diff)
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@2813 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_server')
-rw-r--r--src/zabbix_server/evalfunc.c7
-rw-r--r--src/zabbix_server/functions.c10
-rw-r--r--src/zabbix_server/poller/poller.c23
-rw-r--r--src/zabbix_server/server.c2
-rw-r--r--src/zabbix_server/timer/timer.c7
-rw-r--r--src/zabbix_server/zlog.c33
6 files changed, 43 insertions, 39 deletions
diff --git a/src/zabbix_server/evalfunc.c b/src/zabbix_server/evalfunc.c
index e062d5da..88a2d6f5 100644
--- a/src/zabbix_server/evalfunc.c
+++ b/src/zabbix_server/evalfunc.c
@@ -1109,6 +1109,7 @@ int evaluate_FUNCTION2(char *value,char *host,char *key,char *function,char *par
{
DB_ITEM item;
DB_RESULT result;
+ DB_ROW row;
char sql[MAX_STRING_LEN];
int res;
@@ -1118,7 +1119,9 @@ int evaluate_FUNCTION2(char *value,char *host,char *key,char *function,char *par
snprintf(sql,sizeof(sql)-1,"select %s where h.host='%s' and h.hostid=i.hostid and i.key_='%s'", ZBX_SQL_ITEM_SELECT, host, key );
result = DBselect(sql);
- if(DBnum_rows(result) == 0)
+ row = DBfetch(result);
+
+ if(!row)
{
DBfree_result(result);
zabbix_log(LOG_LEVEL_WARNING, "Query [%s] returned empty result", sql );
@@ -1126,7 +1129,7 @@ int evaluate_FUNCTION2(char *value,char *host,char *key,char *function,char *par
return FAIL;
}
- DBget_item_from_db(&item,result, 0);
+ DBget_item_from_db(&item,row);
zabbix_log(LOG_LEVEL_DEBUG, "Itemid:%d", item.itemid );
diff --git a/src/zabbix_server/functions.c b/src/zabbix_server/functions.c
index 70dc7444..2825592a 100644
--- a/src/zabbix_server/functions.c
+++ b/src/zabbix_server/functions.c
@@ -405,6 +405,7 @@ int process_data(int sockfd,char *server,char *key,char *value,char *lastlogsize
AGENT_RESULT agent;
DB_RESULT result;
+ DB_ROW row;
DB_ITEM item;
char *s;
@@ -424,7 +425,9 @@ int process_data(int sockfd,char *server,char *key,char *value,char *lastlogsize
result = DBselect(sql);
- if(DBnum_rows(result) == 0)
+ row=DBfetch(result);
+
+ if(!row)
{
zabbix_log( LOG_LEVEL_DEBUG, "Before checking autoregistration for [%s]",server);
@@ -433,7 +436,8 @@ int process_data(int sockfd,char *server,char *key,char *value,char *lastlogsize
DBfree_result(result);
result = DBselect(sql);
- if(DBnum_rows(result) == 0)
+ row = DBfetch(result);
+ if(!row)
{
DBfree_result(result);
return FAIL;
@@ -446,7 +450,7 @@ int process_data(int sockfd,char *server,char *key,char *value,char *lastlogsize
}
}
- DBget_item_from_db(&item,result,0);
+ DBget_item_from_db(&item,row);
/* item.itemid=atoi(DBget_field(result,0,0));
strscpy(item.key,DBget_field(result,0,1));
diff --git a/src/zabbix_server/poller/poller.c b/src/zabbix_server/poller/poller.c
index d1bfc8c3..03e43fdd 100644
--- a/src/zabbix_server/poller/poller.c
+++ b/src/zabbix_server/poller/poller.c
@@ -164,6 +164,7 @@ static void update_key_status(int hostid,int host_status)
DB_ITEM item;
DB_RESULT result;
+ DB_ROW row;
zabbix_log(LOG_LEVEL_DEBUG, "In update_key_status(%d,%d)",hostid,host_status);
@@ -171,13 +172,11 @@ static void update_key_status(int hostid,int host_status)
zabbix_log(LOG_LEVEL_DEBUG, "SQL [%s]", sql);
result = DBselect(sql);
- if( DBnum_rows(result) == 0)
- {
- zabbix_log( LOG_LEVEL_DEBUG, "No items to update.");
- }
- else
+ row = DBfetch(result);
+
+ if(row)
{
- DBget_item_from_db(&item,result,0);
+ DBget_item_from_db(&item,row);
/* Do not process new value for status, if previous status is the same */
zabbix_log( LOG_LEVEL_DEBUG, "item.lastvalue[%f] new host status[%d]",item.lastvalue,host_status);
@@ -191,6 +190,10 @@ static void update_key_status(int hostid,int host_status)
update_triggers(item.itemid);
}
}
+ else
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "No items to update.");
+ }
DBfree_result(result);
}
@@ -215,13 +218,13 @@ int get_values(void)
char sql[MAX_STRING_LEN];
DB_RESULT result;
+ DB_ROW row;
- int i;
int now;
int res;
DB_ITEM item;
AGENT_RESULT agent;
- int stop;
+ int stop=0;
now = time(NULL);
@@ -243,9 +246,9 @@ int get_values(void)
}
result = DBselect(sql);
- for(stop=i=0;i<DBnum_rows(result)&&stop==0;i++)
+ while((row=DBfetch(result))&&(stop==0))
{
- DBget_item_from_db(&item,result, i);
+ DBget_item_from_db(&item,row);
init_result(&agent);
zabbix_log( LOG_LEVEL_DEBUG, "GOT VALUE TYPE [0x%X]", agent.type);
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index ae166175..d927ce32 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -490,7 +490,7 @@ void test()
int main(int argc, char **argv)
{
int ch;
- int i,j;
+ int i;
pid_t pid;
struct sigaction phan;
diff --git a/src/zabbix_server/timer/timer.c b/src/zabbix_server/timer/timer.c
index d3cd271e..5dcc27c2 100644
--- a/src/zabbix_server/timer/timer.c
+++ b/src/zabbix_server/timer/timer.c
@@ -64,7 +64,7 @@ extern void update_functions(DB_ITEM *item);
void main_timer_loop()
{
char sql[MAX_STRING_LEN];
- int i,now;
+ int now;
/* int itemid,functionid;
char *function;
@@ -73,6 +73,7 @@ void main_timer_loop()
DB_ITEM item;
DB_RESULT result;
+ DB_ROW row;
for(;;)
{
@@ -95,9 +96,9 @@ void main_timer_loop()
result = DBselect(sql);
- for(i=0;i<DBnum_rows(result);i++)
+ while((row=DBfetch(result)))
{
- DBget_item_from_db(&item,result, i);
+ DBget_item_from_db(&item,row);
/* Update triggers will update value for NODATA */
/* snprintf(sql,sizeof(sql)-1,"update functions set lastvalue='1' where itemid=%d and function='%s' and parameter='%s'" , itemid, function, parameter );
diff --git a/src/zabbix_server/zlog.c b/src/zabbix_server/zlog.c
index 99ef20cc..5a9d36d4 100644
--- a/src/zabbix_server/zlog.c
+++ b/src/zabbix_server/zlog.c
@@ -51,13 +51,13 @@
******************************************************************************/
void zabbix_syslog(const char *fmt, ...)
{
- int i;
va_list ap;
char sql[MAX_STRING_LEN];
char value_str[MAX_STRING_LEN];
DB_ITEM item;
DB_RESULT result;
+ DB_ROW row;
AGENT_RESULT agent;
@@ -66,28 +66,21 @@ void zabbix_syslog(const char *fmt, ...)
snprintf(sql,sizeof(sql)-1,"select %s where h.hostid=i.hostid and i.key_='%s' and i.value_type=%d", ZBX_SQL_ITEM_SELECT, SERVER_ZABBIXLOG_KEY, ITEM_VALUE_TYPE_STR);
result = DBselect(sql);
- if( DBnum_rows(result) == 0)
+ while((row=DBfetch(result)))
{
- zabbix_log( LOG_LEVEL_DEBUG, "No zabbix[log] to update.");
- }
- else
- {
- for(i=0;i<DBnum_rows(result);i++)
- {
- DBget_item_from_db(&item,result, i);
-
- va_start(ap,fmt);
- vsprintf(value_str,fmt,ap);
- value_str[MAX_STRING_LEN-1]=0;
- va_end(ap);
+ DBget_item_from_db(&item,row);
+
+ va_start(ap,fmt);
+ vsprintf(value_str,fmt,ap);
+ value_str[MAX_STRING_LEN-1]=0;
+ va_end(ap);
- init_result(&agent);
- SET_STR_RESULT(&agent, strdup(value_str));
- process_new_value(&item,&agent);
- free_result(&agent);
+ init_result(&agent);
+ SET_STR_RESULT(&agent, strdup(value_str));
+ process_new_value(&item,&agent);
+ free_result(&agent);
- update_triggers(item.itemid);
- }
+ update_triggers(item.itemid);
}
DBfree_result(result);