Source
SET_MSG_RESULT(result, zbx_strdup(NULL, "This item is available only in daemon mode when collectors are"
/*
** Zabbix
** Copyright (C) 2001-2022 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.
**/
static struct statinfo *si = NULL;
int get_diskstat(const char *devname, zbx_uint64_t *dstat)
{
int i;
struct devstat *ds = NULL;
int ret = FAIL;
char dev[DEVSTAT_NAME_LEN + 10];
const char *pd; /* pointer to device name without '/dev/' prefix, e.g. 'da0' */
assert(devname);
for (i = 0; i < ZBX_DSTAT_MAX; i++)
dstat[i] = (zbx_uint64_t)__UINT64_C(0);
if (NULL == si)
{
si = (struct statinfo *)zbx_malloc(si, sizeof(struct statinfo));
si->dinfo = (struct devinfo *)zbx_malloc(NULL, sizeof(struct devinfo));
memset(si->dinfo, 0, sizeof(struct devinfo));
}
pd = devname;
/* skip prefix ZBX_DEV_PFX, if present */
if ('\0' != *devname && 0 == strncmp(pd, ZBX_DEV_PFX, ZBX_CONST_STRLEN(ZBX_DEV_PFX)))
pd += ZBX_CONST_STRLEN(ZBX_DEV_PFX);
if (-1 == devstat_getdevs(NULL, si))
if (-1 == getdevs(si))
return FAIL;