summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-07 16:07:05 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-07 16:07:05 +0000
commitba8ff71d6e665ad0ff150937baaaf2bb073fe10e (patch)
tree192d6a169db1a1c16505ac88511b2adf16d8a26f /src
parent5448b89c2d4c3436b7a24ee8994ea2795e4aff20 (diff)
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@2816 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxdbhigh/db.c27
-rw-r--r--src/zabbix_server/functions.c44
-rw-r--r--src/zabbix_server/pinger/pinger.c4
-rw-r--r--src/zabbix_server/poller/checks_aggregate.c12
-rw-r--r--src/zabbix_server/poller/poller.c16
-rw-r--r--src/zabbix_server/server.c14
6 files changed, 48 insertions, 69 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 200cd7ea..0d123d3f 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -180,6 +180,17 @@ int DBexecute(char *query)
return SUCCEED;
}
+int DBis_null(char *field)
+{
+ int ret = FAIL;
+
+ if(field == NULL) ret = SUCCEED;
+#ifdef HAVE_ORACLE
+ else if(field[0] == 0) ret = SUCCEED;
+#endif
+ return ret;
+}
+
DB_ROW DBfetch(DB_RESULT result)
{
#ifdef HAVE_MYSQL
@@ -261,14 +272,8 @@ DB_RESULT DBselect(char *query)
{
zabbix_log( LOG_LEVEL_ERR, "Query::%s",query);
zabbix_log(LOG_LEVEL_ERR, "Query failed:%s", sqlo_geterror(oracle));
- fprintf(stderr, "Query::%s\n",query);
- fprintf(stderr, "Query failed:%s\n", sqlo_geterror(oracle) );
exit(FAIL);
}
- else
- {
- fprintf(stderr, "Query is ok::%s\n",query);
- }
return sth;
#endif
}
@@ -423,7 +428,7 @@ int DBget_function_result(double *result,char *functionid)
zabbix_syslog("No function for functionid:[%s]", functionid );
res = FAIL;
}
- else if(row[1] == NULL)
+ else if(DBis_null(row[1]) == SUCCEED)
{
zabbix_log(LOG_LEVEL_DEBUG, "function.lastvalue==NULL [%s]", functionid );
res = FAIL;
@@ -1480,7 +1485,7 @@ void DBget_item_from_db(DB_ITEM *item,DB_ROW row)
item->ip=row[11];
item->history=atoi(row[12]);
s=row[13];
- if(s==NULL)
+ if(DBis_null(s)==SUCCEED)
{
item->lastvalue_null=1;
}
@@ -1491,7 +1496,7 @@ void DBget_item_from_db(DB_ITEM *item,DB_ROW row)
item->lastvalue=atof(s);
}
s=row[14];
- if(s==NULL)
+ if(DBis_null(s)==SUCCEED)
{
item->prevvalue_null=1;
}
@@ -1510,7 +1515,7 @@ void DBget_item_from_db(DB_ITEM *item,DB_ROW row)
item->delta=atoi(row[20]);
s=row[21];
- if(s==NULL)
+ if(DBis_null(s)==SUCCEED)
{
item->prevorgvalue_null=1;
}
@@ -1520,7 +1525,7 @@ void DBget_item_from_db(DB_ITEM *item,DB_ROW row)
item->prevorgvalue=atof(s);
}
s=row[22];
- if(s==NULL)
+ if(DBis_null(s)==SUCCEED)
{
item->lastclock=0;
}
diff --git a/src/zabbix_server/functions.c b/src/zabbix_server/functions.c
index 835a2f78..708587c9 100644
--- a/src/zabbix_server/functions.c
+++ b/src/zabbix_server/functions.c
@@ -454,12 +454,6 @@ int process_data(int sockfd,char *server,char *key,char *value,char *lastlogsize
DBget_item_from_db(&item,row);
-/* item.itemid=atoi(DBget_field(result,0,0));
- strscpy(item.key,DBget_field(result,0,1));
- item.host=DBget_field(result,0,2);
- item.type=atoi(DBget_field(result,0,7));
- item.trapper_hosts=DBget_field(result,0,16);*/
-
if( (item.type==ITEM_TYPE_ZABBIX_ACTIVE) && (check_security(sockfd,item.trapper_hosts,1) == FAIL))
{
DBfree_result(result);
@@ -475,44 +469,6 @@ int process_data(int sockfd,char *server,char *key,char *value,char *lastlogsize
DBupdate_item_status_to_notsupported(item.itemid, "Not supported by agent");
}
-/* item.port=atoi(DBget_field(result,0,3));
- item.delay=atoi(DBget_field(result,0,4));
- item.description=DBget_field(result,0,5);
- item.nextcheck=atoi(DBget_field(result,0,6));
- item.snmp_community=DBget_field(result,0,8);
- item.snmp_oid=DBget_field(result,0,9);
- item.useip=atoi(DBget_field(result,0,10));
- item.ip=DBget_field(result,0,11);
- item.history=atoi(DBget_field(result,0,12));
- s=DBget_field(result,0,13);
- if(s==NULL)
- {
- item.lastvalue_null=1;
- }
- else
- {
- item.lastvalue_null=0;
- item.lastvalue_str=s;
- item.lastvalue=atof(s);
- }
- s=DBget_field(result,0,14);
- if(s==NULL)
- {
- item.prevvalue_null=1;
- }
- else
- {
- item.prevvalue_null=0;
- item.prevvalue_str=s;
- item.prevvalue=atof(s);
- }
- item.value_type=atoi(DBget_field(result,0,15));
- item.delta=atoi(DBget_field(result,0,17));
- item.units=DBget_field(result,0,18);
- item.multiplier=atoi(DBget_field(result,0,19));
- item.formula=DBget_field(result,0,20);
- item.logtimefmt=DBget_field(result,0,21);*/
-
s=value;
if( (strncmp(item.key,"log[",4)==0) ||
(strncmp(item.key,"eventlog[",9)==0)
diff --git a/src/zabbix_server/pinger/pinger.c b/src/zabbix_server/pinger/pinger.c
index 1a60f3dc..d27654e4 100644
--- a/src/zabbix_server/pinger/pinger.c
+++ b/src/zabbix_server/pinger/pinger.c
@@ -164,7 +164,7 @@ static int process_value(char *key, char *host, AGENT_RESULT *value)
item.ip=row[11];
item.history=atoi(row[12]);
s=row[13];
- if(s==NULL)
+ if(DBis_null(s)==SUCCEED)
{
item.lastvalue_null=1;
}
@@ -175,7 +175,7 @@ static int process_value(char *key, char *host, AGENT_RESULT *value)
item.lastvalue=atof(s);
}
s=row[14];
- if(s==NULL)
+ if(DBis_null(s)==SUCCEED)
{
item.prevvalue_null=1;
}
diff --git a/src/zabbix_server/poller/checks_aggregate.c b/src/zabbix_server/poller/checks_aggregate.c
index afe69f80..7b755e3e 100644
--- a/src/zabbix_server/poller/checks_aggregate.c
+++ b/src/zabbix_server/poller/checks_aggregate.c
@@ -20,7 +20,7 @@
#include "common.h"
#include "checks_aggregate.h"
-static int evaluate_one(double *result, int *num, char *grpfunc, char *value_str, int valuetype)
+static int evaluate_one(double *result, int *num, char *grpfunc, char const *value_str, int valuetype)
{
int ret = SUCCEED;
double value;
@@ -41,12 +41,12 @@ static int evaluate_one(double *result, int *num, char *grpfunc, char *value_str
if(strcmp(grpfunc,"grpsum") == 0)
{
*result+=value;
- *num++;
+ num++;
}
else if(strcmp(grpfunc,"grpavg") == 0)
{
*result+=value;
- *num++;
+ num++;
}
else if(strcmp(grpfunc,"grpmin") == 0)
{
@@ -58,7 +58,7 @@ static int evaluate_one(double *result, int *num, char *grpfunc, char *value_str
{
*result=value;
}
- *num++;
+ num++;
}
else if(strcmp(grpfunc,"grpmax") == 0)
{
@@ -70,7 +70,7 @@ static int evaluate_one(double *result, int *num, char *grpfunc, char *value_str
{
*result=value;
}
- *num++;
+ num++;
}
else
{
@@ -96,7 +96,7 @@ static int evaluate_aggregate(AGENT_RESULT *res,char *grpfunc, char *hostgroup,
int valuetype;
double d = 0;
- char *value;
+ const char *value;
int num = 0;
int now;
char items[MAX_STRING_LEN],items2[MAX_STRING_LEN];
diff --git a/src/zabbix_server/poller/poller.c b/src/zabbix_server/poller/poller.c
index 6764dcef..c2cdbf46 100644
--- a/src/zabbix_server/poller/poller.c
+++ b/src/zabbix_server/poller/poller.c
@@ -125,11 +125,19 @@ static int get_minnextcheck(int now)
{
if(CONFIG_REFRESH_UNSUPPORTED != 0)
{
+#ifdef HAVE_ORACLE
+ snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d,%d) and mod(i.itemid,%d)=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#else
snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#endif
}
else
{
+#ifdef HAVE_ORACLE
+ snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d) and mod(i.itemid,%d)=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#else
snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#endif
}
}
@@ -239,11 +247,19 @@ int get_values(void)
{
if(CONFIG_REFRESH_UNSUPPORTED != 0)
{
+#ifdef HAVE_ORACLE
+ snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d,%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and mod(i.itemid,%d)=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#else
snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d,%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#endif
}
else
{
+#ifdef HAVE_ORACLE
+ snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and mod(i.itemid,%d)=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#else
snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_POLLER_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
+#endif
}
}
result = DBselect(sql);
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index 411de26e..a5593ae9 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -505,28 +505,30 @@ int main(int argc, char **argv)
char sql[MAX_STRING_LEN];
DB_RESULT result;
DB_ROW row;
-#ifdef HAVE_ORACLE
+#ifdef HAVE_ZZZ
const char ** v;
#endif
-#ifdef HAVE_MYSQL
+#ifdef HAVE_ZZZ
init_config();
DBconnect();
// result = DBselect("select * from history where itemid=20272");
- result = DBselect("select NULL from items");
+ result = DBselect("select NULL from history where itemid=20272222");
+ row=DBfetch(result);
+ if(!row) printf("OK");
+ exit(0);
while((row=DBfetch(result)))
{
- if(row[0]==NULL)
- printf("%s\n",row[0]);
+ printf("[%s]\n",row[0]);
}
DBfree_result(result);
DBclose();
return 0;
#endif
-#ifdef HAVE_ORACLE
+#ifdef HAVE_ZZZ
/* */
DBconnect();
/* DBexecute("update history set value=value-10 where itemid=20272");*/