Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sysinfo.h1
-rw-r--r--src/libs/zbxsysinfo/common/common.c10
-rw-r--r--src/zabbix_agent/zabbix_agentd.c5
3 files changed, 16 insertions, 0 deletions
diff --git a/include/sysinfo.h b/include/sysinfo.h
index 8f49ffb79b1..4f643ee892a 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -213,6 +213,7 @@ void free_key_access_rules(void);
int process(const char *in_command, unsigned flags, AGENT_RESULT *result);
+void set_user_parameter_path(const char *path);
int add_user_parameter(const char *itemkey, char *command, char *error, size_t max_error_len);
int add_user_module(const char *key, int (*function)(void));
void test_parameters(void);
diff --git a/src/libs/zbxsysinfo/common/common.c b/src/libs/zbxsysinfo/common/common.c
index 2b76db7b656..fe0651b64e1 100644
--- a/src/libs/zbxsysinfo/common/common.c
+++ b/src/libs/zbxsysinfo/common/common.c
@@ -95,6 +95,13 @@ ZBX_METRIC parameters_common[] =
{NULL}
};
+const char *user_parameter_path = NULL;
+
+void set_user_parameter_path(const char *path)
+{
+ user_parameter_path = path;
+}
+
static int ONLY_ACTIVE(AGENT_REQUEST *request, AGENT_RESULT *result)
{
ZBX_UNUSED(request);
@@ -116,6 +123,9 @@ int EXECUTE_USER_PARAMETER(AGENT_REQUEST *request, AGENT_RESULT *result)
command = get_rparam(request, 0);
+ if (NULL != user_parameter_path)
+ chdir(user_parameter_path);
+
return EXECUTE_STR(command, result);
}
diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c
index 9d063e0adab..8a5c200ddee 100644
--- a/src/zabbix_agent/zabbix_agentd.c
+++ b/src/zabbix_agent/zabbix_agentd.c
@@ -54,6 +54,7 @@ char *CONFIG_LOAD_MODULE_PATH = NULL;
char **CONFIG_ALIASES = NULL;
char **CONFIG_LOAD_MODULE = NULL;
char **CONFIG_USER_PARAMETERS = NULL;
+char *CONFIG_USER_PARAMETER_PATH = NULL;
#if defined(_WINDOWS)
char **CONFIG_PERF_COUNTERS = NULL;
char **CONFIG_PERF_COUNTERS_EN = NULL;
@@ -829,6 +830,8 @@ static void zbx_load_config(int requirement, ZBX_TASK_EX *task)
PARM_OPT, 0, 0},
{"UserParameter", &CONFIG_USER_PARAMETERS, TYPE_MULTISTRING,
PARM_OPT, 0, 0},
+ {"UserParameterPath", &CONFIG_USER_PARAMETER_PATH, TYPE_STRING,
+ PARM_OPT, 0, 0},
#ifndef _WINDOWS
{"LoadModulePath", &CONFIG_LOAD_MODULE_PATH, TYPE_STRING,
PARM_OPT, 0, 0},
@@ -1317,6 +1320,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
#endif
+ set_user_parameter_path(CONFIG_USER_PARAMETER_PATH);
load_user_parameters(CONFIG_USER_PARAMETERS);
load_aliases(CONFIG_ALIASES);
zbx_free_config();
@@ -1353,6 +1357,7 @@ int main(int argc, char **argv)
break;
default:
zbx_load_config(ZBX_CFG_FILE_REQUIRED, &t);
+ set_user_parameter_path(CONFIG_USER_PARAMETER_PATH);
load_user_parameters(CONFIG_USER_PARAMETERS);
load_aliases(CONFIG_ALIASES);
break;