diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-29 12:19:50 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-29 12:19:50 +0000 |
commit | 1af69e4b46054b7b2efca2b3d834e59caeab36f5 (patch) | |
tree | 9e7829d61b54f230e1e9d81ecaca42f11faaa13f /src | |
parent | cbe396976c682e6534f8f42e497e41f2942371d6 (diff) | |
download | zabbix-1af69e4b46054b7b2efca2b3d834e59caeab36f5.tar.gz zabbix-1af69e4b46054b7b2efca2b3d834e59caeab36f5.tar.xz zabbix-1af69e4b46054b7b2efca2b3d834e59caeab36f5.zip |
- improved "system.run[]" key, added <wait>|<nowait> mode for Linux (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2915 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/zbxsysinfo/common/common.c | 37 | ||||
-rw-r--r-- | src/zabbix_agent/active.c | 2 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agent.c | 2 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agentd.c | 2 | ||||
-rw-r--r-- | src/zabbix_server/actions.c | 2 |
5 files changed, 40 insertions, 5 deletions
diff --git a/src/libs/zbxsysinfo/common/common.c b/src/libs/zbxsysinfo/common/common.c index 5c47d914..783dea2c 100644 --- a/src/libs/zbxsysinfo/common/common.c +++ b/src/libs/zbxsysinfo/common/common.c @@ -330,6 +330,10 @@ void test_parameter(char* key) { printf(" [s|%s]", result.str); } + if(result.type & AR_TEXT) + { + printf(" [t|%s]", result.text); + } if(result.type & AR_MESSAGE) { printf(" [m|%s]", result.msg); @@ -363,6 +367,10 @@ void test_parameters(void) { printf(" [s|%s]", result.str); } + if(result.type & AR_TEXT) + { + printf(" [t|%s]", result.text); + } if(result.type & AR_MESSAGE) { printf(" [m|%s]", result.msg); @@ -1195,7 +1203,7 @@ int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT } } - SET_STR_RESULT(result, strdup(c)); + SET_TEXT_RESULT(result, strdup(c)); return SYSINFO_RET_OK; } @@ -1260,8 +1268,10 @@ int EXECUTE(const char *cmd, const char *command, unsigned flags, AGENT_RESULT * int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { char command[MAX_STRING_LEN]; +#define MAX_FLAG_LEN 10 + char flag[MAX_FLAG_LEN]; pid_t pid; - + assert(result); init_result(result); @@ -1272,7 +1282,7 @@ int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT return SYSINFO_RET_FAIL; } - if(num_param(param) > 1) + if(num_param(param) > 2) { return SYSINFO_RET_FAIL; } @@ -1287,6 +1297,25 @@ int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT return SYSINFO_RET_FAIL; } + if(get_param(param, 2, flag, MAX_FLAG_LEN) != 0) + { + flag[0] = '\0'; + } + + if(flag[0] == '\0') + { + snprintf(flag,MAX_FLAG_LEN,"wait"); + } + + if(strcmp(flag,"wait") == 0) + { + return EXECUTE_STR(cmd,command,flags,result); + } + else if(strcmp(flag,"nowait") != 0) + { + return SYSINFO_RET_FAIL; + } + zabbix_log(LOG_LEVEL_DEBUG, "Run remote command '%s'", command); pid = fork(); /* run new thread 1 */ @@ -1311,7 +1340,7 @@ int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT /* In normal case the program will never reach this point */ exit(0); default: - waitpid(pid, NULL, WNOHANG); /* NO WAIT for thread 2 closing */ + waitpid(pid, NULL, WNOHANG); /* NO WAIT can be used for thread 2 closing */ exit(0); /* close thread 1 and transmit thread 2 to system (solve zombie state) */ break; } diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c index 895cde43..0b9cf597 100644 --- a/src/zabbix_agent/active.c +++ b/src/zabbix_agent/active.c @@ -479,6 +479,8 @@ int process_active_checks(char *server, int port) snprintf(value, MAX_STRING_LEN-1, ZBX_FS_UI64, result.ui64); else if(result.type & AR_STRING) snprintf(value, MAX_STRING_LEN-1, "%s", result.str); + else if(result.type & AR_TEXT) + snprintf(value, MAX_STRING_LEN-1, "%s", result.text); else if(result.type & AR_MESSAGE) snprintf(value, MAX_STRING_LEN-1, "%s", result.msg); free_result(&result); diff --git a/src/zabbix_agent/zabbix_agent.c b/src/zabbix_agent/zabbix_agent.c index 7205310c..4524f4c3 100644 --- a/src/zabbix_agent/zabbix_agent.c +++ b/src/zabbix_agent/zabbix_agent.c @@ -201,6 +201,8 @@ int main(int argc, char **argv) snprintf(value, MAX_STRING_LEN-1, ZBX_FS_UI64, result.ui64); else if(result.type & AR_STRING) snprintf(value, MAX_STRING_LEN-1, "%s", result.str); + else if(result.type & AR_TEXT) + snprintf(value, MAX_STRING_LEN-1, "%s", result.text); else if(result.type & AR_MESSAGE) snprintf(value, MAX_STRING_LEN-1, "%s", result.msg); free_result(&result); diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index de3cc0bc..ecf8d24d 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -379,6 +379,8 @@ void process_child(int sockfd) snprintf(value, MAX_STRING_LEN-1, ZBX_FS_UI64, result.ui64); else if(result.type & AR_STRING) snprintf(value, MAX_STRING_LEN-1, "%s", result.str); + else if(result.type & AR_TEXT) + snprintf(value, MAX_STRING_LEN-1, "%s", result.text); else if(result.type & AR_MESSAGE) snprintf(value, MAX_STRING_LEN-1, "%s", result.msg); free_result(&result); diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c index 6acc9de8..4acc5f1e 100644 --- a/src/zabbix_server/actions.c +++ b/src/zabbix_server/actions.c @@ -250,7 +250,7 @@ static void run_remote_command(char* host_name, char* command) item.useip=atoi(row[2]); item.port=atoi(row[3]); - snprintf(item.key,ITEM_KEY_LEN_MAX-1,"system.run[%s]",command); + snprintf(item.key,ITEM_KEY_LEN_MAX-1,"system.run[%s,nowait]",command); alarm(CONFIG_TIMEOUT); |