diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-05-05 14:51:52 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-05-05 14:51:52 +0000 |
commit | d718570709d62d0223e941a170a70c623a4e6cc2 (patch) | |
tree | 43f221436110b18eec227216695af79faf6c067e | |
parent | 1572af84d4d2936032d0312f3e3485c86adfb858 (diff) | |
download | zabbix-d718570709d62d0223e941a170a70c623a4e6cc2.tar.gz zabbix-d718570709d62d0223e941a170a70c623a4e6cc2.tar.xz zabbix-d718570709d62d0223e941a170a70c623a4e6cc2.zip |
- added parameter RefreshActiveChecks to zabbix_agentd.conf (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1748 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | misc/conf/zabbix_agentd.conf | 4 | ||||
-rw-r--r-- | src/zabbix_agent/active.c | 72 | ||||
-rw-r--r-- | src/zabbix_agent/active.h | 1 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agentd.c | 2 |
5 files changed, 70 insertions, 10 deletions
@@ -1,5 +1,6 @@ Changes for 1.1alpha8: + - added parameter RefreshActiveChecks to zabbix_agentd.conf (Alexei) - better report3.php (Alexei) - better alarms.php (Alexei) - new item type: active check (Alexei) diff --git a/misc/conf/zabbix_agentd.conf b/misc/conf/zabbix_agentd.conf index 0cb5c273..b5063b81 100644 --- a/misc/conf/zabbix_agentd.conf +++ b/misc/conf/zabbix_agentd.conf @@ -26,6 +26,10 @@ Hostname=localhost StartAgents=5 +# How often refresh list of active checks. 2 minutes by default. + +#RefreshActiveChecks=120 + # Specifies debug level # 0 - debug is not created # 1 - critical information diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c index 66ac9200..fad4ad0a 100644 --- a/src/zabbix_agent/active.c +++ b/src/zabbix_agent/active.c @@ -61,6 +61,42 @@ METRIC *metrics=NULL; +void init_list() +{ + zabbix_log( LOG_LEVEL_DEBUG, "In init_list()"); + + if(metrics==NULL) + { + metrics=malloc(sizeof(METRIC)); + metrics[0].key=NULL; + } + else + { + zabbix_log( LOG_LEVEL_WARNING, "Metrics are already initialised"); + } +} +void delete_all_metrics() +{ + int i,count=0; + + zabbix_log( LOG_LEVEL_DEBUG, "In delete_all_metrics()"); + for(i=0;;i++) + { + if(metrics[i].key == NULL) break; + + count++; + } + + for(i=count-1;i>=0;i--) + { + free(metrics[i].key); + } + free(metrics); + + metrics=NULL; + init_list(); +} + int get_min_nextcheck() { int i; @@ -114,8 +150,8 @@ int parse_list_of_checks(char *str) char *key, *refresh; char *s1, *s2; - metrics=malloc(sizeof(METRIC)); - metrics[0].key=NULL; + init_list(); + delete_all_metrics(); line=(char *)strtok_r(str,"\n",&s1); while(line!=NULL) @@ -364,16 +400,10 @@ int process_active_checks() return ret; } -void child_active_main(int i,char *server, int port) +void refresh_metrics(char *server, int port, char *error, int max_error_len) { - char error[MAX_STRING_LEN]; - int sleeptime, nextcheck; - - zabbix_log( LOG_LEVEL_WARNING, "zabbix_agentd %ld started",(long)getpid()); + zabbix_log( LOG_LEVEL_WARNING, "In refresh_metrics()"); -#ifdef HAVE_FUNCTION_SETPROCTITLE - setproctitle("getting list of active checks"); -#endif while(get_active_checks(server, port, error, sizeof(error)) != SUCCEED) { zabbix_log( LOG_LEVEL_WARNING, "Getting list of active checks failed. Will retry after 60 seconds"); @@ -382,6 +412,22 @@ void child_active_main(int i,char *server, int port) #endif sleep(60); } +} + +void child_active_main(int i,char *server, int port) +{ + char error[MAX_STRING_LEN]; + int sleeptime, nextcheck; + int nextrefresh; + + zabbix_log( LOG_LEVEL_WARNING, "zabbix_agentd %ld started",(long)getpid()); + +#ifdef HAVE_FUNCTION_SETPROCTITLE + setproctitle("getting list of active checks"); +#endif + + refresh_metrics(server, port, error, sizeof(error)); + nextrefresh=time(NULL)+CONFIG_REFRESH_ACTIVE_CHECKS; for(;;) { @@ -424,6 +470,12 @@ void child_active_main(int i,char *server, int port) { zabbix_log( LOG_LEVEL_DEBUG, "No sleeping" ); } + + if(time(NULL)>=nextrefresh) + { + refresh_metrics(server, port, error, sizeof(error)); + nextrefresh=time(NULL)+CONFIG_REFRESH_ACTIVE_CHECKS; + } } } diff --git a/src/zabbix_agent/active.h b/src/zabbix_agent/active.h index 642a199b..dd2729e9 100644 --- a/src/zabbix_agent/active.h +++ b/src/zabbix_agent/active.h @@ -21,6 +21,7 @@ #define ZABBIX_ACTIVE_H extern char *CONFIG_HOSTNAME; +extern int CONFIG_REFRESH_ACTIVE_CHECKS; #define METRIC struct metric_type METRIC diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index 5361750e..24b1fd20 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -76,6 +76,7 @@ int CONFIG_NOTIMEWAIT = 0; int CONFIG_TIMEOUT = AGENT_TIMEOUT; int CONFIG_LISTEN_PORT = 10050; int CONFIG_SERVER_PORT = 10051; +int CONFIG_REFRESH_ACTIVE_CHECKS = 120; char *CONFIG_LISTEN_IP = NULL; int CONFIG_LOG_LEVEL = LOG_LEVEL_WARNING; @@ -242,6 +243,7 @@ void init_config(void) {"ListenIP",&CONFIG_LISTEN_IP,0,TYPE_STRING,PARM_OPT,0,0}, {"DebugLevel",&CONFIG_LOG_LEVEL,0,TYPE_INT,PARM_OPT,0,4}, {"StartAgents",&CONFIG_AGENTD_FORKS,0,TYPE_INT,PARM_OPT,1,16}, + {"RefreshActiveChecks",&CONFIG_REFRESH_ACTIVE_CHECKS,0,TYPE_INT,PARM_OPT,60,3600}, {"UserParameter",0,&add_parameter,0,0,0,0}, {0} }; |