diff options
Diffstat (limited to 'src/libs/zbxsysinfo/openbsd/sensors.c')
-rw-r--r-- | src/libs/zbxsysinfo/openbsd/sensors.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/libs/zbxsysinfo/openbsd/sensors.c b/src/libs/zbxsysinfo/openbsd/sensors.c index 420cdac5715..35101721f52 100644 --- a/src/libs/zbxsysinfo/openbsd/sensors.c +++ b/src/libs/zbxsysinfo/openbsd/sensors.c @@ -20,6 +20,7 @@ #include "common.h" #include "sysinfo.h" #include "zbxregexp.h" +#include "log.h" #include <sys/sensors.h> @@ -131,14 +132,26 @@ int GET_SENSOR(AGENT_REQUEST *request, AGENT_RESULT *result) double aggr = 0; if (3 < request->nparam) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters.")); return SYSINFO_RET_FAIL; + } device = get_rparam(request, 0); name = get_rparam(request, 1); function = get_rparam(request, 2); - if (NULL == device || NULL == name) + if (NULL == device || '\0' == *device) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter.")); + return SYSINFO_RET_FAIL; + } + + if (NULL == name || '\0' == *name) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } if (NULL == function || '\0' == *function) do_task = ZBX_DO_ONE; @@ -149,7 +162,10 @@ int GET_SENSOR(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(function, "min")) do_task = ZBX_DO_MIN; else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid third parameter.")); return SYSINFO_RET_FAIL; + } mib[0] = CTL_HW; mib[1] = HW_SENSORS; @@ -168,6 +184,8 @@ int GET_SENSOR(AGENT_REQUEST *request, AGENT_RESULT *result) if (errno == ENOENT) break; + SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", + zbx_strerror(errno))); return SYSINFO_RET_FAIL; } @@ -175,12 +193,18 @@ int GET_SENSOR(AGENT_REQUEST *request, AGENT_RESULT *result) (ZBX_DO_ONE != do_task && NULL != zbx_regexp_match(sensordev.xname, device, NULL))) { if (SUCCEED != get_device_sensors(do_task, mib, &sensordev, name, &aggr, &cnt)) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain sensor information.")); return SYSINFO_RET_FAIL; + } } } if (0 == cnt) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain sensor information.")); return SYSINFO_RET_FAIL; + } if (ZBX_DO_AVG == do_task) SET_DBL_RESULT(result, aggr / cnt); @@ -194,6 +218,7 @@ int GET_SENSOR(AGENT_REQUEST *request, AGENT_RESULT *result) int GET_SENSOR(AGENT_REQUEST *request, AGENT_RESULT *result) { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Agent was compiled without support for \"sensordev\" structure.")); return SYSINFO_RET_FAIL; } |