Source
if (SYSINFO_RET_OK != get_fs_inode_stat(mpoint, &itotal, &inot_used, &iused, &ipfree, &ipused, "pused",
/*
** 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 int get_fs_size_stat(const char *fs, zbx_uint64_t *total, zbx_uint64_t *free,
zbx_uint64_t *used, double *pfree, double *pused, char **error)
{
struct ZBX_STATFS s;
if (0 != ZBX_STATFS(fs, &s))
{
*error = zbx_dsprintf(NULL, "Cannot obtain filesystem information: %s", zbx_strerror(errno));
zabbix_log(LOG_LEVEL_DEBUG,"%s failed with error: %s",__func__, *error);
return SYSINFO_RET_FAIL;
}
/* Available space could be negative (top bit set) if we hit disk space */
/* reserved for non-privileged users. Treat it as 0. */
if (0 != ZBX_IS_TOP_BIT_SET(s.f_bavail))
s.f_bavail = 0;
if (NULL != total)
*total = (zbx_uint64_t)s.f_blocks * s.ZBX_BSIZE;
if (NULL != free)
*free = (zbx_uint64_t)s.f_bavail * s.ZBX_BSIZE;
if (NULL != used)
*used = (zbx_uint64_t)(s.f_blocks - s.f_bfree) * s.ZBX_BSIZE;