extern zbx_mutex_t diskstats_lock;
#define LOCK_DISKSTATS zbx_mutex_lock(diskstats_lock)
#define UNLOCK_DISKSTATS zbx_mutex_unlock(diskstats_lock)
static void apply_diskstat(ZBX_SINGLE_DISKDEVICE_DATA *device, time_t now, zbx_uint64_t *dstat)
time_t clock[ZBX_AVG_COUNT], sec;
int index[ZBX_AVG_COUNT];
if (ZBX_MAX_COLLECTOR_HISTORY == device->index)
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])
if ((device->clock[i] >= (now - (t * 60))) && (clock[ZBX_AVG ## t] > device->clock[i]))\