summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zabbix_agent/active.c15
-rw-r--r--src/zabbix_agent/sysinfo.c2
-rw-r--r--src/zabbix_server/alerter.c28
-rw-r--r--src/zabbix_server/alerter.h4
-rw-r--r--src/zabbix_server/checks_internal.c54
-rw-r--r--src/zabbix_server/housekeeper.c135
-rw-r--r--src/zabbix_server/housekeeper.h4
-rw-r--r--src/zabbix_server/pinger.c68
-rw-r--r--src/zabbix_server/pinger.h4
-rw-r--r--src/zabbix_server/server.c469
-rw-r--r--src/zabbix_server/trapper.c4
11 files changed, 14 insertions, 773 deletions
diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c
index 56ae0eb1..cf7c1820 100644
--- a/src/zabbix_agent/active.c
+++ b/src/zabbix_agent/active.c
@@ -114,7 +114,7 @@ int get_min_nextcheck()
return min;
}
-void add_check(char *key, int refresh)
+void add_check(char *key, int refresh, int lastlogsize)
{
int i;
@@ -128,7 +128,7 @@ void add_check(char *key, int refresh)
metrics[i].refresh=refresh;
metrics[i].nextcheck=0;
metrics[i].status=ITEM_STATUS_ACTIVE;
- metrics[i].lastlogsize=0;
+ metrics[i].lastlogsize=lastlogsize;
metrics=realloc(metrics,(i+2)*sizeof(METRIC));
metrics[i+1].key=NULL;
@@ -141,6 +141,7 @@ void add_check(char *key, int refresh)
metrics[i].nextcheck=0;
}
metrics[i].refresh=refresh;
+ metrics[i].lastlogsize=lastlogsize;
metrics[i].status=ITEM_STATUS_ACTIVE;
break;
}
@@ -151,7 +152,7 @@ void add_check(char *key, int refresh)
int parse_list_of_checks(char *str)
{
char *line;
- char *key, *refresh;
+ char *key, *refresh, *lastlogsize;
char *s1, *s2;
disable_all_metrics();
@@ -167,8 +168,10 @@ int parse_list_of_checks(char *str)
zabbix_log( LOG_LEVEL_DEBUG, "Key [%s]", key);
refresh=(char *)strtok_r(NULL,":",&s2);
zabbix_log( LOG_LEVEL_DEBUG, "Refresh [%s]", refresh);
+ lastlogsize=(char *)strtok_r(NULL,":",&s2);
+ zabbix_log( LOG_LEVEL_DEBUG, "Lastlogsize [%s]", lastlogsize);
- add_check(key, atoi(refresh));
+ add_check(key, atoi(refresh), atoi(lastlogsize));
line=(char *)strtok_r(NULL,"\n",&s1);
}
@@ -380,6 +383,7 @@ int send_value(char *server,int port,char *shortname,char *value)
int process_active_checks(char *server, int port)
{
char value[MAX_STRING_LEN];
+ char value_tmp[MAX_STRING_LEN];
int i, now, count;
int ret = SUCCEED;
@@ -407,7 +411,8 @@ int process_active_checks(char *server, int port)
{
snprintf(shortname, MAX_STRING_LEN-1,"%s:%s",CONFIG_HOSTNAME,metrics[i].key);
zabbix_log( LOG_LEVEL_DEBUG, "%s",shortname);
- if(send_value(server,port,shortname,value) == FAIL)
+ snprintf(value_tmp, MAX_STRING_LEN-1,"%d:%s",metrics[i].lastlogsize,value);
+ if(send_value(server,port,shortname,value_tmp) == FAIL)
{
ret = FAIL;
break;
diff --git a/src/zabbix_agent/sysinfo.c b/src/zabbix_agent/sysinfo.c
index 3191576f..930799b0 100644
--- a/src/zabbix_agent/sysinfo.c
+++ b/src/zabbix_agent/sysinfo.c
@@ -2541,7 +2541,7 @@ int DISK_WBLK(const char *cmd, const char *parameter,double *value)
int VERSION(const char *cmd, const char *parameter,char **value)
{
- static char version[]="1.1alpha9";
+ static char version[]=ZABBIX_VERSION;
*value=strdup(version);
return SYSINFO_RET_OK;
diff --git a/src/zabbix_server/alerter.c b/src/zabbix_server/alerter.c
index 5b1ffb58..b38e9bae 100644
--- a/src/zabbix_server/alerter.c
+++ b/src/zabbix_server/alerter.c
@@ -130,11 +130,7 @@ int send_alert(DB_ALERT *alert,DB_MEDIATYPE *mediatype, char *error, int max_err
return res;
}
-#ifdef ZABBIX_THREADS
-void *main_alerter_loop()
-#else
int main_alerter_loop()
-#endif
{
char sql[MAX_STRING_LEN];
char error[MAX_STRING_LEN];
@@ -144,36 +140,20 @@ int main_alerter_loop()
struct sigaction phan;
-#ifdef ZABBIX_THREADS
- DB_HANDLE database;
-#endif
-
DB_RESULT *result;
DB_ALERT alert;
DB_MEDIATYPE mediatype;
-#ifdef ZABBIX_THREADS
- my_thread_init();
-#endif
-
for(;;)
{
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("connecting to the database");
#endif
-#ifdef ZABBIX_THREADS
- DBconnect_thread(&database);
-#else
DBconnect();
-#endif
snprintf(sql,sizeof(sql)-1,"select a.alertid,a.mediatypeid,a.sendto,a.subject,a.message,a.status,a.retries,mt.mediatypeid,mt.type,mt.description,mt.smtp_server,mt.smtp_helo,mt.smtp_email,mt.exec_path from alerts a,media_type mt where a.status=0 and a.retries<3 and a.mediatypeid=mt.mediatypeid order by a.clock");
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(&database, sql);
-#else
result = DBselect(sql);
-#endif
for(i=0;i<DBnum_rows(result);i++)
{
@@ -215,21 +195,13 @@ int main_alerter_loop()
zabbix_syslog("Error sending alert ID [%d]", alert.alertid);
DBescape_string(error,error_esc,MAX_STRING_LEN);
snprintf(sql,sizeof(sql)-1,"update alerts set retries=retries+1,error='%s' where alertid=%d", error_esc, alert.alertid);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(&database,sql);
-#else
DBexecute(sql);
-#endif
}
}
DBfree_result(result);
-#ifdef ZABBIX_THREADS
- DBclose_thread(&database);
-#else
DBclose();
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("sender [sleeping for %d seconds]", CONFIG_SENDER_FREQUENCY);
#endif
diff --git a/src/zabbix_server/alerter.h b/src/zabbix_server/alerter.h
index 52a0a621..5fba1229 100644
--- a/src/zabbix_server/alerter.h
+++ b/src/zabbix_server/alerter.h
@@ -30,10 +30,6 @@ extern char *CONFIG_ALERT_SCRIPTS_PATH;
extern void signal_handler( int sig );
-#ifdef ZABBIX_THREADS
-void *main_alerter_loop();
-#else
int main_alerter_loop();
-#endif
#endif
diff --git a/src/zabbix_server/checks_internal.c b/src/zabbix_server/checks_internal.c
index 0140f795..a76a6f35 100644
--- a/src/zabbix_server/checks_internal.c
+++ b/src/zabbix_server/checks_internal.c
@@ -20,59 +20,6 @@
#include "common.h"
#include "checks_internal.h"
-#ifdef ZABBIX_THREADS
-int get_value_internal(double *result,char *result_str,DB_ITEM *item,char *error,int max_error_len)
-{
- DB_HANDLE database;
-
- DBconnect_thread(&database);
-
- if(strcmp(item->key,"zabbix[triggers]")==0)
- {
- *result=DBget_triggers_count_thread(&database);
- }
- else if(strcmp(item->key,"zabbix[items]")==0)
- {
- *result=DBget_items_count_thread(&database);
- }
- else if(strcmp(item->key,"zabbix[items_unsupported]")==0)
- {
- *result=DBget_items_unsupported_count_thread(&database);
- }
- else if(strcmp(item->key,"zabbix[history]")==0)
- {
- *result=DBget_history_count_thread(&database);
- }
- else if(strcmp(item->key,"zabbix[history_str]")==0)
- {
- *result=DBget_history_str_count_thread(&database);
- }
- else if(strcmp(item->key,"zabbix[trends]")==0)
- {
- *result=DBget_trends_count_thread(&database);
- }
- else if(strcmp(item->key,"zabbix[queue]")==0)
- {
- *result=DBget_queue_count_thread(&database);
- }
- else
- {
- DBclose_thread(&database);
- zabbix_log( LOG_LEVEL_WARNING, "Internal check [%s] is not supported", item->key);
- snprintf(error,max_error_len-1,"Internal check [%s] is not supported", item->key);
- return NOTSUPPORTED;
- }
-
- snprintf(result_str,MAX_STRING_LEN-1,"%f",*result);
-
- zabbix_log( LOG_LEVEL_DEBUG, "INTERNAL [%s] [%f]", result_str, *result);
-
- DBclose_thread(&database);
-
- return SUCCEED;
-}
-
-#else
int get_value_internal(double *result,char *result_str,DB_ITEM *item,char *error,int max_error_len)
{
if(strcmp(item->key,"zabbix[triggers]")==0)
@@ -115,4 +62,3 @@ int get_value_internal(double *result,char *result_str,DB_ITEM *item,char *error
zabbix_log( LOG_LEVEL_DEBUG, "INTERNAL [%s] [%f]", result_str, *result);
return SUCCEED;
}
-#endif
diff --git a/src/zabbix_server/housekeeper.c b/src/zabbix_server/housekeeper.c
index ceded21c..54e488c5 100644
--- a/src/zabbix_server/housekeeper.c
+++ b/src/zabbix_server/housekeeper.c
@@ -51,70 +51,42 @@
#include "housekeeper.h"
/* Remove items having status 'deleted' */
-#ifdef ZABBIX_THREADS
-void *housekeeping_items(MYSQL *database)
-#else
int housekeeping_items(void)
-#endif
{
char sql[MAX_STRING_LEN];
DB_RESULT *result;
int i,itemid;
snprintf(sql,sizeof(sql)-1,"select itemid from items where status=%d", ITEM_STATUS_DELETED);
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
for(i=0;i<DBnum_rows(result);i++)
{
itemid=atoi(DBget_field(result,i,0));
-#ifdef ZABBIX_THREADS
- DBdelete_item_thread(database, itemid);
-#else
DBdelete_item(itemid);
-#endif
}
DBfree_result(result);
return SUCCEED;
}
/* Remove hosts having status 'deleted' */
-#ifdef ZABBIX_THREADS
-int housekeeping_hosts(MYSQL *database)
-#else
int housekeeping_hosts(void)
-#endif
{
char sql[MAX_STRING_LEN];
DB_RESULT *result;
int i,hostid;
snprintf(sql,sizeof(sql)-1,"select hostid from hosts where status=%d", HOST_STATUS_DELETED);
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
for(i=0;i<DBnum_rows(result);i++)
{
hostid=atoi(DBget_field(result,i,0));
-#ifdef ZABBIX_THREADS
- DBdelete_host_thread(database, hostid);
-#else
DBdelete_host(hostid);
-#endif
}
DBfree_result(result);
return SUCCEED;
}
-#ifdef ZABBIX_THREADS
-int housekeeping_history_and_trends(MYSQL *database, int now)
-#else
int housekeeping_history_and_trends(int now)
-#endif
{
char sql[MAX_STRING_LEN];
DB_ITEM item;
@@ -126,11 +98,7 @@ int housekeeping_history_and_trends(int now)
/* How lastdelete is used ??? */
/* snprintf(sql,sizeof(sql)-1,"select itemid,lastdelete,history,delay,trends from items where lastdelete<=%d", now);*/
snprintf(sql,sizeof(sql)-1,"select itemid,history,delay,trends from items");
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
for(i=0;i<DBnum_rows(result);i++)
{
@@ -150,11 +118,7 @@ int housekeeping_history_and_trends(int now)
#else
snprintf(sql,sizeof(sql)-1,"delete from history where itemid=%d and clock<%d",item.itemid,now-24*3600*item.history);
#endif
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database, sql);
-#else
DBexecute(sql);
-#endif
/* Delete HISTORY_STR */
#ifdef HAVE_MYSQL
@@ -162,11 +126,7 @@ int housekeeping_history_and_trends(int now)
#else
snprintf(sql,sizeof(sql)-1,"delete from history_str where itemid=%d and clock<%d",item.itemid,now-24*3600*item.history);
#endif
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database, sql);
-#else
DBexecute(sql);
-#endif
/* Delete HISTORY_LOG */
#ifdef HAVE_MYSQL
@@ -174,11 +134,7 @@ int housekeeping_history_and_trends(int now)
#else
snprintf(sql,sizeof(sql)-1,"delete from history_log where itemid=%d and clock<%d",item.itemid,now-24*3600*item.history);
#endif
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database, sql);
-#else
DBexecute(sql);
-#endif
/* Delete HISTORY_TRENDS */
#ifdef HAVE_MYSQL
@@ -186,46 +142,23 @@ int housekeeping_history_and_trends(int now)
#else
snprintf(sql,sizeof(sql)-1,"delete from trends where itemid=%d and clock<%d",item.itemid,now-24*3600*item.trends);
#endif
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database,sql);
-#else
- DBexecute(sql);
-#endif
-/* snprintf(sql,sizeof(sql)-1,"update items set lastdelete=%d where itemid=%d",now,item.itemid);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database,sql);
-#else
DBexecute(sql);
-#endif
-*/
}
DBfree_result(result);
return SUCCEED;
}
-#ifdef ZABBIX_THREADS
-int housekeeping_sessions(MYSQL *database, int now)
-#else
int housekeeping_sessions(int now)
-#endif
{
char sql[MAX_STRING_LEN];
snprintf(sql,sizeof(sql)-1,"delete from sessions where lastaccess<%d",now-24*3600);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database,sql);
-#else
DBexecute(sql);
-#endif
return SUCCEED;
}
-#ifdef ZABBIX_THREADS
-int housekeeping_alerts(MYSQL *database, int now)
-#else
int housekeeping_alerts(int now)
-#endif
{
char sql[MAX_STRING_LEN];
int alert_history;
@@ -233,11 +166,7 @@ int housekeeping_alerts(int now)
int res = SUCCEED;
snprintf(sql,sizeof(sql)-1,"select alert_history from config");
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
if(DBnum_rows(result) == 0)
{
@@ -249,22 +178,14 @@ int housekeeping_alerts(int now)
alert_history=atoi(DBget_field(result,0,0));
snprintf(sql,sizeof(sql)-1,"delete from alerts where clock<%d",now-24*3600*alert_history);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database,sql);
-#else
DBexecute(sql);
-#endif
}
DBfree_result(result);
return res;
}
-#ifdef ZABBIX_THREADS
-int housekeeping_alarms(MYSQL *database, int now)
-#else
int housekeeping_alarms(int now)
-#endif
{
char sql[MAX_STRING_LEN];
int alarm_history;
@@ -272,11 +193,7 @@ int housekeeping_alarms(int now)
int res = SUCCEED;
snprintf(sql,sizeof(sql)-1,"select alarm_history from config");
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
if(DBnum_rows(result) == 0)
{
zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'.");
@@ -287,33 +204,17 @@ int housekeeping_alarms(int now)
alarm_history=atoi(DBget_field(result,0,0));
snprintf(sql,sizeof(sql)-1,"delete from alarms where clock<%d",now-24*3600*alarm_history);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database,sql);
-#else
DBexecute(sql);
-#endif
}
DBfree_result(result);
return res;
}
-#ifdef ZABBIX_THREADS
-void *main_housekeeper_loop()
-#else
int main_housekeeper_loop()
-#endif
{
int now;
-#ifdef ZABBIX_THREADS
- DB_HANDLE database;
-#endif
-
-#ifdef ZABBIX_THREADS
- my_thread_init();
-#endif
-
if(CONFIG_DISABLE_HOUSEKEEPING == 1)
{
for(;;)
@@ -332,79 +233,47 @@ int main_housekeeper_loop()
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("connecting to the database");
#endif
-#ifdef ZABBIX_THREADS
- DBconnect_thread(&database);
-#else
DBconnect();
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [removing deleted hosts]");
#endif
-#ifdef ZABBIX_THREADS
- housekeeping_hosts(&database);
-#else
housekeeping_hosts();
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [removing deleted items]");
#endif
-#ifdef ZABBIX_THREADS
- housekeeping_items(&database);
-#else
housekeeping_items();
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [removing old values]");
#endif
-#ifdef ZABBIX_THREADS
- housekeeping_history_and_trends(&database, now);
-#else
housekeeping_history_and_trends(now);
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [removing old alarms]");
#endif
-#ifdef ZABBIX_THREADS
- housekeeping_alarms(&database, now);
-#else
housekeeping_alarms(now);
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [removing old alerts]");
#endif
-#ifdef ZABBIX_THREADS
- housekeeping_alerts(&database, now);
-#else
housekeeping_alerts(now);
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [removing old sessions]");
#endif
-#ifdef ZABBIX_THREADS
- housekeeping_sessions(&database, now);
-#else
housekeeping_sessions(now);
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("housekeeper [vacuuming database]");
#endif
-#ifdef ZABBIX_THREADS
- DBvacuum_thread(&database);
-#else
DBvacuum();
-#endif
zabbix_log( LOG_LEVEL_DEBUG, "Sleeping for %d hours", CONFIG_HOUSEKEEPING_FREQUENCY);
@@ -412,11 +281,7 @@ int main_housekeeper_loop()
setproctitle("housekeeper [sleeping for %d hour(s)]", CONFIG_HOUSEKEEPING_FREQUENCY);
#endif
-#ifdef ZABBIX_THREADS
- DBclose_thread(&database);
-#else
DBclose();
-#endif
sleep(3660*CONFIG_HOUSEKEEPING_FREQUENCY);
}
}
diff --git a/src/zabbix_server/housekeeper.h b/src/zabbix_server/housekeeper.h
index 07c5d008..987c23fe 100644
--- a/src/zabbix_server/housekeeper.h
+++ b/src/zabbix_server/housekeeper.h
@@ -29,10 +29,6 @@ extern char *CONFIG_DBPASSWORD;
extern char *CONFIG_DBSOCKET;
extern char *CONFIG_FPING_LOCATION;
-#ifdef ZABBIX_THREADS
-void *main_housekeeper_loop();
-#else
int main_housekeeper_loop();
-#endif
#endif
diff --git a/src/zabbix_server/pinger.c b/src/zabbix_server/pinger.c
index 810d144f..eae4dc5f 100644
--- a/src/zabbix_server/pinger.c
+++ b/src/zabbix_server/pinger.c
@@ -87,11 +87,7 @@ int is_ip(char *ip)
return res;
}
-#ifdef ZABBIX_THREADS
-int process_value(MYSQL *database, char *key, char *host, char *value)
-#else
int process_value(char *key, char *host, char *value)
-#endif
{
char sql[MAX_STRING_LEN];
@@ -111,11 +107,7 @@ int process_value(char *key, char *host, char *value)
snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.value_type,i.trapper_hosts,i.delta,i.units,i.multiplier,i.formula from items i,hosts h where h.status=%d and h.hostid=i.hostid and h.host='%s' and i.key_='%s' and i.status=%d and i.type=%d", HOST_STATUS_MONITORED, host, key, ITEM_STATUS_ACTIVE, ITEM_TYPE_SIMPLE);
}
zabbix_log( LOG_LEVEL_DEBUG, "SQL [%s]", sql);
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
if(DBnum_rows(result) == 0)
{
@@ -166,24 +158,15 @@ int process_value(char *key, char *host, char *value)
item.multiplier=atoi(DBget_field(result,0,19));
item.formula=DBget_field(result,0,20);
-#ifdef ZABBIX_THREADS
- process_new_value_thread(database,&item,value);
- update_triggers_thread(database,item.itemid);
-#else
process_new_value(&item,value);
update_triggers(item.itemid);
-#endif
DBfree_result(result);
return SUCCEED;
}
-#ifdef ZABBIX_THREADS
-int create_host_file(MYSQL *database)
-#else
int create_host_file(void)
-#endif
{
char sql[MAX_STRING_LEN];
FILE *f;
@@ -206,12 +189,8 @@ int create_host_file(void)
now=time(NULL);
/* Select hosts monitored by IP */
snprintf(sql,sizeof(sql)-1,"select distinct h.ip from hosts h,items i where i.hostid=h.hostid and (h.status=%d or (h.status=%d and h.available=%d and h.disable_until<=%d)) and (i.key_='%s' or i.key_='%s') and i.type=%d and i.status=%d and h.useip=1", HOST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, ITEM_TYPE_SIMPLE, ITEM_STATUS_ACTIVE);
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
-
+
for(i=0;i<DBnum_rows(result);i++)
{
host.ip=DBget_field(result,i,0);
@@ -225,12 +204,8 @@ int create_host_file(void)
/* Select hosts monitored by hostname */
snprintf(sql,sizeof(sql)-1,"select distinct h.host from hosts h,items i where i.hostid=h.hostid and (h.status=%d or (h.status=%d and h.available=%d and h.disable_until<=%d)) and (i.key_='%s' or i.key_='%s') and i.type=%d and i.status=%d and h.useip=0", HOST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, ITEM_TYPE_SIMPLE, ITEM_STATUS_ACTIVE);
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
result = DBselect(sql);
-#endif
-
+
for(i=0;i<DBnum_rows(result);i++)
{
host.host=DBget_field(result,i,0);
@@ -247,11 +222,7 @@ int create_host_file(void)
}
-#ifdef ZABBIX_THREADS
-int do_ping(MYSQL *database)
-#else
int do_ping(void)
-#endif
{
FILE *f;
char ip[MAX_STRING_LEN];
@@ -297,24 +268,14 @@ int do_ping(void)
zabbix_log( LOG_LEVEL_DEBUG, "IP [%s] alive [%d]", ip, alive);
if(0 == alive)
{
-#ifdef ZABBIX_THREADS
- process_value(database,SERVER_ICMPPING_KEY,ip,"0");
- process_value(database,SERVER_ICMPPINGSEC_KEY,ip,"0");
-#else
process_value(SERVER_ICMPPING_KEY,ip,"0");
process_value(SERVER_ICMPPINGSEC_KEY,ip,"0");
-#endif
}
else
{
snprintf(tmp,sizeof(tmp)-1,"%f",mseconds/1000);
-#ifdef ZABBIX_THREADS
- process_value(database,SERVER_ICMPPING_KEY,ip,"1");
- process_value(database,SERVER_ICMPPINGSEC_KEY,ip,tmp);
-#else
process_value(SERVER_ICMPPING_KEY,ip,"1");
process_value(SERVER_ICMPPINGSEC_KEY,ip,tmp);
-#endif
}
}
}
@@ -325,19 +286,10 @@ int do_ping(void)
return SUCCEED;
}
-#ifdef ZABBIX_THREADS
-void *main_pinger_loop()
-#else
int main_pinger_loop()
-#endif
{
int ret = SUCCEED;
-#ifdef ZABBIX_THREADS
- DB_HANDLE database;
-#endif
-
-
if(1 == CONFIG_DISABLE_PINGER)
{
for(;;)
@@ -353,19 +305,11 @@ int main_pinger_loop()
setproctitle("connecting to the database");
#endif
-#ifdef ZABBIX_THREADS
- DBconnect_thread(&database);
-#else
DBconnect();
-#endif
/* zabbix_set_log_level(LOG_LEVEL_DEBUG);*/
-#ifdef ZABBIX_THREADS
- ret = create_host_file(&database);
-#else
ret = create_host_file();
-#endif
if( SUCCEED == ret)
{
@@ -373,21 +317,13 @@ int main_pinger_loop()
setproctitle("pinging hosts");
#endif
-#ifdef ZABBIX_THREADS
- ret = do_ping(&database);
-#else
ret = do_ping();
-#endif
}
unlink("/tmp/zabbix_suckerd.pinger");
/* zabbix_set_log_level(LOG_LEVEL_WARNING); */
-#ifdef ZABBIX_THREADS
- DBclose_thread(&database);
-#else
DBclose();
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("pinger [sleeping for %d seconds]", CONFIG_PINGER_FREQUENCY);
diff --git a/src/zabbix_server/pinger.h b/src/zabbix_server/pinger.h
index c0727fd2..17538f59 100644
--- a/src/zabbix_server/pinger.h
+++ b/src/zabbix_server/pinger.h
@@ -31,10 +31,6 @@ extern char *CONFIG_FPING_LOCATION;
extern void signal_handler( int sig );
-#ifdef ZABBIX_THREADS
-void *main_pinger_loop();
-#else
int main_pinger_loop();
-#endif
#endif
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index ae3a58ee..e653b478 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -42,10 +42,6 @@
#include "log.h"
#include "zlog.h"
-#ifdef ZABBIX_THREADS
- #include <pthread.h>
-#endif
-
#include "common.h"
#include "functions.h"
#include "expression.h"
@@ -62,27 +58,6 @@
#define LISTENQ 1024
-#ifdef ZABBIX_THREADS
-struct poller_answer {
- int status; /* 0 - not received 1 - in processing 2 - received */
- int itemid;
- int ret;
- double value;
- char value_str[100];
-};
-
-struct poller_answer requests[10000];
-int answer_count = 0;
-int request_count = 0;
-
-pthread_mutex_t poller_mutex;
-
-pthread_mutex_t result_mutex;
-pthread_cond_t result_cv;
-int state = 0; /* 0 - select data from DB, 1 - poll values from agents, 2 - update database */
-DB_RESULT *shared_result;
-#endif
-
static pid_t *pids=NULL;
static int sucker_num=0;
@@ -236,7 +211,7 @@ void daemon_init(void)
void usage(char *prog)
{
- printf("zabbix_server - ZABBIX server process v1.1alpha9\n");
+ printf("zabbix_server - ZABBIX server process %s\n", ZABBIX_VERSION);
printf("Usage: %s [-h] [-c <file>]\n", prog);
printf("\nOptions:\n");
printf(" -c <file> Specify configuration file. Default is /etc/zabbix/zabbix_server.conf\n");
@@ -249,11 +224,7 @@ void init_config(void)
static struct cfg_line cfg[]=
{
/* PARAMETER ,VAR ,FUNC, TYPE(0i,1s),MANDATORY,MIN,MAX */
-#ifdef ZABBIX_THREADS
- {"StartSuckers",&CONFIG_SUCKERD_FORKS,0,TYPE_INT,PARM_OPT,6,255},
-#else
{"StartSuckers",&CONFIG_SUCKERD_FORKS,0,TYPE_INT,PARM_OPT,5,255},
-#endif
{"HousekeepingFrequency",&CONFIG_HOUSEKEEPING_FREQUENCY,0,TYPE_INT,PARM_OPT,1,24},
{"SenderFrequency",&CONFIG_SENDER_FREQUENCY,0,TYPE_INT,PARM_OPT,5,3600},
{"PingerFrequency",&CONFIG_PINGER_FREQUENCY,0,TYPE_INT,PARM_OPT,1,3600},
@@ -350,47 +321,6 @@ int get_value(double *result,char *result_str,DB_ITEM *item, char *error, int ma
return res;
}
-#ifdef ZABBIX_THREADS
-int get_minnextcheck_thread(MYSQL *database, int now)
-{
- char sql[MAX_STRING_LEN];
-
- DB_RESULT *result;
-
- int res;
-
-/* Host status 0 == MONITORED
- 1 == NOT MONITORED
- 2 == UNREACHABLE */
- snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and h.hostid=i.hostid and i.status=%d and i.type not in (%d,%d) and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, SERVER_ZABBIXLOG_KEY);
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(database, sql);
-#else
- result = DBselect(sql);
-#endif
-
- if( DBnum_rows(result) == 0)
- {
- zabbix_log(LOG_LEVEL_DEBUG, "No items to update for minnextcheck.");
- res = FAIL;
- }
- else
- {
- if( atoi(DBget_field(result,0,0)) == 0)
- {
- res = FAIL;
- }
- else
- {
- res = atoi(DBget_field(result,0,1));
- }
- }
- DBfree_result(result);
-
- return res;
-}
-#endif
-
int get_minnextcheck(int now)
{
char sql[MAX_STRING_LEN];
@@ -426,40 +356,6 @@ int get_minnextcheck(int now)
return res;
}
-#ifdef ZABBIX_THREADS
-/* Update special host's item - "status" */
-void update_key_status_thread(MYSQL *database, int hostid,int host_status)
-{
- char sql[MAX_STRING_LEN];
- char value_str[MAX_STRING_LEN];
- char *s;
-
- DB_ITEM item;
- DB_RESULT *result;
-
- zabbix_log(LOG_LEVEL_DEBUG, "In update_key_status()");
-
- snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available from items i,hosts h where h.hostid=i.hostid and h.hostid=%d and i.key_='%s'", hostid,SERVER_STATUS_KEY);
- result = DBselect_thread(database, sql);
-
- if( DBnum_rows(result) == 0)
- {
- zabbix_log( LOG_LEVEL_DEBUG, "No items to update.");
- }
- else
- {
- DBget_item_from_db(&item,result,0);
-
- snprintf(value_str,sizeof(value_str)-1,"%d",host_status);
-
- process_new_value_thread(database,&item,value_str);
- update_triggers_thread(database,item.itemid);
- }
-
- DBfree_result(result);
-}
-#endif
-
/* Update special host's item - "status" */
void update_key_status(int hostid,int host_status)
{
@@ -516,11 +412,7 @@ void trend(void)
DBfree_result(result2);
}
-#ifdef ZABBIX_THREADS
-int get_values(MYSQL *database)
-#else
int get_values(void)
-#endif
{
double value;
char value_str[MAX_STRING_LEN];
@@ -539,99 +431,24 @@ int get_values(void)
now = time(NULL);
-#ifdef ZABBIX_THREADS
- snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available from items i,hosts h where i.nextcheck<=%d and i.status=%d and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
-#else
snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available from items i,hosts h where i.nextcheck<=%d and i.status=%d and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, CONFIG_SUCKERD_FORKS-4,sucker_num-4,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);
-#endif
-#ifdef ZABBIX_THREADS
- pthread_mutex_lock (&result_mutex);
-// zabbix_log( LOG_LEVEL_WARNING, "\nSUCKER: waiting for state 0 [select data from DB] state [%d]", state);
- while (state != 0)
- {
- pthread_cond_wait(&result_cv, &result_mutex);
- }
- pthread_mutex_unlock(&result_mutex);
-
- result = DBselect_thread(database, sql);
- shared_result = result;
- answer_count = 0;
- request_count = DBnum_rows(result);
- for(i=0;i<request_count;i++)
- {
- requests[i].status = 0;
- requests[i].itemid=atoi(DBget_field(result,i,0));
- }
-
-
- pthread_mutex_lock (&result_mutex);
- state = 1;
-// pthread_cond_signal(&result_cv);
- zabbix_log( LOG_LEVEL_WARNING, "sucker: broadcast state [%d]", state);
- pthread_cond_broadcast(&result_cv);
- pthread_mutex_unlock(&result_mutex);
-
- pthread_mutex_lock (&result_mutex);
- zabbix_log( LOG_LEVEL_WARNING, "sucker: waiting for request_count [%d] == answer_count [%d] [update data in DB] state [%d]", request_count, answer_count, state);
-// while ( (state != 2) && (answer_count != request_count))
-// while (state != CONFIG_SUCKERD_FORKS-5+request_count)
- while (answer_count!=request_count)
- {
- pthread_cond_wait(&result_cv, &result_mutex);
-/* zabbix_log( LOG_LEVEL_WARNING, "sucker: YOPT %d %d", request_count, answer_count);
- zabbix_log( LOG_LEVEL_WARNING, "sucker: before printing result");
- for(i=0;i<request_count;i++)
- {
- zabbix_log( LOG_LEVEL_WARNING, "sucker: before doing actual DB update: itemid [%d] status [%d]", atoi(DBget_field(shared_result,i,0)), requests[i].status );
- }*/
-// pthread_mutex_unlock (&poller_mutex);
- }
- pthread_mutex_unlock(&result_mutex);
-
- pthread_mutex_lock (&result_mutex);
- state = 0;
-// pthread_cond_signal(&result_cv);
- zabbix_log( LOG_LEVEL_WARNING, "sucker: broadcast state [%d]", state);
- pthread_cond_broadcast(&result_cv);
- pthread_mutex_unlock(&result_mutex);
-#else
result = DBselect(sql);
-#endif
for(i=0;i<DBnum_rows(result);i++)
{
DBget_item_from_db(&item,result, i);
-#ifdef ZABBIX_THREADS
- res = requests[i].ret;
- value = requests[i].value;
- strscpy(value_str,requests[i].value_str);
- if(requests[i].status != 2)
- {
- zabbix_log( LOG_LEVEL_WARNING, "sucker: ERROR status [%d] expected [2] host [%s] key [%s]", requests[i].status, item.host, item.key );
- }
-/* res = get_value(&value,value_str,&item);*/
-#else
res = get_value(&value,value_str,&item,error,sizeof(error));
-#endif
zabbix_log( LOG_LEVEL_DEBUG, "GOT VALUE [%s]", value_str );
if(res == SUCCEED )
{
-#ifdef ZABBIX_THREADS
- process_new_value_thread(database, &item,value_str);
-#else
process_new_value(&item,value_str);
-#endif
if(item.host_network_errors>0)
{
snprintf(sql,sizeof(sql)-1,"update hosts set network_errors=0,error='' where hostid=%d and network_errors>0", item.hostid);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database, sql);
-#else
DBexecute(sql);
-#endif
}
/* if(HOST_STATUS_UNREACHABLE == item.host_status)*/
@@ -640,45 +457,27 @@ int get_values(void)
item.host_available=HOST_AVAILABLE_TRUE;
zabbix_log( LOG_LEVEL_WARNING, "Enabling host [%s]", item.host );
zabbix_syslog("Enabling host [%s]", item.host );
-#ifdef ZABBIX_THREADS
- DBupdate_host_availability_thread(database, item.hostid,HOST_AVAILABLE_TRUE,now,error);
- update_key_status_thread(database, item.hostid,HOST_STATUS_MONITORED);
-#else
DBupdate_host_availability(item.hostid,HOST_AVAILABLE_TRUE,now,error);
update_key_status(item.hostid,HOST_STATUS_MONITORED);
-#endif
/* Why this break??? Trigger needs to be updated anyway!
break;*/
}
-#ifdef ZABBIX_THREADS
- update_triggers_thread(database, item.itemid);
-#else
update_triggers(item.itemid);
-#endif
}
else if(res == NOTSUPPORTED)
{
zabbix_log( LOG_LEVEL_WARNING, "Parameter [%s] is not supported by agent on host [%s]", item.key, item.host );
zabbix_syslog("Parameter [%s] is not supported by agent on host [%s]", item.key, item.host );
-#ifdef ZABBIX_THREADS
- DBupdate_item_status_to_notsupported_thread(database, item.itemid, error);
-#else
DBupdate_item_status_to_notsupported(item.itemid, error);
-#endif
/* if(HOST_STATUS_UNREACHABLE == item.host_status)*/
if(HOST_AVAILABLE_TRUE != item.host_available)
{
item.host_available=HOST_AVAILABLE_TRUE;
zabbix_log( LOG_LEVEL_WARNING, "Enabling host [%s]", item.host );
zabbix_syslog("Enabling host [%s]", item.host );
-#ifdef ZABBIX_THREADS
- DBupdate_host_availability_thread(database, item.hostid,HOST_AVAILABLE_TRUE,now,error);
- update_key_status_thread(database, item.hostid,HOST_STATUS_MONITORED);
-#else
DBupdate_host_availability(item.hostid,HOST_AVAILABLE_TRUE,now,error);
update_key_status(item.hostid,HOST_STATUS_MONITORED);
-#endif
break;
}
@@ -690,29 +489,16 @@ int get_values(void)
{
zabbix_log( LOG_LEVEL_WARNING, "Host [%s] will be checked after [%d] seconds", item.host, DELAY_ON_NETWORK_FAILURE );
zabbix_syslog("Host [%s] will be checked after [%d] seconds", item.host, DELAY_ON_NETWORK_FAILURE );
-#ifdef ZABBIX_THREADS
- DBupdate_host_availability_thread(database, item.hostid,HOST_AVAILABLE_FALSE,now,error);
- update_key_status_thread(database,item.hostid,HOST_AVAILABLE_FALSE);
-#else
DBupdate_host_availability(item.hostid,HOST_AVAILABLE_FALSE,now,error);
update_key_status(item.hostid,HOST_AVAILABLE_FALSE);
-#endif
snprintf(sql,sizeof(sql)-1,"update hosts set network_errors=3 where hostid=%d", item.hostid);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database, sql);
-#else
DBexecute(sql);
-#endif
}
else
{
snprintf(sql,sizeof(sql)-1,"update hosts set network_errors=%d where hostid=%d", item.host_network_errors, item.hostid);
-#ifdef ZABBIX_THREADS
- DBexecute_thread(database, sql);
-#else
DBexecute(sql);
-#endif
}
break;
@@ -738,11 +524,7 @@ int get_values(void)
return SUCCEED;
}
-#ifdef ZABBIX_THREADS
-void *main_nodata_loop()
-#else
int main_nodata_loop()
-#endif
{
char sql[MAX_STRING_LEN];
int i,now;
@@ -750,9 +532,6 @@ int main_nodata_loop()
int itemid,functionid;
char *parameter;
-#ifdef ZABBIX_THREADS
- DB_HANDLE database;
-#endif
DB_RESULT *result;
for(;;)
@@ -761,11 +540,7 @@ int main_nodata_loop()
setproctitle("updating nodata() functions");
#endif
-#ifdef ZABBIX_THREADS
- DBconnect_thread(&database);
-#else
DBconnect();
-#endif
now=time(NULL);
#ifdef HAVE_PGSQL
@@ -774,11 +549,7 @@ int main_nodata_loop()
snprintf(sql,sizeof(sql)-1,"select distinct f.itemid,f.functionid,f.parameter from functions f, items i,hosts h where h.hostid=i.hostid and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and i.itemid=f.itemid and f.function='nodata' and i.lastclock+f.parameter<=%d and i.status=%d and i.type=%d and (f.lastvalue<>1 or f.lastvalue is NULL)", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER);
#endif
-#ifdef ZABBIX_THREADS
- result = DBselect_thread(&database, sql);
-#else
result = DBselect(sql);
-#endif
for(i=0;i<DBnum_rows(result);i++)
{
@@ -787,25 +558,13 @@ int main_nodata_loop()
parameter=DBget_field(result,i,2);
snprintf(sql,sizeof(sql)-1,"update functions set lastvalue='1' where itemid=%d and function='nodata' and parameter='%s'" , itemid, parameter );
-#ifdef ZABBIX_THREADS
- DBexecute_thread(&database, sql);
-#else
DBexecute(sql);
-#endif
-#ifdef ZABBIX_THREADS
- update_triggers_thread(&database, itemid);
-#else
update_triggers(itemid);
-#endif
}
DBfree_result(result);
-#ifdef ZABBIX_THREADS
- DBclose_thread(&database);
-#else
DBclose();
-#endif
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("sleeping for 30 sec");
@@ -814,171 +573,12 @@ int main_nodata_loop()
}
}
-#ifdef ZABBIX_THREADS
-void *main_poller_loop()
-{
- int i, num, ret, end, unprocessed_flag, processed;
- int itemid=0;
-
- DB_ITEM item;
-
- zabbix_log( LOG_LEVEL_DEBUG, "In main_poller_loop()");
- for(;;)
- {
-// zabbix_log( LOG_LEVEL_WARNING, "poller: waiting for state 1..%d [poll values from agents] State [%d]", (CONFIG_SUCKERD_FORKS-4)-1, state);
- zabbix_log( LOG_LEVEL_WARNING, "poller: waiting for state 1 [poll values from agents] State [%d]", state);
- pthread_mutex_lock (&result_mutex);
- while (state != 1)
-// while ( (state != 1) && (answer_count == request_count ))
-// while ( (state < 1) || (state>(CONFIG_SUCKERD_FORKS-4)) )
- {
- pthread_cond_wait(&result_cv, &result_mutex);
- }
- pthread_mutex_unlock (&result_mutex);
-// Do work till there are unprocessed requests
- for(;;)
- {
- pthread_mutex_lock (&poller_mutex);
- unprocessed_flag=0;
- processed=0;
- for(i=0;i<request_count;i++)
- {
-// if(requests[i].status == 1)
-// zabbix_log( LOG_LEVEL_WARNING, "poller: looking for status [0] host [%s] key [%s] status [%d]", DBget_field(shared_result,i,2), DBget_field(shared_result,i,1), requests[i].status);
- num = i;
- if(requests[i].status == 0)
- {
-// zabbix_log( LOG_LEVEL_WARNING, "poller: itemid [%d]", atoi(DBget_field(shared_result,i,0)) );
- if(requests[i].status!=0)
- zabbix_log( LOG_LEVEL_WARNING, "poller: ERROR status [%d] must be [0] host [%s] key [%s]", requests[num].status, item.host, item.key);
- requests[i].status = 1;
- /* we should retrieve info from shared_result here */
- itemid=atoi(DBget_field(shared_result,i,0));
- unprocessed_flag=1;
- break;
- }
- else
- {
- processed++;
- }
- }
- pthread_mutex_unlock (&poller_mutex);
-
-/* zabbix_log( LOG_LEVEL_WARNING, "poller: number of already retrieved items [%d] total [%d]", i, request_count);*/
-
- /* 0 5 6 ? */
-// zabbix_log( LOG_LEVEL_WARNING, "poller: num [%d] answer count [%d] request count [%d]", num, answer_count, request_count);
-// if(processed < request_count-1)
- if( (num < request_count) && (unprocessed_flag == 1))
- {
- /* do logic */
-// zabbix_log( LOG_LEVEL_WARNING, "poller: processing host [%s] key [%s] status [%d]", DBget_field(shared_result,num,2), DBget_field(shared_result,num,1), requests[num].status);
-
- item.key=DBget_field(shared_result,num,1);
- item.host=DBget_field(shared_result,num,2);
- item.port=atoi(DBget_field(shared_result,num,3));
- item.type=atoi(DBget_field(shared_result,num,7));
- item.snmp_community=DBget_field(shared_result,num,8);
- item.snmp_oid=DBget_field(shared_result,num,9);
- item.useip=atoi(DBget_field(shared_result,num,10));
- item.ip=DBget_field(shared_result,num,11);
- item.value_type=atoi(DBget_field(shared_result,num,17));
- item.snmp_port=atoi(DBget_field(shared_result,num,19));
-
- if(requests[num].status!=1)
- zabbix_log( LOG_LEVEL_WARNING, "poller: ERROR status [%d] must be [1] host [%s] key [%s]", requests[num].status, item.host, item.key);
- ret = get_value(&requests[num].value,requests[num].value_str,&item);
- /* end of do logic */
-
- pthread_mutex_lock (&poller_mutex);
- requests[num].ret = ret;
- if(requests[num].status!=1)
- {
- zabbix_log( LOG_LEVEL_WARNING, "poller: ERROR2 status [%d] must be [1] host [%s] key [%s] num [%d] processed [%d] request_count [%d]", requests[num].status, item.host, item.key, num, processed, request_count);
- zabbix_log( LOG_LEVEL_WARNING, "poller: ERROR2 host2 [%s] item.host [%s]", DBget_field(shared_result,num,2), item.host);
- }
- requests[num].status = 2;
- answer_count++;
-// zabbix_log( LOG_LEVEL_WARNING, "poller: answer count [%d] request count [%d]", answer_count, request_count);
- pthread_mutex_unlock (&poller_mutex);
-
-// zabbix_log( LOG_LEVEL_WARNING, "poller: processed [%d] request count [%d]", processed, request_count);
- }
-
-// if(num == request_count-1)
- pthread_mutex_lock (&poller_mutex);
-// zabbix_log( LOG_LEVEL_WARNING, "poller: num [%d] answer count [%d] request count [%d] processed [%d]", num, answer_count, request_count, processed);
- if(processed == request_count) end = 1;
- else end = 0;
- pthread_mutex_unlock (&poller_mutex);
-
- if(end == 1)
- {
- break;
- }
-
- }
-
- pthread_mutex_lock (&result_mutex);
-// if( (state >= 1) && (state< CONFIG_SUCKERD_FORKS-4) )
-
-/* if(state == 1)
- {
- state = 2;
- zabbix_log( LOG_LEVEL_WARNING, "poller: broadcast state [%d]", state);
- pthread_cond_broadcast(&result_cv);
- }
- else
- {
- zabbix_log( LOG_LEVEL_WARNING, "poller: do not broadcast state [2]");
- }
-*/
- state = 2;
- zabbix_log( LOG_LEVEL_WARNING, "poller: broadcast state [%d]", state);
- pthread_cond_broadcast(&result_cv);
- pthread_mutex_unlock (&result_mutex);
-
-/* pthread_mutex_lock (&result_mutex);
-// if( (answer_count == request_count) && (state == 1))
- if( answer_count == request_count)
- {
- state = 2;
- zabbix_log( LOG_LEVEL_WARNING, "poller: broadcast state [%d]", state);
- pthread_cond_signal(&result_cv);
-// pthread_cond_broadcast(&result_cv);
- }
- else
- {
- zabbix_log( LOG_LEVEL_WARNING, "poller: do not broadcast state [2]");
- }
- pthread_mutex_unlock (&result_mutex);*/
- }
- sleep(100000);
-}
-#endif
-
-#ifdef ZABBIX_THREADS
-void *main_sucker_loop()
-#else
int main_sucker_loop()
-#endif
{
int now;
int nextcheck,sleeptime;
-#ifdef ZABBIX_THREADS
- DB_HANDLE database;
-#endif
-
-#ifdef ZABBIX_THREADS
- my_thread_init();
-#endif
-
-#ifdef ZABBIX_THREADS
- DBconnect_thread(&database);
-#else
DBconnect();
-#endif
for(;;)
{
@@ -986,19 +586,11 @@ int main_sucker_loop()
setproctitle("sucker [getting values]");
#endif
now=time(NULL);
-#ifdef ZABBIX_THREADS
- get_values(&database);
-#else
get_values();
-#endif
zabbix_log( LOG_LEVEL_DEBUG, "Spent %d seconds while updating values", (int)time(NULL)-now );
-#ifdef ZABBIX_THREADS
- nextcheck=get_minnextcheck_thread(&database,now);
-#else
nextcheck=get_minnextcheck(now);
-#endif
zabbix_log( LOG_LEVEL_DEBUG, "Nextcheck:%d Time:%d", nextcheck, (int)time(NULL) );
if( FAIL == nextcheck)
@@ -1034,55 +626,6 @@ int main_sucker_loop()
}
}
-#ifdef ZABBIX_THREADS
-
-#define NUM_THREADS 100
-void init_threads(void)
-{
- pthread_t threads[NUM_THREADS];
- int rc, i;
- for(i=0;i < CONFIG_SUCKERD_FORKS;i++){
- zabbix_log( LOG_LEVEL_WARNING, "Creating thread %d", i);
- if(i==0)
- {
- rc = pthread_create(&threads[i], NULL, main_housekeeper_loop, (void *)i);
- }
- else if(i==1)
- {
- rc = pthread_create(&threads[i], NULL, main_alerter_loop, (void *)i);
- }
- else if(i==2)
- {
- rc = pthread_create(&threads[i], NULL, main_nodata_loop, (void *)i);
-// rc = pthread_create(&threads[i], NULL, main_housekeeper_loop, (void *)i);
- }
- else if(i==3)
- {
- rc = pthread_create(&threads[i], NULL, main_pinger_loop, (void *)i);
-// rc = pthread_create(&threads[i], NULL, main_housekeeper_loop, (void *)i);
- }
- else if(i==4)
- {
-#ifdef HAVE_SNMP
- init_snmp("zabbix_server");
-#endif
- rc = pthread_create(&threads[i], NULL, main_sucker_loop, (void *)i);
- }
- else
- {
- rc = pthread_create(&threads[i], NULL, main_poller_loop, (void *)i);
- }
-
- if (rc){
- zabbix_log( LOG_LEVEL_ERR, "ERROR from pthread_create() [%m]");
- exit(-1);
- }
- }
- pthread_exit(NULL);
-}
-#endif
-
-
int tcp_listen(const char *host, int port, socklen_t *addrlenp)
{
int sockfd;
@@ -1198,16 +741,6 @@ int main(int argc, char **argv)
DBclose();
pids=calloc(CONFIG_SUCKERD_FORKS+CONFIG_TRAPPERD_FORKS-1,sizeof(pid_t));
-#ifdef ZABBIX_THREADS
- my_init();
- pthread_mutex_init(&poller_mutex, NULL);
- pthread_mutex_init(&result_mutex, NULL);
- pthread_cond_init(&result_cv, NULL);
- init_threads();
- for(;;) sleep(100000);
- return 0;
-#endif
-
for(i=1;i<CONFIG_SUCKERD_FORKS;i++)
{
if((pid = fork()) == 0)
diff --git a/src/zabbix_server/trapper.c b/src/zabbix_server/trapper.c
index ef1e07f6..cc199488 100644
--- a/src/zabbix_server/trapper.c
+++ b/src/zabbix_server/trapper.c
@@ -45,10 +45,6 @@
#include "log.h"
#include "zlog.h"
-#ifdef ZABBIX_THREADS
- #include <pthread.h>
-#endif
-
#include "common.h"
#include "functions.h"
#include "expression.h"