Source
/*
** Zabbix
** Copyright (C) 2001-2025 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.
**/
/* maximum seconds to wait for vmstat data on the first call */
int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result)
{
char *section, *type;
int wait = ZBX_MAX_WAIT_VMSTAT;
if (!VMSTAT_COLLECTOR_STARTED(collector))
{
SET_MSG_RESULT(result, zbx_strdup(NULL, "Collector is not started."));
return SYSINFO_RET_FAIL;
}
/* if vmstat data is not available yet wait for collector to gather it */
if (0 == collector->vmstat.data_available)
{
collector->vmstat.enabled = 1;
while (wait--)
{
zbx_sleep(1);
if (1 == collector->vmstat.data_available)
break;
}
if (0 == collector->vmstat.data_available)
{
SET_MSG_RESULT(result, zbx_strdup(NULL, "No data available in collector."));
return SYSINFO_RET_FAIL;
}
}
if (2 < request->nparam)
{
SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters."));
return SYSINFO_RET_FAIL;
}
section = get_rparam(request, 0);
type = get_rparam(request, 1);