diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-03-05 22:26:02 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-03-05 22:26:02 +0000 |
commit | 48128969d7b5e22130c3244c6cd1dd978acc020a (patch) | |
tree | d38a78e4106df0421f83df6ef5b8046505dc0873 | |
parent | 696714ced7d0febf942cf8e97d237c22277ce6f5 (diff) | |
download | zabbix-48128969d7b5e22130c3244c6cd1dd978acc020a.tar.gz zabbix-48128969d7b5e22130c3244c6cd1dd978acc020a.tar.xz zabbix-48128969d7b5e22130c3244c6cd1dd978acc020a.zip |
- support for parameter Timeout for zabbix_agentd (Alexei)
- support for parameter Timeout for zabbix_suckerd (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@329 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | misc/conf/zabbix_agentd.conf | 5 | ||||
-rw-r--r-- | misc/conf/zabbix_suckerd.conf | 4 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agent.c | 5 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agentd.c | 31 | ||||
-rw-r--r-- | src/zabbix_sucker/zabbix_sucker.c | 34 |
6 files changed, 62 insertions, 21 deletions
@@ -1,5 +1,7 @@ Noe ready yet: +[ Add parameter Timeout for the rest of processes ] +[ Something wrong with zabbix_agentd ] [ Solve problem with getpeername ] [ All parameters should contain section "How can be used" in the Manual] [ PHP to support non-numerci values ] @@ -9,6 +11,8 @@ Noe ready yet: Changes for 1.0beta3: + - support for parameter Timeout for zabbix_agentd (Alexei) + - support for parameter Timeout for zabbix_suckerd (Alexei) - do not refresh screen if displayed all triggers (Alexei) - fixed "Send message to" in actions.html (Alexei) - support for experimental parameter NoTimeWait (Alexei) diff --git a/misc/conf/zabbix_agentd.conf b/misc/conf/zabbix_agentd.conf index bc393f09..15b3c0b2 100644 --- a/misc/conf/zabbix_agentd.conf +++ b/misc/conf/zabbix_agentd.conf @@ -28,6 +28,11 @@ DebugLevel=2 PidFile=/var/tmp/zabbix_agentd.pid +# Spend no more than Timeout seconds on processing +# Must be between 1 and 30 + +Timeout=3 + ##### Experimental options. Use with care ! ##### # Get rid of sockets in TIME_WAIT state diff --git a/misc/conf/zabbix_suckerd.conf b/misc/conf/zabbix_suckerd.conf index f9eb7be9..6a6fbf20 100644 --- a/misc/conf/zabbix_suckerd.conf +++ b/misc/conf/zabbix_suckerd.conf @@ -25,6 +25,10 @@ HousekeepingFrequency=1 DebugLevel=2 +# Specifies how long we wait for agent (in sec) +# Must be between 1 and 30 +Timeout=5 + # Name of PID file PidFile=/var/tmp/zabbix_suckerd.pid diff --git a/src/zabbix_agent/zabbix_agent.c b/src/zabbix_agent/zabbix_agent.c index ff6faaa5..89eec857 100644 --- a/src/zabbix_agent/zabbix_agent.c +++ b/src/zabbix_agent/zabbix_agent.c @@ -1,4 +1,4 @@ - #define TEST_PARAMETERS +#define TEST_PARAMETERS #include "config.h" @@ -25,7 +25,7 @@ #include "sysinfo.h" #include "zabbix_agent.h" -char *config_host_allowed=NULL; +static char *config_host_allowed=NULL; void signal_handler( int sig ) { @@ -140,6 +140,7 @@ float process_input() int main() { #ifdef TEST_PARAMETERS + process_config_file(); test_parameters(); return SUCCEED; #endif diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index 786d488c..96d54ae0 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -42,11 +42,12 @@ int parent=0; /* Number of processed requests */ int stats_request=0; -char *CONFIG_HOST_ALLOWED=NULL; -char *CONFIG_PID_FILE=NULL; -int CONFIG_AGENTD_FORKS=AGENTD_FORKS; -int CONFIG_NOTIMEWAIT=0; -int CONFIG_LISTEN_PORT=10000; +static char *CONFIG_HOST_ALLOWED=NULL; +static char *CONFIG_PID_FILE=NULL; +static int CONFIG_AGENTD_FORKS=AGENTD_FORKS; +static int CONFIG_NOTIMEWAIT=0; +static int CONFIG_TIMEOUT=AGENT_TIMEOUT; +static int CONFIG_LISTEN_PORT=10000; void uninit(void) { @@ -83,7 +84,8 @@ void signal_handler( int sig ) uninit(); exit( FAIL ); } - else if( SIGCHLD == sig ) +/* parent==1 is mandatory ! EXECUTE sends SIGCHLD as well ... */ + else if( (SIGCHLD == sig) && (parent == 1) ) { syslog( LOG_WARNING, "One child process died. Exiting ..."); uninit(); @@ -238,6 +240,17 @@ void process_config_file(void) { CONFIG_PID_FILE=strdup(value); } + else if(strcmp(parameter,"Timeout")==0) + { + i=atoi(value); + if( (i<1) || (i>30) ) + { + syslog( LOG_CRIT, "Wrong value of Timeout in line %d. Should be between 1 or 30.", lineno); + fclose(file); + exit(1); + } + CONFIG_TIMEOUT=i; + } else if(strcmp(parameter,"NoTimeWait")==0) { i=atoi(value); @@ -367,7 +380,7 @@ void process_child(int sockfd) phan.sa_flags = 0; sigaction(SIGALRM, &phan, NULL); - alarm(AGENT_TIMEOUT); + alarm(CONFIG_TIMEOUT); syslog( LOG_DEBUG, "Before read()"); if( (nread = read(sockfd, line, 1024)) < 0) @@ -507,7 +520,6 @@ int main() sigaction(SIGINT, &phan, NULL); sigaction(SIGQUIT, &phan, NULL); sigaction(SIGTERM, &phan, NULL); - sigaction(SIGCHLD, &phan, NULL); process_config_file(); @@ -533,6 +545,9 @@ int main() parent=1; +/* For parent only. To avoid problems with EXECUTE */ + sigaction(SIGCHLD, &phan, NULL); + #ifdef HAVE_FUNCTION_SETPROCTITLE setproctitle("main process"); #endif diff --git a/src/zabbix_sucker/zabbix_sucker.c b/src/zabbix_sucker/zabbix_sucker.c index 0c4567f8..b514a822 100644 --- a/src/zabbix_sucker/zabbix_sucker.c +++ b/src/zabbix_sucker/zabbix_sucker.c @@ -39,15 +39,16 @@ static pid_t *pids=NULL; -int sucker_num=0; -int CONFIG_SUCKERD_FORKS =SUCKER_FORKS; -int CONFIG_NOTIMEWAIT =0; -int CONFIG_HOUSEKEEPING_FREQUENCY = 1; +static int sucker_num=0; +static int CONFIG_SUCKERD_FORKS =SUCKER_FORKS; +static int CONFIG_NOTIMEWAIT =0; +static int CONFIG_TIMEOUT =SUCKER_TIMEOUT; +static int CONFIG_HOUSEKEEPING_FREQUENCY = 1; static char *CONFIG_PID_FILE = NULL; -char *CONFIG_DBNAME = NULL; -char *CONFIG_DBUSER = NULL; -char *CONFIG_DBPASSWORD = NULL; -char *CONFIG_DBSOCKET = NULL; +static char *CONFIG_DBNAME = NULL; +static char *CONFIG_DBUSER = NULL; +static char *CONFIG_DBPASSWORD = NULL; +static char *CONFIG_DBSOCKET = NULL; void uninit(void) { @@ -221,8 +222,8 @@ void init_config(void) void process_config_file(void) { FILE *file; - char line[1024]; - char parameter[1024]; + char line[1024+1]; + char parameter[1024+1]; char *value; int lineno; int i; @@ -271,6 +272,17 @@ void process_config_file(void) } CONFIG_SUCKERD_FORKS=i; } + else if(strcmp(parameter,"Timeout")==0) + { + i=atoi(value); + if( (i<1) || (i>30) ) + { + syslog( LOG_CRIT, "Wrong value of Timeout in line %d. Should be between 1 and 30.", lineno); + fclose(file); + exit(1); + } + CONFIG_TIMEOUT=i; + } else if(strcmp(parameter,"NoTimeWait")==0) { i=atoi(value); @@ -636,7 +648,7 @@ int get_value(double *result,char **result_str,DB_ITEM *item) phan.sa_flags = 0; sigaction(SIGALRM, &phan, NULL); - alarm(SUCKER_TIMEOUT); + alarm(CONFIG_TIMEOUT); if(item->type == ITEM_TYPE_ZABBIX) { |