summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-01 13:13:03 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-01 13:13:03 +0000
commitde267adc7399911d3d3339c8aa91bcab381ad50a (patch)
tree6afad4a690191af412cd044d4d7fc3a367cca5a2 /src
parent1bda58e4c0bdca8f16a5b055a9586cc04c63202b (diff)
downloadzabbix-de267adc7399911d3d3339c8aa91bcab381ad50a.tar.gz
zabbix-de267adc7399911d3d3339c8aa91bcab381ad50a.tar.xz
zabbix-de267adc7399911d3d3339c8aa91bcab381ad50a.zip
- optimized sysinfo functions for solaris system (Eugene)
- added support of new sysinfo function interface for solaris (Eugene) - fixed some errors in sysinfo functions for linux system (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2235 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxsysinfo/common/file.c1
-rw-r--r--src/libs/zbxsysinfo/linux/linux.c8
-rw-r--r--src/libs/zbxsysinfo/linux/memory.c63
-rw-r--r--src/libs/zbxsysinfo/solaris/cpu.c331
-rw-r--r--src/libs/zbxsysinfo/solaris/diskio.c463
-rw-r--r--src/libs/zbxsysinfo/solaris/diskspace.c356
-rw-r--r--src/libs/zbxsysinfo/solaris/inodes.c294
-rw-r--r--src/libs/zbxsysinfo/solaris/memory.c258
-rw-r--r--src/libs/zbxsysinfo/solaris/net.c439
-rw-r--r--src/libs/zbxsysinfo/solaris/proc.c203
-rw-r--r--src/libs/zbxsysinfo/solaris/sensors.c180
-rw-r--r--src/libs/zbxsysinfo/solaris/solaris.c548
-rw-r--r--src/libs/zbxsysinfo/solaris/swap.c522
-rw-r--r--src/libs/zbxsysinfo/solaris/uptime.c156
14 files changed, 1669 insertions, 2153 deletions
diff --git a/src/libs/zbxsysinfo/common/file.c b/src/libs/zbxsysinfo/common/file.c
index 0481894a..c7af8f72 100644
--- a/src/libs/zbxsysinfo/common/file.c
+++ b/src/libs/zbxsysinfo/common/file.c
@@ -183,6 +183,7 @@ int VFS_FILE_REGEXP(const char *cmd, const char *param, unsigned flags, AGENT_RE
assert(result);
clean_result(result);
+
memset(tmp,0,MAX_STRING_LEN);
if(get_param(param, 1, filename, MAX_STRING_LEN) != 0)
diff --git a/src/libs/zbxsysinfo/linux/linux.c b/src/libs/zbxsysinfo/linux/linux.c
index e7618d0e..df66bf38 100644
--- a/src/libs/zbxsysinfo/linux/linux.c
+++ b/src/libs/zbxsysinfo/linux/linux.c
@@ -237,17 +237,17 @@ ZBX_METRIC parameters_specific[]=
{"net.tcp.service", CF_USEUPARAM, CHECK_SERVICE, 0, "ssh,127.0.0.1,22"},
{"net.tcp.service.perf",CF_USEUPARAM, CHECK_SERVICE_PERF, 0, "ssh,127.0.0.1,22"},
- {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes,avg1"},
- {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes,avg1"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
-
{"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"},
{"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
+ {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+
{"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
{"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
diff --git a/src/libs/zbxsysinfo/linux/memory.c b/src/libs/zbxsysinfo/linux/memory.c
index 6bf06827..c92a434f 100644
--- a/src/libs/zbxsysinfo/linux/memory.c
+++ b/src/libs/zbxsysinfo/linux/memory.c
@@ -22,6 +22,12 @@
#include "common.h"
#include "sysinfo.h"
+static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+static int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+static int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+static int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+
int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#define MEM_FNCLIST struct mem_fnclist_s
@@ -33,12 +39,11 @@ MEM_FNCLIST
MEM_FNCLIST fl[] =
{
- {"free", DISKWRITEOPS1},
- {"shared", DISKWRITEOPS5},
- {"total", DISKWRITEOPS15},
- {"buffers", DISKWRITEBLKS1},
- {"cached", DISKWRITEBLKS5},
- {"free", DISKWRITEBLKS15},
+ {"free", VM_MEMORY_FREE},
+ {"shared", VM_MEMORY_SHARED},
+ {"total", VM_MEMORY_TOTAL},
+ {"buffers", VM_MEMORY_BUFFERS},
+ {"cached", VM_MEMORY_CACHED},
{0, 0}
};
char mode[MAX_STRING_LEN];
@@ -75,7 +80,7 @@ MEM_FNCLIST
return SYSINFO_RET_FAIL;
}
-int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_PROC
/* Get CACHED memory in bytes */
@@ -120,7 +125,7 @@ int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_R
#endif
}
-int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_SYSINFO_BUFFERRAM
struct sysinfo info;
@@ -152,7 +157,7 @@ int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_
#endif
}
-int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_SYSINFO_SHAREDRAM
struct sysinfo info;
@@ -175,8 +180,7 @@ int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_R
{
return SYSINFO_RET_FAIL;
}
-#else
-#ifdef HAVE_SYS_VMMETER_VMTOTAL
+#elif defined(HAVE_SYS_VMMETER_VMTOTAL)
int mib[2],len;
struct vmtotal v;
@@ -196,10 +200,9 @@ int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_R
#else
return SYSINFO_RET_FAIL;
#endif
-#endif
}
-int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
/* Solaris */
#ifdef HAVE_UNISTD_SYSCONF
@@ -210,8 +213,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
result->type |= AR_DOUBLE;
result->dbl=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_SYS_PSTAT_H
+#elif defined(HAVE_SYS_PSTAT_H)
struct pst_static pst;
long page;
@@ -232,8 +234,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
result->dbl=(double)page*pst.physical_memory;
return SYSINFO_RET_OK;
}
-#else
-#ifdef HAVE_SYSINFO_TOTALRAM
+#elif defined(HAVE_SYSINFO_TOTALRAM)
struct sysinfo info;
assert(result);
@@ -254,8 +255,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
{
return SYSINFO_RET_FAIL;
}
-#else
-#ifdef HAVE_SYS_VMMETER_VMTOTAL
+#elif defined(HAVE_SYS_VMMETER_VMTOTAL)
int mib[2],len;
struct vmtotal v;
@@ -272,8 +272,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
result->type |= AR_DOUBLE;
result->dbl=(double)(v.t_rm<<2);
return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_SYS_SYSCTL_H
+#elif defined(HAVE_SYS_SYSCTL_H)
static int mib[] = { CTL_HW, HW_PHYSMEM };
size_t len;
unsigned int memory;
@@ -303,13 +302,9 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
return SYSINFO_RET_FAIL;
#endif
-#endif
-#endif
-#endif
-#endif
}
-int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
/* Solaris */
#ifdef HAVE_UNISTD_SYSCONF
@@ -320,8 +315,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
result->type |= AR_DOUBLE;
result->dbl=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_SYS_PSTAT_H
+#elif defined(HAVE_SYS_PSTAT_H)
struct pst_static pst;
struct pst_dynamic dyn;
long page;
@@ -363,8 +357,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
return SYSINFO_RET_OK;
}
}
-#else
-#ifdef HAVE_SYSINFO_FREERAM
+#elif defined(HAVE_SYSINFO_FREERAM)
struct sysinfo info;
assert(result);
@@ -385,8 +378,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
{
return SYSINFO_RET_FAIL;
}
-#else
-#ifdef HAVE_SYS_VMMETER_VMTOTAL
+#elif defined(HAVE_SYS_VMMETER_VMTOTAL)
int mib[2],len;
struct vmtotal v;
@@ -403,9 +395,8 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
result->type |= AR_DOUBLE;
result->dbl=(double)(v.t_free<<2);
return SYSINFO_RET_OK;
-#else
/* OS/X */
-#ifdef HAVE_MACH_HOST_INFO_H
+#elif defined(HAVE_MACH_HOST_INFO_H)
vm_statistics_data_t page_info;
vm_size_t pagesize;
mach_msg_type_number_t count;
@@ -449,9 +440,5 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
return SYSINFO_RET_FAIL;
#endif
-#endif
-#endif
-#endif
-#endif
}
diff --git a/src/libs/zbxsysinfo/solaris/cpu.c b/src/libs/zbxsysinfo/solaris/cpu.c
index a54f279e..eca819d1 100644
--- a/src/libs/zbxsysinfo/solaris/cpu.c
+++ b/src/libs/zbxsysinfo/solaris/cpu.c
@@ -19,182 +19,71 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-/* HP-UX */
-#ifdef HAVE_SYS_PSTAT_H
- #include <sys/pstat.h>
-#endif
-
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_SYS_SYSCTL_H
- #include <sys/sysctl.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_VM_VM_PARAM_H
- #include <vm/vm_param.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_VMMETER_H
- #include <sys/vmmeter.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
-#endif
-
-#ifdef HAVE_MACH_HOST_INFO_H
- #include <mach/host_info.h>
-#endif
-#ifdef HAVE_MACH_MACH_HOST_H
- #include <mach/mach_host.h>
-#endif
-
-/* AIX CPU */
-#ifdef HAVE_KNLIST_H
- #include <knlist.h>
-#endif
-
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
-
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
-
#include "common.h"
#include "sysinfo.h"
-int SYSTEM_CPU_IDLE1(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[idle1]",value,msg,mlen_max);
+ return get_stat(cmd, flags, result);
}
-int SYSTEM_CPU_IDLE5(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_IDLE1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[idle5]",value,msg,mlen_max);
+ return get_stat("cpu[idle1]",flags, result);
}
-int SYSTEM_CPU_IDLE15(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_IDLE5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[idle15]",value,msg,mlen_max);
+ return get_stat("cpu[idle5]",flags, result);
}
-int SYSTEM_CPU_NICE1(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_IDLE15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[nice1]",value,msg,mlen_max);
+ return get_stat("cpu[idle15]",flags, result);
}
-int SYSTEM_CPU_NICE5(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_NICE1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[nice5]",value,msg,mlen_max);
+ return get_stat("cpu[nice1]",flags, result);
}
-int SYSTEM_CPU_NICE15(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+
+int SYSTEM_CPU_NICE5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[nice15]",value,msg,mlen_max);
+ return get_stat("cpu[nice5]",flags, result);
+}
+int SYSTEM_CPU_NICE15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ return get_stat("cpu[nice15]",flags, result);
}
-int SYSTEM_CPU_USER1(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[user1]",value,msg,mlen_max);
+ return get_stat("cpu[user1]",flags, result);
}
-int SYSTEM_CPU_USER5(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[user5]",value,msg,mlen_max);
+ return get_stat("cpu[user5]",flags, result);
}
-int SYSTEM_CPU_USER15(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_USER15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[user15]",value,msg,mlen_max);
+ return get_stat("cpu[user15]",flags, result);
}
-int SYSTEM_CPU_SYS1(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_SYS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[system1]",value,msg,mlen_max);
+ return get_stat("cpu[system1]",flags, result);
}
-int SYSTEM_CPU_SYS5(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[system5]",value,msg,mlen_max);
+ return get_stat("cpu[system5]",flags, result);
}
-int SYSTEM_CPU_SYS15(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[system15]",value,msg,mlen_max);
+ return get_stat("cpu[system15]",flags, result);
}
static int get_cpu_data(unsigned long long *idle,
@@ -244,44 +133,61 @@ static int get_cpu_data(unsigned long long *idle,
#define CPU_K 2
#define CPU_W 3
-int SYSTEM_CPU_UTILIZATION(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
unsigned long long cpu_val[4];
unsigned long long interval_size;
- char cpu_info[MAX_STRING_LEN];
+ char cpuname[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
int info_id = 0;
- int result = SYSINFO_RET_FAIL;
+ int ret = SYSINFO_RET_FAIL;
- if(num_param(param) > 1)
+ if(num_param(param) > 2)
{
- return SYSINFO_RET_FAIL;
+ return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, cpu_info, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, cpuname, MAX_STRING_LEN) != 0)
+ {
+ cpuname[0] = '\0';
+ }
+ if(cpuname[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(cpuname, "all");
+ }
+ if(strncmp(cpuname, "all", MAX_STRING_LEN))
{
return SYSINFO_RET_FAIL;
}
- else
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+
+ if(mode[0] == '\0')
{
- strscpy(cpu_info, "idle");
+ /* default parameter */
+ strscpy(mode, "idle");
}
- if(strcmp(cpu_info,"idle") == 0)
+ if(strcmp(mode,"idle") == 0)
{
info_id = CPU_I;
}
- else if(strcmp(cpu_info,"user") == 0)
+ else if(strcmp(mode,"user") == 0)
{
info_id = CPU_U;
}
- else if(strcmp(cpu_info,"kernel") == 0)
+ else if(strcmp(mode,"kernel") == 0)
{
info_id = CPU_K;
}
- else if(strcmp(cpu_info,"wait") == 0)
+ else if(strcmp(mode,"wait") == 0)
{
info_id = CPU_W;
}
@@ -296,22 +202,93 @@ int SYSTEM_CPU_UTILIZATION(const char *cmd, const char *param,double *value, co
if (interval_size > 0)
{
- *value = (cpu_val[info_id] * 100.0)/interval_size;
+ result->type |= AR_DOUBLE;
+ result->dbl = (cpu_val[info_id] * 100.0)/interval_size;
- result = SYSINFO_RET_OK;
+ ret = SYSINFO_RET_OK;
}
}
- return result;
+ return ret;
}
-int SYSTEM_CPU_LOAD1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_LOAD(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+
+#define CPU_FNCLIST struct cpu_fnclist_s
+CPU_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
+
+ CPU_FNCLIST fl[] =
+ {
+ {"avg1" , SYSTEM_CPU_LOAD1},
+ {"avg5" , SYSTEM_CPU_LOAD5},
+ {"avg15", SYSTEM_CPU_LOAD15},
+ {0, 0}
+ };
+
+ char cpuname[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, cpuname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+ if(cpuname[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(cpuname, "all");
+ }
+ if(strncmp(cpuname, "all", MAX_STRING_LEN))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "avg1");
+ }
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, param, flags, result);
+ }
+ }
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_GETLOADAVG
double load[3];
+ assert(result);
+
+ clean_result(result);
+
if(getloadavg(load, 3))
{
- *value=load[0];
+ result->type |= AR_DOUBLE;
+ result->dbl = load[0];
return SYSINFO_RET_OK;
}
else
@@ -323,14 +300,19 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *parameter,double *value, cons
#endif
}
-int SYSTEM_CPU_LOAD5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_GETLOADAVG
double load[3];
+ assert(result);
+
+ clean_result(result);
+
if(getloadavg(load, 3))
{
- *value=load[1];
+ result->type = AR_DOUBLE;
+ result->dbl = load[1];
return SYSINFO_RET_OK;
}
else
@@ -342,14 +324,19 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *parameter,double *value, cons
#endif
}
-int SYSTEM_CPU_LOAD15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_GETLOADAVG
double load[3];
+ assert(result);
+
+ clean_result(result);
+
if(getloadavg(load, 3))
{
- *value=load[2];
+ result->type = AR_DOUBLE;
+ result->dbl =load[2];
return SYSINFO_RET_OK;
}
else
@@ -361,7 +348,7 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *parameter,double *value, con
#endif
}
-int SYSTEM_CPU_SWITCHES(const char *cmd, const char *parameter, double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_ctl_t *kc;
kstat_t *k;
@@ -370,6 +357,10 @@ int SYSTEM_CPU_SWITCHES(const char *cmd, const char *parameter, double *value, c
int cpu_count = 0;
double swt_count = 0.0;
+ assert(result);
+
+ clean_result(result);
+
kc = kstat_open();
if(kc != NULL)
@@ -389,17 +380,18 @@ int SYSTEM_CPU_SWITCHES(const char *cmd, const char *parameter, double *value, c
kstat_close(kc);
}
- *value = swt_count;
-
if(cpu_count == 0)
{
return SYSINFO_RET_FAIL;
}
+ result->type = AR_DOUBLE;
+ result->dbl = swt_count;
+
return SYSINFO_RET_OK;
}
-int SYSTEM_CPU_INTR(const char *cmd, const char *parameter, double *value, const char *msg, int mlen_max)
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_ctl_t *kc;
kstat_t *k;
@@ -408,6 +400,10 @@ int SYSTEM_CPU_INTR(const char *cmd, const char *parameter, double *value, const
int cpu_count = 0;
double intr_count = 0.0;
+ assert(result);
+
+ clean_result(result);
+
kc = kstat_open();
if(kc != NULL)
@@ -427,13 +423,14 @@ int SYSTEM_CPU_INTR(const char *cmd, const char *parameter, double *value, const
kstat_close(kc);
}
- *value = intr_count;
-
if(cpu_count == 0)
{
return SYSINFO_RET_FAIL;
}
+ result->type = AR_DOUBLE;
+ result->dbl = intr_count;
+
return SYSINFO_RET_OK;
}
diff --git a/src/libs/zbxsysinfo/solaris/diskio.c b/src/libs/zbxsysinfo/solaris/diskio.c
index 95a8538a..dd25a8a2 100644
--- a/src/libs/zbxsysinfo/solaris/diskio.c
+++ b/src/libs/zbxsysinfo/solaris/diskio.c
@@ -19,119 +19,6 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-
-/* HP-UX */
-#ifdef HAVE_SYS_PSTAT_H
- #include <sys/pstat.h>
-#endif
-
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_SYS_SYSCTL_H
- #include <sys/sysctl.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_VM_VM_PARAM_H
- #include <vm/vm_param.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_VMMETER_H
- #include <sys/vmmeter.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
-#endif
-
-#ifdef HAVE_MACH_HOST_INFO_H
- #include <mach/host_info.h>
-#endif
-#ifdef HAVE_MACH_MACH_HOST_H
- #include <mach/mach_host.h>
-#endif
-
-
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
-
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
-
#include "common.h"
#include "sysinfo.h"
@@ -277,7 +164,7 @@ static int get_disk_kstat_record(const char *name,
/*
* hidden
*/
-int DISKSVC(const char *cmd, const char *device, double *value, const char *msg, int mlen_max)
+int DISKSVC(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
int result = SYSINFO_RET_FAIL;
DISK_DATA *p;
@@ -317,7 +204,7 @@ int DISKSVC(const char *cmd, const char *device, double *value, const char *msg
/*
* hidden
*/
-int DISKBUSY(const char *cmd, const char *device, double *value, const char *msg, int mlen_max)
+int DISKBUSY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
int result = SYSINFO_RET_FAIL;
DISK_DATA *p;
@@ -377,247 +264,273 @@ static int get_kstat_io(
return result;
}
-int VFS_DEV_READ_BYTES(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+static int VFS_DEV_READ_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_io_t kio;
- char device[MAX_STRING_LEN];
- int result;
+ int ret;
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
+ ret = get_kstat_io(param, &kio);
- if(get_param(param, 1, device, MAX_STRING_LEN) != 0)
+ if(ret == SYSINFO_RET_OK)
{
- return SYSINFO_RET_FAIL;
+ result->type |= AR_DOUBLE;
+ /* uint_t reads; number of read operations */
+ result->dbl = kio.reads;
}
-
- result = get_kstat_io(device, &kio);
-
- *value = kio.reads;
- return result;
+ return ret;
}
-int VFS_DEV_READ_OPERATIONS(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+static int VFS_DEV_READ_OPERATIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_io_t kio;
- char device[MAX_STRING_LEN];
- int result;
+ int ret;
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
+ ret = get_kstat_io(param, &kio);
- if(get_param(param, 1, device, MAX_STRING_LEN) != 0)
+ if(ret == SYSINFO_RET_OK)
{
- return SYSINFO_RET_FAIL;
+ result->type |= AR_DOUBLE;
+ /* u_longlong_t nread; number of bytes read */
+ result->dbl = kio.nread;
}
-
- result = get_kstat_io(device, &kio);
- *value = kio.nread;
-
- return result;
+ return ret;
}
-int VFS_DEV_WRITE_BYTES(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+static int VFS_DEV_WRITE_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_io_t kio;
- char device[MAX_STRING_LEN];
- int result;
+ int ret;
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
+ ret = get_kstat_io(param, &kio);
- if(get_param(param, 1, device, MAX_STRING_LEN) != 0)
+ if(ret == SYSINFO_RET_OK)
{
- return SYSINFO_RET_FAIL;
+ result->type |= AR_DOUBLE;
+ /* uint_t writes; number of write operations */
+ result->dbl = kio.writes;
}
-
- result = get_kstat_io(device, &kio);
-
- *value = kio.writes;
- return result;
+ return ret;
}
-int VFS_DEV_WRITE_OPERATIONS(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+static int VFS_DEV_WRITE_OPERATIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_io_t kio;
- char device[MAX_STRING_LEN];
- int result;
+ int ret;
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
+ ret = get_kstat_io(param, &kio);
- if(get_param(param, 1, device, MAX_STRING_LEN) != 0)
+ if(ret == SYSINFO_RET_OK)
{
- return SYSINFO_RET_FAIL;
+ result->type |= AR_DOUBLE;
+ /* u_longlong_t nwritten; number of bytes written */
+ result->dbl = kio.nwritten;
}
-
- result = get_kstat_io(device, &kio);
-
- *value = kio.nwritten;
-
- return result;
-}
-
-int DISKREADOPS1(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_ops1[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-
-int DISKREADOPS5(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_ops5[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-
-int DISKREADOPS15(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_ops15[%s]",device);
- return get_stat(key,value,msg,mlen_max);
+ return ret;
}
-int DISKREADBLKS1(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
+int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_blks1[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-int DISKREADBLKS5(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
+#define DEV_FNCLIST struct dev_fnclist_s
+DEV_FNCLIST
{
- char key[MAX_STRING_LEN];
+ char *mode;
+ int (*function)();
+};
- snprintf(key,sizeof(key)-1,"disk_read_blks5[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-
-int DISKREADBLKS15(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_blks15[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-
-int DISKWRITEOPS1(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_write_ops1[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-
-int DISKWRITEOPS5(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_write_ops5[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-
-int DISKWRITEOPS15(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_write_ops15[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-
-int DISKWRITEBLKS1(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_write_blks1[%s]",device);
+ DEV_FNCLIST fl[] =
+ {
+ {"bytes", VFS_DEV_WRITE_BYTES},
+ {"operations", VFS_DEV_WRITE_OPERATIONS},
+ {0, 0}
+ };
+
+ char devname[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
- return get_stat(key,value,msg,mlen_max);
+ if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "bytes");
+ }
+
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, devname, flags, result);
+ }
+ }
+
+ return SYSINFO_RET_FAIL;
}
-int DISKWRITEBLKS5(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_write_blks5[%s]",device);
-
- return get_stat(key,value,msg,mlen_max);
-}
-int DISKWRITEBLKS15(const char *cmd, const char *device,double *value, const char *msg, int mlen_max)
+#define DEV_FNCLIST struct dev_fnclist_s
+DEV_FNCLIST
{
- char key[MAX_STRING_LEN];
+ char *mode;
+ int (*function)();
+};
- snprintf(key,sizeof(key)-1,"disk_write_blks15[%s]",device);
+ DEV_FNCLIST fl[] =
+ {
+ {"bytes", VFS_DEV_READ_BYTES},
+ {"operations", VFS_DEV_READ_OPERATIONS},
+ {0, 0}
+ };
+
+ char devname[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
- return get_stat(key,value,msg,mlen_max);
+ if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "bytes");
+ }
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, devname, flags, result);
+ }
+ }
+ return SYSINFO_RET_FAIL;
}
-int DISK_IO(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_PROC
- return getPROC("/proc/stat",2,2,value,msg,mlen_max);
+ return getPROC("/proc/stat",2,2, flags, result);
#else
return SYSINFO_RET_FAIL;
#endif
}
-int DISK_RIO(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+static int DISK_RIO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_PROC
- return getPROC("/proc/stat",3,2,value,msg,mlen_max);
+ return getPROC("/proc/stat",3,2, flags, result);
#else
return SYSINFO_RET_FAIL;
#endif
}
-int DISK_WIO(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+static int DISK_WIO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_PROC
- return getPROC("/proc/stat",4,2,value,msg,mlen_max);
+ return getPROC("/proc/stat",4,2, flags, result);
#else
return SYSINFO_RET_FAIL;
#endif
}
-int DISK_RBLK(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+static int DISK_RBLK(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_PROC
- return getPROC("/proc/stat",5,2,value,msg,mlen_max);
+ return getPROC("/proc/stat",5,2, flags, result);
#else
return SYSINFO_RET_FAIL;
#endif
}
-int DISK_WBLK(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+static int DISK_WBLK(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_PROC
- return getPROC("/proc/stat",6,2,value,msg,mlen_max);
+ return getPROC("/proc/stat",6,2, flags, result);
#else
return SYSINFO_RET_FAIL;
#endif
}
+
+int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char key[MAX_STRING_LEN];
+ int ret;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(strcmp(key,"disk_io") == 0)
+ {
+ ret = DISK_IO(cmd, param, flags, result);
+ }
+ else if(strcmp(key,"disk_rio") == 0)
+ {
+ ret = DISK_RIO(cmd, param, flags, result);
+ }
+ else if(strcmp(key,"disk_wio") == 0)
+ {
+ ret = DISK_WIO(cmd, param, flags, result);
+ }
+ else if(strcmp(key,"disk_rblk") == 0)
+ {
+ ret = DISK_RBLK(cmd, param, flags, result);
+ }
+ else if(strcmp(key,"disk_wblk") == 0)
+ {
+ ret = DISK_WBLK(cmd, param, flags, result);
+ }
+ else
+ {
+ ret = SYSINFO_RET_FAIL;
+ }
+
+ return ret;
+}
+
diff --git a/src/libs/zbxsysinfo/solaris/diskspace.c b/src/libs/zbxsysinfo/solaris/diskspace.c
index 91b593b3..3fde0069 100644
--- a/src/libs/zbxsysinfo/solaris/diskspace.c
+++ b/src/libs/zbxsysinfo/solaris/diskspace.c
@@ -19,221 +19,227 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
+#include "common.h"
+#include "sysinfo.h"
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
+int VFS_FS_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
-/* HP-UX */
-#ifdef HAVE_SYS_PSTAT_H
- #include <sys/pstat.h>
-#endif
+#define FS_FNCLIST struct fs_fnclist_s
+FS_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
+ FS_FNCLIST fl[] =
+ {
+ {"free" , VFS_FS_FREE},
+ {"total" , VFS_FS_TOTAL},
+ {"used", VFS_FS_USED},
+ {"pfree" , VFS_FS_PFREE},
+ {"pused" , VFS_FS_PUSED},
+ {0, 0}
+ };
+
+ char fsname[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, fsname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "total");
+ }
+
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, fsname, flags, result);
+ }
+ }
+
+ return SYSINFO_RET_FAIL;
+}
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
+int get_fs_size_stat(char *fs, double *total, double *free, double *usage)
+{
+#ifdef HAVE_SYS_STATVFS_H
+ struct statvfs s;
+#else
+ struct statfs s;
#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_SYSCTL_H
- #include <sys/sysctl.h>
-#endif
+ assert(fs);
-/* Solaris */
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
+#ifdef HAVE_SYS_STATVFS_H
+ if ( statvfs( fs, &s) != 0 )
+#else
+ if ( statfs( fs, &s) != 0 )
#endif
+ {
+ return SYSINFO_RET_FAIL;
+ }
-/* FreeBSD */
-#ifdef HAVE_VM_VM_PARAM_H
- #include <vm/vm_param.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_VMMETER_H
- #include <sys/vmmeter.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
-#endif
+#ifdef HAVE_SYS_STATVFS_H
+ if(total)
+ (*total) = (double)(s.f_blocks * (s.f_frsize / 1024.0));
+ if(free)
+ (*free) = (double)(s.f_bavail * (s.f_frsize / 1024.0));
+ if(usage)
+ (*usage) = (double)((s.f_blocks - s.f_bavail) * (s.f_frsize / 1024.0));
+#else
+ if(total)
+ (*total) = (double)(s.f_blocks * (s.f_bsize / 1024.0));
+ if(free)
+ (*free) = (double)(s.f_bfree * (s.f_bsize / 1024.0));
+ if(usage)
+ (*usage) = (double)((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0));
+#endif
+ return SYSINFO_RET_OK;
+}
-#ifdef HAVE_MACH_HOST_INFO_H
- #include <mach/host_info.h>
-#endif
-#ifdef HAVE_MACH_MACH_HOST_H
- #include <mach/mach_host.h>
-#endif
+int VFS_FS_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
+ assert(result);
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
+ clean_result(result);
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
-#include "common.h"
-#include "sysinfo.h"
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
-int VFS_FS_FREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
-{
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
+ if(get_fs_size_stat(mountPoint, NULL, NULL, &value) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
- if ( statvfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
-/* return s.f_bavail * (s.f_bsize / 1024.0);*/
- *value=s.f_bavail * (s.f_frsize / 1024.0);
- return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
+ return SYSINFO_RET_OK;
}
-int VFS_FS_USED(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
+int VFS_FS_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
- if ( statvfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
+ assert(result);
-/* return (s.f_blocks-s.f_bavail) * (s.f_bsize / 1024.0);*/
- *value=(s.f_blocks-s.f_bavail) * (s.f_frsize / 1024.0);
- return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
+
+ if(get_fs_size_stat(mountPoint, NULL, &value, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
}
-int VFS_FS_TOTAL(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
+int VFS_FS_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
- if ( statvfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_fs_size_stat(mountPoint, &value, NULL, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
-/* return s.f_blocks * (s.f_bsize / 1024.0);*/
- *value= s.f_blocks * (s.f_frsize / 1024.0);
- return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
}
-int VFS_FS_PUSED(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
+int VFS_FS_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- double total;
- double used;
+ char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double free_val = 0;
- if(SYSINFO_RET_OK != VFS_FS_TOTAL(cmd, mountPoint, &total, msg, mlen_max))
- {
- return SYSINFO_RET_FAIL;
- }
+ assert(result);
- if(SYSINFO_RET_OK != VFS_FS_USED(cmd, mountPoint, &used, msg, mlen_max))
- {
- return SYSINFO_RET_FAIL;
- }
+ clean_result(result);
- if(total == 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
- *value = 100*used/total;
- return SYSINFO_RET_OK;
+ if(get_fs_size_stat(mountPoint, &tot_val, &free_val, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = (100.0 * free_val) / tot_val;
+
+ return SYSINFO_RET_OK;
}
-int VFS_FS_PFREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
+int VFS_FS_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- double total;
- double free;
+ char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double usg_val = 0;
- if(SYSINFO_RET_OK != VFS_FS_TOTAL(cmd, mountPoint, &total, msg, mlen_max))
- {
- return SYSINFO_RET_FAIL;
- }
+ assert(result);
- if(SYSINFO_RET_OK != VFS_FS_FREE(cmd, mountPoint, &free, msg, mlen_max))
- {
- return SYSINFO_RET_FAIL;
- }
+ clean_result(result);
- if(total == 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
+
+ if(get_fs_size_stat(mountPoint, &tot_val, NULL, &usg_val) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = (100.0 * usg_val) / tot_val;
- *value = 100*free/total;
- return SYSINFO_RET_OK;
+ return SYSINFO_RET_OK;
}
diff --git a/src/libs/zbxsysinfo/solaris/inodes.c b/src/libs/zbxsysinfo/solaris/inodes.c
index da92ca93..d6b124eb 100644
--- a/src/libs/zbxsysinfo/solaris/inodes.c
+++ b/src/libs/zbxsysinfo/solaris/inodes.c
@@ -19,144 +19,226 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-
-/* FreeBSD/MacOS/OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-
#include "common.h"
#include "sysinfo.h"
#include "md5.h"
-int VFS_FS_INODE_FREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
+int VFS_FS_INODE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
- if ( statvfs( (char *)mountPoint, &s) != 0 )
+#define FS_FNCLIST struct fs_fnclist_s
+FS_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
+
+ FS_FNCLIST fl[] =
{
- return SYSINFO_RET_FAIL;
+ {"free" , VFS_FS_INODE_FREE},
+ {"total" , VFS_FS_INODE_TOTAL},
+ {"used", VFS_FS_INODE_USED},
+ {"pfree" , VFS_FS_INODE_PFREE},
+ {"pused" , VFS_FS_INODE_PUSED},
+ {0, 0}
+ };
+
+ char fsname[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, fsname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "total");
+ }
+
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, fsname, flags, result);
+ }
}
+
+ return SYSINFO_RET_FAIL;
+}
- *value=s.f_favail;
- return SYSINFO_RET_OK;
+int get_fs_inodes_stat(char *fs, double *total, double *free, double *usage)
+{
+#ifdef HAVE_SYS_STATVFS_H
+ struct statvfs s;
#else
struct statfs s;
- long blocks_used;
- long blocks_percent_used;
-
- if ( statfs( (char *)mountPoint, &s) != 0 )
+#endif
+
+ assert(fs);
+
+#ifdef HAVE_SYS_STATVFS_H
+ if ( statvfs( fs, &s) != 0 )
+#else
+ if ( statfs( fs, &s) != 0 )
+#endif
{
return SYSINFO_RET_FAIL;
}
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- *value=s.f_ffree;
- return SYSINFO_RET_OK;
-
- }
- return SYSINFO_RET_FAIL;
+ if(total)
+ (*total) = (double)(s.f_files);
+#ifdef HAVE_SYS_STATVFS_H
+ if(free)
+ (*free) = (double)(s.f_favail);
+ if(usage)
+ (*usage) = (double)(s.f_files - s.f_favail);
+#else
+ if(free)
+ (*free) = (double)(s.ffree);
+ if(usage)
+ (*usage) = (double)(s.f_files - s.f_ffree);
#endif
+ return SYSINFO_RET_OK;
}
-int VFS_FS_INODE_TOTAL(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
+int VFS_FS_INODE_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
+
+ assert(result);
- if ( statvfs( (char *)mountPoint, &s) != 0 )
- {
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
+
+ if(get_fs_inodes_stat(mountPoint, NULL, NULL, &value) != SYSINFO_RET_OK)
return SYSINFO_RET_FAIL;
- }
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
+}
+
+int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
- *value=s.f_files;
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
+
+ if(get_fs_inodes_stat(mountPoint, NULL, &value, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
return SYSINFO_RET_OK;
-#else
- struct statfs s;
- long blocks_used;
- long blocks_percent_used;
+}
- if ( statfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- *value=s.f_files;
- return SYSINFO_RET_OK;
+int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
+
+ assert(result);
- }
- return SYSINFO_RET_FAIL;
-#endif
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_fs_inodes_stat(mountPoint, &value, NULL, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
}
-int VFS_FS_INODE_PFREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
+int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- double total;
- double free;
+ char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double free_val = 0;
+
+ assert(result);
- if(SYSINFO_RET_OK != VFS_FS_INODE_TOTAL(cmd, mountPoint, &total, msg, mlen_max))
- {
- return SYSINFO_RET_FAIL;
- }
+ clean_result(result);
- if(SYSINFO_RET_OK != VFS_FS_INODE_FREE(cmd, mountPoint, &free, msg, mlen_max))
- {
- return SYSINFO_RET_FAIL;
- }
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
- if(total == 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
- *value = 100*free/total;
+ if(get_fs_inodes_stat(mountPoint, &tot_val, &free_val, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = (100.0 * free_val) / tot_val;
+
return SYSINFO_RET_OK;
}
+
+int VFS_FS_INODE_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double usg_val = 0;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
+
+ if(get_fs_inodes_stat(mountPoint, &tot_val, NULL, &usg_val) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = (100.0 * usg_val) / tot_val;
+
+ return SYSINFO_RET_OK;
+}
+
diff --git a/src/libs/zbxsysinfo/solaris/memory.c b/src/libs/zbxsysinfo/solaris/memory.c
index 9fe64906..385ece4a 100644
--- a/src/libs/zbxsysinfo/solaris/memory.c
+++ b/src/libs/zbxsysinfo/solaris/memory.c
@@ -19,234 +19,96 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-
-/* HP-UX */
-#ifdef HAVE_SYS_PSTAT_H
- #include <sys/pstat.h>
-#endif
-
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_SYS_SYSCTL_H
- #include <sys/sysctl.h>
-#endif
+#include "common.h"
+#include "sysinfo.h"
-/* Solaris */
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
+static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-/* FreeBSD */
-#ifdef HAVE_VM_VM_PARAM_H
- #include <vm/vm_param.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_VMMETER_H
- #include <sys/vmmeter.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
-#endif
+int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#define MEM_FNCLIST struct mem_fnclist_s
+MEM_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
-#ifdef HAVE_MACH_HOST_INFO_H
- #include <mach/host_info.h>
-#endif
-#ifdef HAVE_MACH_MACH_HOST_H
- #include <mach/mach_host.h>
-#endif
+ MEM_FNCLIST fl[] =
+ {
+ {"total", VM_MEMORY_TOTAL},
+ {"free", VM_MEMORY_FREE},
+ {0, 0}
+ };
+ char mode[MAX_STRING_LEN];
+ int i;
+ assert(result);
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
+ clean_result(result);
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
-#include "common.h"
-#include "sysinfo.h"
+ if(get_param(param, 1, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
-int VM_MEMORY_CACHED(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
-{
-#ifdef HAVE_PROC
-/* Get CACHED memory in bytes */
-/* return getPROC("/proc/meminfo",8,2,msg,mlen_max);*/
-/* It does not work for both 2.4 and 2.6 */
-/* return getPROC("/proc/meminfo",2,7,msg,mlen_max);*/
- FILE *f;
- char *t;
- char c[MAX_STRING_LEN];
- double result = SYSINFO_RET_FAIL;
-
- f=fopen("/proc/meminfo","r");
- if(NULL == f)
+ if(mode[0] == '\0')
{
- return SYSINFO_RET_FAIL;
+ /* default parameter */
+ sprintf(mode, "total");
}
- while(NULL!=fgets(c,MAX_STRING_LEN,f))
+
+ for(i=0; fl[i].mode!=0; i++)
{
- if(strncmp(c,"Cached:",7) == 0)
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
{
- t=(char *)strtok(c," ");
- t=(char *)strtok(NULL," ");
- sscanf(t, "%lf", &result );
- break;
+ return (fl[i].function)(cmd, param, flags, result);
}
}
- fclose(f);
-
- *value=result;
- return SYSINFO_RET_OK;
-#else
+
return SYSINFO_RET_FAIL;
-#endif
-}
-
-int VM_MEMORY_BUFFERS(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
-{
-#ifdef HAVE_SYSINFO_BUFFERRAM
- struct sysinfo info;
-
- if( 0 == sysinfo(&info))
- {
-#ifdef HAVE_SYSINFO_MEM_UNIT
- *value=(double)info.bufferram * (double)info.mem_unit;
-#else
- *value=(double)info.bufferram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
- return SYSINFO_RET_FAIL;
-#endif
}
-int VM_MEMORY_SHARED(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYSINFO_SHAREDRAM
- struct sysinfo info;
-
- if( 0 == sysinfo(&info))
- {
-#ifdef HAVE_SYSINFO_MEM_UNIT
- *value=(double)info.sharedram * (double)info.mem_unit;
-#else
- *value=(double)info.sharedram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
-#ifdef HAVE_SYS_VMMETER_VMTOTAL
- int mib[2],len;
- struct vmtotal v;
-
- len=sizeof(struct vmtotal);
- mib[0]=CTL_VM;
- mib[1]=VM_METER;
-
- sysctl(mib,2,&v,&len,NULL,0);
+#ifdef HAVE_UNISTD_SYSCONF
+ assert(result);
- *value=(double)(v.t_armshr<<2);
+ clean_result(result);
+
+ result->type |= AR_DOUBLE;
+ result->dbl=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
#else
- return SYSINFO_RET_FAIL;
-#endif
-#endif
-}
+ assert(result);
-int VM_MEMORY_TOTAL(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
-{
-#ifdef HAVE_UNISTD_SYSCONF
- *value=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
- return SYSINFO_RET_OK;
-#else
+ clean_result(result);
+
return SYSINFO_RET_FAIL;
#endif
}
-int VM_MEMORY_FREE(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_UNISTD_SYSCONF
- *value=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
+ assert(result);
+
+ clean_result(result);
+
+ result->type |= AR_DOUBLE;
+ result->dbl=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
#else
+ assert(result);
+
+ clean_result(result);
+
return SYSINFO_RET_FAIL;
#endif
}
+
diff --git a/src/libs/zbxsysinfo/solaris/net.c b/src/libs/zbxsysinfo/solaris/net.c
index 2657fce4..17286960 100644
--- a/src/libs/zbxsysinfo/solaris/net.c
+++ b/src/libs/zbxsysinfo/solaris/net.c
@@ -19,184 +19,16 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#ifdef HAVE_PWD_H
-# include <pwd.h>
-#endif
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-
-#ifdef HAVE_SYS_PROC_H
-# include <sys/proc.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
-
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
-
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
-
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
-
#include "common.h"
#include "sysinfo.h"
-/*
-#define FDI(f, m) fprintf(stderr, "DEBUG INFO: " f "\n" , m) // show debug info to stderr
-#define SDI(m) FDI("%s", m) // string info
-#define IDI(i) FDI("%i", i) // integer info
-*/
-
-#if 0
-typedef union value_overlay
-{
- union
- {
- uint64_t ui64;
- uint32_t ui32;
- } u;
-} VALUE_OVERLAY;
-
-typedef struct rbytes_data
-{
- hrtime_t clock;
- VALUE_OVERLAY rbytes;
-} RBYTES_DATA;
-
-typedef struct obytes_data
-{
- hrtime_t clock;
- VALUE_OVERLAY obytes;
-} OBYTES_DATA;
-
-typedef struct rpackets_data
-{
- hrtime_t clock;
- VALUE_OVERLAY rpackets;
-} RPACKETS_DATA;
-
-typedef struct opackets_data
-{
- hrtime_t clock;
- VALUE_OVERLAY opackets;
-} OPACKETS_DATA;
-
-typedef struct network_data
-{
- struct network_data *next;
- char *name;
- RBYTES_DATA rb;
- OBYTES_DATA ob;
- RPACKETS_DATA rp;
- OPACKETS_DATA op;
-} NETWORK_DATA;
-
-static NETWORK_DATA *interfaces;
-
-static NETWORK_DATA *get_net_data_record(const char *device)
-{
- NETWORK_DATA *p;
-
- p = interfaces;
-
- while ((p) && (strcmp(p->name, device) != 0))
- p = p->next;
-
- if (p == (NETWORK_DATA *) NULL)
- {
- p = (NETWORK_DATA *) calloc(1, sizeof(NETWORK_DATA));
- if (p)
- {
- p->name = strdup(device);
- if (p->name)
- {
- p->next = interfaces;
- interfaces = p;
- }
- else
- {
- free(p);
- p = NULL;
- }
- }
- }
- return p;
-}
-#endif
-
static int get_kstat_named_field(
const char *name,
const char *field,
kstat_named_t *returned_data
)
{
- int result = SYSINFO_RET_FAIL;
+ int ret = SYSINFO_RET_FAIL;
kstat_ctl_t *kc;
kstat_t *kp;
@@ -212,20 +44,137 @@ static int get_kstat_named_field(
if(kn)
{
*returned_data = *kn;
- result = SYSINFO_RET_OK;
+ ret = SYSINFO_RET_OK;
}
}
kstat_close(kc);
}
- return result;
+ return ret;
+}
+
+int NET_IF_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+
+#define NET_FNCLIST struct net_fnclist_s
+NET_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
+
+ NET_FNCLIST fl[] =
+ {
+ {"bytes", NET_IF_IN_BYTES},
+ {"packets", NET_IF_IN_PACKETS},
+ {"errors", NET_IF_IN_ERRORS},
+ {0, 0}
+ };
+
+ char interface[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "bytes");
+ }
+
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, interface, flags, result);
+ }
+ }
+
+ return SYSINFO_RET_FAIL;
}
+int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
-int NET_IF_IN_BYTES(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+#define NET_FNCLIST struct net_fnclist_s
+NET_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
+
+ NET_FNCLIST fl[] =
+ {
+ {"bytes", NET_IF_OUT_BYTES},
+ {"packets", NET_IF_OUT_PACKETS},
+ {"errors", NET_IF_OUT_ERRORS},
+ {0, 0}
+ };
+
+ char interface[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "bytes");
+ }
+
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, interface, flags, result);
+ }
+ }
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_IN_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_named_t kn;
char interface[MAX_STRING_LEN];
- int result;
+ int ret;
+
+ assert(result);
+ clean_result(result);
+
if(num_param(param) > 1)
{
return SYSINFO_RET_FAIL;
@@ -236,26 +185,32 @@ int NET_IF_IN_BYTES(const char *cmd, const char *param,double *value, const cha
return SYSINFO_RET_FAIL;
}
- result = get_kstat_named_field(interface, "rbytes64", &kn);
- if (result == SYSINFO_RET_OK)
+ ret = get_kstat_named_field(interface, "rbytes64", &kn);
+ if (ret == SYSINFO_RET_OK)
{
- *value = (double)kn.value.ui64;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui64;
}
else
{
- result = get_kstat_named_field(interface, "rbytes", &kn);
- *value = (double)kn.value.ui32;
+ ret = get_kstat_named_field(interface, "rbytes", &kn);
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui32;
}
- return result;
+ return ret;
}
-int NET_IF_IN_PACKETS(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+int NET_IF_IN_PACKETS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_named_t kn;
char interface[MAX_STRING_LEN];
- int result;
+ int ret;
+ assert(result);
+
+ clean_result(result);
+
if(num_param(param) > 1)
{
return SYSINFO_RET_FAIL;
@@ -266,26 +221,32 @@ int NET_IF_IN_PACKETS(const char *cmd, const char *param, double *value, const
return SYSINFO_RET_FAIL;
}
- result = get_kstat_named_field(interface, "ipackets64", &kn);
- if (result == SYSINFO_RET_OK)
+ ret = get_kstat_named_field(interface, "ipackets64", &kn);
+ if (ret == SYSINFO_RET_OK)
{
- *value = (double)kn.value.ui64;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui64;
}
else
{
- result = get_kstat_named_field(interface, "ipackets", &kn);
- *value = (double)kn.value.ui32;
+ ret = get_kstat_named_field(interface, "ipackets", &kn);
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui32;
}
- return result;
+ return ret;
}
-int NET_IF_IN_ERRORS(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+int NET_IF_IN_ERRORS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_named_t kn;
char interface[MAX_STRING_LEN];
- int result;
+ int ret;
+
+ assert(result);
+ clean_result(result);
+
if(num_param(param) > 1)
{
return SYSINFO_RET_FAIL;
@@ -296,19 +257,24 @@ int NET_IF_IN_ERRORS(const char *cmd, const char *param, double *value, const c
return SYSINFO_RET_FAIL;
}
- result = get_kstat_named_field(interface, "ierrors", &kn);
+ ret = get_kstat_named_field(interface, "ierrors", &kn);
- *value = (double)kn.value.ui32;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui32;
- return result;
+ return ret;
}
-int NET_IF_OUT_BYTES(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int NET_IF_OUT_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_named_t kn;
char interface[MAX_STRING_LEN];
- int result;
+ int ret;
+ assert(result);
+
+ clean_result(result);
+
if(num_param(param) > 1)
{
return SYSINFO_RET_FAIL;
@@ -319,26 +285,32 @@ int NET_IF_OUT_BYTES(const char *cmd, const char *param,double *value, const ch
return SYSINFO_RET_FAIL;
}
- result = get_kstat_named_field(interface, "obytes64", &kn);
- if (result == SYSINFO_RET_OK)
+ ret = get_kstat_named_field(interface, "obytes64", &kn);
+ if (ret == SYSINFO_RET_OK)
{
- *value = (double)kn.value.ui64;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui64;
}
else
{
- result = get_kstat_named_field(interface, "obytes", &kn);
- *value = (double)kn.value.ui32;
+ ret = get_kstat_named_field(interface, "obytes", &kn);
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui32;
}
- return result;
+ return ret;
}
-int NET_IF_OUT_PACKETS(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int NET_IF_OUT_PACKETS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_named_t kn;
char interface[MAX_STRING_LEN];
- int result;
+ int ret;
+
+ assert(result);
+ clean_result(result);
+
if(num_param(param) > 1)
{
return SYSINFO_RET_FAIL;
@@ -349,26 +321,32 @@ int NET_IF_OUT_PACKETS(const char *cmd, const char *param,double *value, const
return SYSINFO_RET_FAIL;
}
- result = get_kstat_named_field(interface, "opackets64", &kn);
- if (result == SYSINFO_RET_OK)
+ ret = get_kstat_named_field(interface, "opackets64", &kn);
+ if (ret == SYSINFO_RET_OK)
{
- *value = (double)kn.value.ui64;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui64;
}
else
{
- result = get_kstat_named_field(interface, "opackets", &kn);
- *value = (double)kn.value.ui32;
+ ret = get_kstat_named_field(interface, "opackets", &kn);
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui32;
}
- return result;
+ return ret;
}
-int NET_IF_OUT_ERRORS(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int NET_IF_OUT_ERRORS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_named_t kn;
char interface[MAX_STRING_LEN];
- int result;
+ int ret;
+ assert(result);
+
+ clean_result(result);
+
if(num_param(param) > 1)
{
return SYSINFO_RET_FAIL;
@@ -379,19 +357,24 @@ int NET_IF_OUT_ERRORS(const char *cmd, const char *param,double *value, const c
return SYSINFO_RET_FAIL;
}
- result = get_kstat_named_field(interface, "oerrors", &kn);
+ ret = get_kstat_named_field(interface, "oerrors", &kn);
- *value = (double)kn.value.ui32;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui32;
- return result;
+ return ret;
}
-int NET_IF_COLLISIONS(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_named_t kn;
char interface[MAX_STRING_LEN];
- int result;
+ int ret;
+ assert(result);
+
+ clean_result(result);
+
if(num_param(param) > 1)
{
return SYSINFO_RET_FAIL;
@@ -402,21 +385,29 @@ int NET_IF_COLLISIONS(const char *cmd, const char *param,double *value, const c
return SYSINFO_RET_FAIL;
}
- result = get_kstat_named_field(interface, "collisions", &kn);
+ ret = get_kstat_named_field(interface, "collisions", &kn);
- *value = (double)kn.value.ui32;
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)kn.value.ui32;
+ }
- return result;
+ return ret;
}
-int NET_TCP_LISTEN(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- char command[MAX_STRING_LEN];
-
- memset(command, '\0', sizeof(command));
+ char command[MAX_STRING_LEN];
+
+ assert(result);
+
+ clean_result(result);
+
+ memset(command, '\0', sizeof(command));
- snprintf(command, sizeof(command)-1, "netstat -an | grep '*.%s' | wc -l", param);
+ snprintf(command, sizeof(command)-1, "netstat -an | grep '*.%s' | wc -l", param);
- return EXECUTE(NULL, command, value, msg, mlen_max);
+ return EXECUTE(NULL, command, flags, result);
}
diff --git a/src/libs/zbxsysinfo/solaris/proc.c b/src/libs/zbxsysinfo/solaris/proc.c
index 88f8b15a..e28bdef1 100644
--- a/src/libs/zbxsysinfo/solaris/proc.c
+++ b/src/libs/zbxsysinfo/solaris/proc.c
@@ -19,109 +19,15 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#ifdef HAVE_PWD_H
-# include <pwd.h>
-#endif
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-
-#ifdef HAVE_SYS_PROC_H
-# include <sys/proc.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
-
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
-
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
-
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
-
#include "common.h"
#include "sysinfo.h"
-/*
-#define FDI(f, m) fprintf(stderr, "DEBUG INFO: " f "\n" , m) // show debug info to stderr
-#define SDI(m) FDI("%s", m) // string info
-#define IDI(i) FDI("%i", i) // integer info
-*/
-
-#define MAX(a, b) ((a)>(b) ? (a) : (b))
-#define MIN(a, b) ((a)<(b) ? (a) : (b))
-
#define DO_SUM 0
#define DO_MAX 1
#define DO_MIN 2
#define DO_AVG 3
-int PROC_MEMORY(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#if defined(HAVE_PROC_0_PSINFO)
DIR *dir;
@@ -147,35 +53,48 @@ int PROC_MEMORY(const char *cmd, const char *param,double *value, const char *m
double memsize = -1;
int proccount = 0;
- if(num_param(param) > 3)
- {
- return SYSINFO_RET_FAIL;
- }
+ assert(result);
- if(get_param(param, 1, procname, MAX_STRING_LEN) != 0)
+ clean_result(result);
+
+ if(num_param(param) > 3)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, procname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, usrname, MAX_STRING_LEN) != 0)
+ {
+ usrname[0] = '\0';
+ }
+
+ if(usrname[0] == '\0')
+ {
+ usrname[0] = 0;
+ }
+
+ if(usrname[0] != 0)
+ {
+ usrinfo = getpwnam(usrname);
+ if(usrinfo == NULL)
{
+ /* incorrect user name */
return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 2, usrname, MAX_STRING_LEN) != 0)
- {
- usrname[0] = 0;
- }
- else
- {
- if(usrname[0] != 0)
- {
- usrinfo = getpwnam(usrname);
- if(usrinfo == NULL)
- {
- /* incorrect user name */
- return SYSINFO_RET_FAIL;
- }
- }
+ }
}
+
if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
{
+ mode[0] = '\0';
+ }
+
+ if(mode[0] == '\0')
+ {
strscpy(mode, "sum");
}
@@ -299,15 +218,20 @@ int PROC_MEMORY(const char *cmd, const char *param,double *value, const char *m
{
memsize /= (double)proccount;
}
-
- *value = memsize;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = memsize;
return SYSINFO_RET_OK;
#else
+ assert(result);
+
+ clean_result(result);
+
return SYSINFO_RET_FAIL;
#endif
}
-int PROC_NUM(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#if defined(HAVE_PROC_0_PSINFO)
DIR *dir;
@@ -332,7 +256,11 @@ int PROC_NUM(const char *cmd, const char *param,double *value, const char *msg,
psinfo_t psinfo;
int proccount=0;
-
+
+ assert(result);
+
+ clean_result(result);
+
if(num_param(param) > 3)
{
return SYSINFO_RET_FAIL;
@@ -344,23 +272,30 @@ int PROC_NUM(const char *cmd, const char *param,double *value, const char *msg,
}
if(get_param(param, 2, usrname, MAX_STRING_LEN) != 0)
+ {
+ usrname[0] = '\0';
+ }
+
+ if(usrname[0] == '\0')
{
usrname[0] = 0;
}
- else
+ if(usrname[0] != 0)
{
- if(usrname[0] != 0)
+ usrinfo = getpwnam(usrname);
+ if(usrinfo == NULL)
{
- usrinfo = getpwnam(usrname);
- if(usrinfo == NULL)
- {
- /* incorrect user name */
- return SYSINFO_RET_FAIL;
- }
- }
+ /* incorrect user name */
+ return SYSINFO_RET_FAIL;
+ }
}
if(get_param(param, 3, procstat, MAX_STRING_LEN) != 0)
+ {
+ procstat[0] = '\0';
+ }
+
+ if(procstat[0] == '\0')
{
strscpy(procstat,"all");
}
@@ -469,9 +404,15 @@ int PROC_NUM(const char *cmd, const char *param,double *value, const char *msg,
}
}
closedir(dir);
- *value=(double)proccount;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = (double) proccount;
return SYSINFO_RET_OK;
#else
+ assert(result);
+
+ clean_result(result);
+
return SYSINFO_RET_FAIL;
#endif
}
diff --git a/src/libs/zbxsysinfo/solaris/sensors.c b/src/libs/zbxsysinfo/solaris/sensors.c
index 32042922..8620f12d 100644
--- a/src/libs/zbxsysinfo/solaris/sensors.c
+++ b/src/libs/zbxsysinfo/solaris/sensors.c
@@ -19,125 +19,12 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-
-/* HP-UX */
-#ifdef HAVE_SYS_PSTAT_H
- #include <sys/pstat.h>
-#endif
-
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_SYS_SYSCTL_H
- #include <sys/sysctl.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_VM_VM_PARAM_H
- #include <vm/vm_param.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_VMMETER_H
- #include <sys/vmmeter.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
-#endif
-
-#ifdef HAVE_MACH_HOST_INFO_H
- #include <mach/host_info.h>
-#endif
-#ifdef HAVE_MACH_MACH_HOST_H
- #include <mach/mach_host.h>
-#endif
-
-
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
-
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
-
#include "common.h"
#include "sysinfo.h"
#include "md5.h"
-int SENSOR_TEMP1(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SENSOR_TEMP1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
DIR *dir;
struct dirent *entries;
@@ -148,6 +35,10 @@ int SENSOR_TEMP1(const char *cmd, const char *param,double *value, const char *
FILE *f;
+ assert(result);
+
+ clean_result(result);
+
dir=opendir("/proc/sys/dev/sensors");
if(NULL == dir)
{
@@ -173,7 +64,8 @@ int SENSOR_TEMP1(const char *cmd, const char *param,double *value, const char *
if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3)
{
closedir(dir);
- *value=d3;
+ result->type |= AR_DOUBLE;
+ result->dbl = d3;
return SYSINFO_RET_OK;
}
else
@@ -187,7 +79,7 @@ int SENSOR_TEMP1(const char *cmd, const char *param,double *value, const char *
return SYSINFO_RET_FAIL;
}
-int SENSOR_TEMP2(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SENSOR_TEMP2(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
DIR *dir;
struct dirent *entries;
@@ -198,6 +90,10 @@ int SENSOR_TEMP2(const char *cmd, const char *param,double *value, const char *
FILE *f;
+ assert(result);
+
+ clean_result(result);
+
dir=opendir("/proc/sys/dev/sensors");
if(NULL == dir)
{
@@ -223,7 +119,8 @@ int SENSOR_TEMP2(const char *cmd, const char *param,double *value, const char *
if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3)
{
closedir(dir);
- *value=d3;
+ result->type |= AR_DOUBLE;
+ result->dbl = d3;
return SYSINFO_RET_OK;
}
else
@@ -237,7 +134,7 @@ int SENSOR_TEMP2(const char *cmd, const char *param,double *value, const char *
return SYSINFO_RET_FAIL;
}
-int SENSOR_TEMP3(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SENSOR_TEMP3(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
DIR *dir;
struct dirent *entries;
@@ -248,6 +145,10 @@ int SENSOR_TEMP3(const char *cmd, const char *param,double *value, const char *
FILE *f;
+ assert(result);
+
+ clean_result(result);
+
dir=opendir("/proc/sys/dev/sensors");
if(NULL == dir)
{
@@ -273,7 +174,8 @@ int SENSOR_TEMP3(const char *cmd, const char *param,double *value, const char *
if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3)
{
closedir(dir);
- *value=d3;
+ result->type |= AR_DOUBLE;
+ result->dbl = d3;
return SYSINFO_RET_OK;
}
else
@@ -286,3 +188,43 @@ int SENSOR_TEMP3(const char *cmd, const char *param,double *value, const char *
closedir(dir);
return SYSINFO_RET_FAIL;
}
+
+int OLD_SENSOR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char key[MAX_STRING_LEN];
+ int ret;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(strcmp(key,"temp1") == 0)
+ {
+ ret = SENSOR_TEMP1(cmd, param, flags, result);
+ }
+ else if(strcmp(key,"temp2") == 0)
+ {
+ ret = SENSOR_TEMP2(cmd, param, flags, result);
+ }
+ else if(strcmp(key,"temp3") == 0)
+ {
+ ret = SENSOR_TEMP3(cmd, param, flags, result);
+ }
+ else
+ {
+ ret = SYSINFO_RET_FAIL;
+ }
+
+ return ret;
+}
+
diff --git a/src/libs/zbxsysinfo/solaris/solaris.c b/src/libs/zbxsysinfo/solaris/solaris.c
index c2880a96..cdf1fc35 100644
--- a/src/libs/zbxsysinfo/solaris/solaris.c
+++ b/src/libs/zbxsysinfo/solaris/solaris.c
@@ -18,348 +18,256 @@
**/
#include "config.h"
+#include "common.h"
#include "sysinfo.h"
-
-
-int VM_MEMORY_BUFFERS(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int VM_MEMORY_CACHED(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int SYSTEM_CPU_IDLE1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_IDLE5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_IDLE15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_USER1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_USER5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_USER15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_NICE1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_NICE5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_NICE15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_SYS1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_SYS5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_SYS15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int VFS_FS_TOTAL(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-int VFS_FS_FREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-int VFS_FS_USED(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-int VFS_FS_PFREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-int VFS_FS_PUSED(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-
-int DISK_IO(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISK_RIO(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISK_WIO(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISK_RBLK(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISK_WBLK(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int VM_MEMORY_FREE(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int VFS_FILE_ATIME(const char *cmd, const char *filename,double *value, const char *msg, int mlen_max);
-int VFS_FILE_CKSUM(const char *cmd, const char *filename,double *value, const char *msg, int mlen_max);
-int VFS_FILE_CTIME(const char *cmd, const char *filename,double *value, const char *msg, int mlen_max);
-int VFS_FILE_MD5SUM(const char *cmd, const char *filename, char **value, const char *msg, int mlen_max);
-int VFS_FILE_MTIME(const char *cmd, const char *filename,double *value, const char *msg, int mlen_max);
-int VFS_FILE_REGEXP(const char *cmd, const char *filename, char **value, const char *msg, int mlen_max);
-int VFS_FILE_REGMATCH(const char *cmd, const char *filename,double *value, const char *msg, int mlen_max);
-int VFS_FILE_SIZE(const char *cmd, const char *filename,double *value, const char *msg, int mlen_max);
-int VFS_FILE_EXISTS(const char *cmd, const char *filename,double *value, const char *msg, int mlen_max);
-
-int VFS_FS_INODE_FREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-int VFS_FS_INODE_PFREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-int VFS_FS_INODE_TOTAL(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max);
-
-
-int KERNEL_MAXFILES(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int KERNEL_MAXPROC(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_KERNEL_MAXPROC(const char *cmd, const char *parameter, double *value, const char *msg, int mlen_max);
-
-int NET_IF_IBYTES1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_IBYTES5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_IBYTES15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int NET_IF_OBYTES1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_OBYTES5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_OBYTES15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int NET_IF_OBYTES(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_OBYTES15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int NET_IF_COLLISIONS(const char *cmd, const char *param,double *value, const char *msg, int mlen_max);
-int NET_IF_OUT_ERRORS(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_OUT_PACKETS(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_OUT_BYTES(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_IN_ERRORS(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_IN_PACKETS(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int NET_IF_IN_BYTES(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int NET_TCP_LISTEN(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int TCP_LISTEN(const char *cmd, const char *porthex,double *value, const char *msg, int mlen_max);
-
-int VFS_DEV_READ_BYTES(const char *cmd, const char *param,double *value, const char *msg, int mlen_max);
-int VFS_DEV_READ_OPERATIONS(const char *cmd, const char *param,double *value, const char *msg, int mlen_max);
-int VFS_DEV_WRITE_BYTES(const char *cmd, const char *param,double *value, const char *msg, int mlen_max);
-int VFS_DEV_WRITE_OPERATIONS(const char *cmd, const char *param,double *value, const char *msg, int mlen_max);
-
-int DISKREADOPS1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKREADOPS5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKREADOPS15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKREADBLKS1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKREADBLKS5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKREADBLKS15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKWRITEOPS1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKWRITEOPS5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKWRITEOPS15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKWRITEBLKS1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKWRITEBLKS5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int DISKWRITEBLKS15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int AGENT_PING(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int VM_MEMORY_SHARED(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int VM_MEMORY_TOTAL(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int PROC_NUM(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int PROC_MEMORY(const char *cmd, const char *param, double *value, const char *msg, int mlen_max);
-
-int PROCCOUNT(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int SYSTEM_CPU_LOAD1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_LOAD5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_LOAD15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_INTR(const char *cmd, const char *parameter, double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_SWITCHES(const char *cmd, const char *parameter, double *value, const char *msg, int mlen_max);
-int SYSTEM_CPU_UTILIZATION(const char *cmd, const char *param,double *value, const char *msg, int mlen_max);
-
-int SENSOR_TEMP1(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SENSOR_TEMP2(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SENSOR_TEMP3(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-
-int SYSTEM_SWAP_IN_NUM(const char *cmd, const char *param, double *value, const char *msg, int mlen_max);
-int SYSTEM_SWAP_IN_PAGES(const char *cmd, const char *param, double *value, const char *msg, int mlen_max);
-int SYSTEM_SWAP_OUT_NUM(const char *cmd, const char *param, double *value, const char *msg, int mlen_max);
-int SYSTEM_SWAP_OUT_PAGES(const char *cmd, const char *param, double *value, const char *msg, int mlen_max);
-
-int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int SYSTEM_SWAP_FREE(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-int SYSTEM_SWAP_TOTAL(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max);
-
-int EXECUTE(const char *cmd, const char *command,double *value, const char *msg, int mlen_max);
-int EXECUTE_STR(const char *cmd, const char *command, const char *parameter, char **value, const char *msg, int mlen_max);
-int AGENT_VERSION(const char *cmd, const char *command,char **value, const char *msg, int mlen_max);
-
-
-int CHECK_SERVICE(const char *cmd, const char *service,double *value, const char *msg, int mlen_max);
-int CHECK_SERVICE_PERF(const char *cmd, const char *service,double *value, const char *msg, int mlen_max);
-int CHECK_PORT(const char *cmd, const char *ip_and_port,double *value, const char *msg, int mlen_max);
-int CHECK_DNS(const char *cmd, const char *service,double *value, const char *msg, int mlen_max);
-
ZBX_METRIC parameters_specific[]=
-/* KEY FUNCTION (if double) FUNCTION (if string) PARAM*/
+/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
/* Outdated */
-
- {"cksum[*]" ,VFS_FILE_CKSUM, 0, "/etc/services"},
- {"cpu[idle1]" ,SYSTEM_CPU_IDLE1, 0, 0},
- {"cpu[idle5]" ,SYSTEM_CPU_IDLE5, 0, 0},
- {"cpu[idle15]" ,SYSTEM_CPU_IDLE15, 0, 0},
- {"cpu[nice1]" ,SYSTEM_CPU_NICE1, 0, 0},
- {"cpu[nice5]" ,SYSTEM_CPU_NICE5, 0, 0},
- {"cpu[nice15]" ,SYSTEM_CPU_NICE15, 0, 0},
- {"cpu[system1]" ,SYSTEM_CPU_SYS1, 0, 0},
- {"cpu[system5]" ,SYSTEM_CPU_SYS5, 0, 0},
- {"cpu[system15]" ,SYSTEM_CPU_SYS15, 0, 0},
- {"cpu[user1]" ,SYSTEM_CPU_USER1, 0, 0},
- {"cpu[user5]" ,SYSTEM_CPU_USER5, 0, 0},
- {"cpu[user15]" ,SYSTEM_CPU_USER15, 0, 0},
- {"diskfree[*]" ,VFS_FS_FREE, 0, "/"},
- {"disktotal[*]" ,VFS_FS_TOTAL, 0, "/"},
- {"diskused[*]" ,VFS_FS_USED, 0, "/"},
- {"diskfree_perc[*]" ,VFS_FS_PFREE, 0, "/"},
- {"diskused_perc[*]" ,VFS_FS_PUSED, 0, "/"},
- {"file[*]" ,VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"filesize[*]" ,VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"inodefree[*]" ,VFS_FS_INODE_FREE, 0, "/"},
- {"inodetotal[*]" ,VFS_FS_INODE_TOTAL, 0, "/"},
- {"inodefree_perc[*]" ,VFS_FS_INODE_PFREE, 0, "/"},
- {"kern[maxfiles]" ,KERNEL_MAXFILES, 0, 0},
- {"kern[maxproc]" ,SYSTEM_KERNEL_MAXPROC, 0, 0},
- {"md5sum[*]" ,0, VFS_FILE_MD5SUM, "/etc/services"},
- {"memory[buffers]" ,VM_MEMORY_BUFFERS, 0, 0},
- {"memory[cached]" ,VM_MEMORY_CACHED, 0, 0},
- {"memory[free]" ,VM_MEMORY_FREE, 0, 0},
- {"memory[shared]" ,VM_MEMORY_SHARED, 0, 0},
- {"memory[total]" ,VM_MEMORY_TOTAL, 0, 0},
- {"netloadin1[*]" ,NET_IF_IBYTES1, 0, "lo"},
- {"netloadin5[*]" ,NET_IF_IBYTES5, 0, "lo"},
- {"netloadin15[*]" ,NET_IF_IBYTES15, 0, "lo"},
- {"netloadout1[*]" ,NET_IF_OBYTES1, 0, "lo"},
- {"netloadout5[*]" ,NET_IF_OBYTES5, 0, "lo"},
- {"netloadout15[*]" ,NET_IF_OBYTES15, 0, "lo"},
- {"ping" ,AGENT_PING, 0, 0},
- {"proc_cnt[*]" ,PROC_NUM, 0, "inetd"},
- {"swap[free]" ,SYSTEM_SWAP_FREE, 0, 0},
- {"swap[total]" ,SYSTEM_SWAP_TOTAL, 0, 0},
- {"system[procload]" ,SYSTEM_CPU_LOAD1, 0, 0},
- {"system[procload5]" ,SYSTEM_CPU_LOAD5, 0, 0},
- {"system[procload15]" ,SYSTEM_CPU_LOAD15, 0, 0},
- {"system[hostname]" ,0, EXECUTE_STR, "hostname"},
- {"system[uname]" ,0, EXECUTE_STR, "uname -a"},
- {"system[uptime]" ,SYSTEM_UPTIME, 0, 0},
- {"system[users]" ,EXECUTE, 0,"who|wc -l"},
- {"version[zabbix_agent]", 0, AGENT_VERSION, 0},
- {"system[interrupts]" ,SYSTEM_CPU_INTR, 0, 0},
- {"system[switches]" ,SYSTEM_CPU_SWITCHES, 0, 0},
+/* incorrect OLD naming */
+ {"cpu", CF_USEUPARAM, OLD_CPU, 0, "idle1"},
+/*
+ {"cpu[idle1]", 0, 0, 0, 0},
+ {"cpu[idle5]", 0, 0, 0, 0},
+ {"cpu[idle15]", 0, 0, 0, 0},
+ {"cpu[nice1]", 0, 0, 0, 0},
+ {"cpu[nice5]", 0, 0, 0, 0},
+ {"cpu[nice15]", 0, 0, 0, 0},
+ {"cpu[system1]", 0, 0, 0, 0},
+ {"cpu[system5]", 0, 0, 0, 0},
+ {"cpu[system15]", 0, 0, 0, 0},
+ {"cpu[user1]", 0, 0, 0, 0},
+ {"cpu[user5]", 0, 0, 0, 0},
+ {"cpu[user15]", 0, 0, 0, 0},
+*/
+ {"io", CF_USEUPARAM, OLD_IO, 0, "disk_io"},
+/*
+ {"io[disk_io]", 0, 0, 0, 0},
+ {"io[disk_rio]", 0, 0, 0, 0},
+ {"io[disk_wio]", 0, 0, 0, 0},
+ {"io[disk_rblk]", 0, 0, 0, 0},
+ {"io[disk_wblk]", 0, 0, 0, 0},
+*/
+ {"kern", CF_USEUPARAM, OLD_KERNEL, 0, "maxfiles"},
+/*
+ {"kern[maxfiles]", 0, 0, 0, 0},
+ {"kern[maxproc]", 0, 0, 0, 0},
+*/
+ {"memory", CF_USEUPARAM, OLD_MEMORY, 0, "free"},
+/*
+ {"memory[buffers]", 0, 0, 0, 0},
+ {"memory[cached]", 0, 0, 0, 0},
+ {"memory[free]", 0, 0, 0, 0},
+ {"memory[shared]", 0, 0, 0, 0},
+ {"memory[total]", 0, 0, 0, 0},
+*/
+ {"system", CF_USEUPARAM, OLD_SYSTEM, 0, "uname"},
+/*
+ {"system[proccount]", 0, 0, 0, 0},
+
+ {"system[procload]", 0, 0, 0, 0},
+ {"system[procload5]", 0, 0, 0, 0},
+ {"system[procload15]", 0, 0, 0, 0},
+ {"system[hostname]", 0, 0, 0, 0},
+ {"system[uname]", 0, 0, 0, 0},
+ {"system[uptime]", 0, 0, 0, 0},
+ {"system[users]", 0, 0, 0, 0},
+
+ {"system[procrunning]", 0, 0, 0, 0},
+*/
+ {"sensor", CF_USEUPARAM, OLD_SENSOR, 0, "temp1"},
+/*
+ {"sensor[temp1]", 0, 0, 0, 0},
+ {"sensor[temp2]", 0, 0, 0, 0},
+ {"sensor[temp3]", 0, 0, 0, 0},
+*/
+ {"swap", CF_USEUPARAM, OLD_SWAP, 0, "total"},
+/*
+ {"swap[free]", 0, 0, 0, 0},
+ {"swap[total]", 0, 0, 0, 0},
+*/
+ {"version", CF_USEUPARAM, OLD_VERSION, 0, "zabbix_agent"},
+/*
+ {"version[zabbix_agent]", 0, OLD_VERSION, 0, 0},
+*/
+/* correct OLD naming */
+/*
+ {"cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
+*/
+/*
+ {"diskfree", CF_USEUPARAM, VFS_FS_FREE, 0, "/"},
+ {"disktotal", CF_USEUPARAM, VFS_FS_TOTAL, 0, "/"},
+ {"diskused", CF_USEUPARAM, VFS_FS_USED, 0, "/"},
+ {"diskfree_perc", CF_USEUPARAM, VFS_FS_PFREE, 0, "/"},
+ {"diskused_perc", CF_USEUPARAM, VFS_FS_PUSED, 0, "/"},
+*/
+/*
+ {"file", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
+ {"filesize", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
+*/
+/*
+ {"inodefree", CF_USEUPARAM, VFS_FS_INODE_FREE, 0, "/"},
+ {"inodetotal", CF_USEUPARAM, VFS_FS_INODE_TOTAL, 0, "/"},
+ {"inodefree_perc", CF_USEUPARAM, VFS_FS_INODE_PFREE, 0, "/"},
+*/
+/*
+ {"md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+*/
+/*
+ {"netloadin1", CF_USEUPARAM, NET_IF_IBYTES1, 0, "hme0"},
+ {"netloadin5", CF_USEUPARAM, NET_IF_IBYTES5, 0, "hme0"},
+ {"netloadin15", CF_USEUPARAM, NET_IF_IBYTES15, 0, "hme0"},
+ {"netloadout1", CF_USEUPARAM, NET_IF_OBYTES1, 0, "hme0"},
+ {"netloadout5", CF_USEUPARAM, NET_IF_OBYTES5, 0, "hme0"},
+ {"netloadout15", CF_USEUPARAM, NET_IF_OBYTES15, 0, "hme0"},
+*/
+/*
+ {"ping", 0, AGENT_PING, 0, 0},
+*/
/* New naming */
-
- {"agent.ping" ,AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0},
-
- {"kernel.maxfiles]" ,KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc" ,SYSTEM_KERNEL_MAXPROC, 0, 0},
-
- {"proc.num[*]" ,PROC_NUM, 0, "inetd"},
- {"proc.mem[*]" ,PROC_MEMORY, 0, "inetd"},
-
- {"vm.memory.total" ,VM_MEMORY_TOTAL, 0, 0},
- {"vm.memory.shared" ,VM_MEMORY_SHARED, 0, 0},
- {"vm.memory.buffers" ,VM_MEMORY_BUFFERS, 0, 0},
- {"vm.memory.cached" ,VM_MEMORY_CACHED, 0, 0},
- {"vm.memory.free" ,VM_MEMORY_FREE, 0, 0},
-
- {"vfs.fs.free[*]" ,VFS_FS_FREE, 0, "/"},
- {"vfs.fs.total[*]" ,VFS_FS_TOTAL, 0, "/"},
- {"vfs.fs.used[*]" ,VFS_FS_USED, 0, "/"},
-
- {"vfs.fs.pfree[*]" ,VFS_FS_PFREE, 0, "/"},
- {"vfs.fs.pused[*]" ,VFS_FS_PUSED, 0, "/"},
-
- {"vfs.fs.inode.free[*]" ,VFS_FS_INODE_FREE, 0, "/"},
- {"vfs.fs.inode.total[*]",VFS_FS_INODE_TOTAL, 0, "/"},
- {"vfs.fs.inode.pfree[*]",VFS_FS_INODE_PFREE, 0, "/"},
-
- {"vfs.file.atime[*]" ,VFS_FILE_ATIME, 0, "/etc/passwd"},
- {"vfs.file.cksum[*]" ,VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.ctime[*]" ,VFS_FILE_CTIME, 0, "/etc/passwd"},
- {"vfs.file.exists[*]" ,VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.md5sum[*]" ,0, VFS_FILE_MD5SUM, "/etc/services"},
- {"vfs.file.mtime[*]" ,VFS_FILE_MTIME, 0, "/etc/passwd"},
- {"vfs.file.regexp[*]" ,0, VFS_FILE_REGEXP, "/etc/passwd,root"},
- {"vfs.file.regmatch[*]" ,VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.size[*]" ,VFS_FILE_SIZE, 0, "/etc/passwd"},
-
- {"disk_read_ops1[*]" ,DISKREADOPS1, 0, "sd0"},
- {"disk_read_ops5[*]" ,DISKREADOPS5, 0, "sd0"},
- {"disk_read_ops15[*]" ,DISKREADOPS15, 0, "sd0"},
-
- {"disk_read_blks1[*]" ,DISKREADBLKS1, 0, "sd0"},
- {"disk_read_blks5[*]" ,DISKREADBLKS5, 0, "sd0"},
- {"disk_read_blks15[*]" ,DISKREADBLKS15, 0, "sd0"},
-
- {"disk_write_ops1[*]" ,DISKWRITEOPS1, 0, "sd0"},
- {"disk_write_ops5[*]" ,DISKWRITEOPS5, 0, "sd0"},
- {"disk_write_ops15[*]" ,DISKWRITEOPS15, 0, "sd0"},
-
- {"disk_write_blks1[*]" ,DISKWRITEBLKS1, 0, "sd0"},
- {"disk_write_blks5[*]" ,DISKWRITEBLKS5, 0, "sd0"},
- {"disk_write_blks15[*]" ,DISKWRITEBLKS15, 0, "sd0"},
-
- {"vfs.dev.read.bytes[*]" ,VFS_DEV_READ_BYTES, 0, "sd0"},
- {"vfs.dev.read.operations[*]" ,VFS_DEV_READ_OPERATIONS, 0, "sd0"},
- {"vfs.dev.write.bytes[*]" ,VFS_DEV_WRITE_BYTES, 0, "sd0"},
- {"vfs.dev.write.operations[*]" ,VFS_DEV_WRITE_OPERATIONS, 0, "sd0"},
-
- {"system.cpu.idle1" ,SYSTEM_CPU_IDLE1, 0, 0},
- {"system.cpu.idle5" ,SYSTEM_CPU_IDLE5, 0, 0},
- {"system.cpu.idle15" ,SYSTEM_CPU_IDLE15, 0, 0},
- {"system.cpu.nice1" ,SYSTEM_CPU_NICE1, 0, 0},
- {"system.cpu.nice5" ,SYSTEM_CPU_NICE5, 0, 0},
- {"system.cpu.nice15" ,SYSTEM_CPU_NICE15, 0, 0},
- {"system.cpu.sys1" ,SYSTEM_CPU_SYS1, 0, 0},
- {"system.cpu.sys5" ,SYSTEM_CPU_SYS5, 0, 0},
- {"system.cpu.sys15" ,SYSTEM_CPU_SYS15, 0, 0},
- {"system.cpu.user1" ,SYSTEM_CPU_USER1, 0, 0},
- {"system.cpu.user5" ,SYSTEM_CPU_USER5, 0, 0},
- {"system.cpu.user15" ,SYSTEM_CPU_USER15, 0, 0},
-
- {"system.cpu.util[*]" ,SYSTEM_CPU_UTILIZATION, 0, "idle"},
-
- {"net.if.ibytes1[*]" ,NET_IF_IBYTES1, 0, "hme0"},
- {"net.if.ibytes5[*]" ,NET_IF_IBYTES5, 0, "hme0"},
- {"net.if.ibytes15[*]" ,NET_IF_IBYTES15, 0, "hme0"},
- {"net.if.obytes1[*]" ,NET_IF_OBYTES1, 0, "hme0"},
- {"net.if.obytes5[*]" ,NET_IF_OBYTES5, 0, "hme0"},
- {"net.if.obytes15[*]" ,NET_IF_OBYTES15, 0, "hme0"},
-
- {"net.if.in.bytes[*]" ,NET_IF_IN_BYTES, 0, "hme0"},
- {"net.if.in.packets[*]" ,NET_IF_IN_PACKETS, 0, "hme0"},
- {"net.if.in.errors[*]" ,NET_IF_IN_ERRORS, 0, "hme0"},
-
- {"net.if.out.bytes[*]" ,NET_IF_OUT_BYTES, 0, "hme0"},
- {"net.if.out.packets[*]" ,NET_IF_OUT_PACKETS, 0, "hme0"},
- {"net.if.out.errors[*]" ,NET_IF_OUT_ERRORS, 0, "hme0"},
-
- {"net.if.collisions[*]" ,NET_IF_COLLISIONS, 0, "hme0"},
-
- {"net.listen.tcp[*]" ,NET_TCP_LISTEN, 0, "80"},
-
-/* {"tcp_count" ,EXECUTE, 0, "netstat -tn|grep EST|wc -l"}, */
-
- {"sensor[temp1]" ,SENSOR_TEMP1, 0, 0},
- {"sensor[temp2]" ,SENSOR_TEMP2, 0, 0},
- {"sensor[temp3]" ,SENSOR_TEMP3, 0, 0},
-
- {"system.cpu.load1" ,SYSTEM_CPU_LOAD1, 0, 0},
- {"system.cpu.load5" ,SYSTEM_CPU_LOAD5, 0, 0},
- {"system.cpu.load15" ,SYSTEM_CPU_LOAD15, 0, 0},
-
- {"system.hostname" ,0, EXECUTE_STR, "hostname"},
-
- {"system.swap.free" ,SYSTEM_SWAP_FREE, 0, 0},
- {"system.swap.total" ,SYSTEM_SWAP_TOTAL, 0, 0},
- {"swap[in]" ,SYSTEM_SWAP_IN_NUM, 0, 0},
- {"system.swap.in.num" ,SYSTEM_SWAP_IN_NUM, 0, 0},
- {"system.swap.in.pages" ,SYSTEM_SWAP_IN_PAGES, 0, 0},
- {"swap[out]" ,SYSTEM_SWAP_OUT_NUM, 0, 0},
- {"system.swap.out.num" ,SYSTEM_SWAP_OUT_NUM, 0, 0},
- {"system.swap.out.pages",SYSTEM_SWAP_OUT_PAGES, 0, 0},
-
- {"system.uname" ,0, EXECUTE_STR, "uname -a"},
- {"system.uptime" ,SYSTEM_UPTIME, 0, 0},
- {"system.users.num" ,EXECUTE, 0,"who|wc -l"},
+/*
+ {"system.cpu.idle1", 0, SYSTEM_CPU_IDLE1, 0, 0},
+ {"system.cpu.idle5", 0, SYSTEM_CPU_IDLE5, 0, 0},
+ {"system.cpu.idle15", 0, SYSTEM_CPU_IDLE15, 0, 0},
+ {"system.cpu.nice1", 0, SYSTEM_CPU_NICE1, 0, 0},
+ {"system.cpu.nice5", 0, SYSTEM_CPU_NICE5, 0, 0},
+ {"system.cpu.nice15", 0, SYSTEM_CPU_NICE15, 0, 0},
+ {"system.cpu.sys1", 0, SYSTEM_CPU_SYS1, 0, 0},
+ {"system.cpu.sys5", 0, SYSTEM_CPU_SYS5, 0, 0},
+ {"system.cpu.sys15", 0, SYSTEM_CPU_SYS15, 0, 0},
+ {"system.cpu.user1", 0, SYSTEM_CPU_USER1, 0, 0},
+ {"system.cpu.user5", 0, SYSTEM_CPU_USER5, 0, 0},
+ {"system.cpu.user15", 0, SYSTEM_CPU_USER15, 0, 0},
+*/
+/*
+ {"vm.memory.total", 0, VM_MEMORY_TOTAL, 0, 0},
+ {"vm.memory.shared", 0, VM_MEMORY_SHARED, 0, 0},
+ {"vm.memory.buffers", 0, VM_MEMORY_BUFFERS, 0, 0},
+ {"vm.memory.cached", 0, VM_MEMORY_CACHED, 0, 0},
+ {"vm.memory.free", 0, VM_MEMORY_FREE, 0, 0},
+*/
+/*
+ {"vfs.fs.free", CF_USEUPARAM, VFS_FS_FREE, 0, "/"},
+ {"vfs.fs.total", CF_USEUPARAM, VFS_FS_TOTAL, 0, "/"},
+ {"vfs.fs.used", CF_USEUPARAM, VFS_FS_USED, 0, "/"},
+ {"vfs.fs.pfree", CF_USEUPARAM, VFS_FS_PFREE, 0, "/"},
+ {"vfs.fs.pused", CF_USEUPARAM, VFS_FS_PUSED, 0, "/"},
+*/
+/*
+ {"vfs.fs.inode.free", CF_USEUPARAM, VFS_FS_INODE_FREE, 0, "/"},
+ {"vfs.fs.inode.total", CF_USEUPARAM, VFS_FS_INODE_TOTAL, 0, "/"},
+ {"vfs.fs.inode.pfree", CF_USEUPARAM, VFS_FS_INODE_PFREE, 0, "/"},
+*/
+/*
+ {"net.if.ibytes1", CF_USEUPARAM, NET_IF_IBYTES1, 0, "hme0"},
+ {"net.if.ibytes5", CF_USEUPARAM, NET_IF_IBYTES5, 0, "hme0"},
+ {"net.if.ibytes15", CF_USEUPARAM, NET_IF_IBYTES15,0, "hme0"},
+
+ {"net.if.obytes1", CF_USEUPARAM, NET_IF_OBYTES1, 0, "hme0"},
+ {"net.if.obytes5", CF_USEUPARAM, NET_IF_OBYTES5, 0, "hme0"},
+ {"net.if.obytes15", CF_USEUPARAM, NET_IF_OBYTES15,0, "hme0"},
+*/
+/*
+ {"disk_read_ops1", CF_USEUPARAM, DISKREADOPS1, 0, "sd0"},
+ {"disk_read_ops5", CF_USEUPARAM, DISKREADOPS5, 0, "sd0"},
+ {"disk_read_ops15", CF_USEUPARAM, DISKREADOPS15, 0, "sd0"},
+
+ {"disk_read_blks1", CF_USEUPARAM, DISKREADBLKS1, 0, "sd0"},
+ {"disk_read_blks5", CF_USEUPARAM, DISKREADBLKS5, 0, "sd0"},
+ {"disk_read_blks15", CF_USEUPARAM, DISKREADBLKS15, 0, "sd0"},
+
+ {"disk_write_ops1", CF_USEUPARAM, DISKWRITEOPS1, 0, "sd0"},
+ {"disk_write_ops5", CF_USEUPARAM, DISKWRITEOPS5, 0, "sd0"},
+ {"disk_write_ops15", CF_USEUPARAM, DISKWRITEOPS15, 0, "sd0"},
+
+ {"disk_write_blks1", CF_USEUPARAM, DISKWRITEBLKS1, 0, "sd0"},
+ {"disk_write_blks5", CF_USEUPARAM, DISKWRITEBLKS5, 0, "sd0"},
+ {"disk_write_blks15", CF_USEUPARAM, DISKWRITEBLKS15,0, "sd0"},
+*/
+/*
+ {"system.cpu.load1", 0, SYSTEM_CPU_LOAD1, 0, 0},
+ {"system.cpu.load5", 0, SYSTEM_CPU_LOAD5, 0, 0},
+ {"system.cpu.load15", 0, SYSTEM_CPU_LOAD15, 0, 0},
+*/
/****************************************
All these perameters require more than 1 second to retrieve.
{"swap[in]" ,EXECUTE, 0, "vmstat -n 1 2|tail -1|cut -b37-40"},
{"swap[out]" ,EXECUTE, 0, "vmstat -n 1 2|tail -1|cut -b41-44"},
- {"system[interrupts]" ,EXECUTE, 0, "vmstat -n 1 2|tail -1|cut -b57-61"},
+
+ {"system[interrupts]" ,EXECUTE, 0, "vmstat -n 1 2|tail -1|cut -b57-61"},
{"system[switches]" ,EXECUTE, 0, "vmstat -n 1 2|tail -1|cut -b62-67"},
***************************************/
- {"system.cpu.switches" ,SYSTEM_CPU_SWITCHES, 0, 0},
- {"system.cpu.intr" ,SYSTEM_CPU_INTR, 0, 0},
-
- {"io[disk_io]" ,DISK_IO, 0, 0},
- {"io[disk_rio]" ,DISK_RIO, 0, 0},
- {"io[disk_wio]" ,DISK_WIO, 0, 0},
- {"io[disk_rblk]" ,DISK_RBLK, 0, 0},
- {"io[disk_wblk]" ,DISK_WBLK, 0, 0},
+/* {"tcp_count" ,EXECUTE, 0, "netstat -tn|grep EST|wc -l"}, */
+/*
+ {"check_port", CF_USEUPARAM, CHECK_PORT, 0, "80"},
+ {"check_service", CF_USEUPARAM, CHECK_SERVICE, 0, "ssh,127.0.0.1,22"},
+ {"check_service_perf", CF_USEUPARAM, CHECK_SERVICE_PERF, 0, "ssh,127.0.0.1,22"},
+*/
+/*
+ {"dns", CF_USEUPARAM, CHECK_DNS, 0, "127.0.0.1,localhost"},
+*/
+ {"agent.ping", 0, AGENT_PING, 0, 0},
+ {"agent.version", 0, AGENT_VERSION, 0, 0},
+
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+
+ {"vfs.file.atime", CF_USEUPARAM, VFS_FILE_ATIME, 0, "/etc/passwd"},
+ {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
+ {"vfs.file.ctime", CF_USEUPARAM, VFS_FILE_CTIME, 0, "/etc/passwd"},
+ {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
+ {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"vfs.file.mtime", CF_USEUPARAM, VFS_FILE_MTIME, 0, "/etc/passwd"},
+ {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
+ {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
+ {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
+
+/************************************
+ * NEW FUNCTIONS *
+ ************************************/
+
+ {"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
+ {"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
+
+ {"net.tcp.dns", CF_USEUPARAM, CHECK_DNS, 0, "127.0.0.1,localhost"},
+
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
+ {"net.tcp.port", CF_USEUPARAM, CHECK_PORT, 0, "80"},
+ {"net.tcp.service", CF_USEUPARAM, CHECK_SERVICE, 0, "ssh,127.0.0.1,22"},
+ {"net.tcp.service.perf",CF_USEUPARAM, CHECK_SERVICE_PERF, 0, "ssh,127.0.0.1,22"},
+
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "hme0,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "hme0,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "hme0"},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"system[proccount]" ,PROCCOUNT, 0, 0},
+ {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "sd0,bytes"},
+ {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "sd0,bytes"},
+
+ {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
+ {"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,idle"},
- #ifdef HAVE_PROC_LOADAVG
- {"system[procrunning]" ,EXECUTE, 0, "cat /proc/loadavg|cut -f1 -d'/'|cut -f4 -d' '"},
- #endif
-
-
- {"check_port[*]" ,CHECK_PORT, 0, "80"},
+ {"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
+
+ {"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
+
+ {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
- {"check_service[*]" ,CHECK_SERVICE, 0, "ssh,127.0.0.1,22"},
- {"dns[*]" ,CHECK_DNS, 0, "127.0.0.1,localhost"},
- {"check_service_perf[*]",CHECK_SERVICE_PERF, 0, "ssh,127.0.0.1,22"},
+ {"system.uname", 0, SYSTEM_UNAME, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
+ {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/solaris/swap.c b/src/libs/zbxsysinfo/solaris/swap.c
index 84f2ba9e..3882aa36 100644
--- a/src/libs/zbxsysinfo/solaris/swap.c
+++ b/src/libs/zbxsysinfo/solaris/swap.c
@@ -19,136 +19,123 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
+#include "common.h"
+#include "sysinfo.h"
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
+#include "md5.h"
-/* HP-UX */
-#ifdef HAVE_SYS_PSTAT_H
- #include <sys/pstat.h>
-#endif
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
+int SYSTEM_SWAP_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
+#define SWP_FNCLIST struct swp_fnclist_s
+SWP_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
-/* FreeBSD */
-#ifdef HAVE_SYS_SYSCTL_H
- #include <sys/sysctl.h>
-#endif
+ SWP_FNCLIST fl[] =
+ {
+ {"total", SYSTEM_SWAP_FREE},
+ {"free", SYSTEM_SWAP_TOTAL},
+ {0, 0}
+ };
+
+ char swapdev[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
-/* Solaris */
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
+ if(get_param(param, 1, swapdev, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
-/* FreeBSD */
-#ifdef HAVE_VM_VM_PARAM_H
- #include <vm/vm_param.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_VMMETER_H
- #include <sys/vmmeter.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
-#endif
+ if(swapdev[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(swapdev, "all");
+ }
-#ifdef HAVE_MACH_HOST_INFO_H
- #include <mach/host_info.h>
-#endif
-#ifdef HAVE_MACH_MACH_HOST_H
- #include <mach/mach_host.h>
-#endif
+ if(strncmp(swapdev, "all", MAX_STRING_LEN))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "free");
+ }
+
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, param, flags, result);
+ }
+ }
+
+ return SYSINFO_RET_FAIL;
+}
+int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char key[MAX_STRING_LEN];
+ int ret;
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
+ assert(result);
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
+ clean_result(result);
-#include "common.h"
-#include "sysinfo.h"
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
-#include "md5.h"
+ if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+ if(strcmp(key,"free") == 0)
+ {
+ ret = SYSTEM_SWAP_FREE(cmd, param, flags, result);
+ }
+ else if(strcmp(key,"total") == 0)
+ {
+ ret = SYSTEM_SWAP_TOTAL(cmd, param, flags, result);
+ }
+ else
+ {
+ ret = SYSINFO_RET_FAIL;
+ }
-#if 1
+ return ret;
+}
/* Solaris. */
-
#ifndef HAVE_SYSINFO_FREESWAP
#ifdef HAVE_SYS_SWAP_SWAPTABLE
void get_swapinfo(double *total, double *fr)
{
register int cnt, i, page_size;
/* Support for >2Gb */
-/* register int t, f; */
+/* register int t, f;*/
double t, f;
struct swaptable *swt;
struct swapent *ste;
@@ -170,7 +157,7 @@ void get_swapinfo(double *total, double *fr)
swt->swt_n = cnt;
/* fill in ste_path pointers: we don't care about the paths, so we
- point them all to the same buffer */
+point them all to the same buffer */
ste = &(swt->swt_ent[0]);
i = cnt;
while (--i >= 0)
@@ -207,17 +194,22 @@ void get_swapinfo(double *total, double *fr)
#endif
#endif
-int SYSTEM_SWAP_FREE(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+int SYSTEM_SWAP_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_SYSINFO_FREESWAP
struct sysinfo info;
+ assert(result);
+
+ clean_result(result);
+
if( 0 == sysinfo(&info))
{
+ result->type |= AR_DOUBLE;
#ifdef HAVE_SYSINFO_MEM_UNIT
- *value=(double)info.freeswap * (double)info.mem_unit;
+ result->dbl = (double)info.freeswap * (double)info.mem_unit;
#else
- *value=(double)info.freeswap;
+ result->dbl = (double)info.freeswap;
#endif
return SYSINFO_RET_OK;
}
@@ -230,29 +222,41 @@ int SYSTEM_SWAP_FREE(const char *cmd, const char *parameter,double *value, cons
#ifdef HAVE_SYS_SWAP_SWAPTABLE
double swaptotal,swapfree;
+ assert(result);
+
+ clean_result(result);
+
get_swapinfo(&swaptotal,&swapfree);
- *value=swapfree;
+ result->type |= AR_DOUBLE;
+ result->dbl = swapfree;
return SYSINFO_RET_OK;
#else
+ assert(result);
+
+ clean_result(result);
+
return SYSINFO_RET_FAIL;
#endif
#endif
}
-
-
-int SYSTEM_SWAP_TOTAL(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_SYSINFO_TOTALSWAP
struct sysinfo info;
+ assert(result);
+
+ clean_result(result);
+
if( 0 == sysinfo(&info))
{
+ result->type |= AR_DOUBLE;
#ifdef HAVE_SYSINFO_MEM_UNIT
- *value=(double)info.totalswap * (double)info.mem_unit;
+ result->dbl = (double)info.totalswap * (double)info.mem_unit;
#else
- *value=(double)info.totalswap;
+ result->dbl = (double)info.totalswap;
#endif
return SYSINFO_RET_OK;
}
@@ -265,159 +269,37 @@ int SYSTEM_SWAP_TOTAL(const char *cmd, const char *parameter,double *value, con
#ifdef HAVE_SYS_SWAP_SWAPTABLE
double swaptotal,swapfree;
- get_swapinfo(&swaptotal,&swapfree);
+ assert(result);
+
+ clean_result(result);
- *value=(double)swaptotal;
+ get_swapinfo(&swaptotal,&swapfree);
+
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)swaptotal;
return SYSINFO_RET_OK;
#else
- return SYSINFO_RET_FAIL;
-#endif
-#endif
-}
-#endif
+ assert(result);
-#if 0
-static int get_swap_data(
- uint64_t *resv,
- uint64_t *avail,
- uint64_t *free
- )
-{
- kstat_ctl_t *kc;
- kstat_t *ksp;
- vminfo_t *vm;
+ clean_result(result);
- uint64_t oresv;
- uint64_t ofree;
- uint64_t oavail;
-
- int result = SYSINFO_RET_FAIL;
- int i;
-
- kc = kstat_open();
- if (kc)
- {
- ksp = kstat_lookup(kc, "unix", 0, "vminfo");
- if ((ksp) && (kstat_read(kc, ksp, NULL) != -1))
- {
- vm = (vminfo_t *) ksp->ks_data;
-#if 0
- *resv = vm->swap_resv;
- *free = vm->swap_free;
- *avail = vm->swap_avail;
-
- result = SYSINFO_RET_OK;
-#else
- oresv = vm->swap_resv;
- ofree = vm->swap_free;
- oavail = vm->swap_avail;
-
- for (i = 0; i < 12; i++)
- {
- usleep(100000);
- if (kstat_read(kc, ksp, NULL) != -1)
- {
- vm = (vminfo_t *) ksp->ks_data;
- if ((oresv != vm->swap_resv) || (ofree != vm->swap_free) || (oavail != vm->swap_avail))
- {
- *resv = vm->swap_resv - oresv;
- *free = vm->swap_free - ofree;
- *avail = vm->swap_avail - oavail;
-
- result = SYSINFO_RET_OK;
- break;
- }
- }
- }
+ return SYSINFO_RET_FAIL;
+#endif
#endif
- }
- kstat_close(kc);
- }
- return result;
-}
-
-int SYSTEM_SWAP_FREE(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
-{
- int result;
- uint64_t resv = 0;
- uint64_t avail =0;
- uint64_t free = 0;
-
- result = get_swap_data(&resv, &avail, &free);
-
- if (result == SYSINFO_RET_OK)
- {
- *value = free * sysconf(_SC_PAGESIZE);
- }
- return result;
-}
-
-int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
-{
- int result;
- uint64_t resv = 0;
- uint64_t avail =0;
- uint64_t free = 0;
- uint64_t swap_total_bytes = 0;
-
- result = get_swap_data(&resv, &avail, &free);
-
- if (result == SYSINFO_RET_OK)
- {
- swap_total_bytes = (resv + avail) * sysconf(_SC_PAGESIZE);
- *value = (double) swap_total_bytes;
- }
- return result;
}
-#endif
#define DO_SWP_IN 1
#define DO_PG_IN 2
#define DO_SWP_OUT 3
#define DO_PG_OUT 4
-static int SYSTEM_SWAP(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+int get_swap_io(double *swapin, double *pgswapin, double *swapout, double *pgswapout)
{
kstat_ctl_t *kc;
kstat_t *k;
cpu_stat_t *cpu;
int cpu_count = 0;
- double swapin= 0.0;
-
- int do_info;
- char swp_info[MAX_STRING_LEN];
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, swp_info, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(strcmp(swp_info,"swapin") == 0)
- {
- do_info = DO_SWP_IN;
- }
- else if(strcmp(swp_info,"pgswapin") == 0)
- {
- do_info = DO_PG_IN;
- }
- else if(strcmp(swp_info,"swapout") == 0)
- {
- do_info = DO_SWP_OUT;
- }
- else if(strcmp(swp_info,"pgswapout") == 0)
- {
- do_info = DO_PG_OUT;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
kc = kstat_open();
@@ -430,25 +312,25 @@ static int SYSTEM_SWAP(const char *cmd, const char *param, double *value, const
(kstat_read(kc, k, NULL) != -1) )
{
cpu = (cpu_stat_t*) k->ks_data;
- if(do_info == DO_SWP_IN)
+ if(swapin)
{
/* uint_t swapin; // swapins */
- swapin += (double) cpu->cpu_vminfo.swapin;
+ (*swapin) += (double) cpu->cpu_vminfo.swapin;
}
- else if(do_info == DO_PG_IN)
+ else if(pgswapin)
{
/* uint_t pgswapin; // pages swapped in */
- swapin += (double) cpu->cpu_vminfo.pgswapin;
+ (*pgswapin) += (double) cpu->cpu_vminfo.pgswapin;
}
- else if(do_info == DO_SWP_OUT)
+ else if(swapout)
{
/* uint_t swapout; // swapout */
- swapin += (double) cpu->cpu_vminfo.swapin;
+ (*swapout) += (double) cpu->cpu_vminfo.swapout;
}
- else if(do_info == DO_PG_OUT)
+ else if(pgswapout)
{
/* uint_t pgswapout; // pages swapped out */
- swapin += (double) cpu->cpu_vminfo.swapin;
+ (*pgswapout) += (double) cpu->cpu_vminfo.pgswapout;
}
cpu_count += 1;
}
@@ -457,8 +339,6 @@ static int SYSTEM_SWAP(const char *cmd, const char *param, double *value, const
kstat_close(kc);
}
- *value = swapin;
-
if(cpu_count == 0)
{
return SYSINFO_RET_FAIL;
@@ -467,23 +347,119 @@ static int SYSTEM_SWAP(const char *cmd, const char *param, double *value, const
return SYSINFO_RET_OK;
}
-int SYSTEM_SWAP_IN_NUM(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+int SYSTEM_SWAP_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return SYSTEM_SWAP(cmd, "swapin", value, msg, mlen_max);
-}
+ int ret = SYSINFO_RET_FAIL;
+ char swapdev[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ double value = 0;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
-int SYSTEM_SWAP_IN_PAGES(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
-{
- return SYSTEM_SWAP(cmd, "pgswapin", value, msg, mlen_max);
-}
+ if(get_param(param, 1, swapdev, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
-int SYSTEM_SWAP_OUT_NUM(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
-{
- return SYSTEM_SWAP(cmd, "swapout", value, msg, mlen_max);
+ if(swapdev[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(swapdev, "all");
+ }
+
+ if(strncmp(swapdev, "all", MAX_STRING_LEN))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(strcmp(mode,"count") == 0)
+ {
+ ret = get_swap_io(&value, NULL, NULL, NULL);
+ }
+ else if(strcmp(mode,"pages") == 0)
+ {
+ ret = get_swap_io(NULL, &value, NULL, NULL);
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(ret != SYSINFO_RET_OK)
+ return ret;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+ return ret;
}
-int SYSTEM_SWAP_OUT_PAGES(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
+int SYSTEM_SWAP_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return SYSTEM_SWAP(cmd, "pgswapout", value, msg, mlen_max);
+ int ret = SYSINFO_RET_FAIL;
+ char swapdev[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ double value = 0;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, swapdev, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(swapdev[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(swapdev, "all");
+ }
+
+ if(strncmp(swapdev, "all", MAX_STRING_LEN))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(strcmp(mode,"count") == 0)
+ {
+ ret = get_swap_io(NULL, NULL, &value, NULL);
+ }
+ else if(strcmp(mode,"pages") == 0)
+ {
+ ret = get_swap_io(NULL, NULL, NULL, &value);
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(ret != SYSINFO_RET_OK)
+ return ret;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+ return ret;
}
diff --git a/src/libs/zbxsysinfo/solaris/uptime.c b/src/libs/zbxsysinfo/solaris/uptime.c
index fc5e21cf..814ad97d 100644
--- a/src/libs/zbxsysinfo/solaris/uptime.c
+++ b/src/libs/zbxsysinfo/solaris/uptime.c
@@ -19,124 +19,11 @@
#include "config.h"
-#include <errno.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-/* Definitions of uint32_t under OS/X */
-#ifdef HAVE_STDINT_H
- #include <stdint.h>
-#endif
-#ifdef HAVE_STRINGS_H
- #include <strings.h>
-#endif
-#ifdef HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#ifdef HAVE_DIRENT_H
- #include <dirent.h>
-#endif
-/* Linux */
-#ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_SYSINFO_H
- #include <sys/sysinfo.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_STATVFS_H
- #include <sys/statvfs.h>
-#endif
-/* Solaris */
-#ifdef HAVE_SYS_PROCFS_H
-/* This is needed to access the correct procfs.h definitions */
- #define _STRUCTURED_PROC 1
- #include <sys/procfs.h>
-#endif
-#ifdef HAVE_SYS_LOADAVG_H
- #include <sys/loadavg.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
-#endif
-/* OpenBSD/Solaris */
-#ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
-#endif
-
-/* HP-UX */
-#ifdef HAVE_SYS_PSTAT_H
- #include <sys/pstat.h>
-#endif
-
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SWAP_H
- #include <sys/swap.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_SYS_SYSCTL_H
- #include <sys/sysctl.h>
-#endif
-
-/* Solaris */
-#ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
-#endif
-
-/* FreeBSD */
-#ifdef HAVE_VM_VM_PARAM_H
- #include <vm/vm_param.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_VMMETER_H
- #include <sys/vmmeter.h>
-#endif
-/* FreeBSD */
-#ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
-#endif
-
-#ifdef HAVE_MACH_HOST_INFO_H
- #include <mach/host_info.h>
-#endif
-#ifdef HAVE_MACH_MACH_HOST_H
- #include <mach/mach_host.h>
-#endif
-
-
-#ifdef HAVE_KSTAT_H
- #include <kstat.h>
-#endif
-
-#ifdef HAVE_LDAP
- #include <ldap.h>
-#endif
-
#include "common.h"
#include "sysinfo.h"
#if 1
-int SYSTEM_UPTIME(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
+int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
kstat_ctl_t *kc;
kstat_t *kp;
@@ -144,7 +31,11 @@ int SYSTEM_UPTIME(const char *cmd, const char *param,double *value, const char
time_t now;
- int result = SYSINFO_RET_FAIL;
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
kc = kstat_open();
@@ -155,24 +46,30 @@ int SYSTEM_UPTIME(const char *cmd, const char *param,double *value, const char
{
kn = (kstat_named_t*) kstat_data_lookup(kp, "boot_time");
time(&now);
- *value=difftime(now, (time_t) kn->value.ul);
- result = SYSINFO_RET_OK;
+ result->type |= AR_DOUBLE;
+ result->dbl = difftime(now, (time_t) kn->value.ul);
+ ret = SYSINFO_RET_OK;
}
kstat_close(kc);
}
- return result;
+ return ret;
}
#endif
#if 0
-int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
+int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef HAVE_SYSINFO_UPTIME
struct sysinfo info;
+ assert(result);
+
+ clean_result(result);
+
if( 0 == sysinfo(&info))
{
- *value=(double)info.uptime;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)info.uptime;
return SYSINFO_RET_OK;
}
else
@@ -185,6 +82,10 @@ int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value, const c
struct timeval uptime;
int now;
+ assert(result);
+
+ clean_result(result);
+
mib[0]=CTL_KERN;
mib[1]=KERN_BOOTTIME;
@@ -197,8 +98,8 @@ int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value, const c
}
now=time(NULL);
-
- *value=(double)(now-uptime.tv_sec);
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)(now-uptime.tv_sec);
return SYSINFO_RET_OK;
#else
/* Solaris */
@@ -210,6 +111,10 @@ int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value, const c
long hz;
long secs;
+ assert(result);
+
+ clean_result(result);
+
hz = sysconf(_SC_CLK_TCK);
/* open kstat */
@@ -237,9 +142,14 @@ int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value, const c
/* close kstat */
kstat_close(kc);
- *value=(double)secs;
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)secs;
return SYSINFO_RET_OK;
#else
+ assert(result);
+
+ clean_result(result);
+
return SYSINFO_RET_FAIL;
#endif
#endif