Source
db_result = zbx_db_select("select command,host_access,usrgrpid,groupid,type,execute_on,timeout,scope,port,authtype"
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/******************************************************************************
* *
* Purpose: execute remote command and wait for the result *
* *
* Return value: SUCCEED - the remote command was executed successfully *
* FAIL - an error occurred *
* *
******************************************************************************/
static int execute_remote_script(const zbx_script_t *script, const DC_HOST *host, char **info, char *error,
size_t max_error_len)
{
int time_start;
zbx_uint64_t taskid;
DB_RESULT result = NULL;
DB_ROW row;
if (0 == (taskid = zbx_script_create_task(script, host, 0, time(NULL))))
{
zbx_snprintf(error, max_error_len, "Cannot create remote command task.");
return FAIL;
}
for (time_start = time(NULL); SEC_PER_MIN > time(NULL) - time_start; sleep(1))
{
result = zbx_db_select(
"select tr.status,tr.info"
" from task t"
" left join task_remote_command_result tr"
" on tr.taskid=t.taskid"
" where tr.parent_taskid=" ZBX_FS_UI64,
taskid);