diff options
Diffstat (limited to 'src/libs/zbxsysinfo/aix/vmstats.c')
-rw-r--r-- | src/libs/zbxsysinfo/aix/vmstats.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/src/libs/zbxsysinfo/aix/vmstats.c b/src/libs/zbxsysinfo/aix/vmstats.c index e4e5bdb269f..0d4b55e4e8b 100644 --- a/src/libs/zbxsysinfo/aix/vmstats.c +++ b/src/libs/zbxsysinfo/aix/vmstats.c @@ -30,7 +30,7 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) if (!VMSTAT_COLLECTOR_STARTED(collector)) { - SET_MSG_RESULT(result, strdup("Collector is not started!")); + SET_MSG_RESULT(result, zbx_strdup(NULL, "Collector is not started.")); return SYSINFO_RET_FAIL; } @@ -47,27 +47,47 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) } if (0 == collector->vmstat.data_available) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "No data available in collector.")); return SYSINFO_RET_FAIL; + } } if (2 < request->nparam) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters.")); return SYSINFO_RET_FAIL; + } section = get_rparam(request, 0); type = get_rparam(request, 1); if (NULL == section) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter.")); return SYSINFO_RET_FAIL; + } if (0 == strcmp(section, "ent")) { - if (1 == request->nparam && collector->vmstat.shared_enabled) - SET_DBL_RESULT(result, collector->vmstat.ent); - else + if (1 != request->nparam && 0 != collector->vmstat.shared_enabled) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid number of parameters.")); + return SYSINFO_RET_FAIL; + } + else if (0 == collector->vmstat.shared_enabled) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "No data available in collector.")); return SYSINFO_RET_FAIL; + } + else + SET_DBL_RESULT(result, collector->vmstat.ent); } else if (NULL == type) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } if (0 == strcmp(section, "kthr")) { @@ -76,7 +96,10 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(type, "b")) SET_DBL_RESULT(result, collector->vmstat.kthr_b); else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } } else if (0 == strcmp(section, "page")) { @@ -93,7 +116,10 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(type, "sr")) SET_DBL_RESULT(result, collector->vmstat.sr); else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } } else if (0 == strcmp(section, "faults")) { @@ -104,7 +130,10 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(type, "cs")) SET_DBL_RESULT(result, collector->vmstat.cs); else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } } else if (0 == strcmp(section, "cpu")) { @@ -125,7 +154,10 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(type, "app") && collector->vmstat.shared_enabled && collector->vmstat.pool_util_authority) SET_DBL_RESULT(result, collector->vmstat.cpu_app); else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } } else if (0 == strcmp(section, "disk")) { @@ -134,7 +166,10 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(type, "tps")) SET_DBL_RESULT(result, collector->vmstat.disk_tps); else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } } else if (0 == strcmp(section, "memory")) { @@ -143,10 +178,16 @@ int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(type, "fre")) SET_UI64_RESULT(result, collector->vmstat.mem_fre); else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } } else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter.")); return SYSINFO_RET_FAIL; + } return SYSINFO_RET_OK; } |