diff options
Diffstat (limited to 'src/libs/zbxsysinfo/freebsd/diskio.c')
-rw-r--r-- | src/libs/zbxsysinfo/freebsd/diskio.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/libs/zbxsysinfo/freebsd/diskio.c b/src/libs/zbxsysinfo/freebsd/diskio.c index d71980abd92..6795f6b1040 100644 --- a/src/libs/zbxsysinfo/freebsd/diskio.c +++ b/src/libs/zbxsysinfo/freebsd/diskio.c @@ -102,7 +102,10 @@ static int vfs_dev_rw(AGENT_REQUEST *request, AGENT_RESULT *result, int rw) char *pd; /* pointer to device name without '/dev/' prefix, e.g. 'da0' */ if (3 < request->nparam) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters.")); return SYSINFO_RET_FAIL; + } tmp = get_rparam(request, 0); @@ -131,15 +134,24 @@ static int vfs_dev_rw(AGENT_REQUEST *request, AGENT_RESULT *result, int rw) else if (0 == strcmp(tmp, "operations")) type = ZBX_DSTAT_TYPE_OPER; else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } if (type == ZBX_DSTAT_TYPE_BYTE || type == ZBX_DSTAT_TYPE_OPER) { - if (request->nparam > 2) + if (2 < request->nparam) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid number of parameters.")); return SYSINFO_RET_FAIL; + } if (FAIL == get_diskstat(pd, dstats)) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain disk information.")); return SYSINFO_RET_FAIL; + } if (ZBX_DSTAT_TYPE_BYTE == type) SET_UI64_RESULT(result, dstats[(ZBX_DEV_READ == rw ? ZBX_DSTAT_R_BYTE : ZBX_DSTAT_W_BYTE)]); @@ -158,7 +170,10 @@ static int vfs_dev_rw(AGENT_REQUEST *request, AGENT_RESULT *result, int rw) else if (0 == strcmp(tmp, "avg15")) mode = ZBX_AVG15; else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid third parameter.")); return SYSINFO_RET_FAIL; + } if (NULL == collector) { @@ -167,17 +182,24 @@ static int vfs_dev_rw(AGENT_REQUEST *request, AGENT_RESULT *result, int rw) /* the collectors are not available and keys "vfs.dev.read", "vfs.dev.write" with some parameters */ /* (e.g. sps, ops) are not supported. */ - SET_MSG_RESULT(result, strdup("This parameter is available only in daemon mode when collectors are started.")); + SET_MSG_RESULT(result, zbx_strdup(NULL, "This item is available only in daemon mode when collectors are" + " started.")); return SYSINFO_RET_FAIL; } if (NULL == (device = collector_diskdevice_get(pd))) { if (FAIL == get_diskstat(pd, dstats)) /* validate device name */ + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain disk information.")); return SYSINFO_RET_FAIL; + } if (NULL == (device = collector_diskdevice_add(pd))) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot add disk device to agent collector.")); return SYSINFO_RET_FAIL; + } } if (ZBX_DSTAT_TYPE_BPS == type) /* default parameter */ |