diff options
author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-06 14:29:52 +0000 |
---|---|---|
committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-02-06 14:29:52 +0000 |
commit | afbe3957b29944ec3f3114af59aa6f03dbad0560 (patch) | |
tree | 49490ce54fe5bee7c20c8fbd4296cbc9d69b8841 /src/zabbix_proxy | |
parent | 4df122faec3b6b9889dbf644005d4815d4f4d698 (diff) | |
download | zabbix-afbe3957b29944ec3f3114af59aa6f03dbad0560.tar.gz zabbix-afbe3957b29944ec3f3114af59aa6f03dbad0560.tar.xz zabbix-afbe3957b29944ec3f3114af59aa6f03dbad0560.zip |
- [DEV-110] Proxy changes
git-svn-id: svn://svn.zabbix.com/trunk@5331 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_proxy')
-rw-r--r-- | src/zabbix_proxy/Makefile.am | 4 | ||||
-rw-r--r-- | src/zabbix_proxy/proxy.c | 56 | ||||
-rw-r--r-- | src/zabbix_proxy/proxyconfig/proxyconfig.c | 51 | ||||
-rw-r--r-- | src/zabbix_proxy/proxyconfig/proxyconfig.h | 6 |
4 files changed, 20 insertions, 97 deletions
diff --git a/src/zabbix_proxy/Makefile.am b/src/zabbix_proxy/Makefile.am index 70c80e79..be24d342 100644 --- a/src/zabbix_proxy/Makefile.am +++ b/src/zabbix_proxy/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = \ housekeeper \ httppoller \ proxyconfig \ - pinger \ + ../zabbix_server/pinger \ poller \ trapper @@ -27,7 +27,7 @@ zabbix_proxy_LDADD = \ housekeeper/libzbxhousekeeper.a \ httppoller/libzbxhttppoller.a \ proxyconfig/libzbxproxyconfig.a \ - pinger/libzbxpinger.a \ + $(top_srcdir)/src/zabbix_server/pinger/libzbxpinger.a \ poller/libzbxpoller.a \ trapper/libzbxtrapper.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ diff --git a/src/zabbix_proxy/proxy.c b/src/zabbix_proxy/proxy.c index 3202ebd1..5901ea45 100644 --- a/src/zabbix_proxy/proxy.c +++ b/src/zabbix_proxy/proxy.c @@ -29,7 +29,6 @@ #include "log.h" #include "zlog.h" #include "zbxgetopt.h" -#include "mutexs.h" #ifdef ZABBIX_TEST #include "zbxjson.h" @@ -45,7 +44,7 @@ #include "discoverer/discoverer.h" #include "httppoller/httppoller.h" #include "housekeeper/housekeeper.h" -#include "pinger/pinger.h" +#include "../zabbix_server/pinger/pinger.h" #include "poller/poller.h" #include "poller/checks_snmp.h" #include "trapper/trapper.h" @@ -140,6 +139,7 @@ int CONFIG_LOG_LEVEL = LOG_LEVEL_WARNING; char *CONFIG_ALERT_SCRIPTS_PATH = NULL; char *CONFIG_EXTERNALSCRIPTS = NULL; char *CONFIG_FPING_LOCATION = NULL; +char *CONFIG_FPING6_LOCATION = NULL; char *CONFIG_DBHOST = NULL; char *CONFIG_DBNAME = NULL; char *CONFIG_DBUSER = NULL; @@ -151,7 +151,7 @@ int CONFIG_ENABLE_REMOTE_COMMANDS = 0; char *CONFIG_SERVER = NULL; int CONFIG_SERVER_PORT = 10050; char *CONFIG_HOSTNAME = NULL; -int CONFIG_NODEID = 0; +int CONFIG_NODEID = -1; int CONFIG_MASTER_NODEID = 0; int CONFIG_NODE_NOHISTORY = 0; @@ -164,9 +164,6 @@ int CONFIG_REFRESH_UNSUPPORTED = 0; /* Zabbix server sturtup time */ int CONFIG_SERVER_STARTUP_TIME = 0; -/* Mutex for node syncs */ -ZBX_MUTEX node_sync_access; - /****************************************************************************** * * * Function: init_config * @@ -201,6 +198,7 @@ void init_config(void) {"SenderFrequency",&CONFIG_SENDER_FREQUENCY,0,TYPE_INT,PARM_OPT,5,3600}, {"PingerFrequency",&CONFIG_PINGER_FREQUENCY,0,TYPE_INT,PARM_OPT,1,3600}, {"FpingLocation",&CONFIG_FPING_LOCATION,0,TYPE_STRING,PARM_OPT,0,0}, + {"Fping6Location",&CONFIG_FPING6_LOCATION,0,TYPE_STRING,PARM_OPT,0,0}, {"Timeout",&CONFIG_TIMEOUT,0,TYPE_INT,PARM_OPT,1,30}, {"TrapperTimeout",&CONFIG_TRAPPER_TIMEOUT,0,TYPE_INT,PARM_OPT,1,30}, {"UnreachablePeriod",&CONFIG_UNREACHABLE_PERIOD,0,TYPE_INT,PARM_OPT,1,3600}, @@ -223,7 +221,6 @@ void init_config(void) {"DBPassword",&CONFIG_DBPASSWORD,0,TYPE_STRING,PARM_OPT,0,0}, {"DBSocket",&CONFIG_DBSOCKET,0,TYPE_STRING,PARM_OPT,0,0}, {"DBPort",&CONFIG_DBPORT,0,TYPE_INT,PARM_OPT,1024,65535}, - {"NodeID",&CONFIG_NODEID,0,TYPE_INT,PARM_OPT,0,65535}, {0} }; @@ -249,6 +246,10 @@ void init_config(void) { CONFIG_FPING_LOCATION=strdup("/usr/sbin/fping"); } + if(CONFIG_FPING6_LOCATION == NULL) + { + CONFIG_FPING6_LOCATION=strdup("/usr/sbin/fping6"); + } if(CONFIG_EXTERNALSCRIPTS == NULL) { CONFIG_EXTERNALSCRIPTS=strdup("/etc/zabbix/externalscripts"); @@ -376,9 +377,6 @@ int main(int argc, char **argv) int MAIN_ZABBIX_ENTRY(void) { - DB_RESULT result; - DB_ROW row; - int i; pid_t pid; @@ -428,26 +426,6 @@ int MAIN_ZABBIX_ENTRY(void) DBconnect(ZBX_DB_CONNECT_EXIT); - result = DBselect("select refresh_unsupported from config where " ZBX_COND_NODEID, - LOCAL_NODE("configid")); - row = DBfetch(result); - - if( (row != NULL) && DBis_null(row[0]) != SUCCEED) - { - CONFIG_REFRESH_UNSUPPORTED = atoi(row[0]); - } - DBfree_result(result); - - result = DBselect("select masterid from nodes where nodeid=%d", - CONFIG_NODEID); - row = DBfetch(result); - - if( (row != NULL) && DBis_null(row[0]) != SUCCEED) - { - CONFIG_MASTER_NODEID = atoi(row[0]); - } - DBfree_result(result); - /* Need to set trigger status to UNKNOWN since last run */ /* DBconnect() already made in init_config() */ /* DBconnect();*/ @@ -459,11 +437,6 @@ int MAIN_ZABBIX_ENTRY(void) /* Do not close database. It is required for database cache */ /* DBclose();*/ - if (ZBX_MUTEX_ERROR == zbx_mutex_create_force(&node_sync_access, ZBX_MUTEX_NODE_SYNC)) { - zbx_error("Unable to create mutex for node syncs"); - exit(FAIL); - } - threads = calloc(1+CONFIG_POLLER_FORKS+CONFIG_TRAPPERD_FORKS+CONFIG_PINGER_FORKS +CONFIG_HOUSEKEEPER_FORKS+CONFIG_UNREACHABLE_POLLER_FORKS +/*CONFIG_NODEWATCHER_FORKS+*/CONFIG_HTTPPOLLER_FORKS+CONFIG_DISCOVERER_FORKS, @@ -522,10 +495,9 @@ int MAIN_ZABBIX_ENTRY(void) /* child_trapper_make(server_num, listenfd, addrlen); */ } else if(server_num <= CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS + CONFIG_PINGER_FORKS) { - zabbix_log( LOG_LEVEL_WARNING, "server #%d started [ICMP pinger]", - server_num); - main_pinger_loop(server_num-(CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS)); - } else if(server_num <= CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS + CONFIG_PINGER_FORKS + main_pinger_loop(server_num, server_num - (CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS)); + } + else if(server_num <= CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS + CONFIG_PINGER_FORKS +CONFIG_HOUSEKEEPER_FORKS) { zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Housekeeper]", @@ -546,9 +518,8 @@ int MAIN_ZABBIX_ENTRY(void) + CONFIG_HOUSEKEEPER_FORKS + CONFIG_UNREACHABLE_POLLER_FORKS + CONFIG_NODEWATCHER_FORKS) { -zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Node watcher. Node ID:%d]", - server_num, - CONFIG_NODEID); +zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Node watcher. Node ID:]", + server_num); main_nodewatcher_loop();*/ } else if(server_num <= CONFIG_POLLER_FORKS + CONFIG_TRAPPERD_FORKS + CONFIG_PINGER_FORKS + CONFIG_HOUSEKEEPER_FORKS + CONFIG_UNREACHABLE_POLLER_FORKS @@ -620,7 +591,6 @@ void zbx_on_exit() free_database_cache(); } DBclose(); - zbx_mutex_destroy(&node_sync_access); zabbix_close_log(); #ifdef HAVE_SQLITE3 diff --git a/src/zabbix_proxy/proxyconfig/proxyconfig.c b/src/zabbix_proxy/proxyconfig/proxyconfig.c index ed076a0d..fcd2f12d 100644 --- a/src/zabbix_proxy/proxyconfig/proxyconfig.c +++ b/src/zabbix_proxy/proxyconfig/proxyconfig.c @@ -244,29 +244,28 @@ db_error: ******************************************************************************/ static int process_proxyconfig(struct zbx_json_parse *jp) { - char tablename[MAX_STRING_LEN]; - size_t len = sizeof(tablename); + char buf[MAX_STRING_LEN]; + size_t len = sizeof(buf); const char *p = NULL; int res = SUCCEED; zabbix_log(LOG_LEVEL_DEBUG, "In process_proxyconfig()"); DBbegin(); - /* * {"hosts":{"fields":["hostid","host",...],"data":[[1,"zbx01",...],[2,"zbx02",...],...]},"items":{...},...} * ^ */ - while (NULL != (p = zbx_json_pair_next(jp, p, tablename, len)) && res == SUCCEED) { + while (NULL != (p = zbx_json_pair_next(jp, p, buf, len)) && res == SUCCEED) { if (ZBX_JSON_TYPE_OBJECT != zbx_json_type(p)) { zabbix_log(LOG_LEVEL_WARNING, "Invalid type of data for table \"%s\" \"%.40s...\"", - tablename, + buf, p); res = FAIL; break; } - res = process_proxyconfig_table(jp, tablename, p); + res = process_proxyconfig_table(jp, buf, p); } if (res == SUCCEED) DBcommit(); @@ -278,46 +277,6 @@ static int process_proxyconfig(struct zbx_json_parse *jp) /****************************************************************************** * * - * Function: node_sync_lock * - * * - * Purpose: * - * * - * Parameters: * - * * - * Return value: * - * * - * Author: Aleksander Vladishev * - * * - * Comments: * - * * - ******************************************************************************/ -/*void node_sync_lock(int nodeid) -{ - zbx_mutex_lock(&node_sync_access); -}*/ - -/****************************************************************************** - * * - * Function: node_sync_unlock * - * * - * Purpose: * - * * - * Parameters: * - * * - * Return value: * - * * - * Author: Aleksander Vladishev * - * * - * Comments: * - * * - ******************************************************************************/ -/*void node_sync_unlock(int nodeid) -{ - zbx_mutex_unlock(&node_sync_access); -}*/ - -/****************************************************************************** - * * * Function: process_nodes * * * * Purpose: calculates checks sum of config data * diff --git a/src/zabbix_proxy/proxyconfig/proxyconfig.h b/src/zabbix_proxy/proxyconfig/proxyconfig.h index 0bcf0a54..77cb2a29 100644 --- a/src/zabbix_proxy/proxyconfig/proxyconfig.h +++ b/src/zabbix_proxy/proxyconfig/proxyconfig.h @@ -20,12 +20,6 @@ #ifndef ZABBIX_PROXYCONFIG_H #define ZABBIX_PROXYCONFIG_H -/*#include "mutexs.h" - -extern ZBX_MUTEX node_sync_access;*/ - -/*void node_sync_lock(int nodeid); -void node_sync_unlock(int nodeid);*/ void main_proxyconfig_loop(int server_num); #endif |