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 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;
DISKSTAT(1);
DISKSTAT(5);
DISKSTAT(15);