diff options
author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-02 12:59:26 +0000 |
---|---|---|
committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-02 12:59:26 +0000 |
commit | 5ba926456af3b3527adb881976986d11df755f48 (patch) | |
tree | fb95c7188d3d9aa62e6ee07c53285a43e07d0ddd /src | |
parent | e58322734a3b0a38f4fbb9f061bab0987060de60 (diff) | |
download | zabbix-5ba926456af3b3527adb881976986d11df755f48.tar.gz zabbix-5ba926456af3b3527adb881976986d11df755f48.tar.xz zabbix-5ba926456af3b3527adb881976986d11df755f48.zip |
- [ZBX-380] added support of directories for Include in configuration file
git-svn-id: svn://svn.zabbix.com/trunk@5742 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/zbxconf/cfg.c | 49 | ||||
-rw-r--r-- | src/zabbix_server/events.c | 2 |
2 files changed, 46 insertions, 5 deletions
diff --git a/src/libs/zbxconf/cfg.c b/src/libs/zbxconf/cfg.c index 583521db..4b09281e 100644 --- a/src/libs/zbxconf/cfg.c +++ b/src/libs/zbxconf/cfg.c @@ -20,8 +20,12 @@ #include "common.h" #include "cfg.h" #include "log.h" - - +/* +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <dirent.h> +*/ char *CONFIG_FILE = NULL; int CONFIG_ZABBIX_FORKS = 5; @@ -31,6 +35,45 @@ int CONFIG_LOG_FILE_SIZE = 1; char CONFIG_ALLOW_ROOT = 0; int CONFIG_TIMEOUT = AGENT_TIMEOUT; +static int parse_cfg_object(const char *cfg_file, struct cfg_line *cfg) +{ + DIR *dir; + struct stat sb; + struct dirent *d; + char *incl_file = NULL; + int result = SUCCEED; + + if (stat(cfg_file, &sb) == -1) { + zbx_error("%s: %s\n", cfg_file, strerror(errno)); + return FAIL; + } + + if (!S_ISDIR(sb.st_mode)) + return parse_cfg_file(cfg_file, cfg); + + if (NULL == (dir = opendir(cfg_file))) { + zbx_error("%s: %s\n", cfg_file, strerror(errno)); + return FAIL; + } + + while (NULL != (d = readdir(dir))) { + incl_file = zbx_dsprintf(incl_file, "%s/%s", cfg_file, d->d_name); + + if (d->d_type == DT_REG && parse_cfg_file(incl_file, cfg) == FAIL) { + result = FAIL; + break; + } + } + zbx_free(incl_file); + + if (closedir(dir) == -1) { + zbx_error("%s: %s\n", cfg_file, strerror(errno)); + return FAIL; + } + + return result; +} + /****************************************************************************** * * * Function: parse_cfg_file * @@ -117,7 +160,7 @@ int parse_cfg_file(const char *cfg_file,struct cfg_line *cfg) if(strcmp(parameter, "Include") == 0) { - parse_cfg_file(value, cfg); + parse_cfg_object(value, cfg); } for(i = 0; value[i] != '\0'; i++) diff --git a/src/zabbix_server/events.c b/src/zabbix_server/events.c index 2d0dfa5e..4271dc3f 100644 --- a/src/zabbix_server/events.c +++ b/src/zabbix_server/events.c @@ -189,12 +189,10 @@ int process_event(DB_EVENT *event) event->eventid, ALERT_STATUS_NOT_SENT); }*/ -/* zabbix_set_log_level(LOG_LEVEL_DEBUG);*/ if(event->skip_actions == 0) { process_actions(event); } -/* zabbix_set_log_level(LOG_LEVEL_CRIT);*/ if(TRIGGER_VALUE_TRUE == event->value) { |