summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-10-08 12:29:51 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-10-08 12:29:51 +0000
commit47c97bab4d8f41a5517cfc8a351dcf7aa79ae955 (patch)
tree67d99ce76d95c7dfdbeba3902a5f33d8d96ba418 /src/libs
parent81b40b96eb85730e9d2ce3e32539c59faed4fea6 (diff)
downloadzabbix-47c97bab4d8f41a5517cfc8a351dcf7aa79ae955.tar.gz
zabbix-47c97bab4d8f41a5517cfc8a351dcf7aa79ae955.tar.xz
zabbix-47c97bab4d8f41a5517cfc8a351dcf7aa79ae955.zip
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@2142 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/zbxsysinfo/freebsd/cpu.c437
-rw-r--r--src/libs/zbxsysinfo/freebsd/diskio.c289
-rw-r--r--src/libs/zbxsysinfo/freebsd/diskspace.c319
-rw-r--r--src/libs/zbxsysinfo/freebsd/inodes.c162
-rw-r--r--src/libs/zbxsysinfo/freebsd/memory.c430
-rw-r--r--src/libs/zbxsysinfo/freebsd/sensors.c288
-rw-r--r--src/libs/zbxsysinfo/freebsd/supported.c204
-rw-r--r--src/libs/zbxsysinfo/freebsd/swap.c270
-rw-r--r--src/libs/zbxsysinfo/freebsd/uptime.c217
9 files changed, 2616 insertions, 0 deletions
diff --git a/src/libs/zbxsysinfo/freebsd/cpu.c b/src/libs/zbxsysinfo/freebsd/cpu.c
new file mode 100644
index 00000000..da971b3a
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/cpu.c
@@ -0,0 +1,437 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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)
+{
+ return get_stat("cpu[idle1]",value);
+}
+
+int SYSTEM_CPU_IDLE5(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[idle5]",value);
+}
+
+int SYSTEM_CPU_IDLE15(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[idle15]",value);
+}
+
+int SYSTEM_CPU_NICE1(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[nice1]",value);
+}
+
+int SYSTEM_CPU_NICE5(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[nice5]",value);
+}
+int SYSTEM_CPU_NICE15(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[nice15]",value);
+}
+
+int SYSTEM_CPU_USER1(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[user1]",value);
+}
+
+int SYSTEM_CPU_USER5(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[user5]",value);
+}
+
+int SYSTEM_CPU_USER15(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[user15]",value);
+}
+
+int SYSTEM_CPU_SYS1(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[system1]",value);
+}
+
+int SYSTEM_CPU_SYS5(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[system5]",value);
+}
+
+int SYSTEM_CPU_SYS15(const char *cmd, const char *param,double *value)
+{
+ return get_stat("cpu[system15]",value);
+}
+
+/* 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;
+}
+#endif
+
+int SYSTEM_CPU_LOAD1(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_GETLOADAVG
+ double load[3];
+
+ if(getloadavg(load, 3))
+ {
+ *value=load[0];
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+#else
+#ifdef HAVE_SYS_PSTAT_H
+ struct pst_dynamic dyn;
+
+ if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ *value=(double)dyn.psd_avg_1_min;
+ return SYSINFO_RET_OK;
+ }
+#else
+#ifdef HAVE_PROC_LOADAVG
+ return getPROC("/proc/loadavg",1,1,value);
+#else
+#ifdef HAVE_KSTAT_H
+ static kstat_ctl_t *kc = NULL;
+ kstat_t *ks;
+ kstat_named_t *kn;
+
+ 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;
+ }
+ *value=(double)kn->value.ul/256.0;
+ return SYSINFO_RET_OK;
+#else
+#ifdef HAVE_KNLIST_H
+ double loadavg[3];
+
+ if(getloadavg_kmem(loadavg,3) == FAIL)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ *value=loadavg[0];
+ return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+#endif
+#endif
+#endif
+}
+
+int SYSTEM_CPU_LOAD5(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_GETLOADAVG
+ double load[3];
+
+ if(getloadavg(load, 3))
+ {
+ *value=load[1];
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+#else
+#ifdef HAVE_SYS_PSTAT_H
+ struct pst_dynamic dyn;
+
+ if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ *value=(double)dyn.psd_avg_5_min;
+ return SYSINFO_RET_OK;
+ }
+#else
+#ifdef HAVE_PROC_LOADAVG
+ return getPROC("/proc/loadavg",1,2,value);
+#else
+#ifdef HAVE_KSTAT_H
+ static kstat_ctl_t *kc = NULL;
+ kstat_t *ks;
+ kstat_named_t *kn;
+
+ 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;
+ }
+ *value=(double)kn->value.ul/256.0;
+ return SYSINFO_RET_OK;
+#else
+#ifdef HAVE_KNLIST_H
+ double loadavg[3];
+
+ if(getloadavg_kmem(loadavg,3) == FAIL)
+ {
+ return STSINFO_RET_FAIL;
+ }
+
+ *value=loadavg[1];
+ return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+#endif
+#endif
+#endif
+}
+
+int SYSTEM_CPU_LOAD15(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_GETLOADAVG
+ double load[3];
+
+ if(getloadavg(load, 3))
+ {
+ *value=load[2];
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+#else
+#ifdef HAVE_SYS_PSTAT_H
+ struct pst_dynamic dyn;
+
+ if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ *value=(double)dyn.psd_avg_15_min;
+ return SYSINFO_RET_OK;
+ }
+#else
+#ifdef HAVE_PROC_LOADAVG
+ return getPROC("/proc/loadavg",1,3,value);
+#else
+#ifdef HAVE_KSTAT_H
+ static kstat_ctl_t *kc = NULL;
+ kstat_t *ks;
+ kstat_named_t *kn;
+
+ 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;
+ }
+ *value=(double)kn->value.ul/256.0;
+ return SYSINFO_RET_OK;
+#else
+#ifdef HAVE_KNLIST_H
+ double loadavg[3];
+
+ if(getloadavg_kmem(loadavg,3) == FAIL)
+ {
+ return STSINFO_RET_FAIL;
+ }
+
+ *value=loadavg[2];
+ return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+#endif
+#endif
+#endif
+}
diff --git a/src/libs/zbxsysinfo/freebsd/diskio.c b/src/libs/zbxsysinfo/freebsd/diskio.c
new file mode 100644
index 00000000..a030d6f9
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/diskio.c
@@ -0,0 +1,289 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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"
+
+int DISKREADOPS1(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_read_ops1[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKREADOPS5(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_read_ops5[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKREADOPS15(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_read_ops15[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKREADBLKS1(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_read_blks1[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKREADBLKS5(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_read_blks5[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKREADBLKS15(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_read_blks15[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKWRITEOPS1(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_write_ops1[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKWRITEOPS5(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_write_ops5[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKWRITEOPS15(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_write_ops15[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKWRITEBLKS1(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_write_blks1[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKWRITEBLKS5(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_write_blks5[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISKWRITEBLKS15(const char *cmd, const char *device,double *value)
+{
+ char key[MAX_STRING_LEN];
+
+ snprintf(key,sizeof(key)-1,"disk_write_blks15[%s]",device);
+
+ return get_stat(key,value);
+}
+
+int DISK_IO(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_PROC
+ return getPROC("/proc/stat",2,2,value);
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int DISK_RIO(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_PROC
+ return getPROC("/proc/stat",3,2,value);
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int DISK_WIO(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_PROC
+ return getPROC("/proc/stat",4,2,value);
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int DISK_RBLK(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_PROC
+ return getPROC("/proc/stat",5,2,value);
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int DISK_WBLK(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_PROC
+ return getPROC("/proc/stat",6,2,value);
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+}
diff --git a/src/libs/zbxsysinfo/freebsd/diskspace.c b/src/libs/zbxsysinfo/freebsd/diskspace.c
new file mode 100644
index 00000000..49351916
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/diskspace.c
@@ -0,0 +1,319 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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"
+
+int VFS_FS_PUSED(const char *cmd, const char *mountPoint,double *value)
+{
+ double total;
+ double used;
+
+ if(SYSINFO_RET_OK != VFS_FS_TOTAL(cmd, mountPoint, &total))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(SYSINFO_RET_OK != VFS_FS_USED(cmd, mountPoint, &used))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(total == 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ *value = 100*used/total;
+ return SYSINFO_RET_OK;
+}
+
+int VFS_FS_PFREE(const char *cmd, const char *mountPoint,double *value)
+{
+ double total;
+ double free;
+
+ if(SYSINFO_RET_OK != VFS_FS_TOTAL(cmd, mountPoint, &total))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(SYSINFO_RET_OK != VFS_FS_FREE(cmd, mountPoint, &free))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(total == 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ *value = 100*free/total;
+ return SYSINFO_RET_OK;
+}
+
+int VFS_FS_FREE(const char *cmd, const char *mountPoint,double *value)
+{
+#ifdef HAVE_SYS_STATVFS_H
+ struct statvfs s;
+
+ if ( statvfs( (char *)mountPoint, &s) != 0 )
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+/* return s.f_bavail * (s.f_bsize / 1024.0);*/
+ *value=s.f_bavail * (s.f_frsize / 1024.0);
+ 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_bavail * (s.f_bsize / 1024.0);
+ return SYSINFO_RET_OK;
+
+ }
+
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int VFS_FS_USED(const char *cmd, const char *mountPoint,double *value)
+{
+#ifdef HAVE_SYS_STATVFS_H
+ struct statvfs s;
+
+ if ( statvfs( (char *)mountPoint, &s) != 0 )
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+/* 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
+ 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=blocks_used * (s.f_bsize / 1024.0);
+ return SYSINFO_RET_OK;
+
+ }
+
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int VFS_FS_TOTAL(const char *cmd, const char *mountPoint,double *value)
+{
+#ifdef HAVE_SYS_STATVFS_H
+ struct statvfs s;
+
+ if ( statvfs( (char *)mountPoint, &s) != 0 )
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+/* return s.f_blocks * (s.f_bsize / 1024.0);*/
+ *value= s.f_blocks * (s.f_frsize / 1024.0);
+ 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_blocks * (s.f_bsize / 1024.0);
+ return SYSINFO_RET_OK;
+
+ }
+
+ return SYSINFO_RET_FAIL;
+#endif
+}
diff --git a/src/libs/zbxsysinfo/freebsd/inodes.c b/src/libs/zbxsysinfo/freebsd/inodes.c
new file mode 100644
index 00000000..0ea41a7c
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/inodes.c
@@ -0,0 +1,162 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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)
+{
+#ifdef HAVE_SYS_STATVFS_H
+ struct statvfs s;
+
+ if ( statvfs( (char *)mountPoint, &s) != 0 )
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ *value=s.f_favail;
+ 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_ffree;
+ return SYSINFO_RET_OK;
+
+ }
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int VFS_FS_INODE_TOTAL(const char *cmd, const char *mountPoint,double *value)
+{
+#ifdef HAVE_SYS_STATVFS_H
+ struct statvfs s;
+
+ if ( statvfs( (char *)mountPoint, &s) != 0 )
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ *value=s.f_files;
+ 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;
+
+ }
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int VFS_FS_INODE_PFREE(const char *cmd, const char *mountPoint,double *value)
+{
+ double total;
+ double free;
+
+ if(SYSINFO_RET_OK != VFS_FS_INODE_TOTAL(cmd, mountPoint, &total))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(SYSINFO_RET_OK != VFS_FS_INODE_FREE(cmd, mountPoint, &free))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(total == 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ *value = 100*free/total;
+ return SYSINFO_RET_OK;
+}
diff --git a/src/libs/zbxsysinfo/freebsd/memory.c b/src/libs/zbxsysinfo/freebsd/memory.c
new file mode 100644
index 00000000..21461a80
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/memory.c
@@ -0,0 +1,430 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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"
+
+int VM_MEMORY_CACHED(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_PROC
+/* Get CACHED memory in bytes */
+/* return getPROC("/proc/meminfo",8,2);*/
+/* It does not work for both 2.4 and 2.6 */
+/* return getPROC("/proc/meminfo",2,7);*/
+ FILE *f;
+ char *t;
+ char c[MAX_STRING_LEN];
+ double result = SYSINFO_RET_FAIL;
+
+ 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", &result );
+ break;
+ }
+ }
+ 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)
+{
+#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)
+{
+#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);
+
+ *value=(double)(v.t_armshr<<2);
+ return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+}
+
+int VM_MEMORY_TOTAL(const char *cmd, const char *parameter,double *value)
+{
+/* Solaris */
+#ifdef HAVE_UNISTD_SYSCONF
+ *value=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
+ return SYSINFO_RET_OK;
+#else
+#ifdef HAVE_SYS_PSTAT_H
+ struct pst_static pst;
+ long page;
+
+ if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ /* Get page size */
+ page = pst.page_size;
+ /* Total physical memory in bytes */
+ *value=(double)page*pst.physical_memory;
+ return SYSINFO_RET_OK;
+ }
+#else
+#ifdef HAVE_SYSINFO_TOTALRAM
+ struct sysinfo info;
+
+ if( 0 == sysinfo(&info))
+ {
+#ifdef HAVE_SYSINFO_MEM_UNIT
+ *value=(double)info.totalram * (double)info.mem_unit;
+#else
+ *value=(double)info.totalram;
+#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);
+
+ *value=(double)(v.t_rm<<2);
+ return SYSINFO_RET_OK;
+#else
+#ifdef HAVE_SYS_SYSCTL_H
+ static int mib[] = { CTL_HW, HW_PHYSMEM };
+ size_t len;
+ unsigned int memory;
+ int ret;
+
+ len=sizeof(memory);
+
+ if(0==sysctl(mib,2,&memory,&len,NULL,0))
+ {
+ *value=(double)memory;
+ ret=SYSINFO_RET_OK;
+ }
+ else
+ {
+ ret=SYSINFO_RET_FAIL;
+ }
+ return ret;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+#endif
+#endif
+#endif
+}
+
+int VM_MEMORY_FREE(const char *cmd, const char *parameter,double *value)
+{
+/* Solaris */
+#ifdef HAVE_UNISTD_SYSCONF
+ *value=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
+ return SYSINFO_RET_OK;
+#else
+#ifdef HAVE_SYS_PSTAT_H
+ struct pst_static pst;
+ struct pst_dynamic dyn;
+ long page;
+
+ 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 */
+
+ *value=(double)dyn.psd_free * page;
+ return SYSINFO_RET_OK;
+ }
+ }
+#else
+#ifdef HAVE_SYSINFO_FREERAM
+ struct sysinfo info;
+
+ if( 0 == sysinfo(&info))
+ {
+#ifdef HAVE_SYSINFO_MEM_UNIT
+ *value=(double)info.freeram * (double)info.mem_unit;
+#else
+ *value=(double)info.freeram;
+#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);
+
+ *value=(double)(v.t_free<<2);
+ return SYSINFO_RET_OK;
+#else
+/* OS/X */
+#ifdef 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;
+
+ 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)
+ {
+ 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;
+
+ *value=(double)pf;
+ ret = SYSINFO_RET_OK;
+ }
+ else
+ {
+ ret = SYSINFO_RET_FAIL;
+ }
+ return ret;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+#endif
+#endif
+#endif
+}
diff --git a/src/libs/zbxsysinfo/freebsd/sensors.c b/src/libs/zbxsysinfo/freebsd/sensors.c
new file mode 100644
index 00000000..48c6911e
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/sensors.c
@@ -0,0 +1,288 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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)
+{
+ DIR *dir;
+ struct dirent *entries;
+ struct stat buf;
+ char filename[MAX_STRING_LEN];
+ char line[MAX_STRING_LEN];
+ double d1,d2,d3;
+
+ FILE *f;
+
+ dir=opendir("/proc/sys/dev/sensors");
+ if(NULL == dir)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ while((entries=readdir(dir))!=NULL)
+ {
+ strscpy(filename,"/proc/sys/dev/sensors/");
+ strncat(filename,entries->d_name,MAX_STRING_LEN);
+ strncat(filename,"/temp1",MAX_STRING_LEN);
+
+ if(stat(filename,&buf)==0)
+ {
+ f=fopen(filename,"r");
+ if(f==NULL)
+ {
+ continue;
+ }
+ fgets(line,MAX_STRING_LEN,f);
+ fclose(f);
+
+ if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3)
+ {
+ closedir(dir);
+ *value=d3;
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ closedir(dir);
+ return SYSINFO_RET_FAIL;
+ }
+ }
+ }
+ closedir(dir);
+ return SYSINFO_RET_FAIL;
+}
+
+int SENSOR_TEMP2(const char *cmd, const char *param,double *value)
+{
+ DIR *dir;
+ struct dirent *entries;
+ struct stat buf;
+ char filename[MAX_STRING_LEN];
+ char line[MAX_STRING_LEN];
+ double d1,d2,d3;
+
+ FILE *f;
+
+ dir=opendir("/proc/sys/dev/sensors");
+ if(NULL == dir)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ while((entries=readdir(dir))!=NULL)
+ {
+ strscpy(filename,"/proc/sys/dev/sensors/");
+ strncat(filename,entries->d_name,MAX_STRING_LEN);
+ strncat(filename,"/temp2",MAX_STRING_LEN);
+
+ if(stat(filename,&buf)==0)
+ {
+ f=fopen(filename,"r");
+ if(f==NULL)
+ {
+ continue;
+ }
+ fgets(line,MAX_STRING_LEN,f);
+ fclose(f);
+
+ if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3)
+ {
+ closedir(dir);
+ *value=d3;
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ closedir(dir);
+ return SYSINFO_RET_FAIL;
+ }
+ }
+ }
+ closedir(dir);
+ return SYSINFO_RET_FAIL;
+}
+
+int SENSOR_TEMP3(const char *cmd, const char *param,double *value)
+{
+ DIR *dir;
+ struct dirent *entries;
+ struct stat buf;
+ char filename[MAX_STRING_LEN];
+ char line[MAX_STRING_LEN];
+ double d1,d2,d3;
+
+ FILE *f;
+
+ dir=opendir("/proc/sys/dev/sensors");
+ if(NULL == dir)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ while((entries=readdir(dir))!=NULL)
+ {
+ strscpy(filename,"/proc/sys/dev/sensors/");
+ strncat(filename,entries->d_name,MAX_STRING_LEN);
+ strncat(filename,"/temp3",MAX_STRING_LEN);
+
+ if(stat(filename,&buf)==0)
+ {
+ f=fopen(filename,"r");
+ if(f==NULL)
+ {
+ continue;
+ }
+ fgets(line,MAX_STRING_LEN,f);
+ fclose(f);
+
+ if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3)
+ {
+ closedir(dir);
+ *value=d3;
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ closedir(dir);
+ return SYSINFO_RET_FAIL;
+ }
+ }
+ }
+ closedir(dir);
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/freebsd/supported.c b/src/libs/zbxsysinfo/freebsd/supported.c
new file mode 100644
index 00000000..a22af5d6
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/supported.c
@@ -0,0 +1,204 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#include "config.h"
+#include "sysinfo.h"
+
+COMMAND parameters_specific[]=
+/* KEY FUNCTION (if double) FUNCTION (if string) 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]" ,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},
+/* New naming */
+
+ {"agent.ping" ,AGENT_PING, 0, 0},
+ {"agent.version", 0, AGENT_VERSION, 0},
+
+ {"kernel.maxfiles]" ,KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc" ,KERNEL_MAXPROC, 0, 0},
+
+ {"proc.num[*]" ,PROC_NUM, 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"},
+
+ {"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},
+
+ {"net.if.ibytes1[*]" ,NET_IF_IBYTES1, 0, "lo"},
+ {"net.if.ibytes5[*]" ,NET_IF_IBYTES5, 0, "lo"},
+ {"net.if.ibytes15[*]" ,NET_IF_IBYTES15, 0, "lo"},
+ {"net.if.obytes1[*]" ,NET_IF_OBYTES1, 0, "lo"},
+ {"net.if.obytes5[*]" ,NET_IF_OBYTES5, 0, "lo"},
+ {"net.if.obytes15[*]" ,NET_IF_OBYTES15, 0, "lo"},
+
+ {"disk_read_ops1[*]" ,DISKREADOPS1, 0, "hda"},
+ {"disk_read_ops5[*]" ,DISKREADOPS5, 0, "hda"},
+ {"disk_read_ops15[*]" ,DISKREADOPS15, 0, "hda"},
+
+ {"disk_read_blks1[*]" ,DISKREADBLKS1, 0, "hda"},
+ {"disk_read_blks5[*]" ,DISKREADBLKS5, 0, "hda"},
+ {"disk_read_blks15[*]" ,DISKREADBLKS15, 0, "hda"},
+
+ {"disk_write_ops1[*]" ,DISKWRITEOPS1, 0, "hda"},
+ {"disk_write_ops5[*]" ,DISKWRITEOPS5, 0, "hda"},
+ {"disk_write_ops15[*]" ,DISKWRITEOPS15, 0, "hda"},
+
+ {"disk_write_blks1[*]" ,DISKWRITEBLKS1, 0, "hda"},
+ {"disk_write_blks5[*]" ,DISKWRITEBLKS5, 0, "hda"},
+ {"disk_write_blks15[*]" ,DISKWRITEBLKS15, 0, "hda"},
+
+ {"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},
+
+ {"system.uname" ,0, EXECUTE_STR, "uname -a"},
+ {"system.uptime" ,SYSTEM_UPTIME, 0, 0},
+ {"system.users.num" ,EXECUTE, 0,"who|wc -l"},
+
+/****************************************
+ 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[switches]" ,EXECUTE, 0, "vmstat -n 1 2|tail -1|cut -b62-67"},
+***************************************/
+
+ {"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},
+
+
+
+ {"system[proccount]" ,PROCCOUNT, 0, 0},
+
+#ifdef HAVE_PROC_LOADAVG
+ {"system[procrunning]" ,EXECUTE, 0, "cat /proc/loadavg|cut -f1 -d'/'|cut -f4 -d' '"},
+#endif
+
+/* {"tcp_count" ,EXECUTE, 0, "netstat -tn|grep EST|wc -l"}, */
+
+ {"net[listen_23]" ,TCP_LISTEN, 0, "0017"},
+ {"net[listen_80]" ,TCP_LISTEN, 0, "0050"},
+
+ {"check_port[*]" ,CHECK_PORT, 0, "80"},
+
+ {"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"},
+
+ {0}
+ };
diff --git a/src/libs/zbxsysinfo/freebsd/swap.c b/src/libs/zbxsysinfo/freebsd/swap.c
new file mode 100644
index 00000000..d4f13a53
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/swap.c
@@ -0,0 +1,270 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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"
+
+/* 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;*/
+ 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)
+ {
+ *total = 0;
+ *fr = 0;
+ return;
+ }
+ 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)
+ {
+ ste++->ste_path = path;
+ }
+
+ /* 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)
+ {
+ /* 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++;
+ }
+
+ page_size=getpagesize();
+
+ /* fill in the results */
+ *total = page_size*t;
+ *fr = page_size*f;
+ free(swt);
+}
+#endif
+#endif
+
+int SYSTEM_SWAP_FREE(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_SYSINFO_FREESWAP
+ struct sysinfo info;
+
+ if( 0 == sysinfo(&info))
+ {
+#ifdef HAVE_SYSINFO_MEM_UNIT
+ *value=(double)info.freeswap * (double)info.mem_unit;
+#else
+ *value=(double)info.freeswap;
+#endif
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+/* Solaris */
+#else
+#ifdef HAVE_SYS_SWAP_SWAPTABLE
+ double swaptotal,swapfree;
+
+ get_swapinfo(&swaptotal,&swapfree);
+
+ *value=swapfree;
+ return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+}
+
+int SYSTEM_SWAP_TOTAL(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_SYSINFO_TOTALSWAP
+ struct sysinfo info;
+
+ if( 0 == sysinfo(&info))
+ {
+#ifdef HAVE_SYSINFO_MEM_UNIT
+ *value=(double)info.totalswap * (double)info.mem_unit;
+#else
+ *value=(double)info.totalswap;
+#endif
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+/* Solaris */
+#else
+#ifdef HAVE_SYS_SWAP_SWAPTABLE
+ double swaptotal,swapfree;
+
+ get_swapinfo(&swaptotal,&swapfree);
+
+ *value=(double)swaptotal;
+ return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+}
diff --git a/src/libs/zbxsysinfo/freebsd/uptime.c b/src/libs/zbxsysinfo/freebsd/uptime.c
new file mode 100644
index 00000000..9455bef2
--- /dev/null
+++ b/src/libs/zbxsysinfo/freebsd/uptime.c
@@ -0,0 +1,217 @@
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+#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"
+
+int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_SYSINFO_UPTIME
+ struct sysinfo info;
+
+ if( 0 == sysinfo(&info))
+ {
+ *value=(double)info.uptime;
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+#else
+#ifdef HAVE_FUNCTION_SYSCTL_KERN_BOOTTIME
+ int mib[2],len;
+ struct timeval uptime;
+ int now;
+
+ mib[0]=CTL_KERN;
+ mib[1]=KERN_BOOTTIME;
+
+ len=sizeof(uptime);
+
+ if(sysctl(mib,2,&uptime,(size_t *)&len,NULL,0) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+/* printf("Errno [%m]\n");*/
+ }
+
+ now=time(NULL);
+
+ *value=(double)(now-uptime.tv_sec);
+ return SYSINFO_RET_OK;
+#else
+/* Solaris */
+#ifdef HAVE_KSTAT_H
+ kstat_ctl_t *kc;
+ kstat_t *kp;
+ kstat_named_t *kn;
+
+ long hz;
+ long secs;
+
+ hz = sysconf(_SC_CLK_TCK);
+
+ /* open kstat */
+ kc = kstat_open();
+ if (0 == kc)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ /* read uptime counter */
+ kp = kstat_lookup(kc, "unix", 0, "system_misc");
+ if (0 == kp)
+ {
+ kstat_close(kc);
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(-1 == kstat_read(kc, kp, 0))
+ {
+ kstat_close(kc);
+ return SYSINFO_RET_FAIL;
+ }
+ kn = (kstat_named_t*)kstat_data_lookup(kp, "clk_intr");
+ secs = kn->value.ul / hz;
+
+ /* close kstat */
+ kstat_close(kc);
+ *value=(double)secs;
+ return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+#endif
+#endif
+}