summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-03 15:26:18 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-03 15:26:18 +0000
commitb82e7a27e4819f0e552fa9021836f15f486c3a93 (patch)
tree131d9df0687d09ff7db1ca73b3880871b60a9aab
parent483d80c4bfc8df13eaf069c6a6e05ea503dab7f3 (diff)
downloadzabbix-b82e7a27e4819f0e552fa9021836f15f486c3a93.tar.gz
zabbix-b82e7a27e4819f0e552fa9021836f15f486c3a93.tar.xz
zabbix-b82e7a27e4819f0e552fa9021836f15f486c3a93.zip
- integrated 'OpenBSD3.7.c' functionality (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2259 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog1
-rw-r--r--src/libs/zbxsysinfo/aix/aix.c20
-rw-r--r--src/libs/zbxsysinfo/aix/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/freebsd/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/freebsd/freebsd.c20
-rw-r--r--src/libs/zbxsysinfo/freebsd/net.c17
-rw-r--r--src/libs/zbxsysinfo/hpux/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/hpux/hpux.c20
-rw-r--r--src/libs/zbxsysinfo/hpux/net.c17
-rw-r--r--src/libs/zbxsysinfo/linux/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/linux/linux.c20
-rw-r--r--src/libs/zbxsysinfo/linux/net.c17
-rw-r--r--src/libs/zbxsysinfo/netbsd/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/netbsd/net.c17
-rw-r--r--src/libs/zbxsysinfo/netbsd/netbsd.c20
-rwxr-xr-xsrc/libs/zbxsysinfo/openbsd/OpenBSD3.7.c208
-rw-r--r--src/libs/zbxsysinfo/openbsd/cpu.c506
-rw-r--r--src/libs/zbxsysinfo/openbsd/diskio.c286
-rw-r--r--src/libs/zbxsysinfo/openbsd/kernel.c8
-rw-r--r--src/libs/zbxsysinfo/openbsd/memory.c384
-rw-r--r--src/libs/zbxsysinfo/openbsd/net.c382
-rw-r--r--src/libs/zbxsysinfo/openbsd/openbsd.c24
-rw-r--r--src/libs/zbxsysinfo/openbsd/swap.c328
-rw-r--r--src/libs/zbxsysinfo/openbsd/uptime.c19
-rw-r--r--src/libs/zbxsysinfo/osf/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/osf/net.c17
-rw-r--r--src/libs/zbxsysinfo/osf/osf.c20
-rw-r--r--src/libs/zbxsysinfo/osx/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/osx/net.c17
-rw-r--r--src/libs/zbxsysinfo/osx/osx.c20
-rw-r--r--src/libs/zbxsysinfo/solaris/solaris.c2
-rw-r--r--src/libs/zbxsysinfo/solaris/swap.c6
-rw-r--r--src/libs/zbxsysinfo/unknown/cpu.c18
-rw-r--r--src/libs/zbxsysinfo/unknown/net.c17
-rw-r--r--src/libs/zbxsysinfo/unknown/unknown.c20
35 files changed, 1462 insertions, 1115 deletions
diff --git a/ChangeLog b/ChangeLog
index 2104e17e..b5560754 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Changes for 1.1beta3:
+ - integrated 'OpenBSD3.7.c' functionality (Eugene)
- Applied ServerByName patch. (James)
- First pass at optimization of MySQL queries on reports page. (James)
- Fixed Groupid selection in triggers page (James)
diff --git a/src/libs/zbxsysinfo/aix/aix.c b/src/libs/zbxsysinfo/aix/aix.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/aix/aix.c
+++ b/src/libs/zbxsysinfo/aix/aix.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/aix/cpu.c b/src/libs/zbxsysinfo/aix/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/aix/cpu.c
+++ b/src/libs/zbxsysinfo/aix/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/freebsd/cpu.c b/src/libs/zbxsysinfo/freebsd/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/freebsd/cpu.c
+++ b/src/libs/zbxsysinfo/freebsd/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/freebsd/freebsd.c b/src/libs/zbxsysinfo/freebsd/freebsd.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/freebsd/freebsd.c
+++ b/src/libs/zbxsysinfo/freebsd/freebsd.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/freebsd/net.c b/src/libs/zbxsysinfo/freebsd/net.c
index 49867845..54c81126 100644
--- a/src/libs/zbxsysinfo/freebsd/net.c
+++ b/src/libs/zbxsysinfo/freebsd/net.c
@@ -42,3 +42,20 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_FAIL;
}
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/hpux/cpu.c b/src/libs/zbxsysinfo/hpux/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/hpux/cpu.c
+++ b/src/libs/zbxsysinfo/hpux/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/hpux/hpux.c b/src/libs/zbxsysinfo/hpux/hpux.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/hpux/hpux.c
+++ b/src/libs/zbxsysinfo/hpux/hpux.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/hpux/net.c b/src/libs/zbxsysinfo/hpux/net.c
index 49867845..54c81126 100644
--- a/src/libs/zbxsysinfo/hpux/net.c
+++ b/src/libs/zbxsysinfo/hpux/net.c
@@ -42,3 +42,20 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_FAIL;
}
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/linux/cpu.c b/src/libs/zbxsysinfo/linux/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/linux/cpu.c
+++ b/src/libs/zbxsysinfo/linux/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/linux/linux.c b/src/libs/zbxsysinfo/linux/linux.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/linux/linux.c
+++ b/src/libs/zbxsysinfo/linux/linux.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/linux/net.c b/src/libs/zbxsysinfo/linux/net.c
index 49867845..54c81126 100644
--- a/src/libs/zbxsysinfo/linux/net.c
+++ b/src/libs/zbxsysinfo/linux/net.c
@@ -42,3 +42,20 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_FAIL;
}
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/netbsd/cpu.c b/src/libs/zbxsysinfo/netbsd/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/netbsd/cpu.c
+++ b/src/libs/zbxsysinfo/netbsd/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/netbsd/net.c b/src/libs/zbxsysinfo/netbsd/net.c
index 49867845..54c81126 100644
--- a/src/libs/zbxsysinfo/netbsd/net.c
+++ b/src/libs/zbxsysinfo/netbsd/net.c
@@ -42,3 +42,20 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_FAIL;
}
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/netbsd/netbsd.c b/src/libs/zbxsysinfo/netbsd/netbsd.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/netbsd/netbsd.c
+++ b/src/libs/zbxsysinfo/netbsd/netbsd.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/openbsd/OpenBSD3.7.c b/src/libs/zbxsysinfo/openbsd/OpenBSD3.7.c
index 8aa09d53..fb3ea30d 100755
--- a/src/libs/zbxsysinfo/openbsd/OpenBSD3.7.c
+++ b/src/libs/zbxsysinfo/openbsd/OpenBSD3.7.c
@@ -144,12 +144,16 @@ typedef struct network_data
static NETWORK_DATA *interfaces;
static DISK_DATA *disks;
+/*
+ * ADDED to net.c
+ *
static struct nlist kernel_symbols[] =
{
{"_ifnet", N_UNDF, 0, 0, 0},
{"_tcbtable", N_UNDF, 0, 0, 0},
{NULL, 0, 0, 0, 0}
};
+*/
static DISK_DATA *get_disk_data_record(const char *device)
{
@@ -262,6 +266,10 @@ static int PROCCNT(const char *cmd, const char *procname,double *value, const c
return result;
}
+
+/*
+ * ADDED to devio.c
+ *
static int get_disk_stats(const char *device, struct diskstats *returned_stats)
{
int result = SYSINFO_RET_FAIL;
@@ -307,6 +315,10 @@ static int get_disk_stats(const char *device, struct diskstats *returned_stats)
return result;
}
+*/
+/*
+ * ADDED to devio.c
+ *
static int DISKREADOPS(const char *cmd, const char *device, double *value, const char *msg, int mlen_max)
{
int result = SYSINFO_RET_FAIL;
@@ -343,6 +355,10 @@ static int DISKREADOPS(const char *cmd, const char *device, double *value, cons
return result;
}
+*/
+/*
+ * ADDED to devio.c
+ *
static int DISKREADBLOCKS(const char *cmd, const char *device, double *value, const char *msg, int mlen_max)
{
int result = SYSINFO_RET_FAIL;
@@ -379,6 +395,10 @@ static int DISKREADBLOCKS(const char *cmd, const char *device, double *value, c
return result;
}
+*/
+/*
+ * ADDED to devio.c
+ *
static int DISKWRITEOPS(const char *cmd, const char *device, double *value, const char *msg, int mlen_max)
{
int result = SYSINFO_RET_FAIL;
@@ -414,7 +434,10 @@ static int DISKWRITEOPS(const char *cmd, const char *device, double *value, con
return result;
}
-
+*/
+/*
+ * ADDED to devio.c
+ *
static int DISKWRITEBLOCKS(const char *cmd, const char *device, double *value, const char *msg, int mlen_max)
{
int result = SYSINFO_RET_FAIL;
@@ -450,7 +473,7 @@ static int DISKWRITEBLOCKS(const char *cmd, const char *device, double *value,
return result;
}
-
+*/
static int DISKBUSY(const char *cmd, const char *device, double *value, const char *msg, int mlen_max)
{
int result = SYSINFO_RET_FAIL;
@@ -501,42 +524,48 @@ static int DISKBUSY(const char *cmd, const char *device, double *value, const c
return result;
}
+/*
+ * ADDED to cpu.c
+ *
static int CPUIDLE(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
{
- static u_int64_t last[CPUSTATES];
- u_int64_t current[CPUSTATES];
- int result = SYSINFO_RET_FAIL;
+ static u_int64_t last[cpustates];
+ u_int64_t current[cpustates];
+ int result = sysinfo_ret_fail;
int mib[2];
size_t l;
- mib[0] = CTL_KERN;
- mib[1] = KERN_CPTIME;
+ mib[0] = ctl_kern;
+ mib[1] = kern_cptime;
l = sizeof(current);
- if (sysctl(mib, 2, current, &l, NULL, 0) == 0 )
+ if (sysctl(mib, 2, current, &l, null, 0) == 0 )
{
u_int64_t interval_size;
- interval_size = (current[CP_IDLE] - last[CP_IDLE])
- + (current[CP_USER] - last[CP_USER])
- + (current[CP_NICE] - last[CP_NICE])
- + (current[CP_SYS] - last[CP_SYS])
- + (current[CP_INTR] - last[CP_INTR]);
+ interval_size = (current[cp_idle] - last[cp_idle])
+ + (current[cp_user] - last[cp_user])
+ + (current[cp_nice] - last[cp_nice])
+ + (current[cp_sys] - last[cp_sys])
+ + (current[cp_intr] - last[cp_intr]);
if (interval_size > 0)
{
- *value = ((current[CP_IDLE] - last[CP_IDLE]) * 100.0)/interval_size;
+ *value = ((current[cp_idle] - last[cp_idle]) * 100.0)/interval_size;
memcpy(&last, &current, sizeof(current));
- result = SYSINFO_RET_OK;
+ result = sysinfo_ret_ok;
}
}
return result;
}
-
+*/
+/*
+ * ADDED to cpu.c
+ *
static int CPUUSER(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
{
static u_int64_t last[CPUSTATES];
@@ -572,7 +601,10 @@ static int CPUUSER(const char *cmd, const char *param,double *value, const char
return result;
}
-
+*/
+/*
+ * ADDED to cpu.c
+ *
static int CPUSYSTEM(const char *cmd, const char *param,double *value, const char *msg, int mlen_max)
{
static u_int64_t last[CPUSTATES];
@@ -608,7 +640,10 @@ static int CPUSYSTEM(const char *cmd, const char *param,double *value, const ch
return result;
}
-
+*/
+/*
+ * ADDED to cpu.c
+ *
static int CPUNICE(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
{
static u_int64_t last[CPUSTATES];
@@ -644,7 +679,10 @@ static int CPUNICE(const char *cmd, const char *param, double *value, const char
return result;
}
-
+*/
+/*
+ * ADDED to cpu.c
+ *
static int CPUINTERRUPT(const char *cmd, const char *param, double *value, const char *msg, int mlen_max)
{
static u_int64_t last[CPUSTATES];
@@ -680,7 +718,11 @@ static int CPUINTERRUPT(const char *cmd, const char *param, double *value, const
return result;
}
+*/
+/*
+ * ADDED to net.c
+ *
static int get_ifdata(const char *device, struct if_data *returned_data)
{
int result = SYSINFO_RET_FAIL;
@@ -737,7 +779,10 @@ static int get_ifdata(const char *device, struct if_data *returned_data)
return result;
}
-
+*/
+/*
+ * ADDED to net.c
+ *
static int NETLOADIN(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result;
@@ -776,7 +821,10 @@ static int NETLOADIN(const char *cmd, const char *parameter,double *value, cons
return result;
}
-
+*/
+/*
+ * ADDED to net.c
+ *
static int NETPACKETSIN(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result;
@@ -815,7 +863,10 @@ static int NETPACKETSIN(const char *cmd, const char *parameter,double *value, c
return result;
}
-
+*/
+/*
+ * ADDED to net.c
+ *
static int NETERRSIN(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result;
@@ -830,7 +881,10 @@ static int NETERRSIN(const char *cmd, const char *parameter,double *value, cons
return result;
}
-
+*/
+/*
+ * ADDED to net.c
+ *
static int NETLOADOUT(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result;
@@ -869,7 +923,10 @@ static int NETLOADOUT(const char *cmd, const char *parameter,double *value, con
return result;
}
-
+*/
+/*
+ * ADDED to net.c
+ *
static int NETPACKETSOUT(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result;
@@ -908,7 +965,11 @@ static int NETPACKETSOUT(const char *cmd, const char *parameter,double *value,
return result;
}
+*/
+/*
+ * ADDED to net.c
+ *
static int NETERRSOUT(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result;
@@ -923,7 +984,10 @@ static int NETERRSOUT(const char *cmd, const char *parameter,double *value, con
return result;
}
-
+*/
+/*
+ * ADDED to net.c
+ *
static int NETCOLLOUT(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result;
@@ -938,7 +1002,10 @@ static int NETCOLLOUT(const char *cmd, const char *parameter,double *value, con
return result;
}
-
+*/
+/*
+ * IGNORED already added
+ *
int INODEFREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
{
struct statfs s;
@@ -951,7 +1018,10 @@ int INODEFREE(const char *cmd, const char *mountPoint,double *value, const
*value=s.f_ffree;
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * IGNORED already added
+ *
int INODETOTAL(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
{
struct statfs s;
@@ -964,8 +1034,10 @@ int INODETOTAL(const char *cmd, const char *mountPoint,double *value, const
*value=s.f_files;
return SYSINFO_RET_OK;
}
-
-
+*/
+/*
+ * IGNORED already added
+ *
int DISKFREE(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
{
struct statfs s;
@@ -978,7 +1050,10 @@ int DISKFREE(const char *cmd, const char *mountPoint,double *value, const c
*value=s.f_bavail*s.f_bsize;
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * IGNORED already added
+ *
int DISKUSED(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
{
struct statfs s;
@@ -991,7 +1066,10 @@ int DISKUSED(const char *cmd, const char *mountPoint,double *value, const c
*value=(s.f_blocks-s.f_bavail)*s.f_bsize;
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * IGNORED already added
+ *
int DISKTOTAL(const char *cmd, const char *mountPoint,double *value, const char *msg, int mlen_max)
{
struct statfs s;
@@ -1004,7 +1082,7 @@ int DISKTOTAL(const char *cmd, const char *mountPoint,double *value, const
*value= s.f_blocks*s.f_bsize;
return SYSINFO_RET_OK;
}
-
+*/
static int TCP_LISTEN(const char *cmd, const char *porthex, double *value, const char *msg, int mlen_max)
{
@@ -1068,6 +1146,7 @@ static int TCP_LISTEN(const char *cmd, const char *porthex, double *value, cons
return result;
}
+
static int count_active_sockets()
{
kvm_t *kp;
@@ -1226,6 +1305,9 @@ static int TCP_SOCKETS_OUT(const char *cmd, const char *parameter,double *value
return SYSINFO_RET_OK;
}
+/*
+ * ADDED to memory.c
+ *
static int TOTALMEM(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1242,7 +1324,10 @@ static int TOTALMEM(const char *cmd, const char *parameter,double *value, const
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * ADDED to memory.c
+ *
static int FREEMEM(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1259,7 +1344,10 @@ static int FREEMEM(const char *cmd, const char *parameter,double *value, const
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * SKIPED - already added
+ *
static int KERNEL_MAXFILES(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1279,7 +1367,10 @@ static int KERNEL_MAXFILES(const char *cmd, const char *parameter,double *value
*value=(double)(maxfiles);
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * SKIPED - already added
+ *
static int KERNEL_MAXPROC(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1294,13 +1385,15 @@ static int KERNEL_MAXPROC(const char *cmd, const char *parameter,double *va
if(sysctl(mib,2,&maxproc,(size_t *)&len,NULL,0) != 0)
{
return SYSINFO_RET_FAIL;
-/* printf("Errno [%m]");*/
}
*value=(double)(maxproc);
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * ADDED to uptime.c
+ *
static int UPTIME(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1316,7 +1409,6 @@ static int UPTIME(const char *cmd, const char *parameter,double *value, con
if(sysctl(mib,2,&uptime,(size_t *)&len,NULL,0) != 0)
{
return SYSINFO_RET_FAIL;
-/* printf("Errno [%m]\n");*/
}
now=time(NULL);
@@ -1324,7 +1416,10 @@ static int UPTIME(const char *cmd, const char *parameter,double *value, con
*value=(double)(now-uptime.tv_sec);
return SYSINFO_RET_OK;
}
-
+*/
+/*
+ * ADDED to cpu.c
+ *
static int PROCLOAD(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
double load[3];
@@ -1339,7 +1434,10 @@ static int PROCLOAD(const char *cmd, const char *parameter,double *value, c
return SYSINFO_RET_FAIL;
}
}
-
+*/
+/*
+ * ADDED to cpu.c
+ *
static int PROCLOAD5(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
double load[3];
@@ -1354,7 +1452,10 @@ static int PROCLOAD5(const char *cmd, const char *parameter,double *value,
return SYSINFO_RET_FAIL;
}
}
-
+*/
+/*
+ * ADDED to cpu.c
+ *
static int PROCLOAD15(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
double load[3];
@@ -1369,7 +1470,10 @@ static int PROCLOAD15(const char *cmd, const char *parameter,double *value,
return SYSINFO_RET_FAIL;
}
}
-
+*/
+/*
+ * ADDED TO cwap.c
+ *
static int SWAPFREE(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1391,7 +1495,10 @@ static int SWAPFREE(const char *cmd, const char *parameter,double *value, const
else
return SYSINFO_RET_FAIL;
}
-
+*/
+/*
+ * ADDED TO cwap.c
+ *
static int SWAPTOTAL(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1413,7 +1520,10 @@ static int SWAPTOTAL(const char *cmd, const char *parameter,double *value,
else
return SYSINFO_RET_FAIL;
}
-
+*/
+/*
+ * ADDED TO cwap.c
+ *
static int SWAPIN(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1435,7 +1545,9 @@ static int SWAPIN(const char *cmd, const char *parameter,double *value, const c
else
return SYSINFO_RET_FAIL;
}
-
+*/
+/*
+ * ADDED to swap.c
static int SWAPOUT(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int mib[2];
@@ -1457,7 +1569,7 @@ static int SWAPOUT(const char *cmd, const char *parameter,double *value, const
else
return SYSINFO_RET_FAIL;
}
-
+*/
static int PROCCOUNT(const char *cmd, const char *parameter,double *value, const char *msg, int mlen_max)
{
int result = SYSINFO_RET_FAIL;
@@ -1571,6 +1683,9 @@ static int INTERRUPTS(const char *cmd, const char *parameter,double *value, con
return SYSINFO_RET_FAIL;
}
+/*
+ * IGNORED
+ *
#ifdef HAVE_LDAP
static int check_ldap(char *hostname, short port,int *value, const char *msg, int mlen_max)
{
@@ -1628,6 +1743,7 @@ static int check_ldap(char *hostname, short port,int *value, const char *msg,
return SYSINFO_RET_OK;
}
#endif
+*/
ZBX_METRIC agent_commands[]=
/* KEY FUNCTION (if double) FUNCTION (if string) PARAM*/
diff --git a/src/libs/zbxsysinfo/openbsd/cpu.c b/src/libs/zbxsysinfo/openbsd/cpu.c
index 4e7e1502..c96ac331 100644
--- a/src/libs/zbxsysinfo/openbsd/cpu.c
+++ b/src/libs/zbxsysinfo/openbsd/cpu.c
@@ -22,198 +22,144 @@
#include "common.h"
#include "sysinfo.h"
-static int SYSTEM_CPU_IDLE1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[idle1]", flags, result);
-}
-
-static int SYSTEM_CPU_IDLE5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[idle5]", flags, result);
-}
-
-static int SYSTEM_CPU_IDLE15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[idle15]", flags, result);
-}
-
-static int SYSTEM_CPU_NICE1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[nice1]", flags, result);
-}
-
-static int SYSTEM_CPU_NICE5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[nice5]", flags, result);
-}
-static int SYSTEM_CPU_NICE15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- return get_stat("cpu[nice15]", flags, result);
+ return get_stat(cmd, flags, result);
}
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int get_cpu_data(unsigned long long *idle,
+ unsigned long long *user,
+ unsigned long long *nice,
+ unsigned long long *system,
+ unsigned long long *intr)
{
- return get_stat("cpu[user1]", flags, result);
-}
+ static u_int64_t last[CPUSTATES];
+ int ret = SYSINFO_RET_FAIL;
+ int mib[2];
+ size_t l;
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_CLOCKRATE;
-static int SYSTEM_CPU_USER15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user15]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system1]", flags, result);
-}
+ l = sizeof(value);
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
+ if (sysctl(mib, 2, value, &l, null, 0) == 0 )
+ {
+ (*idle) = value[CP_IDLE];
+ (*usr) = value[CP_USER];
+ (*nice) = value[CP_NICE];
+ (*system) = value[CP_SYS];
+ (*intr) = value[CP_INTR];
+ ret = SYSINFO_RET_OK;
+ }
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
+ return ret;
}
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#define CPU_I 0
+#define CPU_U 1
+#define CPU_N 2
+#define CPU_S 3
+#define CPU_T 4
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
+#define CPU_PARAMLIST struct cpy_paramlist_s
+CPU_PARAMLIST
{
- char *type;
- char *mode;
- int (*function)();
+ char *mode;
+ int id;
};
- CPU_FNCLIST fl[] =
+ CPU_PARAMLIST pl[] =
{
- {"idle", "avg1" , SYSTEM_CPU_IDLE1},
- {"idle", "avg5" , SYSTEM_CPU_IDLE5},
- {"idle", "avg15", SYSTEM_CPU_IDLE15},
- {"nice", "avg1" , SYSTEM_CPU_NICE1},
- {"nice", "avg5" , SYSTEM_CPU_NICE5},
- {"nice", "avg15", SYSTEM_CPU_NICE15},
- {"user", "avg1" , SYSTEM_CPU_USER1},
- {"user", "avg5" , SYSTEM_CPU_USER5},
- {"user", "avg15", SYSTEM_CPU_USER15},
- {"system", "avg1" , SYSTEM_CPU_SYS1},
- {"system", "avg5" , SYSTEM_CPU_SYS5},
- {"system", "avg15", SYSTEM_CPU_SYS15},
- {0, 0, 0}
+ {"idle" , CPU_I},
+ {"user" , CPU_U},
+ {"nice", CPU_N},
+ {"system", CPU_S},
+ {"intr", CPU_T},
+ {0, 0}
};
- char cpuname[MAX_STRING_LEN];
- char type[MAX_STRING_LEN];
- char mode[MAX_STRING_LEN];
- int i;
-
- assert(result);
-
- clean_result(result);
-
- if(num_param(param) > 3)
- {
- 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, type, MAX_STRING_LEN) != 0)
- {
- type[0] = '\0';
- }
- if(type[0] == '\0')
- {
- /* default parameter */
- sprintf(type, "user");
- }
-
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
- {
- mode[0] = '\0';
- }
-
- if(mode[0] == '\0')
- {
- /* default parameter */
- sprintf(mode, "avg1");
- }
-
- for(i=0; fl[i].type!=0; i++)
- {
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
+ unsigned long long cpu_val[5];
+ unsigned long long interval_size;
+
+ char cpuname[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+
+ int info_id = 0;
+
+ int ret = SYSINFO_RET_FAIL;
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ 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;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ strscpy(mode, pl[0].mode);
+ }
+
+ for(i=0; pl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, pl[i].mode, MAX_STRING_LEN)==0)
{
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ ret = get_cpu_data(
+ &cpu_val[CPU_I],
+ &cpu_val[CPU_U],
+ &cpu_val[CPU_N],
+ &cpu_val[CPU_S],
+ &cpu_val[CPU_T]);
+
+ if(ret == SYSINFO_RET_OK)
{
- return (fl[i].function)(cmd, param, flags, result);
+ interval_size =
+ cpu_val[CPU_I] +
+ cpu_val[CPU_U] +
+ cpu_val[CPU_N] +
+ cpu_val[CPU_S] +
+ cpu_val[CPU_T];
+
+ if (interval_size > 0)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = (cpu_val[pl[i].id] * 100.0)/interval_size;
+
+ ret = SYSINFO_RET_OK;
+ }
}
+ break;
}
}
- return SYSINFO_RET_FAIL;
-}
-
-/* AIX CPU info */
-#ifdef HAVE_KNLIST_H
-static int getloadavg_kmem(double loadavg[], int nelem)
-{
- struct nlist nl;
- int kmem, i;
- long avenrun[3];
- nl.n_name = "avenrun";
- nl.n_value = 0;
-
- if(knlist(&nl, 1, sizeof(nl)))
- {
- return FAIL;
- }
- if((kmem = open("/dev/kmem", 0, 0)) <= 0)
- {
- return FAIL;
- }
-
- if(pread(kmem, avenrun, sizeof(avenrun), nl.n_value) <
- sizeof(avenrun))
- {
- return FAIL;
- }
-
- for(i=0;i<nelem;i++)
- {
- loadavg[i] = (double) avenrun[i] / 65535;
- }
- return SUCCEED;
+ return ret;
}
-#endif
int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_GETLOADAVG
double load[3];
+ int ret = SYSINFO_RET_FAIL;
assert(result);
@@ -223,88 +169,16 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
{
result->type |= AR_DOUBLE;
result->dbl = load[0];
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
+ ret = SYSINFO_RET_OK;
}
-#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_dynamic dyn;
-
- assert(result);
-
- clean_result(result);
-
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
- result->type |= AR_DOUBLE;
- result->dbl = (double)dyn.psd_avg_1_min;
- return SYSINFO_RET_OK;
- }
-#else
-#ifdef HAVE_PROC_LOADAVG
- return getPROC("/proc/loadavg",1,1, flags, result);
-#else
-#ifdef HAVE_KSTAT_H
- static kstat_ctl_t *kc = NULL;
- kstat_t *ks;
- kstat_named_t *kn;
-
- assert(result);
-
- clean_result(result);
- if (!kc && !(kc = kstat_open()))
- {
- return SYSINFO_RET_FAIL;
- }
- if (!(ks = kstat_lookup(kc, "unix", 0, "system_misc")) ||
- kstat_read(kc, ks, 0) == -1 ||
- !(kn = kstat_data_lookup(ks,"avenrun_1min")))
- {
- return SYSINFO_RET_FAIL;
- }
- result->type |= AR_DOUBLE;
- result->dbl = (double)kn->value.ul/256.0;
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- assert(result);
-
- clean_result(result);
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return SYSINFO_RET_FAIL;
- }
-
- result->type |= AR_DOUBLE;
- result->dbl = loadavg[0];
- return SYSINFO_RET_OK;
-#else
- assert(result);
-
- clean_result(result);
- return SYSINFO_RET_FAIL;
-#endif
-#endif
-#endif
-#endif
-#endif
+ return ret;
}
int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_GETLOADAVG
double load[3];
+ int ret = SYSINFO_RET_FAIL;
assert(result);
@@ -314,173 +188,29 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
{
result->type |= AR_DOUBLE;
result->dbl = load[1];
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
+ ret = SYSINFO_RET_OK;
}
-#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_dynamic dyn;
-
- assert(result);
-
- clean_result(result);
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
- result->type |= AR_DOUBLE;
- result->dbl = (double)dyn.psd_avg_5_min;
- return SYSINFO_RET_OK;
- }
-#else
-#ifdef HAVE_PROC_LOADAVG
- return getPROC("/proc/loadavg",1,2, flags, result);
-#else
-#ifdef HAVE_KSTAT_H
- static kstat_ctl_t *kc = NULL;
- kstat_t *ks;
- kstat_named_t *kn;
-
- assert(result);
-
- clean_result(result);
-
- if (!kc && !(kc = kstat_open()))
- {
- return SYSINFO_RET_FAIL;
- }
- if (!(ks = kstat_lookup(kc, "unix", 0, "system_misc")) ||
- kstat_read(kc, ks, 0) == -1 ||
- !(kn = kstat_data_lookup(ks,"avenrun_5min")))
- {
- return SYSINFO_RET_FAIL;
- }
- result->type |= AR_DOUBLE;
- result->dbl = (double)kn->value.ul/256.0;
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- assert(result);
-
- clean_result(result);
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return STSINFO_RET_FAIL;
- }
-
- result->type |= AR_DOUBLE;
- result->dbl = loadavg[1];
- return SYSINFO_RET_OK;
-#else
- assert(result);
-
- clean_result(result);
- return SYSINFO_RET_FAIL;
-#endif
-#endif
-#endif
-#endif
-#endif
+ return ret;
}
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))
- {
- result->type |= AR_DOUBLE;
- result->dbl = load[2];
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_dynamic dyn;
+ int ret = SYSINFO_RET_FAIL;
assert(result);
clean_result(result);
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
+ if(getloadavg(load, 3))
{
result->type |= AR_DOUBLE;
- result->dbl = (double)dyn.psd_avg_15_min;
- return SYSINFO_RET_OK;
+ result->dbl = load[2];
+ ret = SYSINFO_RET_OK;
}
-#else
-#ifdef HAVE_PROC_LOADAVG
- return getPROC("/proc/loadavg",1,3, flags, result);
-#else
-#ifdef HAVE_KSTAT_H
- static kstat_ctl_t *kc = NULL;
- kstat_t *ks;
- kstat_named_t *kn;
-
- assert(result);
-
- clean_result(result);
-
- if (!kc && !(kc = kstat_open()))
- {
- return SYSINFO_RET_FAIL;
- }
- if (!(ks = kstat_lookup(kc, "unix", 0, "system_misc")) ||
- kstat_read(kc, ks, 0) == -1 ||
- !(kn = kstat_data_lookup(ks,"avenrun_15min")))
- {
- return SYSINFO_RET_FAIL;
- }
- result->type |= AR_DOUBLE;
- result->dbl = (double)kn->value.ul/256.0;
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- assert(result);
-
- clean_result(result);
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return STSINFO_RET_FAIL;
- }
-
- result->type |= AR_DOUBLE;
- result->dbl = loadavg[2];
- return SYSINFO_RET_OK;
-#else
- assert(result);
-
- clean_result(result);
- return SYSINFO_RET_FAIL;
-#endif
-#endif
-#endif
-#endif
-#endif
+ return ret;
}
int SYSTEM_CPU_LOAD(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
diff --git a/src/libs/zbxsysinfo/openbsd/diskio.c b/src/libs/zbxsysinfo/openbsd/diskio.c
index 23d0c450..181eaf3d 100644
--- a/src/libs/zbxsysinfo/openbsd/diskio.c
+++ b/src/libs/zbxsysinfo/openbsd/diskio.c
@@ -22,112 +22,166 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int get_disk_stats(const char *device, struct diskstats *returned_stats)
{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKREADOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKREADOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKREADBLKS1(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]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKREADBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKREADBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_read_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+ int mib[2];
+ int drive_count;
+ size_t l;
+ struct diskstats *stats;
+ int i;
- snprintf(key,sizeof(key)-1,"disk_write_ops1[%s]",param);
+ mib[0] = CTL_HW;
+ mib[1] = HW_DISKCOUNT;
- return get_stat(key, flags, result);
-}
+ l = sizeof(drive_count);
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- snprintf(key,sizeof(key)-1,"disk_write_ops5[%s]",param);
+ if (sysctl(mib, 2, &drive_count, &l, NULL, 0) == 0 )
+ {
+ l = (drive_count * sizeof(struct diskstats));
+ stats = calloc(drive_count, l);
+ if (stats)
+ {
+ mib[0] = CTL_HW;
+ mib[1] = HW_DISKSTATS;
+
+ if (sysctl(mib, 2, stats, &l, NULL, 0) == 0)
+ {
+ for (i = 0; i < drive_count; i++)
+ {
+ if (strcmp(device, stats[i].ds_name) == 0)
+ {
+ memmove(result, &stats[i], sizeof(struct diskstats));
+ ret = SYSINFO_RET_OK;
+ break;
+ }
+ }
+ }
- return get_stat(key, flags, result);
+ free(stats);
+ }
+ }
+ return ret;
}
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VFS_DEV_READ_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- char key[MAX_STRING_LEN];
+ char devname[MAX_STRING_LEN];
+ struct diskstats ds;
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
- snprintf(key,sizeof(key)-1,"disk_write_ops15[%s]",param);
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
- return get_stat(key, flags, result);
+ if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = ds.ds_rbytes;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
}
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VFS_DEV_READ_OPERATIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- char key[MAX_STRING_LEN];
+ char devname[MAX_STRING_LEN];
+ struct diskstats ds;
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
- snprintf(key,sizeof(key)-1,"disk_write_blks1[%s]",param);
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
- return get_stat(key, flags, result);
+ if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = ds.ds_rxfer;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
}
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VFS_DEV_WRITE_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- char key[MAX_STRING_LEN];
+ char devname[MAX_STRING_LEN];
+ struct diskstats ds;
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
- snprintf(key,sizeof(key)-1,"disk_write_blks5[%s]",param);
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
- return get_stat(key, flags, result);
+ if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = ds.ds_wbytes;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
}
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int VFS_DEV_WRITE_OPERATIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- char key[MAX_STRING_LEN];
+ char devname[MAX_STRING_LEN];
+ struct diskstats ds;
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
- snprintf(key,sizeof(key)-1,"disk_write_blks15[%s]",param);
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
- return get_stat(key, flags, result);
+ if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = ds.ds_wxfer;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
}
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -136,24 +190,18 @@ int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESU
#define DEV_FNCLIST struct dev_fnclist_s
DEV_FNCLIST
{
- char *type;
char *mode;
int (*function)();
};
DEV_FNCLIST fl[] =
{
- {"ops", "avg1" , DISKWRITEOPS1},
- {"ops", "avg5" , DISKWRITEOPS5},
- {"ops", "avg15", DISKWRITEOPS15},
- {"bps", "avg1" , DISKWRITEBLKS1},
- {"bps", "avg5" , DISKWRITEBLKS5},
- {"bps", "avg15", DISKWRITEBLKS15},
- {0, 0, 0}
+ {"bytes", VFS_DEV_WRITE_BYTES},
+ {"operations", VFS_DEV_WRITE_OPERATIONS},
+ {0, 0}
};
char devname[MAX_STRING_LEN];
- char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
int i;
@@ -171,17 +219,7 @@ DEV_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, MAX_STRING_LEN) != 0)
- {
- type[0] = '\0';
- }
- if(type[0] == '\0')
- {
- /* default parameter */
- sprintf(type, "bps");
- }
-
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
{
mode[0] = '\0';
}
@@ -189,17 +227,14 @@ DEV_FNCLIST
if(mode[0] == '\0')
{
/* default parameter */
- sprintf(mode, "avg1");
+ sprintf(mode, fl[0].mode);
}
- for(i=0; fl[i].type!=0; i++)
+ for(i=0; fl[i].mode!=0; i++)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
{
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
+ return (fl[i].function)(cmd, devname, flags, result);
}
}
@@ -212,24 +247,18 @@ int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
#define DEV_FNCLIST struct dev_fnclist_s
DEV_FNCLIST
{
- char *type;
char *mode;
int (*function)();
};
DEV_FNCLIST fl[] =
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
+ {"bytes", VFS_DEV_READ_BYTES},
+ {"operations", VFS_DEV_READ_OPERATIONS},
+ {0, 0}
};
char devname[MAX_STRING_LEN];
- char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
int i;
@@ -247,17 +276,7 @@ DEV_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, MAX_STRING_LEN) != 0)
- {
- type[0] = '\0';
- }
- if(type[0] == '\0')
- {
- /* default parameter */
- sprintf(type, "bps");
- }
-
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
{
mode[0] = '\0';
}
@@ -265,17 +284,14 @@ DEV_FNCLIST
if(mode[0] == '\0')
{
/* default parameter */
- sprintf(mode, "avg1");
+ sprintf(mode, fl[0].mode);
}
- for(i=0; fl[i].type!=0; i++)
+ for(i=0; fl[i].mode!=0; i++)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
{
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
+ return (fl[i].function)(cmd, devname, flags, result);
}
}
diff --git a/src/libs/zbxsysinfo/openbsd/kernel.c b/src/libs/zbxsysinfo/openbsd/kernel.c
index 14157f22..2e122ed6 100644
--- a/src/libs/zbxsysinfo/openbsd/kernel.c
+++ b/src/libs/zbxsysinfo/openbsd/kernel.c
@@ -24,7 +24,6 @@
int KERNEL_MAXFILES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_FUNCTION_SYSCTL_KERN_MAXFILES
int mib[2],len;
int maxfiles;
@@ -45,14 +44,10 @@ int KERNEL_MAXFILES(const char *cmd, const char *param, unsigned flags, AGENT_RE
result->type |= AR_DOUBLE;
result->dbl = (double)(maxfiles);
return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
}
int KERNEL_MAXPROC(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_FUNCTION_SYSCTL_KERN_MAXPROC
int mib[2],len;
int maxproc;
@@ -74,9 +69,6 @@ int KERNEL_MAXPROC(const char *cmd, const char *param, unsigned flags, AGENT_RES
result->type |= AR_DOUBLE;
result->dbl = (double)(maxproc);
return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
}
int OLD_KERNEL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
diff --git a/src/libs/zbxsysinfo/openbsd/memory.c b/src/libs/zbxsysinfo/openbsd/memory.c
index 7dc0fcbe..82af3bd5 100644
--- a/src/libs/zbxsysinfo/openbsd/memory.c
+++ b/src/libs/zbxsysinfo/openbsd/memory.c
@@ -22,366 +22,76 @@
#include "common.h"
#include "sysinfo.h"
-static int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
-#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 res = 0;
-
- assert(result);
-
- clean_result(result);
-
- f=fopen("/proc/meminfo","r");
- if(NULL == f)
- {
- return SYSINFO_RET_FAIL;
- }
- while(NULL!=fgets(c,MAX_STRING_LEN,f))
- {
- if(strncmp(c,"Cached:",7) == 0)
- {
- t=(char *)strtok(c," ");
- t=(char *)strtok(NULL," ");
- sscanf(t, "%lf", &res );
- break;
- }
- }
- fclose(f);
-
- result->type |= AR_DOUBLE;
- result->dbl=res;
- return SYSINFO_RET_OK;
-#else
- assert(result);
-
- clean_result(result);
-
- return SYSINFO_RET_FAIL;
-#endif
-}
-
-static int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
-#ifdef HAVE_SYSINFO_BUFFERRAM
- struct sysinfo info;
-
- assert(result);
-
- clean_result(result);
-
- if( 0 == sysinfo(&info))
- {
- result->type |= AR_DOUBLE;
-#ifdef HAVE_SYSINFO_MEM_UNIT
- result->dbl=(double)info.bufferram * (double)info.mem_unit;
-#else
- result->dbl=(double)info.bufferram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
- assert(result);
-
- clean_result(result);
-
- return SYSINFO_RET_FAIL;
-#endif
-}
-
static int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYSINFO_SHAREDRAM
- struct sysinfo info;
-
- assert(result);
-
- clean_result(result);
-
- if( 0 == sysinfo(&info))
- {
- result->type |= AR_DOUBLE;
-#ifdef HAVE_SYSINFO_MEM_UNIT
- result->dbl=(double)info.sharedram * (double)info.mem_unit;
-#else
- result->dbl=(double)info.sharedram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#elif defined(HAVE_SYS_VMMETER_VMTOTAL)
- int mib[2],len;
+ int mib[2];
+ size_t len;
struct vmtotal v;
-
+ int ret=SYSINFO_RET_FAIL;
+
assert(result);
clean_result(result);
- len=sizeof(struct vmtotal);
+ len=sizeof(v);
mib[0]=CTL_VM;
mib[1]=VM_METER;
- sysctl(mib,2,&v,&len,NULL,0);
-
- result->type |= AR_DOUBLE;
- result->dbl=(double)(v.t_armshr<<2);
- return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
-}
-
-static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
-/* Solaris */
-#ifdef HAVE_UNISTD_SYSCONF
- assert(result);
-
- clean_result(result);
-
- result->type |= AR_DOUBLE;
- result->dbl=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
- return SYSINFO_RET_OK;
-#elif defined(HAVE_SYS_PSTAT_H)
- struct pst_static pst;
- long page;
-
- assert(result);
-
- clean_result(result);
-
- if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
+ if(0==sysctl(mib,2,&v,&len,NULL,0))
{
- /* Get page size */
- page = pst.page_size;
- /* Total physical memory in bytes */
result->type |= AR_DOUBLE;
- result->dbl=(double)page*pst.physical_memory;
- return SYSINFO_RET_OK;
+ result->dbl=(double)(t_rmshr * sysconf(_SC_PAGESIZE));
+ ret=SYSINFO_RET_OK;
}
-#elif defined(HAVE_SYSINFO_TOTALRAM)
- struct sysinfo info;
-
- assert(result);
+ return ret;
+}
- clean_result(result);
-
- if( 0 == sysinfo(&info))
- {
- result->type |= AR_DOUBLE;
-#ifdef HAVE_SYSINFO_MEM_UNIT
- result->dbl=(double)info.totalram * (double)info.mem_unit;
-#else
- result->dbl=(double)info.totalram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#elif defined(HAVE_SYS_VMMETER_VMTOTAL)
- int mib[2],len;
+static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ int mib[2];
+ size_t len;
struct vmtotal v;
-
+ int ret=SYSINFO_RET_FAIL;
+
assert(result);
clean_result(result);
- len=sizeof(struct vmtotal);
+ len=sizeof(v);
mib[0]=CTL_VM;
mib[1]=VM_METER;
- sysctl(mib,2,&v,&len,NULL,0);
-
- result->type |= AR_DOUBLE;
- result->dbl=(double)(v.t_rm<<2);
- return SYSINFO_RET_OK;
-#elif defined(HAVE_SYS_SYSCTL_H)
- static int mib[] = { CTL_HW, HW_PHYSMEM };
- size_t len;
- unsigned int memory;
- int ret;
-
- assert(result);
-
- clean_result(result);
-
- len=sizeof(memory);
-
- if(0==sysctl(mib,2,&memory,&len,NULL,0))
+ if(0==sysctl(mib,2,&v,&len,NULL,0))
{
result->type |= AR_DOUBLE;
- result->dbl=(double)memory;
+ result->dbl=(double)((v.t_rm+v.t_free) * sysconf(_SC_PAGESIZE));
ret=SYSINFO_RET_OK;
}
- else
- {
- ret=SYSINFO_RET_FAIL;
- }
return ret;
-#else
- assert(result);
-
- clean_result(result);
-
- return SYSINFO_RET_FAIL;
-#endif
}
static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-/* Solaris */
-#ifdef HAVE_UNISTD_SYSCONF
- assert(result);
-
- clean_result(result);
-
- result->type |= AR_DOUBLE;
- result->dbl=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
- return SYSINFO_RET_OK;
-#elif defined(HAVE_SYS_PSTAT_H)
- struct pst_static pst;
- struct pst_dynamic dyn;
- long page;
-
- assert(result);
-
- clean_result(result);
-
- if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
- /* Get page size */
- page = pst.page_size;
-/* return pst.physical_memory;*/
-
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
-/* cout<<"total virtual memory allocated is " << dyn.psd_vm << "
- pages, " << dyn.psd_vm * page << " bytes" << endl;
- cout<<"active virtual memory is " << dyn.psd_avm <<" pages, " <<
- dyn.psd_avm * page << " bytes" << endl;
- cout<<"total real memory is " << dyn.psd_rm << " pages, " <<
- dyn.psd_rm * page << " bytes" << endl;
- cout<<"active real memory is " << dyn.psd_arm << " pages, " <<
- dyn.psd_arm * page << " bytes" << endl;
- cout<<"free memory is " << dyn.psd_free << " pages, " <<
-*/
- /* Free memory in bytes */
-
- result->type |= AR_DOUBLE;
- result->dbl=(double)dyn.psd_free * page;
- return SYSINFO_RET_OK;
- }
- }
-#elif defined(HAVE_SYSINFO_FREERAM)
- struct sysinfo info;
-
- assert(result);
-
- clean_result(result);
-
- if( 0 == sysinfo(&info))
- {
- result->type |= AR_DOUBLE;
-#ifdef HAVE_SYSINFO_MEM_UNIT
- result->dbl=(double)info.freeram * (double)info.mem_unit;
-#else
- result->dbl=(double)info.freeram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#elif defined(HAVE_SYS_VMMETER_VMTOTAL)
- int mib[2],len;
+ int mib[2];
+ size_t len;
struct vmtotal v;
-
+ int ret=SYSINFO_RET_FAIL;
+
assert(result);
clean_result(result);
- len=sizeof(struct vmtotal);
+ len=sizeof(v);
mib[0]=CTL_VM;
mib[1]=VM_METER;
- sysctl(mib,2,&v,&len,NULL,0);
-
- result->type |= AR_DOUBLE;
- result->dbl=(double)(v.t_free<<2);
- return SYSINFO_RET_OK;
-/* OS/X */
-#elif defined(HAVE_MACH_HOST_INFO_H)
- vm_statistics_data_t page_info;
- vm_size_t pagesize;
- mach_msg_type_number_t count;
- kern_return_t kret;
- int ret;
-
- assert(result);
-
- clean_result(result);
-
- pagesize = 0;
- kret = host_page_size (mach_host_self(), &pagesize);
-
- count = HOST_VM_INFO_COUNT;
- kret = host_statistics (mach_host_self(), HOST_VM_INFO,
- (host_info_t)&page_info, &count);
- if (kret == KERN_SUCCESS)
+ if(0==sysctl(mib,2,&v,&len,NULL,0))
{
- double pw, pa, pi, pf, pu;
-
- pw = (double)page_info.wire_count*pagesize;
- pa = (double)page_info.active_count*pagesize;
- pi = (double)page_info.inactive_count*pagesize;
- pf = (double)page_info.free_count*pagesize;
-
- pu = pw+pa+pi;
-
result->type |= AR_DOUBLE;
- result->dbl=(double)pf;
- ret = SYSINFO_RET_OK;
- }
- else
- {
- ret = SYSINFO_RET_FAIL;
+ result->dbl=(double)(v.t_free * sysconf(_SC_PAGESIZE));
+ ret=SYSINFO_RET_OK;
}
return ret;
-#else
- assert(result);
-
- clean_result(result);
-
- return SYSINFO_RET_FAIL;
-#endif
}
int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -398,12 +108,11 @@ MEM_FNCLIST
{"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];
- int i;
+ int ret = SYSINFO_RET_FAIL;
+ int i;
assert(result);
@@ -411,28 +120,29 @@ MEM_FNCLIST
if(num_param(param) > 1)
{
- return SYSINFO_RET_FAIL;
+ ret = SYSINFO_RET_FAIL;
}
+ else
+ {
+ if(get_param(param, 1, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
- if(get_param(param, 1, mode, MAX_STRING_LEN) != 0)
- {
- mode[0] = '\0';
- }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "total");
+ }
- 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)
+ for(i=0; fl[i].mode!=0; i++)
{
- return (fl[i].function)(cmd, param, flags, result);
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ ret = (fl[i].function)(cmd, param, flags, result);
+ }
}
}
-
- return SYSINFO_RET_FAIL;
+ return ret;
}
diff --git a/src/libs/zbxsysinfo/openbsd/net.c b/src/libs/zbxsysinfo/openbsd/net.c
index 49867845..7fad4c51 100644
--- a/src/libs/zbxsysinfo/openbsd/net.c
+++ b/src/libs/zbxsysinfo/openbsd/net.c
@@ -22,23 +22,401 @@
#include "common.h"
#include "sysinfo.h"
+static struct nlist kernel_symbols[] =
+{
+ {"_ifnet", N_UNDF, 0, 0, 0},
+ {"_tcbtable", N_UNDF, 0, 0, 0},
+ {NULL, 0, 0, 0, 0}
+};
+
+#define IFNET_ID 0
+
+static int get_ifdata(const char *device, struct if_data *result)
+{
+ struct ifnet_head head;
+ struct ifnet *ifp;
+
+ char ifname[IFNAMSIZ+1];
+ kvm_t *kp;
+ int ret = SYSINFO_RET_FAIL;
+
+ kp = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
+
+ if(kp)
+ {
+ if(kernel_symbols[IFNET_ID].n_type == N_UNDF)
+ {
+ if(kvm_nlist(kp, &kernel_symbols[0]) != 0)
+ {
+ kernel_symbols[IFNET_ID].n_type = N_UNDF;
+ }
+ }
+
+ if(kernel_symbols[IFNET_ID].n_type != N_UNDF)
+ {
+ len = sizeof(struct ifnet_head);
+ if(kvm_read(kp, kernel_symbols[IFNET_ID].n_value, &head, len) >= len)
+ {
+ len = sizeof(struct if_data);
+ for(ifp = head.tqh_first; ifp; ifp = result->if_list.tqe_next)
+ {
+ if(kvm_read(kp, (u_long) ifp, result, len) < len)
+ break;
+
+ memcpy(
+ ifname,
+ result->if_xname,
+ MIN(sizeof(ifname)- 1, IFNAMSIZ)
+ );
+ ifname[IFNAMSIZ] = '\0';
+
+ if(strcmp(device, ifname) == 0)
+ {
+ ret = SYSINFO_RET_OK;
+ break;
+ }
+ }
+ }
+ }
+ kvm_close(kp);
+ }
+
+ return ret;
+}
+
+static int NET_IF_IN_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct if_data value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = value.if_ibytes;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
+}
+
+static int NET_IF_IN_PACKETS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct if_data value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = value.if_ipackets;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
+}
+
+static int NET_IF_IN_ERRORS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct if_data value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = value.if_ierrors;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
+}
+
int NET_IF_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
+LIST 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;
+}
+
+static int NET_IF_OUT_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct if_data value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = value.if_obytes;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
+}
+
+static int NET_IF_OUT_PACKETS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct if_data value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = value.if_opackets;
+ ret = SYSINFO_RET_OK;
+ }
- return SYSINFO_RET_FAIL;
+ return ret;
+}
+
+static int NET_IF_OUT_ERRORS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct if_data value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = value.if_oerrors;
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
}
int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
+LIST 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;
+}
+
+static int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct if_data value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = value.if_collisions;
+ ret = SYSINFO_RET_OK;
+ }
- return SYSINFO_RET_FAIL;
+ return ret;
}
diff --git a/src/libs/zbxsysinfo/openbsd/openbsd.c b/src/libs/zbxsysinfo/openbsd/openbsd.c
index df66bf38..fcd094b0 100644
--- a/src/libs/zbxsysinfo/openbsd/openbsd.c
+++ b/src/libs/zbxsysinfo/openbsd/openbsd.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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"},
-
+ {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,bytes"},
+ {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,operations"},
+
{"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,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,pages"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/openbsd/swap.c b/src/libs/zbxsysinfo/openbsd/swap.c
index 3d80fec9..b026fe60 100644
--- a/src/libs/zbxsysinfo/openbsd/swap.c
+++ b/src/libs/zbxsysinfo/openbsd/swap.c
@@ -25,164 +25,75 @@
#include "md5.h"
-/* Solaris. */
-#ifndef HAVE_SYSINFO_FREESWAP
-#ifdef HAVE_SYS_SWAP_SWAPTABLE
-void get_swapinfo(double *total, double *fr)
+static void get_swap_size(double *total, double *free)
{
- register int cnt, i, page_size;
-/* Support for >2Gb */
-/* register int t, f;*/
- double t, f;
- struct swaptable *swt;
- struct swapent *ste;
- static char path[256];
-
- /* get total number of swap entries */
- cnt = swapctl(SC_GETNSWP, 0);
-
- /* allocate enough space to hold count + n swapents */
- swt = (struct swaptable *)malloc(sizeof(int) +
- cnt * sizeof(struct swapent));
-
- if (swt == NULL)
+ int mib[2];
+ size_t len;
+ struct uvmexp vm;
+
+ mib[0]=CTL_VM;
+ mib[1]=VM_UVMEXP;
+
+ len=sizeof vm;
+
+ if(sysctl(mib,2,&vm,&len,NULL,0) == -1)
{
- *total = 0;
- *fr = 0;
- return;
+ return SYSINFO_RET_FAIL;
}
- 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 */
- ste = &(swt->swt_ent[0]);
- i = cnt;
- while (--i >= 0)
+ if(total)
{
- ste++->ste_path = path;
+ /* int swpages; number of PAGE_SIZE'ed swap pages */
+ /* int pagesize; size of a page (PAGE_SIZE): must be power of 2 */
+ (*total) = (double)(((long) vm.swpages) * vm.pagesize);
}
-
- /* grab all swap info */
- swapctl(SC_LIST, swt);
-
- /* walk thru the structs and sum up the fields */
- t = f = 0;
- ste = &(swt->swt_ent[0]);
- i = cnt;
- while (--i >= 0)
+ if(free)
{
- /* dont count slots being deleted */
- if (!(ste->ste_flags & ST_INDEL) &&
- !(ste->ste_flags & ST_DOINGDEL))
- {
- t += ste->ste_pages;
- f += ste->ste_free;
- }
- ste++;
+ /* int swpages; number of PAGE_SIZE'ed swap pages */
+ /* int swpginuse; number of swap pages in use */
+ /* int pagesize; size of a page (PAGE_SIZE): must be power of 2 */
+ (*free) = (double)(((long) (vm.swpages - vm.swpginuse)) * vm.pagesize);
}
- page_size=getpagesize();
-
- /* fill in the results */
- *total = page_size*t;
- *fr = page_size*f;
- free(swt);
+ return SYSINFO_RET_OK;
}
-#endif
-#endif
static int SYSTEM_SWAP_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYSINFO_FREESWAP
- struct sysinfo info;
-
- assert(result);
+ double value;
+ int ret = SYSINFO_RET_FAIL;
- clean_result(result);
-
- if( 0 == sysinfo(&info))
- {
- result->type |= AR_DOUBLE;
-#ifdef HAVE_SYSINFO_MEM_UNIT
- result->dbl = (double)info.freeswap * (double)info.mem_unit;
-#else
- result->dbl = (double)info.freeswap;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-/* Solaris */
-#else
-#ifdef HAVE_SYS_SWAP_SWAPTABLE
- double swaptotal,swapfree;
-
- assert(result);
+ assert(result);
clean_result(result);
-
- get_swapinfo(&swaptotal,&swapfree);
+
+ ret = get_swap_size(NULL, &value);
+
+ if(ret != SYSINFO_RET_OK)
+ return ret;
result->type |= AR_DOUBLE;
- result->dbl = swapfree;
- return SYSINFO_RET_OK;
-#else
- assert(result);
-
- clean_result(result);
-
- return SYSINFO_RET_FAIL;
-#endif
-#endif
+ result->dbl = value;
+ return ret;
}
static int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYSINFO_TOTALSWAP
- struct sysinfo info;
-
- assert(result);
+ double value;
+ int ret = SYSINFO_RET_FAIL;
- clean_result(result);
-
- if( 0 == sysinfo(&info))
- {
- result->type |= AR_DOUBLE;
-#ifdef HAVE_SYSINFO_MEM_UNIT
- result->dbl = (double)info.totalswap * (double)info.mem_unit;
-#else
- result->dbl = (double)info.totalswap;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-/* Solaris */
-#else
-#ifdef HAVE_SYS_SWAP_SWAPTABLE
- double swaptotal,swapfree;
-
- assert(result);
+ assert(result);
clean_result(result);
-
- get_swapinfo(&swaptotal,&swapfree);
- result->type |= AR_DOUBLE;
- result->dbl = (double)swaptotal;
- return SYSINFO_RET_OK;
-#else
- assert(result);
-
- clean_result(result);
+ ret = get_swap_size(&value, NULL);
+
+ if(ret != SYSINFO_RET_OK)
+ return ret;
- return SYSINFO_RET_FAIL;
-#endif
-#endif
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+ return ret;
}
int SYSTEM_SWAP_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -288,3 +199,158 @@ int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
return ret;
}
+int get_swap_io(double *swapin, double *pgswapin, double *swapout, double *pgswapout)
+{
+ int mib[2];
+ size_t len;
+ struct uvmexp vm;
+
+ mib[0]=CTL_VM;
+ mib[1]=VM_UVMEXP;
+
+ len = sizeof(vm);
+
+ if(sysctl(mib,2,&vm,&len,NULL,0) == -1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(swapin)
+ {
+ /* int swapins; swapins */
+ (*swapin) += (double) vm.swapins;
+ }
+ if(pgswapin)
+ {
+ /* int pgswapin; pages swapped in */
+ (*pgswapin) += (double) vm.pgswapin;
+ }
+ if(swapout)
+ {
+ /* int swapouts; swapouts */
+ (*swapout) += (double) vm.swapouts;
+ }
+ if(pgswapout)
+ {
+ /* int pgswapout; pages swapped out */
+ (*pgswapout) += (double) vm.pgswapout;
+ }
+
+ return SYSINFO_RET_OK;
+}
+
+int SYSTEM_SWAP_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ 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(&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(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ 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/openbsd/uptime.c b/src/libs/zbxsysinfo/openbsd/uptime.c
index abb674b0..7492af1e 100644
--- a/src/libs/zbxsysinfo/openbsd/uptime.c
+++ b/src/libs/zbxsysinfo/openbsd/uptime.c
@@ -25,9 +25,10 @@
int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
int mib[2];
- size_t len;
+ size_t len;
struct timeval uptime;
int now;
+ int ret = SYSINFO_RET_FAIL;
assert(result);
clean_result(result);
@@ -37,15 +38,15 @@ int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESU
len=sizeof(uptime);
- if(sysctl(mib,2,&uptime,(size_t *)&len,NULL,0) != 0)
+ if(sysctl(mib,2,&uptime,(size_t *)&len,NULL,0) == 0)
{
- return SYSINFO_RET_FAIL;
- }
-
- now=time(NULL);
+ now=time(NULL);
- result->type |= AR_DOUBLE;
- result->dbl = (double)(now-uptime.tv_sec);
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)(now-uptime.tv_sec);
- return SYSINFO_RET_OK;
+ ret = SYSINFO_RET_OK;
+ }
+ return ret;
}
+
diff --git a/src/libs/zbxsysinfo/osf/cpu.c b/src/libs/zbxsysinfo/osf/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/osf/cpu.c
+++ b/src/libs/zbxsysinfo/osf/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/osf/net.c b/src/libs/zbxsysinfo/osf/net.c
index 49867845..54c81126 100644
--- a/src/libs/zbxsysinfo/osf/net.c
+++ b/src/libs/zbxsysinfo/osf/net.c
@@ -42,3 +42,20 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_FAIL;
}
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/osf/osf.c b/src/libs/zbxsysinfo/osf/osf.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/osf/osf.c
+++ b/src/libs/zbxsysinfo/osf/osf.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/osx/cpu.c b/src/libs/zbxsysinfo/osx/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/osx/cpu.c
+++ b/src/libs/zbxsysinfo/osx/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/osx/net.c b/src/libs/zbxsysinfo/osx/net.c
index 49867845..54c81126 100644
--- a/src/libs/zbxsysinfo/osx/net.c
+++ b/src/libs/zbxsysinfo/osx/net.c
@@ -42,3 +42,20 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_FAIL;
}
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/osx/osx.c b/src/libs/zbxsysinfo/osx/osx.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/osx/osx.c
+++ b/src/libs/zbxsysinfo/osx/osx.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/solaris/solaris.c b/src/libs/zbxsysinfo/solaris/solaris.c
index cdf1fc35..9d325c44 100644
--- a/src/libs/zbxsysinfo/solaris/solaris.c
+++ b/src/libs/zbxsysinfo/solaris/solaris.c
@@ -262,6 +262,8 @@ ZBX_METRIC parameters_specific[]=
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
diff --git a/src/libs/zbxsysinfo/solaris/swap.c b/src/libs/zbxsysinfo/solaris/swap.c
index 86221190..d95cfe3b 100644
--- a/src/libs/zbxsysinfo/solaris/swap.c
+++ b/src/libs/zbxsysinfo/solaris/swap.c
@@ -317,17 +317,17 @@ int get_swap_io(double *swapin, double *pgswapin, double *swapout, double *pgswa
/* uint_t swapin; // swapins */
(*swapin) += (double) cpu->cpu_vminfo.swapin;
}
- else if(pgswapin)
+ if(pgswapin)
{
/* uint_t pgswapin; // pages swapped in */
(*pgswapin) += (double) cpu->cpu_vminfo.pgswapin;
}
- else if(swapout)
+ if(swapout)
{
/* uint_t swapout; // swapout */
(*swapout) += (double) cpu->cpu_vminfo.swapout;
}
- else if(pgswapout)
+ if(pgswapout)
{
/* uint_t pgswapout; // pages swapped out */
(*pgswapout) += (double) cpu->cpu_vminfo.pgswapout;
diff --git a/src/libs/zbxsysinfo/unknown/cpu.c b/src/libs/zbxsysinfo/unknown/cpu.c
index 4e7e1502..f45b39db 100644
--- a/src/libs/zbxsysinfo/unknown/cpu.c
+++ b/src/libs/zbxsysinfo/unknown/cpu.c
@@ -548,3 +548,21 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
+int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
diff --git a/src/libs/zbxsysinfo/unknown/net.c b/src/libs/zbxsysinfo/unknown/net.c
index 49867845..54c81126 100644
--- a/src/libs/zbxsysinfo/unknown/net.c
+++ b/src/libs/zbxsysinfo/unknown/net.c
@@ -42,3 +42,20 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_FAIL;
}
+int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
+
+int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ assert(result);
+
+ clean_result(result);
+
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/unknown/unknown.c b/src/libs/zbxsysinfo/unknown/unknown.c
index df66bf38..e635572f 100644
--- a/src/libs/zbxsysinfo/unknown/unknown.c
+++ b/src/libs/zbxsysinfo/unknown/unknown.c
@@ -231,32 +231,40 @@ ZBX_METRIC parameters_specific[]=
* 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, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 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,,"},
{"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"},
{"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"},
-
+
{"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"},
-
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,count"},
+
{"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
{"system.uname", 0, SYSTEM_UNAME, 0, 0},