Source
/*
** 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 Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static kstat_ctl_t *kc = NULL;
static kid_t kc_id = 0;
static kstat_t *kc_vminfo;
static zbx_mutex_t kstat_lock = ZBX_MUTEX_NULL;
/******************************************************************************
* *
* Purpose: refreshes kstat environment *
* *
* Parameters: error - [OUT] error message *
* *
* Return value: SUCCEED - kstat environment was refreshed successfully *
* FAIL - otherwise *
* *
******************************************************************************/
static int zbx_kstat_refresh(char **error)
{
int ret;
kid_t kid;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
if (-1 == (kid = kstat_chain_update(kc)))
{
*error = zbx_dsprintf(*error, "failed to update kstat chain: %s", zbx_strerror(errno));
ret = FAIL;
goto out;
}
if (0 != kid)
kc_id = kid;
if (NULL == (kc_vminfo = kstat_lookup(kc, "unix", -1, "vminfo")))
{
*error = zbx_dsprintf(*error, "failed to find vminfo data: %s", zbx_strerror(errno));
ret = FAIL;
goto out;