Source
SET_MSG_RESULT(result, zbx_strdup(NULL, "Agent was compiled without support for \"sensordev\" structure."));
/*
** 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 count_sensor(int do_task, const struct sensor *sensor, double *aggr, int *cnt)
{
double value = sensor->value;
switch (sensor->type)
{
case SENSOR_TEMP:
value = (value - 273150000) / 1000000;
break;
case SENSOR_VOLTS_DC:
case SENSOR_VOLTS_AC:
case SENSOR_AMPS:
case SENSOR_LUX:
value /= 1000000;
break;
case SENSOR_TIMEDELTA:
value /= 1000000000;
break;
default:
break;
}
(*cnt)++;
switch (do_task)
{
case ZBX_DO_ONE:
*aggr = value;
break;
case ZBX_DO_AVG:
*aggr += value;
break;
case ZBX_DO_MAX:
*aggr = (1 == *cnt ? value : MAX(*aggr, value));
break;
case ZBX_DO_MIN:
*aggr = (1 == *cnt ? value : MIN(*aggr, value));
break;
}
}