Source
SET_UI64_RESULT(result, ((zbx_uint64_t)info.totalswap - (zbx_uint64_t)info.freeswap) *
/*
** 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.
**/
/* Solaris. */
static void get_swapinfo(double *total, double *fr)
{
int cnt, i, page_size;
/* Support for >2Gb */
/* int t, f;*/
double t, f;
struct swaptable *swt;
struct swapent *ste;
static char path[256];
/* get total number of swap entries */
cnt = swapctl(SC_GETNSWP, 0);
/* allocate enough space to hold count + n swapents */
swt = (struct swaptable *)malloc(sizeof(int) +
cnt * sizeof(struct swapent));
if (swt == NULL)
{
*total = 0;
*fr = 0;
return;
}
swt->swt_n = cnt;
/* fill in ste_path pointers: we don't care about the paths, so we
point them all to the same buffer */
ste = &(swt->swt_ent[0]);
i = cnt;
while (--i >= 0)
{
ste++->ste_path = path;
}
/* grab all swap info */
swapctl(SC_LIST, swt);
/* walk through the structs and sum up the fields */