Source
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
extern zbx_mutex_t diskstats_lock;
static void apply_diskstat(ZBX_SINGLE_DISKDEVICE_DATA *device, time_t now, zbx_uint64_t *dstat)
{
register int i;
time_t clock[ZBX_AVG_COUNT], sec;
int index[ZBX_AVG_COUNT];
assert(device);
device->index++;
if (ZBX_MAX_COLLECTOR_HISTORY == device->index)
device->index = 0;
device->clock[device->index] = now;
device->r_sect[device->index] = dstat[ZBX_DSTAT_R_SECT];
device->r_oper[device->index] = dstat[ZBX_DSTAT_R_OPER];
device->r_byte[device->index] = dstat[ZBX_DSTAT_R_BYTE];
device->w_sect[device->index] = dstat[ZBX_DSTAT_W_SECT];
device->w_oper[device->index] = dstat[ZBX_DSTAT_W_OPER];
device->w_byte[device->index] = dstat[ZBX_DSTAT_W_BYTE];
clock[ZBX_AVG1] = clock[ZBX_AVG5] = clock[ZBX_AVG15] = now + 1;
index[ZBX_AVG1] = index[ZBX_AVG5] = index[ZBX_AVG15] = -1;
for (i = 0; i < ZBX_MAX_COLLECTOR_HISTORY; i++)
{
if (0 == device->clock[i])
continue;