summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-12 15:24:16 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-12 15:24:16 +0000
commit883163bc42892ffe0885e94b701ef9da4da3cf70 (patch)
treed9b8592102201e0396de3807a223d5b87c72f1bd /src
parente929cc4053168b46b81475715e98230eed01badc (diff)
downloadzabbix-883163bc42892ffe0885e94b701ef9da4da3cf70.tar.gz
zabbix-883163bc42892ffe0885e94b701ef9da4da3cf70.tar.xz
zabbix-883163bc42892ffe0885e94b701ef9da4da3cf70.zip
- fixed system.cpu.util[] (Eugene)
- improved configuration script (Eugene) - fixed floats values (Eugene) - developed agent result convertion (Eugene) - more fixes - TODO: WinXX agent \!\!\! git-svn-id: svn://svn.zabbix.com/trunk@3886 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/Makefile.am22
-rw-r--r--src/libs/zbxcommon/misc.c64
-rw-r--r--src/libs/zbxdb/Makefile.am2
-rw-r--r--src/libs/zbxdb/db.c8
-rw-r--r--src/libs/zbxdbhigh/Makefile.am2
-rw-r--r--src/libs/zbxdbhigh/db.c13
-rw-r--r--src/libs/zbxdbhigh/graph.c2
-rw-r--r--src/libs/zbxjabber/Makefile.am2
-rw-r--r--src/libs/zbxsysinfo/Makefile.am42
-rw-r--r--src/libs/zbxsysinfo/aix/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/aix/aix.c41
-rw-r--r--src/libs/zbxsysinfo/aix/cpu.c157
-rw-r--r--src/libs/zbxsysinfo/aix/diskio.c248
-rw-r--r--src/libs/zbxsysinfo/aix/proc.c12
-rw-r--r--src/libs/zbxsysinfo/common/Makefile.am10
-rw-r--r--src/libs/zbxsysinfo/common/common.c1920
-rw-r--r--src/libs/zbxsysinfo/common/common.h31
-rw-r--r--src/libs/zbxsysinfo/common/file.c204
-rw-r--r--src/libs/zbxsysinfo/common/file.h34
-rw-r--r--src/libs/zbxsysinfo/common/http.c2
-rw-r--r--src/libs/zbxsysinfo/common/http.h28
-rw-r--r--src/libs/zbxsysinfo/common/net.c298
-rw-r--r--src/libs/zbxsysinfo/common/net.h29
-rw-r--r--src/libs/zbxsysinfo/common/system.c40
-rw-r--r--src/libs/zbxsysinfo/common/system.h29
-rw-r--r--src/libs/zbxsysinfo/freebsd/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/freebsd/cpu.c151
-rw-r--r--src/libs/zbxsysinfo/freebsd/diskio.c242
-rw-r--r--src/libs/zbxsysinfo/freebsd/freebsd.c52
-rw-r--r--src/libs/zbxsysinfo/hpux/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/hpux/cpu.c143
-rw-r--r--src/libs/zbxsysinfo/hpux/diskio.c236
-rw-r--r--src/libs/zbxsysinfo/hpux/hpux.c48
-rw-r--r--src/libs/zbxsysinfo/linux/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/linux/boottime.c62
-rw-r--r--src/libs/zbxsysinfo/linux/cpu.c213
-rw-r--r--src/libs/zbxsysinfo/linux/diskio.c4
-rw-r--r--src/libs/zbxsysinfo/linux/linux.c52
-rw-r--r--src/libs/zbxsysinfo/netbsd/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/netbsd/cpu.c143
-rw-r--r--src/libs/zbxsysinfo/netbsd/diskio.c244
-rw-r--r--src/libs/zbxsysinfo/netbsd/netbsd.c48
-rw-r--r--src/libs/zbxsysinfo/openbsd/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/openbsd/cpu.c5
-rw-r--r--src/libs/zbxsysinfo/openbsd/openbsd.c49
-rw-r--r--src/libs/zbxsysinfo/osf/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/osf/cpu.c5
-rw-r--r--src/libs/zbxsysinfo/osf/diskio.c236
-rw-r--r--src/libs/zbxsysinfo/osf/osf.c50
-rw-r--r--src/libs/zbxsysinfo/osx/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/osx/cpu.c145
-rw-r--r--src/libs/zbxsysinfo/osx/diskio.c238
-rw-r--r--src/libs/zbxsysinfo/osx/osx.c52
-rw-r--r--src/libs/zbxsysinfo/simple/Makefile.am7
-rw-r--r--src/libs/zbxsysinfo/simple/ntp.c (renamed from src/libs/zbxsysinfo/common/ntp.c)6
-rw-r--r--src/libs/zbxsysinfo/simple/ntp.h24
-rw-r--r--src/libs/zbxsysinfo/simple/simple.c434
-rw-r--r--src/libs/zbxsysinfo/simple/simple.h29
-rw-r--r--src/libs/zbxsysinfo/solaris/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/solaris/cpu.c5
-rw-r--r--src/libs/zbxsysinfo/solaris/solaris.c46
-rw-r--r--src/libs/zbxsysinfo/specsysinfo.h24
-rw-r--r--src/libs/zbxsysinfo/sysinfo.c780
-rw-r--r--src/libs/zbxsysinfo/unknown/Makefile.am6
-rw-r--r--src/libs/zbxsysinfo/unknown/cpu.c143
-rw-r--r--src/libs/zbxsysinfo/unknown/diskio.c238
-rw-r--r--src/libs/zbxsysinfo/unknown/unknown.c48
-rw-r--r--src/libs/zbxsysinfo/win32/win32.c85
-rw-r--r--src/zabbix_agent/Makefile.am18
-rw-r--r--src/zabbix_agent/cpustat.c368
-rw-r--r--src/zabbix_agent/cpustat.h44
-rw-r--r--src/zabbix_agent/diskdevices.c36
-rw-r--r--src/zabbix_agent/diskdevices.h16
-rw-r--r--src/zabbix_agent/interfaces.c20
-rw-r--r--src/zabbix_agent/interfaces.h8
-rw-r--r--src/zabbix_agent/listener.c28
-rw-r--r--src/zabbix_agent/stats.c7
-rw-r--r--src/zabbix_agent/stats.h1
-rw-r--r--src/zabbix_agent/zabbix_agent.c2
-rw-r--r--src/zabbix_agent/zabbix_agentd.c25
-rw-r--r--src/zabbix_agent/zbxconf.c7
-rw-r--r--src/zabbix_get/zabbix_get.c5
-rw-r--r--src/zabbix_server/Makefile.am10
-rw-r--r--src/zabbix_server/alerter/Makefile.am2
-rw-r--r--src/zabbix_server/alerter/alerter.h4
-rw-r--r--src/zabbix_server/evalfunc.c113
-rw-r--r--src/zabbix_server/expression.c4
-rw-r--r--src/zabbix_server/functions.c385
-rw-r--r--src/zabbix_server/functions.h1
-rw-r--r--src/zabbix_server/housekeeper/Makefile.am2
-rw-r--r--src/zabbix_server/httppoller/Makefile.am2
-rw-r--r--src/zabbix_server/httppoller/httptest.c8
-rw-r--r--src/zabbix_server/nodewatcher/Makefile.am2
-rw-r--r--src/zabbix_server/pinger/Makefile.am2
-rw-r--r--src/zabbix_server/poller/Makefile.am2
-rw-r--r--src/zabbix_server/poller/checks_agent.h16
-rw-r--r--src/zabbix_server/poller/checks_aggregate.c10
-rw-r--r--src/zabbix_server/poller/checks_aggregate.h5
-rw-r--r--src/zabbix_server/poller/checks_internal.h5
-rw-r--r--src/zabbix_server/poller/checks_snmp.c9
-rw-r--r--src/zabbix_server/poller/checks_snmp.h27
-rw-r--r--src/zabbix_server/server.c26
-rw-r--r--src/zabbix_server/timer/Makefile.am2
-rw-r--r--src/zabbix_server/trapper/Makefile.am2
-rw-r--r--src/zabbix_server/trapper/trapper.c2
-rw-r--r--src/zabbix_server/utils/Makefile.am2
-rw-r--r--src/zabbix_server/watchdog/Makefile.am2
-rw-r--r--src/zabbix_server/watchdog/watchdog.c2
108 files changed, 3630 insertions, 5189 deletions
diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am
index 303ac23b..df1f00e7 100644
--- a/src/libs/Makefile.am
+++ b/src/libs/Makefile.am
@@ -5,9 +5,9 @@ DIST_SUBDIRS = \
zbxdb \
zbxemail \
zbxsms \
- zbxcomms \
zbxcrypto \
zbxcommon \
+ zbxcomms \
zbxlog \
zbxnet \
zbxnix \
@@ -18,13 +18,29 @@ DIST_SUBDIRS = \
zbxjabber
if SERVER
-SERVER_SUBDIRS = zbxdb zbxdbhigh zbxemail zbxsms zbxcomms
+SERVER_SUBDIRS = \
+ zbxdb \
+ zbxdbhigh \
+ zbxemail \
+ zbxsms
endif
if JABBER
JABBER_SUBDIRS = zbxjabber
endif
-SUBDIRS = zbxcrypto zbxcommon zbxlog zbxnet zbxnix zbxconf zbxsysinfo zbxplugin zbxsys $(JABBER_SUBDIRS) $(SERVER_SUBDIRS)
+SUBDIRS = \
+ zbxcrypto \
+ zbxcommon \
+ zbxlog \
+ zbxnet \
+ zbxnix \
+ zbxconf \
+ zbxsysinfo \
+ zbxplugin \
+ zbxsys \
+ zbxcomms \
+ $(JABBER_SUBDIRS) \
+ $(SERVER_SUBDIRS)
EXTRA_DISTR = zbxwin32
diff --git a/src/libs/zbxcommon/misc.c b/src/libs/zbxcommon/misc.c
index ee504619..4b50cf97 100644
--- a/src/libs/zbxcommon/misc.c
+++ b/src/libs/zbxcommon/misc.c
@@ -274,9 +274,9 @@ int check_time_period(const char *period, time_t now)
* *
* Function: cmp_double *
* *
- * Purpose: compares two float values *
+ * Purpose: compares two double values *
* *
- * Parameters: a,b - floats to compare *
+ * Parameters: a,b - doubled to compare *
* *
* Return value: 0 - the values are equal *
* 1 - otherwise *
@@ -299,11 +299,11 @@ int cmp_double(double a,double b)
* *
* Function: is_double_prefix *
* *
- * Purpose: check if the string is float *
+ * Purpose: check if the string is double *
* *
* Parameters: c - string to check *
* *
- * Return value: SUCCEED - the string is float *
+ * Return value: SUCCEED - the string is double *
* FAIL - otherwise *
* *
* Author: Alexei Vladishev *
@@ -347,11 +347,11 @@ int is_double_prefix(char *c)
* *
* Function: is_double *
* *
- * Purpose: check if the string is float *
+ * Purpose: check if the string is double *
* *
* Parameters: c - string to check *
* *
- * Return value: SUCCEED - the string is float *
+ * Return value: SUCCEED - the string is double *
* FAIL - otherwise *
* *
* Author: Alexei Vladishev *
@@ -456,55 +456,3 @@ int is_uint(char *c)
return SUCCEED;
}
-int set_result_type(AGENT_RESULT *result, int value_type, char *c)
-{
- int ret = FAIL;
-
- if(value_type == ITEM_VALUE_TYPE_UINT64)
- {
- del_zeroes(c);
- if(is_uint(c) == SUCCEED)
- {
-#ifdef HAVE_ATOLL
- SET_UI64_RESULT(result, atoll(c));
-#else
- SET_UI64_RESULT(result, atol(c));
-#endif
- ret = SUCCEED;
- }
- }
- else if(value_type == ITEM_VALUE_TYPE_FLOAT)
- {
- if(is_double(c) == SUCCEED)
- {
- SET_DBL_RESULT(result, atof(c));
- ret = SUCCEED;
- }
- else if(is_uint(c) == SUCCEED)
- {
-#ifdef HAVE_ATOLL
- SET_DBL_RESULT(result, (double)atoll(c));
-#else
- SET_DBL_RESULT(result, (double)atol(c));
-#endif
- ret = SUCCEED;
- }
- }
- else if(value_type == ITEM_VALUE_TYPE_STR)
- {
- SET_STR_RESULT(result, strdup(c));
- ret = SUCCEED;
- }
- else if(value_type == ITEM_VALUE_TYPE_TEXT)
- {
- SET_TEXT_RESULT(result, strdup(c));
- ret = SUCCEED;
- }
- else if(value_type == ITEM_VALUE_TYPE_LOG)
- {
- SET_STR_RESULT(result, strdup(c));
- ret = SUCCEED;
- }
-
- return ret;
-}
diff --git a/src/libs/zbxdb/Makefile.am b/src/libs/zbxdb/Makefile.am
index 20475d72..3e356ae4 100644
--- a/src/libs/zbxdb/Makefile.am
+++ b/src/libs/zbxdb/Makefile.am
@@ -4,5 +4,3 @@ noinst_LIBRARIES = libzbxdb.a
libzbxdb_a_SOURCES = \
db.c
-
-libzbxdb_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/libs/zbxdb/db.c b/src/libs/zbxdb/db.c
index 043203a3..b0631f87 100644
--- a/src/libs/zbxdb/db.c
+++ b/src/libs/zbxdb/db.c
@@ -447,8 +447,8 @@ lbl_exec:
#endif
/* gettimeofday(&tv, NULL);
- if((float)(tv.tv_usec-msec)/1000000 > 0.1)
- zabbix_log( LOG_LEVEL_WARNING, "Long query: %f sec, query %s", (float)(tv.tv_usec-msec)/1000000, sql );*/
+ if((double)(tv.tv_usec-msec)/1000000 > 0.1)
+ zabbix_log( LOG_LEVEL_WARNING, "Long query: " ZBX_FS_DBL " sec, query %s", (double)(tv.tv_usec-msec)/1000000, sql );*/
zbx_free(sql);
return ret;
@@ -700,8 +700,8 @@ lbl_get_table:
#endif
/* gettimeofday(&tv, NULL);
- if((float)(tv.tv_usec-msec)/1000000 > 0.1)
- zabbix_log( LOG_LEVEL_WARNING, "Long query: %f sec, query %s", (float)(tv.tv_usec-msec)/1000000, sql );*/
+ if((double)(tv.tv_usec-msec)/1000000 > 0.1)
+ zabbix_log( LOG_LEVEL_WARNING, "Long query: " ZBX_FS_DBL " sec, query %s", (double)(tv.tv_usec-msec)/1000000, sql );*/
zbx_free(sql);
return result;
diff --git a/src/libs/zbxdbhigh/Makefile.am b/src/libs/zbxdbhigh/Makefile.am
index 399cc03b..f3b36fb8 100644
--- a/src/libs/zbxdbhigh/Makefile.am
+++ b/src/libs/zbxdbhigh/Makefile.am
@@ -10,4 +10,4 @@ libzbxdbhigh_a_SOURCES = \
host.c \
db.c
-libzbxdbhigh_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_server/ $(DB_CPPFLAGS)
+libzbxdbhigh_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_server/
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 8f76fa43..02b867e9 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -807,12 +807,12 @@ int DBadd_trend(zbx_uint64_t itemid, double value, int clock)
if(value>value_max) value_max=value;
value_avg=(num*value_avg+value)/(num+1);
num++;
- DBexecute("update trends set num=%d, value_min=%f, value_avg=%f, value_max=%f where itemid=" ZBX_FS_UI64 " and clock=%d",
+ DBexecute("update trends set num=%d, value_min=" ZBX_FS_DBL ", value_avg=" ZBX_FS_DBL ", value_max=" ZBX_FS_DBL " where itemid=" ZBX_FS_UI64 " and clock=%d",
num, value_min, value_avg, value_max, itemid, hour);
}
else
{
- DBexecute("insert into trends (clock,itemid,num,value_min,value_avg,value_max) values (%d," ZBX_FS_UI64 ",%d,%f,%f,%f)",
+ DBexecute("insert into trends (clock,itemid,num,value_min,value_avg,value_max) values (%d," ZBX_FS_UI64 ",%d," ZBX_FS_DBL "," ZBX_FS_DBL "," ZBX_FS_DBL ")",
hour, itemid, 1, value, value, value);
}
@@ -825,14 +825,14 @@ int DBadd_history(zbx_uint64_t itemid, double value, int clock)
{
zabbix_log(LOG_LEVEL_DEBUG,"In add_history()");
- DBexecute("insert into history (clock,itemid,value) values (%d," ZBX_FS_UI64 ",%f)",
+ DBexecute("insert into history (clock,itemid,value) values (%d," ZBX_FS_UI64 "," ZBX_FS_DBL ")",
clock,itemid,value);
DBadd_trend(itemid, value, clock);
if(CONFIG_MASTER_NODEID>0)
{
- DBexecute("insert into history_sync (nodeid,clock,itemid,value) values (%d,%d," ZBX_FS_UI64 ",%f)",
+ DBexecute("insert into history_sync (nodeid,clock,itemid,value) values (%d,%d," ZBX_FS_UI64 "," ZBX_FS_DBL ")",
get_nodeid_by_id(itemid),clock,itemid,value);
}
@@ -1223,9 +1223,8 @@ int DBadd_alert(zbx_uint64_t actionid, zbx_uint64_t userid, zbx_uint64_t trigger
DBescape_string(message,message_esc,size);
DBexecute("insert into alerts (alertid, actionid,triggerid,userid,clock,mediatypeid,sendto,subject,message,status,retries)"
- " values (" ZBX_FS_UI64 "," ZBX_FS_UI64 "," ZBX_FS_UI64 "," ZBX_FS_UI64 ",%d," ZBX_FS_UI64 ",'%s','%s','%s',0,0,%d,%d)",
- DBget_maxid("alerts","alertid"),
- actionid,triggerid,userid,now,mediatypeid,sendto_esc,subject_esc,message_esc);
+ " values (" ZBX_FS_UI64 "," ZBX_FS_UI64 "," ZBX_FS_UI64 "," ZBX_FS_UI64 ",%d," ZBX_FS_UI64 ",'%s','%s','%s',0,0)",
+ DBget_maxid("alerts","alertid"), actionid,triggerid,userid,now,mediatypeid,sendto_esc,subject_esc,message_esc);
zbx_free(sendto_esc);
zbx_free(subject_esc);
diff --git a/src/libs/zbxdbhigh/graph.c b/src/libs/zbxdbhigh/graph.c
index 3c0d5473..9adc54ff 100644
--- a/src/libs/zbxdbhigh/graph.c
+++ b/src/libs/zbxdbhigh/graph.c
@@ -37,7 +37,7 @@ int DBadd_graph(char *name, int width, int height, int yaxistype, double yaxismi
DBescape_string(name,name_esc,GRAPH_NAME_LEN_MAX);
- if(FAIL == (exec_res = DBexecute("insert into graphs (name,width,height,yaxistype,yaxismin,yaxismax) values ('%s',%d,%d,%d,%f,%f)", name_esc, width, height, yaxistype, yaxismin, yaxismax)))
+ if(FAIL == (exec_res = DBexecute("insert into graphs (name,width,height,yaxistype,yaxismin,yaxismax) values ('%s',%d,%d,%d," ZBX_FS_DBL "," ZBX_FS_DBL ")", name_esc, width, height, yaxistype, yaxismin, yaxismax)))
{
return FAIL;
}
diff --git a/src/libs/zbxjabber/Makefile.am b/src/libs/zbxjabber/Makefile.am
index b7c42fc9..2a16b936 100644
--- a/src/libs/zbxjabber/Makefile.am
+++ b/src/libs/zbxjabber/Makefile.am
@@ -3,5 +3,3 @@
noinst_LIBRARIES = libzbxjabber.a
libzbxjabber_a_SOURCES = jabber.c
-
-libzbxjabber_a_CPPFLAGS = $(JABBER_CPPFLAGS)
diff --git a/src/libs/zbxsysinfo/Makefile.am b/src/libs/zbxsysinfo/Makefile.am
index 8fb3d66c..dcdbed4f 100644
--- a/src/libs/zbxsysinfo/Makefile.am
+++ b/src/libs/zbxsysinfo/Makefile.am
@@ -1,18 +1,7 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = $(ARCH)
-
-noinst_LIBRARIES = libzbxsysinfo.a
-
-libzbxsysinfo_a_SOURCES = \
- common/common.c \
- common/file.c \
- common/ntp.c \
- common/system.c \
- common/http.c \
- @ARCH@/@ARCH@.c
-
DIST_SUBDIRS = \
+ common \
aix \
freebsd \
hpux \
@@ -21,8 +10,14 @@ DIST_SUBDIRS = \
openbsd \
osf \
osx \
+ simple \
solaris \
- unknown
+ unknown
+
+SUBDIRS = \
+ common \
+ simple \
+ @ARCH@
EXTRA_DIST = \
aix/aix.c \
@@ -36,3 +31,24 @@ EXTRA_DIST = \
solaris/solaris.c \
unknown/unknown.c \
win32
+
+noinst_LIBRARIES = \
+ libzbxagentsysinfo.a \
+ libzbxserversysinfo.a
+
+# AGENT version of sysinfo library
+libzbxagentsysinfo_a_CPPFLAGS = \
+ -DWITH_COMMON_METRICS \
+ -DWITH_SIMPLE_METRICS \
+ -DWITH_SPECIFIC_METRICS
+
+libzbxagentsysinfo_a_SOURCES = \
+ sysinfo.c \
+ @ARCH@/@ARCH@.c specsysinfo.h
+
+# SERVER version of sysinfo library
+libzbxserversysinfo_a_CPPFLAGS = \
+ -DWITH_SIMPLE_METRICS
+
+libzbxserversysinfo_a_SOURCES = \
+ sysinfo.c
diff --git a/src/libs/zbxsysinfo/aix/Makefile.am b/src/libs/zbxsysinfo/aix/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/aix/Makefile.am
+++ b/src/libs/zbxsysinfo/aix/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/aix/aix.c b/src/libs/zbxsysinfo/aix/aix.c
index a0b6ca2e..28187562 100644
--- a/src/libs/zbxsysinfo/aix/aix.c
+++ b/src/libs/zbxsysinfo/aix/aix.c
@@ -17,27 +17,14 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
-
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
-
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
-
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
{"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
@@ -45,21 +32,17 @@ ZBX_METRIC parameters_specific[]=
{"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"},
{"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
- {"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.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
- {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
- {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -70,11 +53,7 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/aix/cpu.c b/src/libs/zbxsysinfo/aix/cpu.c
index 74d91441..aacb713a 100644
--- a/src/libs/zbxsysinfo/aix/cpu.c
+++ b/src/libs/zbxsysinfo/aix/cpu.c
@@ -21,103 +21,13 @@
#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)
-{
- return get_stat("cpu[nice15]", flags, result);
-}
-
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user1]", flags, result);
-}
-
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
-
-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);
-}
-
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
-}
-
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#include "stats.h"
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
-
- CPU_FNCLIST fl[] =
- {
- {"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}
- };
-
char cpuname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -128,7 +38,7 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, cpuname, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, cpuname, sizeof(cpuname)) != 0)
{
return SYSINFO_RET_FAIL;
}
@@ -137,12 +47,12 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(cpuname, sizeof(cpuname), "all");
}
- if(strncmp(cpuname, "all", MAX_STRING_LEN))
+ if(strncmp(cpuname, "all", sizeof(cpuname)))
{
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, MAX_STRING_LEN) != 0)
+ if(get_param(param, 2, type, sizeof(type)) != 0)
{
type[0] = '\0';
}
@@ -152,7 +62,7 @@ CPU_FNCLIST
zbx_snprintf(type, sizeof(type), "user");
}
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 3, mode, sizeof(mode)) != 0)
{
mode[0] = '\0';
}
@@ -162,18 +72,49 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, param, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"idle"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.idle1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.idle5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.idle15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"nice"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.nice1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.nice5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.nice15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"user"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.user1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.user5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.user15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else if( 0 == strcmp(type,"system"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.system1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.system5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.system15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
}
/* AIX CPU info */
@@ -502,7 +443,7 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, cpuname, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, cpuname, sizeof(cpuname)) != 0)
{
return SYSINFO_RET_FAIL;
}
@@ -511,12 +452,12 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(cpuname, sizeof(cpuname), "all");
}
- if(strncmp(cpuname, "all", MAX_STRING_LEN))
+ if(strncmp(cpuname, "all", sizeof(cpuname)))
{
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 2, mode, sizeof(mode)) != 0)
{
mode[0] = '\0';
}
diff --git a/src/libs/zbxsysinfo/aix/diskio.c b/src/libs/zbxsysinfo/aix/diskio.c
index c486acfd..642ac402 100644
--- a/src/libs/zbxsysinfo/aix/diskio.c
+++ b/src/libs/zbxsysinfo/aix/diskio.c
@@ -22,140 +22,15 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#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}
- };
-
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -166,12 +41,12 @@ DEV_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, devname, sizeof(devname)) != 0)
{
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, MAX_STRING_LEN) != 0)
+ if(get_param(param, 2, type, sizeof(type)) != 0)
{
type[0] = '\0';
}
@@ -181,7 +56,7 @@ DEV_FNCLIST
zbx_snprintf(type, sizeof(type), "bps");
}
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 3, mode, sizeof(mode)) != 0)
{
mode[0] = '\0';
}
@@ -191,47 +66,47 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
-}
-int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
-#define DEV_FNCLIST struct dev_fnclist_s
-DEV_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
- DEV_FNCLIST fl[] =
+ }
+ else
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
- };
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
+}
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -242,12 +117,12 @@ DEV_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, devname, sizeof(devname)) != 0)
{
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, MAX_STRING_LEN) != 0)
+ if(get_param(param, 2, type, sizeof(type)) != 0)
{
type[0] = '\0';
}
@@ -257,7 +132,7 @@ DEV_FNCLIST
zbx_snprintf(type, sizeof(type), "bps");
}
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 3, mode, sizeof(mode)) != 0)
{
mode[0] = '\0';
}
@@ -267,19 +142,36 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
}
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -341,7 +233,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, key, sizeof(key)) != 0)
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/aix/proc.c b/src/libs/zbxsysinfo/aix/proc.c
index eadf19c2..5c4880b4 100644
--- a/src/libs/zbxsysinfo/aix/proc.c
+++ b/src/libs/zbxsysinfo/aix/proc.c
@@ -26,6 +26,18 @@
#define DO_MAX 1
#define DO_MIN 2
#define DO_AVG 3
+
+#ifndef HAVE_SYS_PROCFS_H
+int getprocs(
+ struct procsinfo *ProcessBuffer,
+ int ProcessSize,
+ struct fdsinfo *FileBuffer,
+ int FileSize,
+ pid_t *IndexPointer,
+ int Count
+ );
+#endif /* ndef HAVE_SYS_PROCFS_H */
+
int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{ /* usage: <function name>[ <process name>, <user name>, <mode>, <command> ] */
diff --git a/src/libs/zbxsysinfo/common/Makefile.am b/src/libs/zbxsysinfo/common/Makefile.am
new file mode 100644
index 00000000..4f2d4f05
--- /dev/null
+++ b/src/libs/zbxsysinfo/common/Makefile.am
@@ -0,0 +1,10 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_LIBRARIES = libcommonsysinfo.a
+
+libcommonsysinfo_a_SOURCES = \
+ common.c common.h \
+ file.c file.h \
+ http.c http.h \
+ net.c net.h \
+ system.c system.h
diff --git a/src/libs/zbxsysinfo/common/common.c b/src/libs/zbxsysinfo/common/common.c
index 684d2964..cb44a717 100644
--- a/src/libs/zbxsysinfo/common/common.c
+++ b/src/libs/zbxsysinfo/common/common.c
@@ -20,975 +20,60 @@
#include "common.h"
#include "sysinfo.h"
-#include "alias.h"
-#include "md5.h"
#include "log.h"
#include "threads.h"
-#include "cfg.h"
-#include "zbxsock.h"
-ZBX_METRIC *commands=NULL;
-extern ZBX_METRIC parameters_specific[];
+#include "file.h"
+#include "http.h"
+#include "net.h"
+#include "system.h"
+
+#if !defined(_WINDOWS)
+# define VFS_TEST_FILE "/etc/passwd"
+# define VFS_TEST_REGEXP "root"
+#else
+# define VFS_TEST_FILE "c:\\windows\\win.ini"
+# define VFS_TEST_REGEXP "fonts"
+#endif /* _WINDOWS */
+
+static int AGENT_PING(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+static int AGENT_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
ZBX_METRIC parameters_common[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
+ {"agent.ping", 0, AGENT_PING, 0, 0},
+ {"agent.version", 0, AGENT_VERSION, 0, 0},
+
{"system.localtime", 0, SYSTEM_LOCALTIME, 0, 0},
{"system.run", CF_USEUPARAM, RUN_COMMAND, 0, "echo test"},
+
{"web.page.get", CF_USEUPARAM, WEB_PAGE_GET, 0, "localhost,,80"},
{"web.page.perf", CF_USEUPARAM, WEB_PAGE_PERF, 0, "localhost,,80"},
{"web.page.regexp", CF_USEUPARAM, WEB_PAGE_REGEXP, 0, "localhost,,80,OK"},
- {0}
- };
-
-void add_metric(ZBX_METRIC *new)
-{
-
- int i;
-
- if(new->key == NULL)
- return;
-
- for(i=0;;i++)
- {
- if(commands[i].key == NULL)
- {
-
- commands[i].key = strdup(new->key);
- commands[i].flags = new->flags;
-
- commands[i].function=new->function;
-
- if(new->main_param == NULL)
- commands[i].main_param=NULL;
- else
- commands[i].main_param=strdup(new->main_param);
-
- if(new->test_param == NULL)
- commands[i].test_param=NULL;
- else
- commands[i].test_param=strdup(new->test_param);
-
- commands=realloc(commands,(i+2)*sizeof(ZBX_METRIC));
- commands[i+1].key=NULL;
- break;
- }
- }
-}
-
-void add_user_parameter(char *key,char *command)
-{
- int i;
- char usr_cmd[MAX_STRING_LEN];
- char usr_param[MAX_STRING_LEN];
- unsigned flag = 0;
-
- i = parse_command(key, usr_cmd, MAX_STRING_LEN, usr_param, MAX_STRING_LEN);
- if(i == 0)
- {
- zabbix_log( LOG_LEVEL_WARNING, "Can't add user specifed key \"%s\". Can't parse key!", key);
- return;
- }
- else if(i == 2) /* with specifed parameters */
- {
- if(strcmp(usr_param,"*")){ /* must be '*' parameters */
- zabbix_log(LOG_LEVEL_WARNING, "Can't add user specifed key \"%s\". Incorrect key!", key);
- return;
- }
- flag |= CF_USEUPARAM;
- }
-
- for(i=0;;i++)
- {
- /* Add new parameters */
- if( commands[i].key == 0)
- {
- commands[i].key = strdup(usr_cmd);
- commands[i].flags = flag;
- commands[i].function = &EXECUTE_STR;
- commands[i].main_param = strdup(command);
- commands[i].test_param = 0;
-
- commands=realloc(commands,(i+2)*sizeof(ZBX_METRIC));
- commands[i+1].key=NULL;
-
- break;
- }
-
- /* Replace existing parameters */
- if(strcmp(commands[i].key, key) == 0)
- {
- if(commands[i].key)
- free(commands[i].key);
- if(commands[i].main_param)
- free(commands[i].main_param);
- if(commands[i].test_param)
- free(commands[i].test_param);
-
- commands[i].key = strdup(key);
- commands[i].flags = flag;
- commands[i].function = &EXECUTE_STR;
- commands[i].main_param = strdup(command);
- commands[i].test_param = 0;
-
- break;
- }
- }
-}
-
-void init_metrics()
-{
- int i;
-
- commands = malloc(sizeof(ZBX_METRIC));
- commands[0].key=NULL;
-
- for(i=0;parameters_common[i].key!=0;i++)
- {
- add_metric(&parameters_common[i]);
- }
-
- for(i=0;parameters_specific[i].key!=0;i++)
- {
- add_metric(&parameters_specific[i]);
- }
-}
-
-void escape_string(char *from, char *to, int maxlen)
-{
- int i,ptr;
- char *f;
-
- ptr=0;
- f=(char *)strdup(from);
- for(i=0;f[i]!=0;i++)
- {
- if( (f[i]=='\'') || (f[i]=='\\'))
- {
- if(ptr>maxlen-1) break;
- to[ptr]='\\';
- if(ptr+1>maxlen-1) break;
- to[ptr+1]=f[i];
- ptr+=2;
- }
- else
- {
- if(ptr>maxlen-1) break;
- to[ptr]=f[i];
- ptr++;
- }
- }
- free(f);
-
- to[ptr]=0;
- to[maxlen-1]=0;
-}
-
-static void init_result_list(ZBX_LIST *list)
-{
- /* don't use `free_result_list(list)`, dangerous recycling */
-
- /* nothin to do */
-}
-static void free_result_list(ZBX_LIST *list)
-{
- /* nothin to do */
-}
-
-static int copy_result_list(ZBX_LIST *src, ZBX_LIST *dist)
-{
- /* nothin to do */
- return 0;
-}
-
-int copy_result(AGENT_RESULT *src, AGENT_RESULT *dist)
-{
- assert(src);
- assert(dist);
-
- free_result(dist);
- dist->type = src->type;
- dist->dbl = src->dbl;
- if(src->str)
- {
- dist->str = strdup(src->str);
- if(!dist->str)
- return 1;
- }
- if(src->msg)
- {
- dist->msg = strdup(src->msg);
- if(!dist->msg)
- return 1;
- }
- return copy_result_list(&(src->list), &(dist->list));
-}
-
-void free_result(AGENT_RESULT *result)
-{
-
- UNSET_DBL_RESULT(result);
- UNSET_UI64_RESULT(result);
- UNSET_STR_RESULT(result);
- UNSET_TEXT_RESULT(result);
- UNSET_MSG_RESULT(result);
-
- if(result->type & AR_LIST)
- {
- free_result_list(&(result->list));
-
- result->type &= ~AR_LIST;
- }
-
-}
-
-void init_result(AGENT_RESULT *result)
-{
- /* don't use `free_result(result)`, dangerous recycling */
-
- result->type = 0;
-
- result->ui64 = 0;
- result->dbl = 0;
- result->str = NULL;
- result->text = NULL;
- result->msg = NULL;
-
- init_result_list(&(result->list));
-}
-
-int parse_command( /* return value: 0 - error; 1 - command without parameters; 2 - command with parameters */
- const char *command,
- char *cmd,
- int cmd_max_len,
- char *param,
- int param_max_len
- )
-{
- char *pl, *pr;
- char localstr[MAX_STRING_LEN];
- int ret = 2;
-
- zbx_strlcpy(localstr, command, MAX_STRING_LEN);
-
- if(cmd)
- zbx_strlcpy(cmd, "", cmd_max_len);
- if(param)
- zbx_strlcpy(param, "", param_max_len);
-
- pl = strstr(localstr, "[");
- pr = strstr(localstr, "]");
-
- if(pl > pr)
- return 0;
-
- if((pl && !pr) || (!pl && pr))
- return 0;
-
- if(pl != NULL)
- pl[0] = 0;
- if(pr != NULL)
- pr[0] = 0;
-
- if(cmd)
- zbx_strlcpy(cmd, localstr, cmd_max_len);
-
- if(pl && pr && param)
- zbx_strlcpy(param, &pl[1] , param_max_len);
-
- if(!pl && !pr)
- ret = 1;
-
- return ret;
-}
-
-void test_parameter(char* key)
-{
- AGENT_RESULT result;
-
- memset(&result, 0, sizeof(AGENT_RESULT));
- process(key, PROCESS_TEST, &result);
- if(result.type & AR_DOUBLE)
- {
- printf(" [d|" ZBX_FS_DBL "]", result.dbl);
- }
- if(result.type & AR_UINT64)
- {
- printf(" [u|" ZBX_FS_UI64 "]", result.ui64);
- }
- if(result.type & AR_STRING)
- {
- printf(" [s|%s]", result.str);
- }
- if(result.type & AR_TEXT)
- {
- printf(" [t|%s]", result.text);
- }
- if(result.type & AR_MESSAGE)
- {
- printf(" [m|%s]", result.msg);
- }
-
- free_result(&result);
- printf("\n");
-
- fflush(stdout);
-}
-
-void test_parameters(void)
-{
- int i;
- AGENT_RESULT result;
-
-#if defined(_WINDOWS)
-#endif
-
- memset(&result, 0, sizeof(AGENT_RESULT));
-
- for(i=0; 0 != commands[i].key; i++)
- {
- process(commands[i].key, PROCESS_TEST | PROCESS_USE_TEST_PARAM, &result);
- if(result.type & AR_DOUBLE)
- {
- printf(" [d|" ZBX_FS_DBL "]", result.dbl);
- }
- if(result.type & AR_UINT64)
- {
- printf(" [u|" ZBX_FS_UI64 "]", result.ui64);
- }
- if(result.type & AR_STRING)
- {
- printf(" [s|%s]", result.str);
- }
- if(result.type & AR_TEXT)
- {
- printf(" [t|%s]", result.text);
- }
- if(result.type & AR_MESSAGE)
- {
- printf(" [m|%s]", result.msg);
- }
- free_result(&result);
- printf("\n");
-
- fflush(stdout);
- }
-}
-
-int replace_param(const char *cmd, const char *param, char *out, int outlen)
-{
- int ret = SUCCEED;
- char buf[MAX_STRING_LEN];
- char command[MAX_STRING_LEN];
- char *pl, *pr;
-
- assert(out);
-
- out[0] = '\0';
-
- if(!cmd && !param)
- return ret;
-
- zbx_strlcpy(command, cmd, MAX_STRING_LEN);
-
- pl = command;
- while((pr = strchr(pl, '$')) && outlen > 0)
- {
- pr[0] = '\0';
- zbx_strlcat(out, pl, outlen);
- outlen -= MIN((int)strlen(pl), (int)outlen);
- pr[0] = '$';
-
- if (pr[1] >= '0' && pr[1] <= '9')
- {
- buf[0] = '\0';
-
- if(pr[1] == '0')
- {
- zbx_strlcpy(buf, command, MAX_STRING_LEN);
- }
- else
- {
- get_param(param, (int)(pr[1] - '0'), buf, MAX_STRING_LEN);
- }
-
- zbx_strlcat(out, buf, outlen);
- outlen -= MIN((int)strlen(buf), (int)outlen);
-
- pl = pr + 2;
- continue;
- } else if(pr[1] == '$')
- {
- pr++; /* remove second '$' symbol */
- }
-
- pl = pr + 1;
- zbx_strlcat(out, "$", outlen);
- outlen -= 1;
- }
- zbx_strlcat(out, pl, outlen);
- outlen -= MIN((int)strlen(pl), (int)outlen);
-
- return ret;
-}
-
-int process(const char *in_command, unsigned flags, AGENT_RESULT *result)
-{
- char *p;
- int i;
- int (*function)() = NULL;
- int ret = SUCCEED;
- int err = SYSINFO_RET_OK;
-
- char usr_cmd[MAX_STRING_LEN];
- char usr_param[MAX_STRING_LEN];
-
- char usr_command[MAX_STRING_LEN];
- int usr_command_len;
-
- char param[MAX_STRING_LEN];
-
-
- assert(result);
- init_result(result);
-
- alias_expand(in_command, usr_command, MAX_STRING_LEN);
-
- usr_command_len = (int)strlen(usr_command);
-
- for( p=usr_command+usr_command_len-1; p>usr_command && ( *p=='\r' || *p =='\n' || *p == ' ' ); --p );
-
- if( (p[1]=='\r') || (p[1]=='\n') || (p[1]==' '))
- {
- p[1]=0;
- }
-
- function=0;
-
- if(parse_command(usr_command, usr_cmd, MAX_STRING_LEN, usr_param, MAX_STRING_LEN) != 0)
- {
-
- for(i=0; commands[i].key != 0; i++)
- {
- if( strcmp(commands[i].key, usr_cmd) == 0)
- {
- function=commands[i].function;
- break;
- }
- }
- }
-
- param[0] = '\0';
- if(function != 0)
- {
-
- if(commands[i].flags & CF_USEUPARAM)
- {
- if((flags & PROCESS_TEST) && (flags & PROCESS_USE_TEST_PARAM) && commands[i].test_param)
- {
- zbx_strlcpy(usr_param, commands[i].test_param, MAX_STRING_LEN);
- }
- }
- else
- {
- usr_param[0] = '\0';
- }
-
- if(commands[i].main_param)
- {
- if(commands[i].flags & CF_USEUPARAM)
- {
- err = replace_param(
- commands[i].main_param,
- usr_param,
- param,
- MAX_STRING_LEN);
- }
- else
- {
- zbx_snprintf(param, sizeof(param), "%s", commands[i].main_param);
- }
- }
- else
- {
- zbx_snprintf(param, sizeof(param), "%s", usr_param);
- }
-
- if(err != FAIL)
- {
- err = function(usr_command, param, flags, result);
-
- if(err == SYSINFO_RET_FAIL)
- err = NOTSUPPORTED;
- else if(err == SYSINFO_RET_TIMEOUT)
- err = TIMEOUT_ERROR;
- }
- }
- else
- {
- err = NOTSUPPORTED;
- }
-
- if(flags & PROCESS_TEST)
- {
- printf("%s", usr_cmd);
- if(commands[i].flags & CF_USEUPARAM)
- {
- printf("[%s]", param);
- i = (int)strlen(param)+2;
- } else i = 0;
- i += (int)strlen(usr_cmd);
-
-#define COLUMN_2_X 45 /* max of spaces count */
- i = i > COLUMN_2_X ? 1 : (COLUMN_2_X - i);
-
- printf("%-*.*s", i, i, " "); /* print spaces */
- }
-
- if(err == NOTSUPPORTED)
- {
- if(!(result->type & AR_MESSAGE))
- {
- SET_MSG_RESULT(result, strdup("ZBX_NOTSUPPORTED"));
- }
- ret = NOTSUPPORTED;
- }
- else if(err == TIMEOUT_ERROR)
- {
- if(!(result->type & AR_MESSAGE))
- {
- SET_MSG_RESULT(result, strdup("ZBX_ERROR"));
- }
- ret = TIMEOUT_ERROR;
- }
-
- return ret;
-}
-
-/* MD5 sum calculation */
-
-int VFS_FILE_MD5SUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- FILE *file = NULL;
- int i;
- size_t nr;
- struct stat buf_stat;
-
- md5_state_t state;
- u_char buf[16 * 1024];
-
- unsigned char hashText[MD5_DIGEST_SIZE*2+1];
- md5_byte_t hash[MD5_DIGEST_SIZE];
-
- char filename[MAX_STRING_LEN];
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, filename, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(stat(filename,&buf_stat) != 0)
- {
- /* Cannot stat() file */
- return SYSINFO_RET_FAIL;
- }
-
- if(buf_stat.st_size > 64*1024*1024)
- {
- /* Will not calculate MD5 for files larger than 64M */
- return SYSINFO_RET_FAIL;
- }
-
- if(NULL == (file = fopen(filename,"rb")))
- {
- return SYSINFO_RET_FAIL;
- }
-
- md5_init(&state);
- while ((nr = fread(buf, 1, (size_t)sizeof(buf), file)) > 0)
- {
- md5_append(&state,(const md5_byte_t *)buf, (int)nr);
- }
- md5_finish(&state, hash);
-
- zbx_fclose(file);
-
-/* Convert MD5 hash to text form */
- for(i=0;i<MD5_DIGEST_SIZE;i++)
- {
- zbx_snprintf((char *)&hashText[i<<1], sizeof(hashText) - (i<<1), "%02x",hash[i]);
- }
-
- SET_STR_RESULT(result, strdup((char*)hashText));
-
- return SYSINFO_RET_OK;
-
-}
-
-/* Code for cksum is based on code from cksum.c */
-
-static u_long crctab[] = {
- 0x0,
- 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
- 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
- 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
- 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,
- 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f,
- 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a,
- 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
- 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58,
- 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033,
- 0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe,
- 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
- 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4,
- 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
- 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5,
- 0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
- 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07,
- 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c,
- 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,
- 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
- 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b,
- 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698,
- 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d,
- 0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
- 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f,
- 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
- 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80,
- 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
- 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a,
- 0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629,
- 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c,
- 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
- 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,
- 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65,
- 0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8,
- 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
- 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2,
- 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
- 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74,
- 0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
- 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21,
- 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a,
- 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087,
- 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
- 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d,
- 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce,
- 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,
- 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
- 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09,
- 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
- 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf,
- 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
-};
-
-/*
- * Compute a POSIX 1003.2 checksum. These routines have been broken out so
- * that other programs can use them. The first routine, crc(), takes a file
- * descriptor to read from and locations to store the crc and the number of
- * bytes read. The second routine, crc_buf(), takes a buffer and a length,
- * and a location to store the crc. Both routines return 0 on success and 1
- * on failure. Errno is set on failure.
- */
-
-int VFS_FILE_CKSUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- register u_char *p;
- register int nr;
-
-/* AV Crashed under 64 platforms. Must be 32 bit! */
-/* register u_long crc, len;*/
- register uint32_t crc, len;
-
- u_char buf[16 * 1024];
- u_long cval, clen;
- FILE *f;
- char filename[MAX_STRING_LEN];
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, filename, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(NULL == (f = fopen(filename,"rb")))
- {
- return SYSINFO_RET_FAIL;
- }
-
-#define COMPUTE(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
-
- crc = len = 0;
- while ((nr = (int)fread(buf, 1, sizeof(buf), f)) > 0)
- {
- for( len += nr, p = buf; nr--; ++p)
- {
- COMPUTE(crc, *p);
- }
- }
- zbx_fclose(f);
-
- if (nr < 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- clen = len;
- /* Include the length of the file. */
- for (; len != 0; len >>= 8) {
- COMPUTE(crc, len & 0xff);
- }
+ {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, VFS_TEST_FILE},
+ {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, VFS_TEST_FILE ",modify"},
+ {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, VFS_TEST_FILE},
+ {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, VFS_TEST_FILE "," VFS_TEST_REGEXP},
+ {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, VFS_TEST_FILE "," VFS_TEST_REGEXP},
+ {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, VFS_TEST_FILE},
+ {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, VFS_TEST_FILE},
- cval = ~crc;
+ {"net.tcp.dns", CF_USEUPARAM, CHECK_DNS, 0, "127.0.0.1,localhost"},
+ {"net.tcp.port", CF_USEUPARAM, CHECK_PORT, 0, ",80"},
- SET_UI64_RESULT(result, cval);
+ {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
+ {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- return SYSINFO_RET_OK;
-}
-
-int
-crc_buf2(p, clen, cval)
- register u_char *p;
- u_long clen;
- u_long *cval;
-{
- register u_long crc, len;
-
- crc = 0;
- for (len = clen; len--; ++p)
- COMPUTE(crc, *p);
-
- /* Include the length of the file. */
- for (len = clen; len != 0; len >>= 8)
- COMPUTE(crc, len & 0xff);
-
- *cval = ~crc;
- return (0);
-}
+ {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
-int get_stat(const char *key, unsigned flags, AGENT_RESULT *result)
-{
- FILE *f = NULL;
- char line[MAX_STRING_LEN];
- char name1[MAX_STRING_LEN];
- char name2[MAX_STRING_LEN];
- int ret = SYSINFO_RET_FAIL;
-
- assert(result);
-
- init_result(result);
-
- if(NULL == (f = fopen("/tmp/zabbix_agentd.tmp","r")))
- {
- return SYSINFO_RET_FAIL;
- }
-
- while(fgets(line,MAX_STRING_LEN,f))
- {
- if(sscanf(line,"%s %s\n",name1,name2)==2)
- {
- if(strcmp(name1,key) == 0)
- {
- SET_UI64_RESULT(result, atoi(name2));
- ret = SYSINFO_RET_OK;
- break;
- }
- }
-
- }
-
- zbx_fclose(f);
-
- return ret;
-}
-
-int NET_IF_IBYTES1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"netloadin1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-int NET_IF_IBYTES5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"netloadin5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-int NET_IF_IBYTES15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"netloadin15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-int NET_IF_OBYTES1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"netloadout1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-int NET_IF_OBYTES5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"netloadout5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-int NET_IF_OBYTES15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"netloadout15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-int TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
-#ifdef HAVE_PROC
- FILE *f = NULL;
- char c[MAX_STRING_LEN];
- char porthex[MAX_STRING_LEN];
- char pattern[MAX_STRING_LEN];
- int ret = SYSINFO_RET_FAIL;
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, porthex, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- strscpy(pattern,porthex);
- zbx_strlcat(pattern," 00000000:0000 0A", MAX_STRING_LEN);
-
- if(NULL == (f = fopen("/proc/net/tcp","r")))
- {
- return SYSINFO_RET_FAIL;
- }
-
- while (NULL != fgets(c,MAX_STRING_LEN,f))
- {
- if(NULL != strstr(c,pattern))
- {
- SET_UI64_RESULT(result, 1);
- ret = SYSINFO_RET_OK;
- break;
- }
- }
- zbx_fclose(f);
-
- SET_UI64_RESULT(result, 0);
-
- return ret;
-#else
- return SYSINFO_RET_FAIL;
-#endif
-}
-
-#ifdef HAVE_PROC
-int getPROC2(char *file, char *param, int fieldno, unsigned flags, int type, AGENT_RESULT *result)
-{
-
- FILE *f;
- char *res;
- char buf[MAX_STRING_LEN];
- int i;
- int found;
- unsigned long uValue;
- double fValue;
-
- if (NULL == (f = fopen(file,"r")))
- {
- return SYSINFO_RET_FAIL;
- }
-
- /* find line */
- found = 0;
- while ( fgets(buf, MAX_STRING_LEN, f) != NULL )
- {
- if (strncmp(buf, "btime", 5) == 0)
- {
- found = 1;
- break;
- }
- }
-
- if (!found) return SYSINFO_RET_FAIL;
-
- /* find field */
- res = (char *)strtok(buf, " "); /* btime field1 field2 */
- for(i=1; i<=fieldno; i++)
- {
- res = (char *)strtok(NULL," ");
- }
-
- zbx_fclose(f);
-
- if ( res == NULL )
- {
- return SYSINFO_RET_FAIL;
- }
-
- /* convert field to right type */
- switch (type)
- {
- case AR_UINT64:
- sscanf(res, "%lu", &uValue);
- SET_UI64_RESULT(result, uValue);
- break;
- case AR_DOUBLE:
- sscanf(res, "%lf", &fValue);
- SET_DBL_RESULT(result, fValue);
- break;
- case AR_STRING: default:
- SET_STR_RESULT(result, buf);
- break;
- }
-
- return SYSINFO_RET_OK;
-}
+ {0}
+ };
int getPROC(char *file, int lineno, int fieldno, unsigned flags, AGENT_RESULT *result)
{
+#ifdef HAVE_PROC
FILE *f;
char *t;
char c[MAX_STRING_LEN];
@@ -1021,10 +106,12 @@ int getPROC(char *file, int lineno, int fieldno, unsigned flags, AGENT_RESULT *r
SET_DBL_RESULT(result, value);
return SYSINFO_RET_OK;
+#else
+ return SYSINFO_RET_FAIL;
+#endif /* HAVE_PROC */
}
-#endif
-int AGENT_PING(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int AGENT_PING(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
assert(result);
@@ -1034,136 +121,7 @@ int AGENT_PING(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_OK;
}
-int PROCCOUNT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
-#ifdef HAVE_SYSINFO_PROCS
- struct sysinfo info;
-
- assert(result);
-
- init_result(result);
-
- if( 0 == sysinfo(&info))
- {
- SET_UI64_RESULT(result, info.procs);
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
-#ifdef HAVE_PROC_0_PSINFO
- DIR *dir;
- struct dirent *entries;
- struct stat buf;
- char filename[MAX_STRING_LEN];
-
- int fd;
-/* In the correct procfs.h, the structure name is psinfo_t */
- psinfo_t psinfo;
-
- int proccount=0;
- assert(result);
-
- init_result(result);
-
- dir=opendir("/proc");
- if(NULL == dir)
- {
- return SYSINFO_RET_FAIL;
- }
-
- while((entries=readdir(dir))!=NULL)
- {
- strscpy(filename,"/proc/");
- zbx_strlcat(filename,entries->d_name,MAX_STRING_LEN);
- zbx_strlcat(filename,"/psinfo",MAX_STRING_LEN);
-
- if(stat(filename,&buf)==0)
- {
- fd = open (filename, O_RDONLY);
- if (fd != -1)
- {
- if (read (fd, &psinfo, sizeof(psinfo)) == -1)
- {
- closedir(dir);
- return SYSINFO_RET_FAIL;
- }
- else
- {
- proccount++;
- }
- close (fd);
- }
- else
- {
- continue;
- }
- }
- }
- closedir(dir);
-
- SET_UI64_RESULT(result, proccount);
-
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_PROC_1_STATUS
- DIR *dir;
- struct dirent *entries;
- struct stat buf;
- char filename[MAX_STRING_LEN];
- char line[MAX_STRING_LEN];
-
- FILE *f;
-
- int proccount=0;
-
- assert(result);
-
- init_result(result);
-
- dir=opendir("/proc");
- if(NULL == dir)
- {
- return SYSINFO_RET_FAIL;
- }
-
- while((entries=readdir(dir))!=NULL)
- {
- strscpy(filename,"/proc/");
- zbx_strlcat(filename,entries->d_name,MAX_STRING_LEN);
- zbx_strlcat(filename,"/status",MAX_STRING_LEN);
-
- if(stat(filename,&buf)==0)
- {
- if(NULL == (f = fopen(filename,"r")))
- {
- continue;
- }
-
- /* This check can be skipped. No need to read anything from this file. */
- if(NULL != fgets(line,MAX_STRING_LEN,f))
- {
- proccount++;
- }
-
- zbx_fclose(f);
- }
- }
- closedir(dir);
-
- SET_UI64_RESULT(result, proccount);
-
- return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
-#endif
-#endif
-}
-
-int AGENT_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+static int AGENT_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
static char version[]=ZABBIX_VERSION;
@@ -1176,36 +134,6 @@ int AGENT_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESU
return SYSINFO_RET_OK;
}
-int OLD_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
- int ret;
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(strcmp(key,"zabbix_agent") == 0)
- {
- ret = AGENT_VERSION(cmd, param, flags, result);
- }
- else
- {
- ret = SYSINFO_RET_FAIL;
- }
-
- return ret;
-}
int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
@@ -1327,8 +255,6 @@ int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
cmd_result[len] = '\0';
- zabbix_log(LOG_LEVEL_DEBUG, "Run remote command [%s] Result [%d] [%s]", command, strlen(cmd_result), cmd_result);
-
if(pclose(f) == -1)
{
switch (errno)
@@ -1358,6 +284,8 @@ int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
}
}
+ zabbix_log(LOG_LEVEL_DEBUG, "Run remote command [%s] Result [%d] [%s]", command, strlen(cmd_result), cmd_result);
+
SET_TEXT_RESULT(result, strdup(cmd_result));
return SYSINFO_RET_OK;
@@ -1519,769 +447,3 @@ int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
return SYSINFO_RET_OK;
}
-
-
-/*
-static int forward_request(char *proxy, char *command, int port, unsigned flags, AGENT_RESULT *result)
-{
- ZBX_SOCKET s;
- ZBX_SOCKADDR servaddr_in;
-
- struct hostent *hp;
-
- char buf[MAX_BUF_LEN];
-
- int len;
-
- assert(result);
-
- init_result(result);
-
- if(NULL == (hp = zbx_gethost(proxy)) )
- {
- SET_MSG_RESULT(result, strdup("ZBX_NETWORK_ERROR"));
- return SYSINFO_RET_FAIL;
- }
-
- memset(&servaddr_in, 0, sizeof(ZBX_SOCKADDR));
-
- servaddr_in.sin_family = AF_INET;
- servaddr_in.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
- servaddr_in.sin_port = htons(port);
-
- if(INVALID_SOCKET == (s = socket(AF_INET,SOCK_STREAM,0)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error in socket() [%s:%u] [%s]",proxy, port, strerror_from_system(errno));
- SET_MSG_RESULT(result, strdup("ZBX_NOTSUPPORTED"));
- return SYSINFO_RET_FAIL;
- }
-
-
- if(SOCKET_ERROR == connect(s,(struct sockaddr *)&servaddr_in,sizeof(ZBX_SOCKADDR)))
- {
- zabbix_log( LOG_LEVEL_WARNING, "Error in connect() [%s:%u] [%s]",proxy, port, strerror_from_system(errno));
- zbx_sock_close(s);
- SET_MSG_RESULT(result, strdup("ZBX_NETWORK_ERROR"));
- return SYSINFO_RET_FAIL;
- }
-
-
- if(SOCKET_ERROR == zbx_sock_write(s, command, strlen(command)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error during sending [%s:%u] [%s]",proxy, port, strerror_from_system(errno));
- zbx_sock_close(s);
- SET_MSG_RESULT(result, strdup("ZBX_NETWORK_ERROR"));
- return SYSINFO_RET_FAIL;
- }
-
- memset(buf, 0, sizeof(buf));
-
- if(SOCKET_ERROR == (len = zbx_sock_read(s, buf, sizeof(buf)-1, CONFIG_TIMEOUT)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error in reading() [%s:%u] [%s]",proxy, port, strerror_from_system(errno));
- zbx_sock_close(s);
- SET_MSG_RESULT(result, strdup("ZBX_ERROR"));
- return SYSINFO_RET_FAIL;
- }
-
- zbx_sock_close(s);
-
- SET_STR_RESULT(result, strdup(buf));
-
- return SYSINFO_RET_OK;
-}
-*/
-
-/*
- * 0 - NOT OK
- * 1 - OK
- * */
-static int tcp_expect(const char *hostname, short port, const char *request, const char *expect, const char *sendtoclose, int *value_int)
-{
- ZBX_SOCKET s;
- ZBX_SOCKADDR servaddr_in;
-
- struct hostent *hp;
-
- char buf[MAX_BUF_LEN];
-
- int len;
-
- assert(hostname);
- assert(value_int);
-
- *value_int = 0;
-
- if(NULL == (hp = zbx_gethost(hostname)) )
- {
- return SYSINFO_RET_OK;
- }
-
- memset(&servaddr_in, 0, sizeof(ZBX_SOCKADDR));
-
- servaddr_in.sin_family = AF_INET;
- servaddr_in.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
- servaddr_in.sin_port = htons(port);
-
- if(INVALID_SOCKET == (s = (ZBX_SOCKET)socket(AF_INET,SOCK_STREAM,0)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error in socket() [%s:%u] [%s]", hostname, port, strerror_from_system(errno));
- return SYSINFO_RET_OK;
- }
-
- if(SOCKET_ERROR == connect(s,(struct sockaddr *)&servaddr_in,sizeof(ZBX_SOCKADDR)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error in connect() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
- zbx_sock_close(s);
- return SYSINFO_RET_OK;
- }
-
- if(NULL != request)
- {
- if(SOCKET_ERROR == zbx_sock_write(s, (void *)request, (int)strlen(request)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error during sending [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
- zbx_sock_close(s);
- return SYSINFO_RET_OK;
- }
- }
-
- if( NULL == expect)
- {
- zbx_sock_close(s);
- *value_int = 1;
- return SYSINFO_RET_OK;
- }
-
- memset(buf, 0, sizeof(buf));
-
- if(SOCKET_ERROR == (len = zbx_sock_read(s, buf, sizeof(buf)-1, CONFIG_TIMEOUT)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error in reading() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
- zbx_sock_close(s);
- return SYSINFO_RET_OK;
- }
-
- buf[sizeof(buf)-1] = '\0';
-
- if( strcmp(buf, expect) == 0 )
- {
- *value_int = 1;
- }
- else
- {
- *value_int = 0;
- }
-
- if(NULL != sendtoclose)
- {
- if(SOCKET_ERROR == zbx_sock_write(s, (void *)sendtoclose, (int)strlen(sendtoclose)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error during close string sending [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
- }
- }
-
- zbx_sock_close(s);
-
- return SYSINFO_RET_OK;
-}
-
-#ifdef HAVE_LDAP
-
-static int check_ldap(char *hostname, short port, int *value_int)
-{
- LDAP *ldap = NULL;
- LDAPMessage *res = NULL;
- LDAPMessage *msg = NULL;
- BerElement *ber = NULL;
-
- char *attrs[2] = { "namingContexts", NULL };
-
- char *attr = NULL;
- char **valRes = NULL;
-
- int ldapErr = 0;
-
- assert(value_int);
-
- *value_int = 0;
-
- if(NULL == (ldap = ldap_init(hostname, port)) )
- {
- zabbix_log( LOG_LEVEL_DEBUG, "LDAP - initialization failed [%s:%u]",hostname, port);
- return SYSINFO_RET_OK;
- }
-
- if( LDAP_SUCCESS != (ldapErr = ldap_search_s(
- ldap,
- "",
- LDAP_SCOPE_BASE,
- "(objectClass=*)",
- attrs,
- 0,
- &res)) )
- {
- zabbix_log( LOG_LEVEL_DEBUG, "LDAP - serching failed [%s] [%s]",hostname, ldap_err2string(ldapErr));
- goto lbl_ret;
- }
-
- if(NULL == (msg = ldap_first_entry(ldap, res)) )
- {
- zabbix_log( LOG_LEVEL_DEBUG, " LDAP - empty sort result. [%s] [%s]", hostname, ldap_err2string(ldapErr));
- goto lbl_ret;
- }
-
- attr = ldap_first_attribute (ldap, msg, &ber);
-
- valRes = ldap_get_values( ldap, msg, attr );
-
- *value_int = 1;
-
-lbl_ret:
- if(valRes) ldap_value_free(valRes);
- if(attr) ldap_memfree(attr);
- if(ber) ber_free(ber, 0);
- if(res) ldap_msgfree(res);
- if(res) ldap_unbind(ldap);
-
- return SYSINFO_RET_OK;
-}
-#endif
-
-
-/*
- * 0- NOT OK
- * 1 - OK
- * */
-static int check_ssh(const char *hostname, short port, int *value_int)
-{
-
- ZBX_SOCKET s;
- ZBX_SOCKADDR servaddr_in;
-
- struct hostent *hp;
-
- char buf[MAX_BUF_LEN];
- char buf2[MAX_BUF_LEN];
- char *ssh_server,
- *ssh_proto;
-
- int len;
-
- assert(hostname);
- assert(value_int);
-
- *value_int = 0;
-
- if(NULL == (hp = zbx_gethost(hostname)) )
- {
- return SYSINFO_RET_OK;
- }
-
- memset(&servaddr_in, 0, sizeof(ZBX_SOCKADDR));
-
- servaddr_in.sin_family = AF_INET;
- servaddr_in.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
- servaddr_in.sin_port = htons(port);
-
- if(INVALID_SOCKET == (s = (ZBX_SOCKET)socket(AF_INET,SOCK_STREAM,0)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error in socket() [%s:%u] [%s]", hostname, port, strerror_from_system(errno));
- return SYSINFO_RET_OK;
- }
-
- if(SOCKET_ERROR == connect(s,(struct sockaddr *)&servaddr_in,sizeof(ZBX_SOCKADDR)))
- {
- zabbix_log( LOG_LEVEL_WARNING, "Error in connect() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
- zbx_sock_close(s);
- return SYSINFO_RET_OK;
- }
-
- memset(buf, 0, sizeof(buf));
-
- if(SOCKET_ERROR == (len = zbx_sock_read(s, buf, sizeof(buf)-1, CONFIG_TIMEOUT)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error in reading() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
- zbx_sock_close(s);
- return SYSINFO_RET_OK;
- }
-
- buf[sizeof(buf)-1] = '\0';
-
- if ( strncmp(buf, "SSH", 3) == 0 )
- {
- ssh_server = ssh_proto = buf + 4;
- ssh_server += strspn (ssh_proto, "0123456789-. ") ;
- ssh_server[-1] = '\0';
-
- zbx_snprintf(buf2,sizeof(buf2),"SSH-%s-%s\n", ssh_proto, "zabbix_agent");
- *value_int = 1;
- }
- else
- {
- zbx_snprintf(buf2,sizeof(buf2),"0\n");
- *value_int = 0;
- }
-
- if(SOCKET_ERROR == zbx_sock_write(s, buf2, (int)strlen(buf2)))
- {
- zabbix_log( LOG_LEVEL_DEBUG, "Error during sending [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
- }
-
- zbx_sock_close(s);
-
- return SYSINFO_RET_OK;
-}
-
-/* Example check_service[ssh], check_service[smtp,29],check_service[ssh,127.0.0.1,22]*/
-/* check_service[ssh,127.0.0.1,ssh] */
-int CHECK_SERVICE_PERF(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- unsigned short port=0;
- char service[MAX_STRING_LEN];
- char ip[MAX_STRING_LEN];
- char str_port[MAX_STRING_LEN];
-
- double start_time = 0;
-
- int ret = SYSINFO_RET_OK;
- int value_int;
-
- assert(result);
-
- init_result(result);
-
- start_time = zbx_time();
-
- if(num_param(param) > 3)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, service, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 2, ip, MAX_STRING_LEN) != 0)
- {
- ip[0] = '\0';
- }
-
- if(ip[0] == '\0')
- {
- strscpy(ip, "127.0.0.1");
- }
-
- if(get_param(param, 3, str_port, MAX_STRING_LEN) != 0)
- {
- str_port[0] = '\0';
- }
-
- if(str_port[0] != '\0')
- {
- port = atoi(str_port);
- }
- else
- {
- port = 0;
- }
-
-/* printf("IP:[%s]",ip);
- printf("Service:[%s]",service);
- printf("Port:[%d]",port);*/
-
- if(strcmp(service,"ssh") == 0)
- {
- if(port == 0) port=22;
- ret=check_ssh(ip,port,&value_int);
- }
-#ifdef HAVE_LDAP
- else if(strcmp(service,"ldap") == 0)
- {
- if(port == 0) port=389;
- ret=check_ldap(ip,port,&value_int);
- }
-#endif
- else if(strcmp(service,"smtp") == 0)
- {
- if(port == 0) port=25;
- ret=tcp_expect(ip,port,NULL,"220","QUIT\n",&value_int);
- }
- else if(strcmp(service,"ftp") == 0)
- {
- if(port == 0) port=21;
- ret=tcp_expect(ip,port,NULL,"220","",&value_int);
- }
- else if(strcmp(service,"http") == 0)
- {
- if(port == 0) port=80;
- ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
- }
- else if(strcmp(service,"pop") == 0)
- {
- if(port == 0) port=110;
- ret=tcp_expect(ip,port,NULL,"+OK","",&value_int);
- }
- else if(strcmp(service,"nntp") == 0)
- {
- if(port == 0) port=119;
-/* 220 is incorrect */
-/* ret=tcp_expect(ip,port,"220","");*/
- ret=tcp_expect(ip,port,NULL,"200","",&value_int);
- }
- else if(strcmp(service,"imap") == 0)
- {
- if(port == 0) port=143;
- ret=tcp_expect(ip,port,NULL,"* OK","a1 LOGOUT\n",&value_int);
- }
- else if(strcmp(service,"tcp") == 0)
- {
- if(port == 0) port=80;
- ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(SYSINFO_RET_OK == ret)
- {
- if(value_int)
- {
- SET_DBL_RESULT(result, zbx_time() - start_time);
- }
- else
- {
- SET_DBL_RESULT(result, 0.0);
- }
- }
-
-
- return ret;
-}
-
-/* Example check_service[ssh], check_service[smtp,29],check_service[ssh,127.0.0.1,22]*/
-/* check_service[ssh,127.0.0.1,ssh] */
-int CHECK_SERVICE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- unsigned short port=0;
- char service[MAX_STRING_LEN];
- char ip[MAX_STRING_LEN];
- char str_port[MAX_STRING_LEN];
-
- int ret;
- int value_int = 0;
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 3)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, service, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 2, ip, MAX_STRING_LEN) != 0)
- {
- ip[0] = '\0';
- }
-
- if(ip[0] == '\0')
- {
- strscpy(ip, "127.0.0.1");
- }
-
- if(get_param(param, 3, str_port, MAX_STRING_LEN) != 0)
- {
- str_port[0] = '\0';
- }
-
- if(str_port[0] != '\0')
- {
- port = atoi(str_port);
- }
- else
- {
- port = 0;
- }
-
-/* printf("IP:[%s]",ip);
- printf("Service:[%s]",service);
- printf("Port:[%d]",port);*/
-
- if(strcmp(service,"ssh") == 0)
- {
- if(port == 0) port=22;
- ret=check_ssh(ip,port,&value_int);
- }
- else if(strcmp(service,"service.ntp") == 0)
- {
- if(port == 0) port=123;
- ret=check_ntp(ip,port,&value_int);
- }
-#ifdef HAVE_LDAP
- else if(strcmp(service,"ldap") == 0)
- {
- if(port == 0) port=389;
- ret=check_ldap(ip,port,&value_int);
- }
-#endif
- else if(strcmp(service,"smtp") == 0)
- {
- if(port == 0) port=25;
- ret=tcp_expect(ip,port,NULL,"220","QUIT\n",&value_int);
- }
- else if(strcmp(service,"ftp") == 0)
- {
- if(port == 0) port=21;
- ret=tcp_expect(ip,port,NULL,"220","",&value_int);
- }
- else if(strcmp(service,"http") == 0)
- {
- if(port == 0) port=80;
- ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
- }
- else if(strcmp(service,"pop") == 0)
- {
- if(port == 0) port=110;
- ret=tcp_expect(ip,port,NULL,"+OK","",&value_int);
- }
- else if(strcmp(service,"nntp") == 0)
- {
- if(port == 0) port=119;
-/* 220 is incorrect */
-/* ret=tcp_expect(ip,port,"220","");*/
- ret=tcp_expect(ip,port,NULL,"200","",&value_int);
- }
- else if(strcmp(service,"imap") == 0)
- {
- if(port == 0) port=143;
- ret=tcp_expect(ip,port,NULL,"* OK","a1 LOGOUT\n",&value_int);
- }
- else if(strcmp(service,"tcp") == 0)
- {
- if(port == 0) port=80;
- ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(SYSINFO_RET_OK == ret)
- {
- SET_UI64_RESULT(result, value_int);
- }
-
- return ret;
-}
-
-int CHECK_PORT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- short port=0;
- int value_int;
- int ret;
- char ip[MAX_STRING_LEN];
- char port_str[MAX_STRING_LEN];
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 2)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, ip, MAX_STRING_LEN) != 0)
- {
- ip[0] = '\0';
- }
-
- if(ip[0] == '\0')
- {
- strscpy(ip, "127.0.0.1");
- }
-
- if(get_param(param, 2, port_str, MAX_STRING_LEN) != 0)
- {
- port_str[0] = '\0';
- }
-
- if(port_str[0] == '\0')
- {
- return SYSINFO_RET_FAIL;
- }
-
- port=atoi(port_str);
-
- ret = tcp_expect(ip,port,NULL,NULL,"",&value_int);
-
- if(ret == SYSINFO_RET_OK)
- {
- SET_UI64_RESULT(result, value_int);
- }
-
- return ret;
-}
-
-
-int CHECK_DNS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
-#ifdef TODO
-
-#if !defined(PACKETSZ)
-# define PACKETSZ 512
-#endif /* PACKETSZ */
-
-#if !defined(C_IN)
-# define C_IN ns_c_in
-#endif /* C_IN */
-
-#if !defined(T_SOA)
-# define T_SOA ns_t_soa
-#endif /* T_SOA */
-
-
- int res;
- char ip[MAX_STRING_LEN];
- char zone[MAX_STRING_LEN];
-#ifdef PACKETSZ
- char respbuf[PACKETSZ];
-#else
- char respbuf[NS_PACKETSZ];
-#endif
- struct in_addr in;
-
- /* extern char *h_errlist[]; */
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 2)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, ip, MAX_STRING_LEN) != 0)
- {
- ip[0] = '\0';
- }
-
- if(ip[0] == '\0')
- {
- strscpy(ip, "127.0.0.1");
- }
-
- if(get_param(param, 2, zone, MAX_STRING_LEN) != 0)
- {
- zone[0] = '\0';
- }
-
- if(zone[0] == '\0')
- {
- strscpy(zone, "localhost");
- }
-
- res = inet_aton(ip, &in);
- if(res != 1)
- {
- SET_UI64_RESULT(result,0);
- return SYSINFO_RET_FAIL;
- }
-
- res_init();
-
- res = res_query(zone, C_IN, T_SOA, (unsigned char *)respbuf, sizeof(respbuf));
-
- SET_UI64_RESULT(result, res != -1 ? 1 : 0);
-
- return SYSINFO_RET_OK;
-
-#endif /* TODO */
- return SYSINFO_RET_FAIL;
-}
-
-int SYSTEM_UNUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- assert(result);
-
- init_result(result);
-
-#ifdef TODO
-#error Realize function SYSTEM_UNUM!!!
-#endif /* todo */
-
- return EXECUTE_INT(cmd, "who|wc -l", flags, result);
-}
-
-int OLD_SYSTEM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
- int ret;
-
- assert(result);
-
- init_result(result);
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(strcmp(key,"proccount") == 0)
- {
- ret = PROCCOUNT(cmd, param, flags, result);
- }
- else if(strcmp(key,"procrunning") == 0)
- {
- ret = EXECUTE_INT(cmd, "cat /proc/loadavg|cut -f1 -d'/'|cut -f4 -d' '", flags, result);
- }
- else if(strcmp(key,"uptime") == 0)
- {
- ret = SYSTEM_UPTIME(cmd, param, flags, result);
- }
- else if(strcmp(key,"procload") == 0)
- {
- ret = SYSTEM_CPU_LOAD(cmd, "all,avg1", flags, result);
- }
- else if(strcmp(key,"procload5") == 0)
- {
- ret = SYSTEM_CPU_LOAD(cmd, "all,avg5", flags, result);
- }
- else if(strcmp(key,"procload15") == 0)
- {
- ret = SYSTEM_CPU_LOAD(cmd, "all,avg15", flags, result);
- }
- else if(strcmp(key,"hostname") == 0)
- {
- ret = SYSTEM_HOSTNAME(cmd, param, flags, result);
- }
- else if(strcmp(key,"uname") == 0)
- {
- ret = SYSTEM_UNAME(cmd, param, flags, result);
- }
- else if(strcmp(key,"users") == 0)
- {
- ret = SYSTEM_UNUM(cmd, param, flags, result);
- }
- else
- {
- ret = SYSINFO_RET_FAIL;
- }
-
- return ret;
-}
-
diff --git a/src/libs/zbxsysinfo/common/common.h b/src/libs/zbxsysinfo/common/common.h
new file mode 100644
index 00000000..d597013e
--- /dev/null
+++ b/src/libs/zbxsysinfo/common/common.h
@@ -0,0 +1,31 @@
+/*
+** 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.
+**/
+
+#if !defined(SYSINFO_COMMON_H_INCLUDED)
+
+#include "sysinfo.h"
+
+extern ZBX_METRIC parameters_common[];
+
+int getPROC(char *file, int lineno, int fieldno, unsigned flags, AGENT_RESULT *result);
+int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int EXECUTE_INT(const char *cmd, const char *command, unsigned flags, AGENT_RESULT *result);
+int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+
+#endif /* SYSINFO_COMMON_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/common/file.c b/src/libs/zbxsysinfo/common/file.c
index 1df95cb7..56e050a5 100644
--- a/src/libs/zbxsysinfo/common/file.c
+++ b/src/libs/zbxsysinfo/common/file.c
@@ -17,11 +17,12 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
-#define MAX_FILE_LEN (1024*1024)
+#include "md5.h"
+
+#include "file.h"
int VFS_FILE_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
@@ -273,3 +274,202 @@ lbl_fail:
return SYSINFO_RET_FAIL;
}
+
+/* MD5 sum calculation */
+
+int VFS_FILE_MD5SUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ FILE *file = NULL;
+ int i;
+ size_t nr;
+ struct stat buf_stat;
+
+ md5_state_t state;
+ u_char buf[16 * 1024];
+
+ unsigned char hashText[MD5_DIGEST_SIZE*2+1];
+ md5_byte_t hash[MD5_DIGEST_SIZE];
+
+ char filename[MAX_STRING_LEN];
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, filename, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(stat(filename,&buf_stat) != 0)
+ {
+ /* Cannot stat() file */
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(buf_stat.st_size > 64*1024*1024)
+ {
+ /* Will not calculate MD5 for files larger than 64M */
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(NULL == (file = fopen(filename,"rb")))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ md5_init(&state);
+ while ((nr = fread(buf, 1, (size_t)sizeof(buf), file)) > 0)
+ {
+ md5_append(&state,(const md5_byte_t *)buf, (int)nr);
+ }
+ md5_finish(&state, hash);
+
+ zbx_fclose(file);
+
+/* Convert MD5 hash to text form */
+ for(i=0;i<MD5_DIGEST_SIZE;i++)
+ {
+ zbx_snprintf((char *)&hashText[i<<1], sizeof(hashText) - (i<<1), "%02x",hash[i]);
+ }
+
+ SET_STR_RESULT(result, strdup((char*)hashText));
+
+ return SYSINFO_RET_OK;
+
+}
+
+/* Code for cksum is based on code from cksum.c */
+
+static u_long crctab[] = {
+ 0x0,
+ 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
+ 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
+ 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
+ 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,
+ 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f,
+ 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a,
+ 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
+ 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58,
+ 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033,
+ 0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe,
+ 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
+ 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4,
+ 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
+ 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5,
+ 0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
+ 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07,
+ 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c,
+ 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,
+ 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
+ 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b,
+ 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698,
+ 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d,
+ 0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
+ 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f,
+ 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
+ 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80,
+ 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
+ 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a,
+ 0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629,
+ 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c,
+ 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
+ 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,
+ 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65,
+ 0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8,
+ 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
+ 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2,
+ 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
+ 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74,
+ 0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
+ 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21,
+ 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a,
+ 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087,
+ 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
+ 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d,
+ 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce,
+ 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,
+ 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
+ 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09,
+ 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
+ 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf,
+ 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
+};
+
+/*
+ * Compute a POSIX 1003.2 checksum. These routines have been broken out so
+ * that other programs can use them. The first routine, crc(), takes a file
+ * descriptor to read from and locations to store the crc and the number of
+ * bytes read. The second routine, crc_buf(), takes a buffer and a length,
+ * and a location to store the crc. Both routines return 0 on success and 1
+ * on failure. Errno is set on failure.
+ */
+
+int VFS_FILE_CKSUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ register u_char *p;
+ register int nr;
+
+/* AV Crashed under 64 platforms. Must be 32 bit! */
+/* register u_long crc, len;*/
+ register uint32_t crc, len;
+
+ u_char buf[16 * 1024];
+ u_long cval, clen;
+ FILE *f;
+ char filename[MAX_STRING_LEN];
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, filename, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(NULL == (f = fopen(filename,"rb")))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+#define COMPUTE(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
+
+ crc = len = 0;
+ while ((nr = (int)fread(buf, 1, sizeof(buf), f)) > 0)
+ {
+ for( len += nr, p = buf; nr--; ++p)
+ {
+ COMPUTE(crc, *p);
+ }
+ }
+ zbx_fclose(f);
+
+ if (nr < 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ clen = len;
+
+ /* Include the length of the file. */
+ for (; len != 0; len >>= 8) {
+ COMPUTE(crc, len & 0xff);
+ }
+
+ cval = ~crc;
+
+ SET_UI64_RESULT(result, cval);
+
+ return SYSINFO_RET_OK;
+}
diff --git a/src/libs/zbxsysinfo/common/file.h b/src/libs/zbxsysinfo/common/file.h
new file mode 100644
index 00000000..a94c182d
--- /dev/null
+++ b/src/libs/zbxsysinfo/common/file.h
@@ -0,0 +1,34 @@
+/*
+** 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.
+**/
+
+#if !defined(SYSINFO_COMMON_FILE_H_INCLUDED)
+
+#include "sysinfo.h"
+
+#define MAX_FILE_LEN (1024*1024)
+
+int VFS_FILE_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int VFS_FILE_TIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int VFS_FILE_EXISTS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int VFS_FILE_REGEXP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int VFS_FILE_REGMATCH(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int VFS_FILE_MD5SUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int VFS_FILE_CKSUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+
+#endif /* SYSINFO_COMMON_FILE_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/common/http.c b/src/libs/zbxsysinfo/common/http.c
index b7219183..3e8dc850 100644
--- a/src/libs/zbxsysinfo/common/http.c
+++ b/src/libs/zbxsysinfo/common/http.c
@@ -24,6 +24,8 @@
#include "zbxsock.h"
#include "cfg.h"
+#include "http.h"
+
static int get_http_page(char *hostname, char *param, unsigned short port, char *buffer, int max_buf_len)
{
char request[MAX_STRING_LEN];
diff --git a/src/libs/zbxsysinfo/common/http.h b/src/libs/zbxsysinfo/common/http.h
new file mode 100644
index 00000000..4f0fc118
--- /dev/null
+++ b/src/libs/zbxsysinfo/common/http.h
@@ -0,0 +1,28 @@
+/*
+** 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.
+**/
+
+#if !defined(SYSINFO_COMMON_HTTP_H_INCLUDED)
+
+#include "sysinfo.h"
+
+int WEB_PAGE_GET(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int WEB_PAGE_PERF(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int WEB_PAGE_REGEXP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+
+#endif /* SYSINFO_COMMON_HTTP_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/common/net.c b/src/libs/zbxsysinfo/common/net.c
new file mode 100644
index 00000000..ca915040
--- /dev/null
+++ b/src/libs/zbxsysinfo/common/net.c
@@ -0,0 +1,298 @@
+/*
+** 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 "common.h"
+#include "sysinfo.h"
+
+#include "zbxsock.h"
+#include "log.h"
+#include "cfg.h"
+
+#include "net.h"
+
+/*
+ * 0 - NOT OK
+ * 1 - OK
+ * */
+int tcp_expect(const char *hostname, short port, const char *request, const char *expect, const char *sendtoclose, int *value_int)
+{
+ ZBX_SOCKET s;
+ ZBX_SOCKADDR servaddr_in;
+
+ struct hostent *hp;
+
+ char buf[MAX_BUF_LEN];
+
+ int len;
+
+ assert(hostname);
+ assert(value_int);
+
+ *value_int = 0;
+
+ if(NULL == (hp = zbx_gethost(hostname)) )
+ {
+ return SYSINFO_RET_OK;
+ }
+
+ memset(&servaddr_in, 0, sizeof(ZBX_SOCKADDR));
+
+ servaddr_in.sin_family = AF_INET;
+ servaddr_in.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
+ servaddr_in.sin_port = htons(port);
+
+ if(INVALID_SOCKET == (s = (ZBX_SOCKET)socket(AF_INET,SOCK_STREAM,0)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error in socket() [%s:%u] [%s]", hostname, port, strerror_from_system(errno));
+ return SYSINFO_RET_OK;
+ }
+
+ if(SOCKET_ERROR == connect(s,(struct sockaddr *)&servaddr_in,sizeof(ZBX_SOCKADDR)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error in connect() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
+ zbx_sock_close(s);
+ return SYSINFO_RET_OK;
+ }
+
+ if(NULL != request)
+ {
+ if(SOCKET_ERROR == zbx_sock_write(s, (void *)request, (int)strlen(request)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error during sending [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
+ zbx_sock_close(s);
+ return SYSINFO_RET_OK;
+ }
+ }
+
+ if( NULL == expect)
+ {
+ zbx_sock_close(s);
+ *value_int = 1;
+ return SYSINFO_RET_OK;
+ }
+
+ memset(buf, 0, sizeof(buf));
+
+ if(SOCKET_ERROR == (len = zbx_sock_read(s, buf, sizeof(buf)-1, CONFIG_TIMEOUT)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error in reading() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
+ zbx_sock_close(s);
+ return SYSINFO_RET_OK;
+ }
+
+ buf[sizeof(buf)-1] = '\0';
+
+ if( strcmp(buf, expect) == 0 )
+ {
+ *value_int = 1;
+ }
+ else
+ {
+ *value_int = 0;
+ }
+
+ if(NULL != sendtoclose)
+ {
+ if(SOCKET_ERROR == zbx_sock_write(s, (void *)sendtoclose, (int)strlen(sendtoclose)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error during close string sending [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
+ }
+ }
+
+ zbx_sock_close(s);
+
+ return SYSINFO_RET_OK;
+}
+
+int TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifdef HAVE_PROC
+ FILE *f = NULL;
+ char c[MAX_STRING_LEN];
+ char porthex[MAX_STRING_LEN];
+ char pattern[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, porthex, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ strscpy(pattern,porthex);
+ zbx_strlcat(pattern," 00000000:0000 0A", MAX_STRING_LEN);
+
+ if(NULL == (f = fopen("/proc/net/tcp","r")))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ while (NULL != fgets(c,MAX_STRING_LEN,f))
+ {
+ if(NULL != strstr(c,pattern))
+ {
+ SET_UI64_RESULT(result, 1);
+ ret = SYSINFO_RET_OK;
+ break;
+ }
+ }
+ zbx_fclose(f);
+
+ SET_UI64_RESULT(result, 0);
+
+ return ret;
+#else
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int CHECK_PORT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ short port=0;
+ int value_int;
+ int ret;
+ char ip[MAX_STRING_LEN];
+ char port_str[MAX_STRING_LEN];
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, ip, MAX_STRING_LEN) != 0)
+ {
+ ip[0] = '\0';
+ }
+
+ if(ip[0] == '\0')
+ {
+ strscpy(ip, "127.0.0.1");
+ }
+
+ if(get_param(param, 2, port_str, MAX_STRING_LEN) != 0)
+ {
+ port_str[0] = '\0';
+ }
+
+ if(port_str[0] == '\0')
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ port=atoi(port_str);
+
+ ret = tcp_expect(ip,port,NULL,NULL,"",&value_int);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ SET_UI64_RESULT(result, value_int);
+ }
+
+ return ret;
+}
+
+
+int CHECK_DNS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifdef TODO
+
+#if !defined(PACKETSZ)
+# define PACKETSZ 512
+#endif /* PACKETSZ */
+
+#if !defined(C_IN)
+# define C_IN ns_c_in
+#endif /* C_IN */
+
+#if !defined(T_SOA)
+# define T_SOA ns_t_soa
+#endif /* T_SOA */
+
+
+ int res;
+ char ip[MAX_STRING_LEN];
+ char zone[MAX_STRING_LEN];
+#ifdef PACKETSZ
+ char respbuf[PACKETSZ];
+#else
+ char respbuf[NS_PACKETSZ];
+#endif
+ struct in_addr in;
+
+ /* extern char *h_errlist[]; */
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, ip, MAX_STRING_LEN) != 0)
+ {
+ ip[0] = '\0';
+ }
+
+ if(ip[0] == '\0')
+ {
+ strscpy(ip, "127.0.0.1");
+ }
+
+ if(get_param(param, 2, zone, MAX_STRING_LEN) != 0)
+ {
+ zone[0] = '\0';
+ }
+
+ if(zone[0] == '\0')
+ {
+ strscpy(zone, "localhost");
+ }
+
+ res = inet_aton(ip, &in);
+ if(res != 1)
+ {
+ SET_UI64_RESULT(result,0);
+ return SYSINFO_RET_FAIL;
+ }
+
+ res_init();
+
+ res = res_query(zone, C_IN, T_SOA, (unsigned char *)respbuf, sizeof(respbuf));
+
+ SET_UI64_RESULT(result, res != -1 ? 1 : 0);
+
+ return SYSINFO_RET_OK;
+
+#endif /* TODO */
+ return SYSINFO_RET_FAIL;
+}
diff --git a/src/libs/zbxsysinfo/common/net.h b/src/libs/zbxsysinfo/common/net.h
new file mode 100644
index 00000000..4452f80a
--- /dev/null
+++ b/src/libs/zbxsysinfo/common/net.h
@@ -0,0 +1,29 @@
+/*
+** 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.
+**/
+
+#if !defined(SYSINFO_COMMON_NET_H_INCLUDED)
+
+#include "sysinfo.h"
+
+int tcp_expect(const char *hostname, short port, const char *request, const char *expect, const char *sendtoclose, int *value_int);
+int TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int CHECK_PORT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int CHECK_DNS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+
+#endif /* SYSINFO_COMMON_NET_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/common/system.c b/src/libs/zbxsysinfo/common/system.c
index 4ce153cc..d0c4a3cb 100644
--- a/src/libs/zbxsysinfo/common/system.c
+++ b/src/libs/zbxsysinfo/common/system.c
@@ -17,42 +17,66 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
-
#include "common.h"
#include "sysinfo.h"
+#include "system.h"
+
int SYSTEM_LOCALTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- int ret = SYSINFO_RET_OK;
-
assert(result);
init_result(result);
SET_UI64_RESULT(result, time(NULL));
- return ret;
+ return SYSINFO_RET_OK;
}
-#if !defined(_WINDOWS)
+int SYSTEM_UNUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#if defined(_WINDOWS)
+# ifdef TODO
+# error Realize function SYSTEM_UNUM!!!
+# endif /* todo */
+ return SYSINFO_RET_FAIL;
+#else
+ assert(result);
+
+ init_result(result);
+
+ return EXECUTE_INT(cmd, "who|wc -l", flags, result);
+#endif /* _WINDOWS */
+}
int SYSTEM_UNAME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
+#if defined(_WINDOWS)
+# ifdef TODO
+# error Realize function SYSTEM_UNAME!!!
+# endif /* todo */
+ return SYSINFO_RET_FAIL;
+#else
assert(result);
init_result(result);
return EXECUTE_STR(cmd, "uname -a", flags, result);
+#endif /* _WINDOWS */
}
int SYSTEM_HOSTNAME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
+#if defined(_WINDOWS)
+# ifdef TODO
+# error Realize function SYSTEM_HOSTNAME!!!
+# endif /* todo */
+ return SYSINFO_RET_FAIL;
+#else
assert(result);
init_result(result);
return EXECUTE_STR(cmd, "hostname", flags, result);
+#endif /* _WINDOWS */
}
-
-#endif /* not _WINDOWS */
diff --git a/src/libs/zbxsysinfo/common/system.h b/src/libs/zbxsysinfo/common/system.h
new file mode 100644
index 00000000..a4356fa6
--- /dev/null
+++ b/src/libs/zbxsysinfo/common/system.h
@@ -0,0 +1,29 @@
+/*
+** 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.
+**/
+
+#if !defined(SYSINFO_COMMON_SYSTEM_H_INCLUDED)
+
+#include "sysinfo.h"
+
+int SYSTEM_LOCALTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int SYSTEM_UNUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int SYSTEM_UNAME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int SYSTEM_HOSTNAME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+
+#endif /* SYSINFO_COMMON_SYSTEM_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/freebsd/Makefile.am b/src/libs/zbxsysinfo/freebsd/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/freebsd/Makefile.am
+++ b/src/libs/zbxsysinfo/freebsd/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/freebsd/cpu.c b/src/libs/zbxsysinfo/freebsd/cpu.c
index 1b2f4961..aacb713a 100644
--- a/src/libs/zbxsysinfo/freebsd/cpu.c
+++ b/src/libs/zbxsysinfo/freebsd/cpu.c
@@ -21,103 +21,13 @@
#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)
-{
- return get_stat("cpu[nice15]", flags, result);
-}
-
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user1]", flags, result);
-}
-
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
-
-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);
-}
-
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
-}
-
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#include "stats.h"
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
-
- CPU_FNCLIST fl[] =
- {
- {"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}
- };
-
char cpuname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -128,7 +38,7 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, cpuname, sizeof(type)) != 0)
+ if(get_param(param, 1, cpuname, sizeof(cpuname)) != 0)
{
return SYSINFO_RET_FAIL;
}
@@ -137,7 +47,7 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(cpuname, sizeof(cpuname), "all");
}
- if(strncmp(cpuname, "all", MAX_STRING_LEN))
+ if(strncmp(cpuname, "all", sizeof(cpuname)))
{
return SYSINFO_RET_FAIL;
}
@@ -162,18 +72,49 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, param, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"idle"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.idle1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.idle5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.idle15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"nice"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.nice1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.nice5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.nice15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"user"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.user1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.user5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.user15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else if( 0 == strcmp(type,"system"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.system1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.system5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.system15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
}
/* AIX CPU info */
@@ -502,7 +443,7 @@ CPU_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, cpuname, sizeof(mode)) != 0)
+ if(get_param(param, 1, cpuname, sizeof(cpuname)) != 0)
{
return SYSINFO_RET_FAIL;
}
@@ -511,7 +452,7 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(cpuname, sizeof(cpuname), "all");
}
- if(strncmp(cpuname, "all", MAX_STRING_LEN))
+ if(strncmp(cpuname, "all", sizeof(cpuname)))
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/freebsd/diskio.c b/src/libs/zbxsysinfo/freebsd/diskio.c
index 171973e0..642ac402 100644
--- a/src/libs/zbxsysinfo/freebsd/diskio.c
+++ b/src/libs/zbxsysinfo/freebsd/diskio.c
@@ -22,140 +22,15 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#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}
- };
-
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -191,47 +66,47 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
-}
-int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
-#define DEV_FNCLIST struct dev_fnclist_s
-DEV_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
- DEV_FNCLIST fl[] =
+ }
+ else
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
- };
+ return SYSINFO_RET_FAIL;
+ }
+ return SYSINFO_RET_OK;
+#endif /* TODO */
+}
+
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -242,19 +117,19 @@ DEV_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, devname, sizeof(mode)) != 0)
+ if(get_param(param, 1, devname, sizeof(devname)) != 0)
{
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, sizeof(mode)) != 0)
+ if(get_param(param, 2, type, sizeof(type)) != 0)
{
type[0] = '\0';
}
if(type[0] == '\0')
{
/* default parameter */
- zbx_snprintf(type, sizeof(mode), "bps");
+ zbx_snprintf(type, sizeof(type), "bps");
}
if(get_param(param, 3, mode, sizeof(mode)) != 0)
@@ -267,19 +142,36 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
}
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -341,7 +233,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, key, sizeof(key)) != 0)
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/freebsd/freebsd.c b/src/libs/zbxsysinfo/freebsd/freebsd.c
index 8c85c385..117136ad 100644
--- a/src/libs/zbxsysinfo/freebsd/freebsd.c
+++ b/src/libs/zbxsysinfo/freebsd/freebsd.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,41 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"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.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
- {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -67,14 +51,10 @@ 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_IN, 0, "all"},
- {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
-
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/hpux/Makefile.am b/src/libs/zbxsysinfo/hpux/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/hpux/Makefile.am
+++ b/src/libs/zbxsysinfo/hpux/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/hpux/cpu.c b/src/libs/zbxsysinfo/hpux/cpu.c
index 9b125afa..2a50ecff 100644
--- a/src/libs/zbxsysinfo/hpux/cpu.c
+++ b/src/libs/zbxsysinfo/hpux/cpu.c
@@ -21,103 +21,13 @@
#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)
-{
- return get_stat("cpu[nice15]", flags, result);
-}
-
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user1]", flags, result);
-}
-
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
-
-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);
-}
-
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
-}
-
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#include "stats.h"
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
-
- CPU_FNCLIST fl[] =
- {
- {"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}
- };
-
char cpuname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -162,18 +72,49 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, param, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"idle"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.idle1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.idle5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.idle15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"nice"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.nice1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.nice5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.nice15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"user"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.user1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.user5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.user15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else if( 0 == strcmp(type,"system"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.system1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.system5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.system15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
}
int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
diff --git a/src/libs/zbxsysinfo/hpux/diskio.c b/src/libs/zbxsysinfo/hpux/diskio.c
index 0f70ba14..642ac402 100644
--- a/src/libs/zbxsysinfo/hpux/diskio.c
+++ b/src/libs/zbxsysinfo/hpux/diskio.c
@@ -22,140 +22,15 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#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}
- };
-
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -191,47 +66,47 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
-}
-int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
-#define DEV_FNCLIST struct dev_fnclist_s
-DEV_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
- DEV_FNCLIST fl[] =
+ }
+ else
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
- };
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
+}
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -267,19 +142,36 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
}
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -341,7 +233,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, key, sizeof(key)) != 0)
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/hpux/hpux.c b/src/libs/zbxsysinfo/hpux/hpux.c
index 32974871..c39b2a4c 100644
--- a/src/libs/zbxsysinfo/hpux/hpux.c
+++ b/src/libs/zbxsysinfo/hpux/hpux.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,41 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"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.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
- {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -70,11 +54,7 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/linux/Makefile.am b/src/libs/zbxsysinfo/linux/Makefile.am
index d52238b6..60df1487 100644
--- a/src/libs/zbxsysinfo/linux/Makefile.am
+++ b/src/libs/zbxsysinfo/linux/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/linux/boottime.c b/src/libs/zbxsysinfo/linux/boottime.c
index 1f7cee0e..1fff9ddb 100644
--- a/src/libs/zbxsysinfo/linux/boottime.c
+++ b/src/libs/zbxsysinfo/linux/boottime.c
@@ -22,6 +22,68 @@
#include "common.h"
#include "sysinfo.h"
+static int getPROC2(char *file, char *param, int fieldno, unsigned flags, int type, AGENT_RESULT *result)
+{
+
+ FILE *f;
+ char *res;
+ char buf[MAX_STRING_LEN];
+ int i;
+ int found;
+ unsigned long uValue;
+ double fValue;
+
+ if (NULL == (f = fopen(file,"r")))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ /* find line */
+ found = 0;
+ while ( fgets(buf, MAX_STRING_LEN, f) != NULL )
+ {
+ if (strncmp(buf, "btime", 5) == 0)
+ {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) return SYSINFO_RET_FAIL;
+
+ /* find field */
+ res = (char *)strtok(buf, " "); /* btime field1 field2 */
+ for(i=1; i<=fieldno; i++)
+ {
+ res = (char *)strtok(NULL," ");
+ }
+
+ zbx_fclose(f);
+
+ if ( res == NULL )
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ /* convert field to right type */
+ switch (type)
+ {
+ case AR_UINT64:
+ sscanf(res, "%lu", &uValue);
+ SET_UI64_RESULT(result, uValue);
+ break;
+ case AR_DOUBLE:
+ sscanf(res, "%lf", &fValue);
+ SET_DBL_RESULT(result, fValue);
+ break;
+ case AR_STRING: default:
+ SET_STR_RESULT(result, buf);
+ break;
+ }
+
+ return SYSINFO_RET_OK;
+}
+
int SYSTEM_BOOTTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
assert(result);
diff --git a/src/libs/zbxsysinfo/linux/cpu.c b/src/libs/zbxsysinfo/linux/cpu.c
index bb2a2046..d48b9793 100644
--- a/src/libs/zbxsysinfo/linux/cpu.c
+++ b/src/libs/zbxsysinfo/linux/cpu.c
@@ -21,103 +21,13 @@
#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)
-{
- return get_stat("cpu[nice15]", flags, result);
-}
-
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user1]", flags, result);
-}
-
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
-
-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);
-}
-
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
-}
-
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#include "stats.h"
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
-
- CPU_FNCLIST fl[] =
- {
- {"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}
- };
-
char cpuname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -137,7 +47,7 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(cpuname, sizeof(cpuname), "all");
}
- if(strncmp(cpuname, "all", MAX_STRING_LEN))
+ if(strncmp(cpuname, "all", sizeof(cpuname)))
{
return SYSINFO_RET_FAIL;
}
@@ -162,53 +72,50 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, param, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
- 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( 0 == strcmp(type,"idle"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.idle1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.idle5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.idle15)
+ else return SYSINFO_RET_FAIL;
- if(knlist(&nl, 1, sizeof(nl)))
+ }
+ else if( 0 == strcmp(type,"nice"))
{
- return FAIL;
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.nice1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.nice5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.nice15)
+ else return SYSINFO_RET_FAIL;
+
}
- if((kmem = open("/dev/kmem", 0, 0)) <= 0)
+ else if( 0 == strcmp(type,"user"))
{
- return FAIL;
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.user1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.user5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.user15)
+ else return SYSINFO_RET_FAIL;
}
-
- if(pread(kmem, avenrun, sizeof(avenrun), nl.n_value) <
- sizeof(avenrun))
+ else if( 0 == strcmp(type,"system"))
{
- return FAIL;
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.system1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.system5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.system15)
+ else return SYSINFO_RET_FAIL;
}
-
- for(i=0;i<nelem;i++)
+ else
{
- loadavg[i] = (double) avenrun[i] / 65535;
+ return SYSINFO_RET_FAIL;
}
- return SUCCEED;
+
+ return SYSINFO_RET_OK;
}
-#endif
int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
@@ -271,21 +178,6 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
SET_DBL_RESULT(result, ((double)kn->value.ul)/256.0);
return SYSINFO_RET_OK;
#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- assert(result);
-
- init_result(result);
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return SYSINFO_RET_FAIL;
- }
-
- SET_DBL_RESULT(result, loadavg[0])
- return SYSINFO_RET_OK;
-#else
assert(result);
init_result(result);
@@ -294,7 +186,6 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
#endif
#endif
#endif
-#endif
}
int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -358,21 +249,6 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
SET_DBL_RESULT(result, ((double)kn->value.ul)/256.0);
return SYSINFO_RET_OK;
#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- assert(result);
-
- init_result(result);
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return STSINFO_RET_FAIL;
- }
-
- SET_DBL_RESULT(result, loadavg[1]);
- return SYSINFO_RET_OK;
-#else
assert(result);
init_result(result);
@@ -381,7 +257,6 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
#endif
#endif
#endif
-#endif
}
int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -445,21 +320,6 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_
SET_DBL_RESULT(result, ((double)kn->value.ul)/256.0);
return SYSINFO_RET_OK;
#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- assert(result);
-
- init_result(result);
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return STSINFO_RET_FAIL;
- }
-
- SET_DBL_RESULT(result, loadavg[2]);
- return SYSINFO_RET_OK;
-#else
assert(result);
init_result(result);
@@ -468,7 +328,6 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_
#endif
#endif
#endif
-#endif
}
int SYSTEM_CPU_LOAD(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -527,7 +386,7 @@ CPU_FNCLIST
}
for(i=0; fl[i].mode!=0; i++)
{
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ if(strncmp(mode, fl[i].mode, sizeof(mode))==0)
{
return (fl[i].function)(cmd, param, flags, result);
}
@@ -561,12 +420,12 @@ int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGEN
if(NULL != ( f = fopen("/proc/stat","r") ))
{
- while(fgets(line,MAX_STRING_LEN,f) != NULL)
+ while(fgets(line,sizeof(line),f) != NULL)
{
if(sscanf(line,"%s\t" ZBX_FS_UI64 "\n", name, &value) != 2)
continue;
- if(strncmp(name, "intr", MAX_STRING_LEN) == 0)
+ if(strncmp(name, "intr", sizeof(name)) == 0)
{
SET_UI64_RESULT(result, value);
ret = SYSINFO_RET_OK;
diff --git a/src/libs/zbxsysinfo/linux/diskio.c b/src/libs/zbxsysinfo/linux/diskio.c
index a6f0b501..2392c183 100644
--- a/src/libs/zbxsysinfo/linux/diskio.c
+++ b/src/libs/zbxsysinfo/linux/diskio.c
@@ -17,11 +17,11 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
-
#include "common.h"
#include "sysinfo.h"
+#include "../common/common.h"
+
struct disk_stat_s {
zbx_uint64_t rio;
zbx_uint64_t rsect;
diff --git a/src/libs/zbxsysinfo/linux/linux.c b/src/libs/zbxsysinfo/linux/linux.c
index 484c37a3..52de4c91 100644
--- a/src/libs/zbxsysinfo/linux/linux.c
+++ b/src/libs/zbxsysinfo/linux/linux.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,43 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "sda,operations"},
+ {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "sda,sectors"},
- {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
- {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "sda,operations"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "sda,sectors"},
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "total"},
+ {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "total"},
- {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,,"},
- {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -72,12 +54,8 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.boottime", 0, SYSTEM_BOOTTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
+ {"system.boottime", 0, SYSTEM_BOOTTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/netbsd/Makefile.am b/src/libs/zbxsysinfo/netbsd/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/netbsd/Makefile.am
+++ b/src/libs/zbxsysinfo/netbsd/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/netbsd/cpu.c b/src/libs/zbxsysinfo/netbsd/cpu.c
index 135e7534..aacb713a 100644
--- a/src/libs/zbxsysinfo/netbsd/cpu.c
+++ b/src/libs/zbxsysinfo/netbsd/cpu.c
@@ -21,103 +21,13 @@
#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)
-{
- return get_stat("cpu[nice15]", flags, result);
-}
-
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user1]", flags, result);
-}
-
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
-
-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);
-}
-
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
-}
-
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#include "stats.h"
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
-
- CPU_FNCLIST fl[] =
- {
- {"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}
- };
-
char cpuname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -162,18 +72,49 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, param, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"idle"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.idle1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.idle5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.idle15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"nice"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.nice1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.nice5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.nice15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"user"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.user1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.user5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.user15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else if( 0 == strcmp(type,"system"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.system1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.system5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.system15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
}
/* AIX CPU info */
diff --git a/src/libs/zbxsysinfo/netbsd/diskio.c b/src/libs/zbxsysinfo/netbsd/diskio.c
index dada912d..642ac402 100644
--- a/src/libs/zbxsysinfo/netbsd/diskio.c
+++ b/src/libs/zbxsysinfo/netbsd/diskio.c
@@ -22,140 +22,15 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#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}
- };
-
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -171,7 +46,7 @@ DEV_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, sizeof(type) ) != 0)
+ if(get_param(param, 2, type, sizeof(type)) != 0)
{
type[0] = '\0';
}
@@ -191,47 +66,47 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
-}
-int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
-#define DEV_FNCLIST struct dev_fnclist_s
-DEV_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
- DEV_FNCLIST fl[] =
+ }
+ else
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
- };
+ return SYSINFO_RET_FAIL;
+ }
+ return SYSINFO_RET_OK;
+#endif /* TODO */
+}
+
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -242,12 +117,12 @@ DEV_FNCLIST
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, devname, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, devname, sizeof(devname)) != 0)
{
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 2, type, MAX_STRING_LEN) != 0)
+ if(get_param(param, 2, type, sizeof(type)) != 0)
{
type[0] = '\0';
}
@@ -257,7 +132,7 @@ DEV_FNCLIST
zbx_snprintf(type, sizeof(type), "bps");
}
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 3, mode, sizeof(mode)) != 0)
{
mode[0] = '\0';
}
@@ -267,19 +142,36 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
}
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -341,7 +233,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, key, sizeof(key)) != 0)
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/netbsd/netbsd.c b/src/libs/zbxsysinfo/netbsd/netbsd.c
index e39c93fb..8697cfa5 100644
--- a/src/libs/zbxsysinfo/netbsd/netbsd.c
+++ b/src/libs/zbxsysinfo/netbsd/netbsd.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,41 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.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,ops,avg1"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -70,11 +54,7 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/openbsd/Makefile.am b/src/libs/zbxsysinfo/openbsd/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/openbsd/Makefile.am
+++ b/src/libs/zbxsysinfo/openbsd/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/openbsd/cpu.c b/src/libs/zbxsysinfo/openbsd/cpu.c
index c9d3e4b7..e7da71f3 100644
--- a/src/libs/zbxsysinfo/openbsd/cpu.c
+++ b/src/libs/zbxsysinfo/openbsd/cpu.c
@@ -22,11 +22,6 @@
#include "common.h"
#include "sysinfo.h"
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
-
static int get_cpu_data(unsigned long long *idle,
unsigned long long *user,
unsigned long long *nice,
diff --git a/src/libs/zbxsysinfo/openbsd/openbsd.c b/src/libs/zbxsysinfo/openbsd/openbsd.c
index 35104abf..eb32f748 100644
--- a/src/libs/zbxsysinfo/openbsd/openbsd.c
+++ b/src/libs/zbxsysinfo/openbsd/openbsd.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,42 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.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,bytes"},
+ {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,operations"},
- {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,bytes"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,operations"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
-
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -71,11 +54,7 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all,pages"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/osf/Makefile.am b/src/libs/zbxsysinfo/osf/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/osf/Makefile.am
+++ b/src/libs/zbxsysinfo/osf/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/osf/cpu.c b/src/libs/zbxsysinfo/osf/cpu.c
index 7d42ba91..d30f45a6 100644
--- a/src/libs/zbxsysinfo/osf/cpu.c
+++ b/src/libs/zbxsysinfo/osf/cpu.c
@@ -22,11 +22,6 @@
#include "common.h"
#include "sysinfo.h"
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
-
static int SYSTEM_CPU_IDLE1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
return EXECUTE_INT(cmd, "iostat 1 2 | tail -n 1 | awk '{printf(\"%s\",$(NF))}'", flags, result);
diff --git a/src/libs/zbxsysinfo/osf/diskio.c b/src/libs/zbxsysinfo/osf/diskio.c
index 0f70ba14..642ac402 100644
--- a/src/libs/zbxsysinfo/osf/diskio.c
+++ b/src/libs/zbxsysinfo/osf/diskio.c
@@ -22,140 +22,15 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#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}
- };
-
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -191,47 +66,47 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
-}
-int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
-#define DEV_FNCLIST struct dev_fnclist_s
-DEV_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
- DEV_FNCLIST fl[] =
+ }
+ else
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
- };
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
+}
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -267,19 +142,36 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
}
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -341,7 +233,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, key, sizeof(key)) != 0)
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/osf/osf.c b/src/libs/zbxsysinfo/osf/osf.c
index efc42446..c39b2a4c 100644
--- a/src/libs/zbxsysinfo/osf/osf.c
+++ b/src/libs/zbxsysinfo/osf/osf.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,43 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"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.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
- {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -72,11 +54,7 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/osx/Makefile.am b/src/libs/zbxsysinfo/osx/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/osx/Makefile.am
+++ b/src/libs/zbxsysinfo/osx/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/osx/cpu.c b/src/libs/zbxsysinfo/osx/cpu.c
index fdd04ed3..aacb713a 100644
--- a/src/libs/zbxsysinfo/osx/cpu.c
+++ b/src/libs/zbxsysinfo/osx/cpu.c
@@ -21,103 +21,13 @@
#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)
-{
- return get_stat("cpu[nice15]", flags, result);
-}
-
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user1]", flags, result);
-}
-
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
-
-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);
-}
-
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
-}
-
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#include "stats.h"
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
-
- CPU_FNCLIST fl[] =
- {
- {"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}
- };
-
char cpuname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -162,18 +72,49 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, param, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"idle"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.idle1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.idle5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.idle15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"nice"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.nice1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.nice5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.nice15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"user"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.user1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.user5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.user15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else if( 0 == strcmp(type,"system"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.system1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.system5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.system15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
}
/* AIX CPU info */
@@ -511,7 +452,7 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(cpuname, sizeof(cpuname), "all");
}
- if(strncmp(cpuname, "all", MAX_STRING_LEN))
+ if(strncmp(cpuname, "all", sizeof(cpuname)))
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/osx/diskio.c b/src/libs/zbxsysinfo/osx/diskio.c
index e9eccdcb..642ac402 100644
--- a/src/libs/zbxsysinfo/osx/diskio.c
+++ b/src/libs/zbxsysinfo/osx/diskio.c
@@ -22,140 +22,15 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#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}
- };
-
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -181,7 +56,7 @@ DEV_FNCLIST
zbx_snprintf(type, sizeof(type), "bps");
}
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 3, mode, sizeof(mode)) != 0)
{
mode[0] = '\0';
}
@@ -191,47 +66,47 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
-}
-int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
-#define DEV_FNCLIST struct dev_fnclist_s
-DEV_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
- DEV_FNCLIST fl[] =
+ }
+ else
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
- };
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
+}
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -267,19 +142,36 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
}
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -341,7 +233,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, key, sizeof(key)) != 0)
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/osx/osx.c b/src/libs/zbxsysinfo/osx/osx.c
index 8c85c385..117136ad 100644
--- a/src/libs/zbxsysinfo/osx/osx.c
+++ b/src/libs/zbxsysinfo/osx/osx.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,41 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"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.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
- {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -67,14 +51,10 @@ 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_IN, 0, "all"},
- {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
-
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
+ {"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
+ {"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/simple/Makefile.am b/src/libs/zbxsysinfo/simple/Makefile.am
new file mode 100644
index 00000000..6a50dc4c
--- /dev/null
+++ b/src/libs/zbxsysinfo/simple/Makefile.am
@@ -0,0 +1,7 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_LIBRARIES = libsimplesysinfo.a
+
+libsimplesysinfo_a_SOURCES = \
+ simple.c simple.h \
+ ntp.c ntp.h
diff --git a/src/libs/zbxsysinfo/common/ntp.c b/src/libs/zbxsysinfo/simple/ntp.c
index 164de72d..5023196f 100644
--- a/src/libs/zbxsysinfo/common/ntp.c
+++ b/src/libs/zbxsysinfo/simple/ntp.c
@@ -167,11 +167,11 @@ endian problems. Note that it ignores fields irrelevant to SNTP. */
/*
static void display_data (ntp_data *data) {
- printf("sta = %d ver = %d mod = %d str = %d pol = %d dis = %.6f ref = %.6f\n",
+ printf("sta = %d ver = %d mod = %d str = %d pol = %d dis = " ZBX_FS_DBL_EXT(6) " ref = " ZBX_FS_DBL_EXT(6) "\n",
data->status,data->version,data->mode,data->stratum,data->polling,
data->dispersion,data->reference);
- printf("ori = %.6f rec = %.6f\n",data->originate, data->receive);
- printf("tra = %.6f cur = %.6f\n",data->transmit, data->current);
+ printf("ori = " ZBX_FS_DBL_EXT(6) " rec = " ZBX_FS_DBL_EXT(6) "\n",data->originate, data->receive);
+ printf("tra = " ZBX_FS_DBL_EXT(6) " cur = " ZBX_FS_DBL_EXT(6) "\n",data->transmit, data->current);
}
*/
diff --git a/src/libs/zbxsysinfo/simple/ntp.h b/src/libs/zbxsysinfo/simple/ntp.h
new file mode 100644
index 00000000..2805b36a
--- /dev/null
+++ b/src/libs/zbxsysinfo/simple/ntp.h
@@ -0,0 +1,24 @@
+/*
+** 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.
+**/
+
+#if !defined(SYSINFO_SYMPLE_NTP_H_INCLUDED)
+
+int check_ntp(char *host, unsigned short port, int *value_int);
+
+#endif /* SYSINFO_SYMPLE_NTP_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/simple/simple.c b/src/libs/zbxsysinfo/simple/simple.c
new file mode 100644
index 00000000..b5f0fac4
--- /dev/null
+++ b/src/libs/zbxsysinfo/simple/simple.c
@@ -0,0 +1,434 @@
+/*
+** 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 "common.h"
+#include "sysinfo.h"
+#include "zbxsock.h"
+#include "log.h"
+#include "cfg.h"
+
+#include "../common/net.h"
+#include "ntp.h"
+
+#include "simple.h"
+
+ZBX_METRIC parameters_simple[]=
+/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
+ {
+ {"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"},
+ {0}
+ };
+
+#ifdef HAVE_LDAP
+
+static int check_ldap(char *hostname, short port, int *value_int)
+{
+ LDAP *ldap = NULL;
+ LDAPMessage *res = NULL;
+ LDAPMessage *msg = NULL;
+ BerElement *ber = NULL;
+
+ char *attrs[2] = { "namingContexts", NULL };
+
+ char *attr = NULL;
+ char **valRes = NULL;
+
+ int ldapErr = 0;
+
+ assert(value_int);
+
+ *value_int = 0;
+
+ if(NULL == (ldap = ldap_init(hostname, port)) )
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "LDAP - initialization failed [%s:%u]",hostname, port);
+ return SYSINFO_RET_OK;
+ }
+
+ if( LDAP_SUCCESS != (ldapErr = ldap_search_s(
+ ldap,
+ "",
+ LDAP_SCOPE_BASE,
+ "(objectClass=*)",
+ attrs,
+ 0,
+ &res)) )
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "LDAP - serching failed [%s] [%s]",hostname, ldap_err2string(ldapErr));
+ goto lbl_ret;
+ }
+
+ if(NULL == (msg = ldap_first_entry(ldap, res)) )
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, " LDAP - empty sort result. [%s] [%s]", hostname, ldap_err2string(ldapErr));
+ goto lbl_ret;
+ }
+
+ attr = ldap_first_attribute (ldap, msg, &ber);
+
+ valRes = ldap_get_values( ldap, msg, attr );
+
+ *value_int = 1;
+
+lbl_ret:
+ if(valRes) ldap_value_free(valRes);
+ if(attr) ldap_memfree(attr);
+ if(ber) ber_free(ber, 0);
+ if(res) ldap_msgfree(res);
+ if(res) ldap_unbind(ldap);
+
+ return SYSINFO_RET_OK;
+}
+#endif
+
+
+/*
+ * 0- NOT OK
+ * 1 - OK
+ * */
+static int check_ssh(const char *hostname, short port, int *value_int)
+{
+
+ ZBX_SOCKET s;
+ ZBX_SOCKADDR servaddr_in;
+
+ struct hostent *hp;
+
+ char buf[MAX_BUF_LEN];
+ char buf2[MAX_BUF_LEN];
+ char *ssh_server,
+ *ssh_proto;
+
+ int len;
+
+ assert(hostname);
+ assert(value_int);
+
+ *value_int = 0;
+
+ if(NULL == (hp = zbx_gethost(hostname)) )
+ {
+ return SYSINFO_RET_OK;
+ }
+
+ memset(&servaddr_in, 0, sizeof(ZBX_SOCKADDR));
+
+ servaddr_in.sin_family = AF_INET;
+ servaddr_in.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
+ servaddr_in.sin_port = htons(port);
+
+ if(INVALID_SOCKET == (s = (ZBX_SOCKET)socket(AF_INET,SOCK_STREAM,0)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error in socket() [%s:%u] [%s]", hostname, port, strerror_from_system(errno));
+ return SYSINFO_RET_OK;
+ }
+
+ if(SOCKET_ERROR == connect(s,(struct sockaddr *)&servaddr_in,sizeof(ZBX_SOCKADDR)))
+ {
+ zabbix_log( LOG_LEVEL_WARNING, "Error in connect() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
+ zbx_sock_close(s);
+ return SYSINFO_RET_OK;
+ }
+
+ memset(buf, 0, sizeof(buf));
+
+ if(SOCKET_ERROR == (len = zbx_sock_read(s, buf, sizeof(buf)-1, CONFIG_TIMEOUT)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error in reading() [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
+ zbx_sock_close(s);
+ return SYSINFO_RET_OK;
+ }
+
+ buf[sizeof(buf)-1] = '\0';
+
+ if ( strncmp(buf, "SSH", 3) == 0 )
+ {
+ ssh_server = ssh_proto = buf + 4;
+ ssh_server += strspn (ssh_proto, "0123456789-. ") ;
+ ssh_server[-1] = '\0';
+
+ zbx_snprintf(buf2,sizeof(buf2),"SSH-%s-%s\n", ssh_proto, "zabbix_agent");
+ *value_int = 1;
+ }
+ else
+ {
+ zbx_snprintf(buf2,sizeof(buf2),"0\n");
+ *value_int = 0;
+ }
+
+ if(SOCKET_ERROR == zbx_sock_write(s, buf2, (int)strlen(buf2)))
+ {
+ zabbix_log( LOG_LEVEL_DEBUG, "Error during sending [%s:%u] [%s]",hostname, port, strerror_from_system(errno));
+ }
+
+ zbx_sock_close(s);
+
+ return SYSINFO_RET_OK;
+}
+
+/* Example check_service[ssh], check_service[smtp,29],check_service[ssh,127.0.0.1,22]*/
+/* check_service[ssh,127.0.0.1,ssh] */
+int CHECK_SERVICE_PERF(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ unsigned short port=0;
+ char service[MAX_STRING_LEN];
+ char ip[MAX_STRING_LEN];
+ char str_port[MAX_STRING_LEN];
+
+ double start_time = 0;
+
+ int ret = SYSINFO_RET_OK;
+ int value_int;
+
+ assert(result);
+
+ init_result(result);
+
+ start_time = zbx_time();
+
+ if(num_param(param) > 3)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, service, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, ip, MAX_STRING_LEN) != 0)
+ {
+ ip[0] = '\0';
+ }
+
+ if(ip[0] == '\0')
+ {
+ strscpy(ip, "127.0.0.1");
+ }
+
+ if(get_param(param, 3, str_port, MAX_STRING_LEN) != 0)
+ {
+ str_port[0] = '\0';
+ }
+
+ if(str_port[0] != '\0')
+ {
+ port = atoi(str_port);
+ }
+ else
+ {
+ port = 0;
+ }
+
+/* printf("IP:[%s]",ip);
+ printf("Service:[%s]",service);
+ printf("Port:[%d]",port);*/
+
+ if(strcmp(service,"ssh") == 0)
+ {
+ if(port == 0) port=22;
+ ret=check_ssh(ip,port,&value_int);
+ }
+#ifdef HAVE_LDAP
+ else if(strcmp(service,"ldap") == 0)
+ {
+ if(port == 0) port=389;
+ ret=check_ldap(ip,port,&value_int);
+ }
+#endif
+ else if(strcmp(service,"smtp") == 0)
+ {
+ if(port == 0) port=25;
+ ret=tcp_expect(ip,port,NULL,"220","QUIT\n",&value_int);
+ }
+ else if(strcmp(service,"ftp") == 0)
+ {
+ if(port == 0) port=21;
+ ret=tcp_expect(ip,port,NULL,"220","",&value_int);
+ }
+ else if(strcmp(service,"http") == 0)
+ {
+ if(port == 0) port=80;
+ ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
+ }
+ else if(strcmp(service,"pop") == 0)
+ {
+ if(port == 0) port=110;
+ ret=tcp_expect(ip,port,NULL,"+OK","",&value_int);
+ }
+ else if(strcmp(service,"nntp") == 0)
+ {
+ if(port == 0) port=119;
+/* 220 is incorrect */
+/* ret=tcp_expect(ip,port,"220","");*/
+ ret=tcp_expect(ip,port,NULL,"200","",&value_int);
+ }
+ else if(strcmp(service,"imap") == 0)
+ {
+ if(port == 0) port=143;
+ ret=tcp_expect(ip,port,NULL,"* OK","a1 LOGOUT\n",&value_int);
+ }
+ else if(strcmp(service,"tcp") == 0)
+ {
+ if(port == 0) port=80;
+ ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(SYSINFO_RET_OK == ret)
+ {
+ if(value_int)
+ {
+ SET_DBL_RESULT(result, zbx_time() - start_time);
+ }
+ else
+ {
+ SET_DBL_RESULT(result, 0.0);
+ }
+ }
+
+
+ return ret;
+}
+
+/* Example check_service[ssh], check_service[smtp,29],check_service[ssh,127.0.0.1,22]*/
+/* check_service[ssh,127.0.0.1,ssh] */
+int CHECK_SERVICE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ unsigned short port=0;
+ char service[MAX_STRING_LEN];
+ char ip[MAX_STRING_LEN];
+ char str_port[MAX_STRING_LEN];
+
+ int ret;
+ int value_int = 0;
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 3)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, service, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, ip, MAX_STRING_LEN) != 0)
+ {
+ ip[0] = '\0';
+ }
+
+ if(ip[0] == '\0')
+ {
+ strscpy(ip, "127.0.0.1");
+ }
+
+ if(get_param(param, 3, str_port, MAX_STRING_LEN) != 0)
+ {
+ str_port[0] = '\0';
+ }
+
+ if(str_port[0] != '\0')
+ {
+ port = atoi(str_port);
+ }
+ else
+ {
+ port = 0;
+ }
+
+/* printf("IP:[%s]",ip);
+ printf("Service:[%s]",service);
+ printf("Port:[%d]",port);*/
+
+ if(strcmp(service,"ssh") == 0)
+ {
+ if(port == 0) port=22;
+ ret=check_ssh(ip,port,&value_int);
+ }
+ else if(strcmp(service,"service.ntp") == 0)
+ {
+ if(port == 0) port=123;
+ ret=check_ntp(ip,port,&value_int);
+ }
+#ifdef HAVE_LDAP
+ else if(strcmp(service,"ldap") == 0)
+ {
+ if(port == 0) port=389;
+ ret=check_ldap(ip,port,&value_int);
+ }
+#endif
+ else if(strcmp(service,"smtp") == 0)
+ {
+ if(port == 0) port=25;
+ ret=tcp_expect(ip,port,NULL,"220","QUIT\n",&value_int);
+ }
+ else if(strcmp(service,"ftp") == 0)
+ {
+ if(port == 0) port=21;
+ ret=tcp_expect(ip,port,NULL,"220","",&value_int);
+ }
+ else if(strcmp(service,"http") == 0)
+ {
+ if(port == 0) port=80;
+ ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
+ }
+ else if(strcmp(service,"pop") == 0)
+ {
+ if(port == 0) port=110;
+ ret=tcp_expect(ip,port,NULL,"+OK","",&value_int);
+ }
+ else if(strcmp(service,"nntp") == 0)
+ {
+ if(port == 0) port=119;
+/* 220 is incorrect */
+/* ret=tcp_expect(ip,port,"220","");*/
+ ret=tcp_expect(ip,port,NULL,"200","",&value_int);
+ }
+ else if(strcmp(service,"imap") == 0)
+ {
+ if(port == 0) port=143;
+ ret=tcp_expect(ip,port,NULL,"* OK","a1 LOGOUT\n",&value_int);
+ }
+ else if(strcmp(service,"tcp") == 0)
+ {
+ if(port == 0) port=80;
+ ret=tcp_expect(ip,port,NULL,NULL,"",&value_int);
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(SYSINFO_RET_OK == ret)
+ {
+ SET_UI64_RESULT(result, value_int);
+ }
+
+ return ret;
+}
+
diff --git a/src/libs/zbxsysinfo/simple/simple.h b/src/libs/zbxsysinfo/simple/simple.h
new file mode 100644
index 00000000..cc00e2ce
--- /dev/null
+++ b/src/libs/zbxsysinfo/simple/simple.h
@@ -0,0 +1,29 @@
+/*
+** 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.
+**/
+
+#if !defined(SYSINFO_SIMPLE_H_INCLUDED)
+
+#include "sysinfo.h"
+
+extern ZBX_METRIC parameters_simple[];
+
+int CHECK_SERVICE_PERF(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+int CHECK_SERVICE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+
+#endif /* SYSINFO_SIMPLE_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/solaris/Makefile.am b/src/libs/zbxsysinfo/solaris/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/solaris/Makefile.am
+++ b/src/libs/zbxsysinfo/solaris/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/solaris/cpu.c b/src/libs/zbxsysinfo/solaris/cpu.c
index 0a971868..859e3771 100644
--- a/src/libs/zbxsysinfo/solaris/cpu.c
+++ b/src/libs/zbxsysinfo/solaris/cpu.c
@@ -22,11 +22,6 @@
#include "common.h"
#include "sysinfo.h"
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
-
static int get_cpu_data(
const char* cpuname,
unsigned long long *idle,
diff --git a/src/libs/zbxsysinfo/solaris/solaris.c b/src/libs/zbxsysinfo/solaris/solaris.c
index d4261f43..536375e5 100644
--- a/src/libs/zbxsysinfo/solaris/solaris.c
+++ b/src/libs/zbxsysinfo/solaris/solaris.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,41 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "sd0,bytes"},
+ {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "sd0,bytes"},
- {"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, "sd0,bytes"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "sd0,bytes"},
-
- {"net.tcp.dns", CF_USEUPARAM, CHECK_DNS, 0, "127.0.0.1,localhost"},
{"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"net.tcp.port", CF_USEUPARAM, CHECK_PORT, 0, ",80"},
- {"net.tcp.service", CF_USEUPARAM, CHECK_SERVICE, 0, "ssh,127.0.0.1,22"},
- {"net.tcp.service.perf",CF_USEUPARAM, CHECK_SERVICE_PERF, 0, "ssh,127.0.0.1,22"},
- {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "hme0,bytes"},
- {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "hme0,bytes"},
- {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "hme0,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "hme0,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "hme0,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "hme0,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "hme0"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -70,11 +54,7 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/specsysinfo.h b/src/libs/zbxsysinfo/specsysinfo.h
new file mode 100644
index 00000000..06adb3d9
--- /dev/null
+++ b/src/libs/zbxsysinfo/specsysinfo.h
@@ -0,0 +1,24 @@
+/*
+** 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.
+**/
+
+#if !defined(SPECSYSINFO_H_INCLUDED)
+
+extern ZBX_METRIC parameters_specific[];
+
+#endif /* SPECSYSINFO_H_INCLUDED */
diff --git a/src/libs/zbxsysinfo/sysinfo.c b/src/libs/zbxsysinfo/sysinfo.c
new file mode 100644
index 00000000..67a8adc3
--- /dev/null
+++ b/src/libs/zbxsysinfo/sysinfo.c
@@ -0,0 +1,780 @@
+/*
+** 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 "common.h"
+#include "sysinfo.h"
+#include "log.h"
+#include "alias.h"
+
+#include "common/common.h"
+
+#if defined(WITH_COMMON_METRICS)
+# include "common/common.h"
+#endif /* USE_COMMON_METRICS */
+
+#if defined(WITH_SIMPLE_METRICS)
+# include "simple/simple.h"
+#endif /* USE_SIMPLE_METRICS */
+
+#if defined(WITH_SPECIFIC_METRICS)
+# include "specsysinfo.h"
+#endif /* USE_SPECIFIC_METRICS */
+
+ZBX_METRIC *commands=NULL;
+
+void add_metric(ZBX_METRIC *new)
+{
+ register int i;
+
+ assert(new);
+
+ if(new->key == NULL)
+ return;
+
+ for(i=0;;i++)
+ {
+ if(commands[i].key == NULL)
+ {
+
+ commands[i].key = strdup(new->key);
+ commands[i].flags = new->flags;
+
+ commands[i].function=new->function;
+
+ if(new->main_param == NULL)
+ commands[i].main_param=NULL;
+ else
+ commands[i].main_param=strdup(new->main_param);
+
+ if(new->test_param == NULL)
+ commands[i].test_param=NULL;
+ else
+ commands[i].test_param=strdup(new->test_param);
+
+ commands=realloc(commands,(i+2)*sizeof(ZBX_METRIC));
+ commands[i+1].key=NULL;
+ break;
+ }
+ }
+}
+
+void add_user_parameter(char *key,char *command)
+{
+ register int i;
+ char usr_cmd[MAX_STRING_LEN];
+ char usr_param[MAX_STRING_LEN];
+ unsigned flag = 0;
+
+ i = parse_command(key, usr_cmd, MAX_STRING_LEN, usr_param, MAX_STRING_LEN);
+ if(i == 0)
+ {
+ zabbix_log( LOG_LEVEL_WARNING, "Can't add user specifed key \"%s\". Can't parse key!", key);
+ return;
+ }
+ else if(i == 2) /* with specifed parameters */
+ {
+ if(strcmp(usr_param,"*")){ /* must be '*' parameters */
+ zabbix_log(LOG_LEVEL_WARNING, "Can't add user specifed key \"%s\". Incorrect key!", key);
+ return;
+ }
+ flag |= CF_USEUPARAM;
+ }
+
+ for(i=0;;i++)
+ {
+ /* Add new parameters */
+ if( commands[i].key == 0)
+ {
+ commands[i].key = strdup(usr_cmd);
+ commands[i].flags = flag;
+ commands[i].function = &EXECUTE_STR;
+ commands[i].main_param = strdup(command);
+ commands[i].test_param = 0;
+
+ commands=realloc(commands,(i+2)*sizeof(ZBX_METRIC));
+ commands[i+1].key=NULL;
+
+ break;
+ }
+
+ /* Replace existing parameters */
+ if(strcmp(commands[i].key, key) == 0)
+ {
+ if(commands[i].key)
+ free(commands[i].key);
+ if(commands[i].main_param)
+ free(commands[i].main_param);
+ if(commands[i].test_param)
+ free(commands[i].test_param);
+
+ commands[i].key = strdup(key);
+ commands[i].flags = flag;
+ commands[i].function = &EXECUTE_STR;
+ commands[i].main_param = strdup(command);
+ commands[i].test_param = 0;
+
+ break;
+ }
+ }
+}
+
+void init_metrics()
+{
+ register int i;
+
+ commands = malloc(sizeof(ZBX_METRIC));
+ commands[0].key=NULL;
+
+#if defined(WITH_COMMON_METRICS)
+ for(i=0;parameters_common[i].key!=0;i++)
+ {
+ add_metric(&parameters_common[i]);
+ }
+#endif /* USE_COMMON_METRICS */
+
+#if defined(WITH_SPECIFIC_METRICS)
+ for(i=0;parameters_specific[i].key!=0;i++)
+ {
+ add_metric(&parameters_specific[i]);
+ }
+#endif /* USE_SPECIFIC_METRICS */
+
+#if defined(WITH_SIMPLE_METRICS)
+ for(i=0;parameters_simple[i].key!=0;i++)
+ {
+ add_metric(&parameters_simple[i]);
+ }
+#endif /* USE_SIMPLE_METRICS */
+}
+
+void escape_string(char *from, char *to, int maxlen)
+{
+ register int i,ptr;
+ char *f;
+
+ ptr=0;
+ f=(char *)strdup(from);
+ for(i=0;f[i]!=0;i++)
+ {
+ if( (f[i]=='\'') || (f[i]=='\\'))
+ {
+ if(ptr>maxlen-1) break;
+ to[ptr]='\\';
+ if(ptr+1>maxlen-1) break;
+ to[ptr+1]=f[i];
+ ptr+=2;
+ }
+ else
+ {
+ if(ptr>maxlen-1) break;
+ to[ptr]=f[i];
+ ptr++;
+ }
+ }
+ free(f);
+
+ to[ptr]=0;
+ to[maxlen-1]=0;
+}
+
+int copy_result(AGENT_RESULT *src, AGENT_RESULT *dist)
+{
+ assert(src);
+ assert(dist);
+
+ free_result(dist);
+ dist->type = src->type;
+ dist->dbl = src->dbl;
+ if(src->str)
+ {
+ dist->str = strdup(src->str);
+ if(!dist->str)
+ return 1;
+ }
+ if(src->msg)
+ {
+ dist->msg = strdup(src->msg);
+ if(!dist->msg)
+ return 1;
+ }
+ return 0;
+}
+
+void free_result(AGENT_RESULT *result)
+{
+ UNSET_DBL_RESULT(result);
+ UNSET_UI64_RESULT(result);
+ UNSET_STR_RESULT(result);
+ UNSET_TEXT_RESULT(result);
+ UNSET_MSG_RESULT(result);
+}
+
+void init_result(AGENT_RESULT *result)
+{
+ /* don't use `free_result(result)`, dangerous recycling */
+
+ result->type = 0;
+
+ result->ui64 = 0;
+ result->dbl = 0;
+ result->str = NULL;
+ result->text = NULL;
+ result->msg = NULL;
+}
+
+int parse_command( /* return value: 0 - error; 1 - command without parameters; 2 - command with parameters */
+ const char *command,
+ char *cmd,
+ int cmd_max_len,
+ char *param,
+ int param_max_len
+ )
+{
+ char *pl, *pr;
+ char localstr[MAX_STRING_LEN];
+ int ret = 2;
+
+ zbx_strlcpy(localstr, command, MAX_STRING_LEN);
+
+ if(cmd)
+ zbx_strlcpy(cmd, "", cmd_max_len);
+ if(param)
+ zbx_strlcpy(param, "", param_max_len);
+
+ pl = strstr(localstr, "[");
+ pr = strstr(localstr, "]");
+
+ if(pl > pr)
+ return 0;
+
+ if((pl && !pr) || (!pl && pr))
+ return 0;
+
+ if(pl != NULL)
+ pl[0] = 0;
+ if(pr != NULL)
+ pr[0] = 0;
+
+ if(cmd)
+ zbx_strlcpy(cmd, localstr, cmd_max_len);
+
+ if(pl && pr && param)
+ zbx_strlcpy(param, &pl[1] , param_max_len);
+
+ if(!pl && !pr)
+ ret = 1;
+
+ return ret;
+}
+
+void test_parameter(char* key)
+{
+ AGENT_RESULT result;
+
+ memset(&result, 0, sizeof(AGENT_RESULT));
+ process(key, PROCESS_TEST, &result);
+ if(result.type & AR_DOUBLE)
+ {
+ printf(" [d|" ZBX_FS_DBL "]", result.dbl);
+ }
+ if(result.type & AR_UINT64)
+ {
+ printf(" [u|" ZBX_FS_UI64 "]", result.ui64);
+ }
+ if(result.type & AR_STRING)
+ {
+ printf(" [s|%s]", result.str);
+ }
+ if(result.type & AR_TEXT)
+ {
+ printf(" [t|%s]", result.text);
+ }
+ if(result.type & AR_MESSAGE)
+ {
+ printf(" [m|%s]", result.msg);
+ }
+
+ free_result(&result);
+ printf("\n");
+
+ fflush(stdout);
+}
+
+void test_parameters(void)
+{
+ register int i;
+ AGENT_RESULT result;
+
+#if defined(_WINDOWS)
+#endif
+
+ memset(&result, 0, sizeof(AGENT_RESULT));
+
+ for(i=0; 0 != commands[i].key; i++)
+ {
+ process(commands[i].key, PROCESS_TEST | PROCESS_USE_TEST_PARAM, &result);
+ if(result.type & AR_DOUBLE)
+ {
+ printf(" [d|" ZBX_FS_DBL "]", result.dbl);
+ }
+ if(result.type & AR_UINT64)
+ {
+ printf(" [u|" ZBX_FS_UI64 "]", result.ui64);
+ }
+ if(result.type & AR_STRING)
+ {
+ printf(" [s|%s]", result.str);
+ }
+ if(result.type & AR_TEXT)
+ {
+ printf(" [t|%s]", result.text);
+ }
+ if(result.type & AR_MESSAGE)
+ {
+ printf(" [m|%s]", result.msg);
+ }
+ free_result(&result);
+ printf("\n");
+
+ fflush(stdout);
+ }
+}
+
+int replace_param(const char *cmd, const char *param, char *out, int outlen)
+{
+ int ret = SUCCEED;
+ char buf[MAX_STRING_LEN];
+ char command[MAX_STRING_LEN];
+ register char *pl, *pr;
+
+ assert(out);
+
+ out[0] = '\0';
+
+ if(!cmd && !param)
+ return ret;
+
+ zbx_strlcpy(command, cmd, MAX_STRING_LEN);
+
+ pl = command;
+ while((pr = strchr(pl, '$')) && outlen > 0)
+ {
+ pr[0] = '\0';
+ zbx_strlcat(out, pl, outlen);
+ outlen -= MIN((int)strlen(pl), (int)outlen);
+ pr[0] = '$';
+
+ if (pr[1] >= '0' && pr[1] <= '9')
+ {
+ buf[0] = '\0';
+
+ if(pr[1] == '0')
+ {
+ zbx_strlcpy(buf, command, MAX_STRING_LEN);
+ }
+ else
+ {
+ get_param(param, (int)(pr[1] - '0'), buf, MAX_STRING_LEN);
+ }
+
+ zbx_strlcat(out, buf, outlen);
+ outlen -= MIN((int)strlen(buf), (int)outlen);
+
+ pl = pr + 2;
+ continue;
+ } else if(pr[1] == '$')
+ {
+ pr++; /* remove second '$' symbol */
+ }
+
+ pl = pr + 1;
+ zbx_strlcat(out, "$", outlen);
+ outlen -= 1;
+ }
+ zbx_strlcat(out, pl, outlen);
+ outlen -= MIN((int)strlen(pl), (int)outlen);
+
+ return ret;
+}
+
+int process(const char *in_command, unsigned flags, AGENT_RESULT *result)
+{
+ register char *p;
+ register int i;
+
+ int (*function)() = NULL;
+ int ret = SUCCEED;
+ int err = SYSINFO_RET_OK;
+
+ char usr_cmd[MAX_STRING_LEN];
+ char usr_param[MAX_STRING_LEN];
+
+ char usr_command[MAX_STRING_LEN];
+ int usr_command_len;
+
+ char param[MAX_STRING_LEN];
+
+
+ assert(result);
+ init_result(result);
+
+ alias_expand(in_command, usr_command, MAX_STRING_LEN);
+
+ usr_command_len = (int)strlen(usr_command);
+
+ for( p=usr_command+usr_command_len-1; p>usr_command && ( *p=='\r' || *p =='\n' || *p == ' ' ); --p );
+
+ if( (p[1]=='\r') || (p[1]=='\n') || (p[1]==' '))
+ {
+ p[1]=0;
+ }
+
+ function=0;
+
+ if(parse_command(usr_command, usr_cmd, MAX_STRING_LEN, usr_param, MAX_STRING_LEN) != 0)
+ {
+
+ for(i=0; commands[i].key != 0; i++)
+ {
+ if( strcmp(commands[i].key, usr_cmd) == 0)
+ {
+ function=commands[i].function;
+ break;
+ }
+ }
+ }
+
+ param[0] = '\0';
+ if(function != 0)
+ {
+
+ if(commands[i].flags & CF_USEUPARAM)
+ {
+ if((flags & PROCESS_TEST) && (flags & PROCESS_USE_TEST_PARAM) && commands[i].test_param)
+ {
+ zbx_strlcpy(usr_param, commands[i].test_param, MAX_STRING_LEN);
+ }
+ }
+ else
+ {
+ usr_param[0] = '\0';
+ }
+
+ if(commands[i].main_param)
+ {
+ if(commands[i].flags & CF_USEUPARAM)
+ {
+ err = replace_param(
+ commands[i].main_param,
+ usr_param,
+ param,
+ MAX_STRING_LEN);
+ }
+ else
+ {
+ zbx_snprintf(param, sizeof(param), "%s", commands[i].main_param);
+ }
+ }
+ else
+ {
+ zbx_snprintf(param, sizeof(param), "%s", usr_param);
+ }
+
+ if(err != FAIL)
+ {
+ err = function(usr_command, param, flags, result);
+
+ if(err == SYSINFO_RET_FAIL)
+ err = NOTSUPPORTED;
+ else if(err == SYSINFO_RET_TIMEOUT)
+ err = TIMEOUT_ERROR;
+ }
+ }
+ else
+ {
+ err = NOTSUPPORTED;
+ }
+
+ if(flags & PROCESS_TEST)
+ {
+ printf("%s", usr_cmd);
+ if(commands[i].flags & CF_USEUPARAM)
+ {
+ printf("[%s]", param);
+ i = (int)strlen(param)+2;
+ } else i = 0;
+ i += (int)strlen(usr_cmd);
+
+#define COLUMN_2_X 45 /* max of spaces count */
+ i = i > COLUMN_2_X ? 1 : (COLUMN_2_X - i);
+
+ printf("%-*.*s", i, i, " "); /* print spaces */
+ }
+
+ if(err == NOTSUPPORTED)
+ {
+ if(!(result->type & AR_MESSAGE))
+ {
+ SET_MSG_RESULT(result, strdup("ZBX_NOTSUPPORTED"));
+ }
+ ret = NOTSUPPORTED;
+ }
+ else if(err == TIMEOUT_ERROR)
+ {
+ if(!(result->type & AR_MESSAGE))
+ {
+ SET_MSG_RESULT(result, strdup("ZBX_ERROR"));
+ }
+ ret = TIMEOUT_ERROR;
+ }
+
+ return ret;
+}
+
+int set_result_type(AGENT_RESULT *result, int value_type, char *c)
+{
+ int ret = FAIL;
+
+ assert(result);
+
+ if(value_type == ITEM_VALUE_TYPE_UINT64)
+ {
+ del_zeroes(c);
+ if(is_uint(c) == SUCCEED)
+ {
+ SET_UI64_RESULT(result, zbx_atoui64(c));
+ ret = SUCCEED;
+ }
+ }
+ else if(value_type == ITEM_VALUE_TYPE_FLOAT)
+ {
+ if(is_double(c) == SUCCEED)
+ {
+ SET_DBL_RESULT(result, atof(c));
+ ret = SUCCEED;
+ }
+ else if(is_uint(c) == SUCCEED)
+ {
+ SET_DBL_RESULT(result, strtod(c, NULL));
+ ret = SUCCEED;
+ }
+ }
+ else if(value_type == ITEM_VALUE_TYPE_STR)
+ {
+ SET_STR_RESULT(result, strdup(c));
+ ret = SUCCEED;
+ }
+ else if(value_type == ITEM_VALUE_TYPE_TEXT)
+ {
+ SET_TEXT_RESULT(result, strdup(c));
+ ret = SUCCEED;
+ }
+ else if(value_type == ITEM_VALUE_TYPE_LOG)
+ {
+ SET_STR_RESULT(result, strdup(c));
+ ret = SUCCEED;
+ }
+
+ return ret;
+}
+
+static zbx_uint64_t* get_result_ui64_value(AGENT_RESULT *result)
+{
+ zbx_uint64_t tmp;
+
+ assert(result);
+
+ if(ISSET_UI64(result))
+ {
+ /* nothing to do */
+ }
+ else if(ISSET_DBL(result))
+ {
+ SET_UI64_RESULT(result, result->dbl);
+ }
+ else if(ISSET_STR(result))
+ {
+ if(EOF != sscanf(result->str, ZBX_FS_UI64, &tmp))
+ SET_UI64_RESULT(result, tmp);
+ }
+ else if(ISSET_TEXT(result))
+ {
+ if(EOF != sscanf(result->text, ZBX_FS_UI64, &tmp))
+ SET_UI64_RESULT(result, tmp);
+ }
+ /* skip AR_MESSAGE - it is information field */
+
+ if(ISSET_UI64(result))
+ {
+ return &result->ui64;
+ }
+
+ return NULL;
+}
+
+static double* get_result_dbl_value(AGENT_RESULT *result)
+{
+ double tmp;
+
+ assert(result);
+
+ if(ISSET_DBL(result))
+ {
+ /* nothing to do */
+ }
+ else if(ISSET_UI64(result))
+ {
+ SET_DBL_RESULT(result, result->ui64);
+ }
+ else if(ISSET_STR(result))
+ {
+ if(EOF != sscanf(result->str, ZBX_FS_DBL, &tmp))
+ SET_DBL_RESULT(result, tmp);
+ }
+ else if(ISSET_TEXT(result))
+ {
+ if(EOF != sscanf(result->text, ZBX_FS_DBL, &tmp))
+ SET_DBL_RESULT(result, tmp);
+ }
+ /* skip AR_MESSAGE - it is information field */
+
+ if(ISSET_DBL(result))
+ {
+ return &result->dbl;
+ }
+
+ return NULL;
+}
+
+static char** get_result_str_value(AGENT_RESULT *result)
+{
+ register char *p, tmp;
+
+ assert(result);
+
+ if(ISSET_STR(result))
+ {
+ /* nothing to do */
+ }
+ else if(ISSET_TEXT(result))
+ {
+ /* NOTE: copy only line */
+ for(p = result->text; *p != '\0' && *p != '\r' && *p != '\n'; p++);
+ tmp = *p; /* remember result->text character */
+ *p = '\0'; /* replace to EOL */
+ SET_STR_RESULT(result, strdup(result->text)); /* copy line */
+ *p = tmp; /* restore result->text character */
+
+ }
+ else if(ISSET_UI64(result))
+ {
+ SET_STR_RESULT(result, zbx_dsprintf(NULL, ZBX_FS_UI64, result->ui64))
+ }
+ else if(ISSET_DBL(result))
+ {
+ SET_STR_RESULT(result, zbx_dsprintf(NULL, ZBX_FS_DBL, result->dbl))
+ }
+ /* skip AR_MESSAGE - it is information field */
+
+ if(ISSET_STR(result))
+ {
+ return &result->str;
+ }
+
+ return NULL;
+}
+
+static char** get_result_text_value(AGENT_RESULT *result)
+{
+ assert(result);
+
+ if(ISSET_TEXT(result))
+ {
+ /* nothing to do */
+ }
+ else if(ISSET_STR(result))
+ {
+ SET_TEXT_RESULT(result, strdup(result->str));
+ }
+ else if(ISSET_UI64(result))
+ {
+ SET_TEXT_RESULT(result, zbx_dsprintf(NULL, ZBX_FS_UI64, result->ui64))
+ }
+ else if(ISSET_DBL(result))
+ {
+ SET_TEXT_RESULT(result, zbx_dsprintf(NULL, ZBX_FS_DBL, result->dbl))
+ }
+ /* skip AR_MESSAGE - it is information field */
+
+ if(ISSET_TEXT(result))
+ {
+ return &result->text;
+ }
+
+ return NULL;
+}
+
+/******************************************************************************
+ * *
+ * Function: get_result_value_by_type *
+ * *
+ * Purpose: return vslue of result in special type *
+ * if falue missed convert existed value to requested type *
+ * *
+ * Return value: *
+ * NULL - if value are missed or can't be conferted *
+ * *
+ * Author: Eugene Grigorjev *
+ * *
+ * Comments: beter use definitions *
+ * GET_UI64_RESULT *
+ * GET_DBL_RESULT *
+ * GET_STR_RESULT *
+ * GET_TEXT_RESULT *
+ * GET_MSG_RESULT *
+ * *
+ * AR_MESSAGE - skiped in convertion *
+ * *
+ ******************************************************************************/
+void *get_result_value_by_type(AGENT_RESULT *result, int require_type)
+{
+ assert(result);
+
+ switch(require_type)
+ {
+ case AR_UINT64:
+ return (void*)get_result_ui64_value(result);
+ break;
+ case AR_DOUBLE:
+ return (void*)get_result_dbl_value(result);
+ break;
+ case AR_STRING:
+ return (void*)get_result_str_value(result);
+ break;
+ case AR_TEXT:
+ return (void*)get_result_text_value(result);
+ break;
+ case AR_MESSAGE:
+ if(ISSET_MSG(result)) return (void*)(&result->msg);
+ break;
+ default:
+ break;
+ }
+ return NULL;
+}
diff --git a/src/libs/zbxsysinfo/unknown/Makefile.am b/src/libs/zbxsysinfo/unknown/Makefile.am
index 06659da1..92dc918f 100644
--- a/src/libs/zbxsysinfo/unknown/Makefile.am
+++ b/src/libs/zbxsysinfo/unknown/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxsysinfo2.a
+noinst_LIBRARIES = libspecsysinfo.a
-libzbxsysinfo2_a_SOURCES = \
+libspecsysinfo_a_CPPFLAGS = -I@top_srcdir@/src/zabbix_agent/
+
+libspecsysinfo_a_SOURCES = \
cpu.c \
diskio.c \
diskspace.c \
diff --git a/src/libs/zbxsysinfo/unknown/cpu.c b/src/libs/zbxsysinfo/unknown/cpu.c
index 135e7534..aacb713a 100644
--- a/src/libs/zbxsysinfo/unknown/cpu.c
+++ b/src/libs/zbxsysinfo/unknown/cpu.c
@@ -21,103 +21,13 @@
#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)
-{
- return get_stat("cpu[nice15]", flags, result);
-}
-
-static int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user1]", flags, result);
-}
-
-static int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[user5]", flags, result);
-}
-
-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);
-}
-
-static int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system5]", flags, result);
-}
-
-static int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat("cpu[system15]", flags, result);
-}
-
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- return get_stat(cmd, flags, result);
-}
+#include "stats.h"
int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#define CPU_FNCLIST struct cpu_fnclist_s
-CPU_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
-
- CPU_FNCLIST fl[] =
- {
- {"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}
- };
-
char cpuname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -162,18 +72,49 @@ CPU_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, param, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"idle"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.idle1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.idle5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.idle15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"nice"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.nice1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.nice5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.nice15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"user"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.user1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.user5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.user15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else if( 0 == strcmp(type,"system"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.system1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.system5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.system15)
+ else return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
}
/* AIX CPU info */
diff --git a/src/libs/zbxsysinfo/unknown/diskio.c b/src/libs/zbxsysinfo/unknown/diskio.c
index bad61e3a..642ac402 100644
--- a/src/libs/zbxsysinfo/unknown/diskio.c
+++ b/src/libs/zbxsysinfo/unknown/diskio.c
@@ -22,140 +22,15 @@
#include "common.h"
#include "sysinfo.h"
-static int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"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];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_ops15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks1[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key), "disk_write_blks5[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
-static int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
- char key[MAX_STRING_LEN];
-
- zbx_snprintf(key,sizeof(key),"disk_write_blks15[%s]",param);
-
- return get_stat(key, flags, result);
-}
-
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-
-#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}
- };
-
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -181,7 +56,7 @@ DEV_FNCLIST
zbx_snprintf(type, sizeof(type), "bps");
}
- if(get_param(param, 3, mode, MAX_STRING_LEN) != 0)
+ if(get_param(param, 3, mode, sizeof(mode)) != 0)
{
mode[0] = '\0';
}
@@ -191,47 +66,47 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
-}
-int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
-{
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
-#define DEV_FNCLIST struct dev_fnclist_s
-DEV_FNCLIST
-{
- char *type;
- char *mode;
- int (*function)();
-};
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
- DEV_FNCLIST fl[] =
+ }
+ else
{
- {"ops", "avg1" , DISKREADOPS1},
- {"ops", "avg5" , DISKREADOPS5},
- {"ops", "avg15", DISKREADOPS15},
- {"bps", "avg1" , DISKREADBLKS1},
- {"bps", "avg5" , DISKREADBLKS5},
- {"bps", "avg15", DISKREADBLKS15},
- {0, 0, 0}
- };
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
+}
+int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#ifndef TODO
+ return SYSINFO_RET_FAIL;
+#else
+ /* !!!TODO!!! */
char devname[MAX_STRING_LEN];
char type[MAX_STRING_LEN];
char mode[MAX_STRING_LEN];
- int i;
assert(result);
@@ -267,19 +142,36 @@ DEV_FNCLIST
/* default parameter */
zbx_snprintf(mode, sizeof(mode), "avg1");
}
-
- for(i=0; fl[i].type!=0; i++)
+
+ if(NULL == collector)
{
- if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0)
- {
- if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
- {
- return (fl[i].function)(cmd, devname, flags, result);
- }
- }
+ SET_MSG_RESULT(result, strdup("Collector is not started!"));
+ return SYSINFO_RET_OK;
}
-
- return SYSINFO_RET_FAIL;
+
+ if( 0 == strcmp(type,"ops"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else if( 0 == strcmp(type,"bps"))
+ {
+ if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->diskdevices.XXX1)
+ else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->diskdevices.XXX5)
+ else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->diskdevices.XXX15)
+ else return SYSINFO_RET_FAIL;
+
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
+#endif /* TODO */
}
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
@@ -341,7 +233,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, key, MAX_STRING_LEN) != 0)
+ if(get_param(param, 1, key, sizeof(key)) != 0)
{
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/unknown/unknown.c b/src/libs/zbxsysinfo/unknown/unknown.c
index 0591e666..4c16eab4 100644
--- a/src/libs/zbxsysinfo/unknown/unknown.c
+++ b/src/libs/zbxsysinfo/unknown/unknown.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-#include "config.h"
#include "common.h"
#include "sysinfo.h"
@@ -25,41 +24,26 @@ ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "/etc/passwd,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"},
+ {"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.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},
- {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
-
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"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,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -70,11 +54,7 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
{0}
};
diff --git a/src/libs/zbxsysinfo/win32/win32.c b/src/libs/zbxsysinfo/win32/win32.c
index ccfa5a08..06b7ad46 100644
--- a/src/libs/zbxsysinfo/win32/win32.c
+++ b/src/libs/zbxsysinfo/win32/win32.c
@@ -22,77 +22,30 @@
#include "service.h"
-/*
-SKIP { "__exec{*}", NULL, H_Execute, NULL },
-SKIP { "__usercnt{*}", H_UserCounter, NULL, NULL },
-OK { "system.run[*]", NULL, H_RunCommand, NULL },
-SKIP { "agent.stat[avg_collector_time]", H_NumericPtr, NULL, (char *)&statAvgCollectorTime },
-SKIP { "agent.stat[max_collector_time]", H_NumericPtr, NULL, (char *)&statMaxCollectorTime },
-SKIP { "agent.stat[accepted_requests]", H_NumericPtr, NULL, (char *)&statAcceptedRequests },
-SKIP { "agent.stat[rejected_requests]", H_NumericPtr, NULL, (char *)&statRejectedRequests },
-SKIP { "agent.stat[accept_errors]", H_NumericPtr, NULL, (char *)&statAcceptErrors },
-SKIP { "agent.stat[processed_requests]", H_NumericPtr, NULL, (char *)&statProcessedRequests },
-SKIP { "agent.stat[failed_requests]", H_NumericPtr, NULL, (char *)&statFailedRequests },
-SKIP { "agent.stat[unsupported_requests]", H_NumericPtr, NULL, (char *)&statUnsupportedRequests },
-OK { "proc_info[*]", H_ProcInfo, NULL, NULL }, // TODO 'new realization and naming'
-OK { "perf_counter[*]", H_PerfCounter, NULL, NULL }, // TODO 'new naming'
-OK { "service_state[*]", H_ServiceState, NULL, NULL }, // TODO 'new naming'
-
-OK { "net.tcp.port[*]", H_CheckTcpPort, NULL, NULL },
-OK { "system.cpu.util[*]", H_CpuUtil, NULL, NULL},
-OK { "system.cpu.load[*]", H_CpuLoad, NULL, NULL},
-OK { "vfs.fs.size[*]", H_DiskInfo, NULL, NULL },
-OK { "vfs.file.size[*]", H_FileSize, NULL, NULL },
-OK { "vfs.file.cksum[*]", H_CRC32, NULL, NULL },
-OK { "vfs.file.md5sum[*]", NULL, H_MD5Hash, NULL },
-OK { "system.swap.size[*]", H_SwapSize, NULL, NULL },
-OK { "vm.memory.size[*]", H_MemorySize, NULL, NULL },
-OK { "agent.ping", H_NumericConstant, NULL, (char *)1 },
-OK { "proc.num[*]", H_ProcNum, NULL, NULL },
-OK { "system.uname", NULL, H_SystemUname, NULL },
-OK { "system.hostname", NULL, H_HostName, NULL },
-OK { "agent.version", NULL, H_StringConstant, AGENT_VERSION },
-*/
-
ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{
- {"agent.ping", 0, AGENT_PING, 0, 0},
- {"agent.version", 0, AGENT_VERSION, 0, 0},
-
- {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
- {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
+ {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0},
+ {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0},
- {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "c:\\windows\\win.ini"},
- {"vfs.file.time", CF_USEUPARAM, VFS_FILE_TIME, 0, "c:\\windows\\win.ini,modify"},
- {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "c:\\windows\\win.ini"},
- {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "c:\\windows\\win.ini,fonts"},
- {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "c:\\windows\\win.ini,fonts"},
- {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "c:\\windows\\win.ini"},
- {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "c:\\windows\\win.ini"},
+ {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "c:,free"},
+ {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "c:,free"},
- {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "c:,free"},
- {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "c:,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,ops,avg1"},
- {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"},
+ {"net.tcp.listen", CF_USEUPARAM, NET_TCP_LISTEN, 0, "80"},
- {"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.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
+ {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
+ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
- {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
+ {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"},
- {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "svchost.exe,"},
- {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "svchost.exe,,"},
+ {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "svchost.exe,"},
+ {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "svchost.exe,,"},
{"system.cpu.switches", 0, SYSTEM_CPU_SWITCHES, 0, 0},
{"system.cpu.intr", 0, SYSTEM_CPU_INTR, 0, 0},
@@ -103,15 +56,11 @@ ZBX_METRIC parameters_specific[]=
{"system.swap.in", CF_USEUPARAM, SYSTEM_SWAP_IN, 0, "all"},
{"system.swap.out", CF_USEUPARAM, SYSTEM_SWAP_OUT, 0, "all,count"},
- {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0},
-
- {"system.uname", 0, SYSTEM_UNAME, 0, 0},
- {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"system.users.num", 0, SYSTEM_UNUM, 0, 0},
+ {"system.uptime", 0, SYSTEM_UPTIME, 0, 0},
- {"service_state", CF_USEUPARAM, SERVICE_STATE, 0, ZABBIX_SERVICE_NAME},
- {"perf_counter", CF_USEUPARAM, PERF_MONITOR, 0, "\\System\\Processes"},
- {"proc_info", CF_USEUPARAM, PROC_INFO, 0, "svchost.exe"},
+ {"service_state", CF_USEUPARAM, SERVICE_STATE, 0, ZABBIX_SERVICE_NAME},
+ {"perf_counter", CF_USEUPARAM, PERF_MONITOR, 0, "\\System\\Processes"},
+ {"proc_info", CF_USEUPARAM, PROC_INFO, 0, "svchost.exe"},
{0}
};
diff --git a/src/zabbix_agent/Makefile.am b/src/zabbix_agent/Makefile.am
index 87af71a2..c5b2fe43 100644
--- a/src/zabbix_agent/Makefile.am
+++ b/src/zabbix_agent/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
agents_ldadd = \
- $(top_srcdir)/src/libs/zbxsysinfo/libzbxsysinfo.a \
- $(top_srcdir)/src/libs/zbxsysinfo/$(ARCH)/libzbxsysinfo2.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/libzbxagentsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/$(ARCH)/libspecsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
$(top_srcdir)/src/libs/zbxlog/libzbxlog.a \
$(top_srcdir)/src/libs/zbxsys/libzbxsys.a \
$(top_srcdir)/src/libs/zbxnix/libzbxnix.a \
@@ -17,14 +19,14 @@ bin_PROGRAMS = \
zabbix_agent_SOURCES = \
zabbix_agent.c zabbix_agent.h \
+ stats.c stats.h \
+ cpustat.c cpustat.h \
+ diskdevices.c diskdevices.h \
+ interfaces.c interfaces.h \
zbxconf.c zbxconf.h
zabbix_agent_LDADD = $(agents_ldadd)
-zabbix_agent_CPPFLAGS = $(LDAP_CPPFLAGS)
-
-zabbix_agent_LDFLAGS = $(LDAP_LDFLAGS)
-
zabbix_agentd_SOURCES = \
active.c active.h \
stats.c stats.h \
@@ -39,6 +41,4 @@ zabbix_agentd_SOURCES = \
zabbix_agentd_LDADD = $(agents_ldadd)
-zabbix_agentd_CPPFLAGS = -DZABBIX_DAEMON $(LDAP_CPPFLAGS)
-
-zabbix_agentd_LDFLAGS = $(LDAP_LDFLAGS)
+zabbix_agentd_CPPFLAGS = -DZABBIX_DAEMON
diff --git a/src/zabbix_agent/cpustat.c b/src/zabbix_agent/cpustat.c
index 74a248c0..c5ebd9b1 100644
--- a/src/zabbix_agent/cpustat.c
+++ b/src/zabbix_agent/cpustat.c
@@ -23,28 +23,7 @@
#include "log.h"
#ifdef _WINDOWS
-
#include "perfmon.h"
-
-#else /* not _WINDOWS */
-
- static int get_cpustat(
- int *now,
- float *cpu_user,
- float *cpu_system,
- float *cpu_nice,
- float *cpu_idle
- );
-
- static void apply_cpustat(
- ZBX_CPUS_STAT_DATA *pcpus,
- int now,
- float cpu_user,
- float cpu_system,
- float cpu_nice,
- float cpu_idle
- );
-
#endif /* _WINDOWS */
@@ -193,6 +172,191 @@ void close_cpu_collector(ZBX_CPUS_STAT_DATA *pcpus)
}
+#if !defined(_WINDOWS)
+
+static int get_cpustat(int *now,zbx_uint64_t *cpu_user,zbx_uint64_t *cpu_system,zbx_uint64_t *cpu_nice,zbx_uint64_t *cpu_idle)
+{
+ #if defined(HAVE_PROC_STAT)
+
+ FILE *file;
+ char line[MAX_STRING_LEN];
+
+ #elif defined(HAVE_SYS_PSTAT_H) /* not HAVE_PROC_STAT */
+
+ struct pst_dynamic stats;
+
+ #else /* not HAVE_SYS_PSTAT_H */
+
+ return 1;
+
+ #endif /* HAVE_PROC_STAT */
+
+ *now = time(NULL);
+
+ #if defined(HAVE_PROC_STAT)
+
+ if(NULL == (file = fopen("/proc/stat","r") ))
+ {
+ zbx_error("Cannot open [%s] [%s]\n","/proc/stat", strerror(errno));
+ return 1;
+ }
+
+ *cpu_user = *cpu_nice = *cpu_system = *cpu_idle = -1;
+
+ while(fgets(line,1024,file) != NULL)
+ {
+ if(strstr(line,"cpu ") == NULL) continue;
+
+ sscanf(line, "cpu " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64, cpu_user, cpu_nice, cpu_system, cpu_idle);
+ break;
+ }
+ zbx_fclose(file);
+
+ if(*cpu_user < 0)
+ return 1;
+
+ #elif defined(HAVE_SYS_PSTAT_H) /* HAVE_PROC_STAT */
+
+ pstat_getdynamic(&stats, sizeof( struct pst_dynamic ), 1, 0 );
+ *cpu_user = (zbx_uint64_t)stats.psd_cpu_time[CP_USER];
+ *cpu_nice = (zbx_uint64_t)stats.psd_cpu_time[CP_NICE];
+ *cpu_system = (zbx_uint64_t)stats.psd_cpu_time[CP_SYS];
+ *cpu_idle = (zbx_uint64_t)stats.psd_cpu_time[CP_IDLE];
+
+ #endif /* HAVE_SYS_PSTAT_H */
+ return 0;
+}
+
+
+static void apply_cpustat(
+ ZBX_CPUS_STAT_DATA *pcpus,
+ int now,
+ zbx_uint64_t cpu_user,
+ zbx_uint64_t cpu_system,
+ zbx_uint64_t cpu_nice,
+ zbx_uint64_t cpu_idle
+ )
+{
+ register int i = 0;
+
+ int time = 0,
+ time1 = 0,
+ time5 = 0,
+ time15 = 0;
+
+ zbx_uint64_t
+ idle,
+ idle1,
+ idle5,
+ idle15,
+ user,
+ user1,
+ user5,
+ user15,
+ system,
+ system1,
+ system5,
+ system15,
+ nice,
+ nice1,
+ nice5,
+ nice15,
+ all,
+ all1,
+ all5,
+ all15;
+
+
+ for(i=0; i < MAX_CPU_HISTORY; i++)
+ {
+ if(pcpus->clock[i] < now - MAX_CPU_HISTORY)
+ {
+ pcpus->clock[i] = now;
+
+ user = pcpus->h_user[i] = cpu_user;
+ system = pcpus->h_system[i] = cpu_system;
+ nice = pcpus->h_nice[i] = cpu_nice;
+ idle = pcpus->h_idle[i] = cpu_idle;
+
+ all = cpu_idle + cpu_user + cpu_nice + cpu_system;
+ break;
+ }
+ }
+
+ time = time1 = time5 = time15 = now+1;
+
+ for(i=0; i < MAX_CPU_HISTORY; i++)
+ {
+ if(0 == pcpus->clock[i]) continue;
+
+ if(pcpus->clock[i] == now)
+ {
+ idle = pcpus->h_idle[i];
+ user = pcpus->h_user[i];
+ nice = pcpus->h_nice[i];
+ system = pcpus->h_system[i];
+ all = idle + user + nice + system;
+ }
+
+ if((pcpus->clock[i] >= (now - 60)) && (time1 > pcpus->clock[i]))
+ {
+ time1 = pcpus->clock[i];
+ idle1 = pcpus->h_idle[i];
+ user1 = pcpus->h_user[i];
+ nice1 = pcpus->h_nice[i];
+ system1 = pcpus->h_system[i];
+ all1 = idle1 + user1 + nice1 + system1;
+ }
+ if((pcpus->clock[i] >= (now - (5*60))) && (time5 > pcpus->clock[i]))
+ {
+ time5 = pcpus->clock[i];
+ idle5 = pcpus->h_idle[i];
+ user5 = pcpus->h_user[i];
+ nice5 = pcpus->h_nice[i];
+ system5 = pcpus->h_system[i];
+ all5 = idle5 + user5 + nice5 + system5;
+ }
+ if((pcpus->clock[i] >= (now - (15*60))) && (time15 > pcpus->clock[i]))
+ {
+ time15 = pcpus->clock[i];
+ idle15 = pcpus->h_idle[i];
+ user15 = pcpus->h_user[i];
+ nice15 = pcpus->h_nice[i];
+ system15 = pcpus->h_system[i];
+ all15 = idle15 + user15 + nice15 + system15;
+ }
+ }
+
+#define CALC_CPU_LOAD(type, time) \
+ if((type) - (type ## time) > 0 && (all) - (all ## time) > 0) \
+ { \
+ pcpus->type ## time = 100. * ((double)((type) - (type ## time)))/ \
+ ((double)((all) - (all ## time))); \
+ } \
+ else \
+ { \
+ pcpus->type ## time = 0.; \
+ }
+
+ CALC_CPU_LOAD(idle, 1);
+ CALC_CPU_LOAD(idle, 5);
+ CALC_CPU_LOAD(idle, 15);
+
+ CALC_CPU_LOAD(user, 1);
+ CALC_CPU_LOAD(user, 5);
+ CALC_CPU_LOAD(user, 15);
+
+ CALC_CPU_LOAD(nice, 1);
+ CALC_CPU_LOAD(nice, 5);
+ CALC_CPU_LOAD(nice, 15);
+
+ CALC_CPU_LOAD(system, 1);
+ CALC_CPU_LOAD(system, 5);
+ CALC_CPU_LOAD(system, 15);
+}
+
+#endif /* not _WINDOWS */
+
void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus)
{
#ifdef _WINDOWS
@@ -306,7 +470,7 @@ void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus)
#else /* not _WINDOWS */
int now = 0;
- float cpu_user, cpu_nice, cpu_system, cpu_idle;
+ zbx_uint64_t cpu_user, cpu_nice, cpu_system, cpu_idle;
if(0 != get_cpustat(&now, &cpu_user, &cpu_system, &cpu_nice, &cpu_idle))
@@ -316,163 +480,3 @@ void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus)
#endif /* _WINDOWS */
}
-
-#if !defined(_WINDOWS)
-
-static int get_cpustat(int *now,float *cpu_user,float *cpu_system,float *cpu_nice,float *cpu_idle)
-{
- #if defined(HAVE_PROC_STAT)
-
- FILE *file;
- char line[MAX_STRING_LEN];
-
- #elif defined(HAVE_SYS_PSTAT_H) /* not HAVE_PROC_STAT */
-
- struct pst_dynamic stats;
-
- #else /* not HAVE_SYS_PSTAT_H */
-
- return 1;
-
- #endif /* HAVE_PROC_STAT */
-
- *now = time(NULL);
-
- #if defined(HAVE_PROC_STAT)
-
- if(NULL == (file = fopen("/proc/stat","r") ))
- {
- zbx_error("Cannot open [%s] [%s]\n","/proc/stat", strerror(errno));
- return 1;
- }
-
- *cpu_user = *cpu_nice = *cpu_system = *cpu_idle = -1;
-
- while(fgets(line,1024,file) != NULL)
- {
- if(strstr(line,"cpu ") == NULL) continue;
-
- sscanf(line, "cpu %f %f %f %f", cpu_user, cpu_nice, cpu_system, cpu_idle);
- break;
- }
- zbx_fclose(file);
-
- if(*cpu_user < 0)
- return 1;
-
- #elif defined(HAVE_SYS_PSTAT_H) /* HAVE_PROC_STAT */
-
- pstat_getdynamic(&stats, sizeof( struct pst_dynamic ), 1, 0 );
- *cpu_user = (float)stats.psd_cpu_time[CP_USER];
- *cpu_nice = (float)stats.psd_cpu_time[CP_NICE];
- *cpu_system = (float)stats.psd_cpu_time[CP_SYS];
- *cpu_idle = (float)stats.psd_cpu_time[CP_IDLE];
-
- #endif /* HAVE_SYS_PSTAT_H */
- return 0;
-}
-
-
-#define CALC_CPU_LOAD(now_val, tim_val, now_all_val, tim_all_val) \
- if((now_val) - (tim_val) > 0 && (now_all_val) - (tim_all_val) > 0) \
- { \
- tim_val = 100 * (float)((now_val) - (tim_val)/(now_all_val) - (tim_all_val)); \
- } \
- else \
- { \
- tim_val = 0; \
- }
-
-static void apply_cpustat(
- ZBX_CPUS_STAT_DATA *pcpus,
- int now,
- float cpu_user,
- float cpu_system,
- float cpu_nice,
- float cpu_idle
- )
-{
- int i = 0,
- time = 0,
- time1 = 0,
- time5 = 0,
- time15 = 0;
-
- for(i=0; i < MAX_CPU_HISTORY; i++)
- {
- if(pcpus->clock[i] < now - MAX_CPU_HISTORY)
- {
- pcpus->clock[i] = now;
-
- pcpus->user = pcpus->h_user[i] = cpu_user;
- pcpus->system = pcpus->h_system[i] = cpu_system;
- pcpus->nice = pcpus->h_nice[i] = cpu_nice;
- pcpus->idle = pcpus->h_idle[i] = cpu_idle;
-
- pcpus->all = cpu_idle + cpu_user + cpu_nice + cpu_system;
- break;
- }
- }
-
- time = time1 = time5 = time15 = now+1;
-
- for(i=0; i < MAX_CPU_HISTORY; i++)
- {
- if(0 == pcpus->clock[i]) continue;
-
- if(pcpus->clock[i] == now)
- {
- pcpus->idle = pcpus->h_idle[i];
- pcpus->user = pcpus->h_user[i];
- pcpus->nice = pcpus->h_nice[i];
- pcpus->system = pcpus->h_system[i];
- pcpus->all = pcpus->idle + pcpus->user + pcpus->nice + pcpus->system;
- }
-
- if((pcpus->clock[i] >= (now - 60)) && (time1 > pcpus->clock[i]))
- {
- time1 = pcpus->clock[i];
- pcpus->idle1 = pcpus->h_idle[i];
- pcpus->user1 = pcpus->h_user[i];
- pcpus->nice1 = pcpus->h_nice[i];
- pcpus->system1 = pcpus->h_system[i];
- pcpus->all1 = pcpus->idle1 + pcpus->user1 + pcpus->nice1 + pcpus->system1;
- }
- if((pcpus->clock[i] >= (now - (5*60))) && (time5 > pcpus->clock[i]))
- {
- time5 = pcpus->clock[i];
- pcpus->idle5 = pcpus->h_idle[i];
- pcpus->user5 = pcpus->h_user[i];
- pcpus->nice5 = pcpus->h_nice[i];
- pcpus->system5 = pcpus->h_system[i];
- pcpus->all5 = pcpus->idle5 + pcpus->user5 + pcpus->nice5 + pcpus->system5;
- }
- if((pcpus->clock[i] >= (now - (15*60))) && (time15 > pcpus->clock[i]))
- {
- time15 = pcpus->clock[i];
- pcpus->idle15 = pcpus->h_idle[i];
- pcpus->user15 = pcpus->h_user[i];
- pcpus->nice15 = pcpus->h_nice[i];
- pcpus->system15 = pcpus->h_system[i];
- pcpus->all15 = pcpus->idle15 + pcpus->user15 + pcpus->nice15 + pcpus->system15;
- }
- }
-
- CALC_CPU_LOAD(pcpus->idle, pcpus->idle1, pcpus->all, pcpus->all1);
- CALC_CPU_LOAD(pcpus->idle, pcpus->idle5, pcpus->all, pcpus->all5);
- CALC_CPU_LOAD(pcpus->idle, pcpus->idle15, pcpus->all, pcpus->all15);
-
- CALC_CPU_LOAD(pcpus->user, pcpus->user1, pcpus->all, pcpus->all1);
- CALC_CPU_LOAD(pcpus->user, pcpus->user5, pcpus->all, pcpus->all5);
- CALC_CPU_LOAD(pcpus->user, pcpus->user15, pcpus->all, pcpus->all15);
-
- CALC_CPU_LOAD(pcpus->nice, pcpus->nice1, pcpus->all, pcpus->all1);
- CALC_CPU_LOAD(pcpus->nice, pcpus->nice5, pcpus->all, pcpus->all5);
- CALC_CPU_LOAD(pcpus->nice, pcpus->nice15, pcpus->all, pcpus->all15);
-
- CALC_CPU_LOAD(pcpus->system, pcpus->system1, pcpus->all, pcpus->all1);
- CALC_CPU_LOAD(pcpus->system, pcpus->system5, pcpus->all, pcpus->all5);
- CALC_CPU_LOAD(pcpus->system, pcpus->system15, pcpus->all, pcpus->all15);
-}
-
-#endif /* not _WINDOWS */
diff --git a/src/zabbix_agent/cpustat.h b/src/zabbix_agent/cpustat.h
index 6a00496c..a23602c9 100644
--- a/src/zabbix_agent/cpustat.h
+++ b/src/zabbix_agent/cpustat.h
@@ -63,32 +63,26 @@
typedef struct s_cpus_stat_data
{
+ /* private */
int clock[MAX_CPU_HISTORY];
- float h_user[MAX_CPU_HISTORY];
- float h_system[MAX_CPU_HISTORY];
- float h_nice[MAX_CPU_HISTORY];
- float h_idle[MAX_CPU_HISTORY];
-
- float idle;
- float idle1;
- float idle5;
- float idle15;
- float user;
- float user1;
- float user5;
- float user15;
- float system;
- float system1;
- float system5;
- float system15;
- float nice;
- float nice1;
- float nice5;
- float nice15;
- float all;
- float all1;
- float all5;
- float all15;
+ zbx_uint64_t h_user[MAX_CPU_HISTORY];
+ zbx_uint64_t h_system[MAX_CPU_HISTORY];
+ zbx_uint64_t h_nice[MAX_CPU_HISTORY];
+ zbx_uint64_t h_idle[MAX_CPU_HISTORY];
+
+ /* public */
+ double idle1;
+ double idle5;
+ double idle15;
+ double user1;
+ double user5;
+ double user15;
+ double system1;
+ double system5;
+ double system15;
+ double nice1;
+ double nice5;
+ double nice15;
} ZBX_CPUS_STAT_DATA;
diff --git a/src/zabbix_agent/diskdevices.c b/src/zabbix_agent/diskdevices.c
index eb60ef8f..74351c66 100644
--- a/src/zabbix_agent/diskdevices.c
+++ b/src/zabbix_agent/diskdevices.c
@@ -238,10 +238,10 @@ void report_stats_diskdevices(FILE *file, int now)
* [2] - avg5
* [3] - avg15
*/
- float read_io_ops[4];
- float blks_read[4];
- float write_io_ops[4];
- float blks_write[4];
+ double read_io_ops[4];
+ double blks_read[4];
+ double write_io_ops[4];
+ double blks_write[4];
int i,j;
@@ -321,7 +321,7 @@ void report_stats_diskdevices(FILE *file, int now)
if((read_io_ops[0]!=0)&&(read_io_ops[1]!=0))
{
- fprintf(file,"disk_read_ops1[%s] %f\n", diskdevices[i].device, (float)((read_io_ops[0]-read_io_ops[1])/(now-time1)));
+ fprintf(file,"disk_read_ops1[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((read_io_ops[0]-read_io_ops[1])/(now-time1)));
}
else
{
@@ -329,7 +329,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((read_io_ops[0]!=0)&&(read_io_ops[2]!=0))
{
- fprintf(file,"disk_read_ops5[%s] %f\n", diskdevices[i].device, (float)((read_io_ops[0]-read_io_ops[2])/(now-time5)));
+ fprintf(file,"disk_read_ops5[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((read_io_ops[0]-read_io_ops[2])/(now-time5)));
}
else
{
@@ -337,7 +337,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((read_io_ops[0]!=0)&&(read_io_ops[3]!=0))
{
- fprintf(file,"disk_read_ops15[%s] %f\n", diskdevices[i].device, (float)((read_io_ops[0]-read_io_ops[3])/(now-time15)));
+ fprintf(file,"disk_read_ops15[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((read_io_ops[0]-read_io_ops[3])/(now-time15)));
}
else
{
@@ -346,7 +346,7 @@ void report_stats_diskdevices(FILE *file, int now)
if((blks_read[0]!=0)&&(blks_read[1]!=0))
{
- fprintf(file,"disk_read_blks1[%s] %f\n", diskdevices[i].device, (float)((blks_read[0]-blks_read[1])/(now-time1)));
+ fprintf(file,"disk_read_blks1[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((blks_read[0]-blks_read[1])/(now-time1)));
}
else
{
@@ -354,7 +354,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((blks_read[0]!=0)&&(blks_read[2]!=0))
{
- fprintf(file,"disk_read_blks5[%s] %f\n", diskdevices[i].device, (float)((blks_read[0]-blks_read[2])/(now-time5)));
+ fprintf(file,"disk_read_blks5[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((blks_read[0]-blks_read[2])/(now-time5)));
}
else
{
@@ -362,7 +362,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((blks_read[0]!=0)&&(blks_read[3]!=0))
{
- fprintf(file,"disk_read_blks15[%s] %f\n", diskdevices[i].device, (float)((blks_read[0]-blks_read[3])/(now-time15)));
+ fprintf(file,"disk_read_blks15[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((blks_read[0]-blks_read[3])/(now-time15)));
}
else
{
@@ -371,7 +371,7 @@ void report_stats_diskdevices(FILE *file, int now)
if((write_io_ops[0]!=0)&&(write_io_ops[1]!=0))
{
- fprintf(file,"disk_write_ops1[%s] %f\n", diskdevices[i].device, (float)((write_io_ops[0]-write_io_ops[1])/(now-time1)));
+ fprintf(file,"disk_write_ops1[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((write_io_ops[0]-write_io_ops[1])/(now-time1)));
}
else
{
@@ -379,7 +379,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((write_io_ops[0]!=0)&&(write_io_ops[2]!=0))
{
- fprintf(file,"disk_write_ops5[%s] %f\n", diskdevices[i].device, (float)((write_io_ops[0]-write_io_ops[2])/(now-time5)));
+ fprintf(file,"disk_write_ops5[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((write_io_ops[0]-write_io_ops[2])/(now-time5)));
}
else
{
@@ -387,7 +387,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((write_io_ops[0]!=0)&&(write_io_ops[3]!=0))
{
- fprintf(file,"disk_write_ops15[%s] %f\n", diskdevices[i].device, (float)((write_io_ops[0]-write_io_ops[3])/(now-time15)));
+ fprintf(file,"disk_write_ops15[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((write_io_ops[0]-write_io_ops[3])/(now-time15)));
}
else
{
@@ -396,7 +396,7 @@ void report_stats_diskdevices(FILE *file, int now)
if((blks_write[0]!=0)&&(blks_write[1]!=0))
{
- fprintf(file,"disk_write_blks1[%s] %f\n", diskdevices[i].device, (float)((blks_write[0]-blks_write[1])/(now-time1)));
+ fprintf(file,"disk_write_blks1[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((blks_write[0]-blks_write[1])/(now-time1)));
}
else
{
@@ -404,7 +404,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((blks_write[0]!=0)&&(blks_write[2]!=0))
{
- fprintf(file,"disk_write_blks5[%s] %f\n", diskdevices[i].device, (float)((blks_write[0]-blks_write[2])/(now-time5)));
+ fprintf(file,"disk_write_blks5[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((blks_write[0]-blks_write[2])/(now-time5)));
}
else
{
@@ -412,7 +412,7 @@ void report_stats_diskdevices(FILE *file, int now)
}
if((blks_write[0]!=0)&&(blks_write[3]!=0))
{
- fprintf(file,"disk_write_blks15[%s] %f\n", diskdevices[i].device, (float)((blks_write[0]-blks_write[3])/(now-time15)));
+ fprintf(file,"disk_write_blks15[%s] " ZBX_FS_DBL "\n", diskdevices[i].device, (double)((blks_write[0]-blks_write[3])/(now-time15)));
}
else
{
@@ -424,11 +424,11 @@ void report_stats_diskdevices(FILE *file, int now)
}
-void add_values_diskdevices(int now,int major,int diskno,float read_io_ops,float blks_read,float write_io_ops,float blks_write)
+void add_values_diskdevices(int now,int major,int diskno,double read_io_ops,double blks_read,double write_io_ops,double blks_write)
{
int i,j;
-/* printf("Add_values [%s] [%f] [%f]\n",interface,value_sent,value_received);*/
+/* printf("Add_values [%s] [" ZBX_FS_DBL "] [" ZBX_FS_DBL "]\n",interface,value_sent,value_received);*/
for(i=0;i<MAX_DISKDEVICES;i++)
{
diff --git a/src/zabbix_agent/diskdevices.h b/src/zabbix_agent/diskdevices.h
index 404c66b5..961b3656 100644
--- a/src/zabbix_agent/diskdevices.h
+++ b/src/zabbix_agent/diskdevices.h
@@ -29,10 +29,10 @@ typedef struct c_single_diskdevice_data
int major;
int diskno;
int clock[60*15];
- float read_io_ops[60*15];
- float blks_read[60*15];
- float write_io_ops[60*15];
- float blks_write[60*15];
+ double read_io_ops[60*15];
+ double blks_read[60*15];
+ double write_io_ops[60*15];
+ double blks_write[60*15];
} ZBX_SINGLE_DISKDEVICE_DATA;
typedef struct c_diskdevices_data
@@ -52,10 +52,10 @@ DISKDEVICE
int major;
int diskno;
int clock[60*15];
- float read_io_ops[60*15];
- float blks_read[60*15];
- float write_io_ops[60*15];
- float blks_write[60*15];
+ double read_io_ops[60*15];
+ double blks_read[60*15];
+ double write_io_ops[60*15];
+ double blks_write[60*15];
};
void collect_stats_diskdevices(FILE *outfile);
diff --git a/src/zabbix_agent/interfaces.c b/src/zabbix_agent/interfaces.c
index eb34a43c..83855278 100644
--- a/src/zabbix_agent/interfaces.c
+++ b/src/zabbix_agent/interfaces.c
@@ -152,7 +152,7 @@ void report_stats_interfaces(FILE *file, int now)
time1=0,
time5=0,
time15=0;
- float
+ double
sent=0,
sent1=0,
sent5=0,
@@ -227,7 +227,7 @@ void report_stats_interfaces(FILE *file, int now)
}
if((sent!=0)&&(sent1!=0))
{
- fprintf(file,"netloadout1[%s] %f\n", interfaces[i].interface, (float)((sent-sent1)/(now-time1)));
+ fprintf(file,"netloadout1[%s] " ZBX_FS_DBL "\n", interfaces[i].interface, (double)((sent-sent1)/(now-time1)));
}
else
{
@@ -235,7 +235,7 @@ void report_stats_interfaces(FILE *file, int now)
}
if((sent!=0)&&(sent5!=0))
{
- fprintf(file,"netloadout5[%s] %f\n", interfaces[i].interface, (float)((sent-sent5)/(now-time5)));
+ fprintf(file,"netloadout5[%s] " ZBX_FS_DBL "\n", interfaces[i].interface, (double)((sent-sent5)/(now-time5)));
}
else
{
@@ -243,7 +243,7 @@ void report_stats_interfaces(FILE *file, int now)
}
if((sent!=0)&&(sent15!=0))
{
- fprintf(file,"netloadout15[%s] %f\n", interfaces[i].interface, (float)((sent-sent15)/(now-time15)));
+ fprintf(file,"netloadout15[%s] " ZBX_FS_DBL "\n", interfaces[i].interface, (double)((sent-sent15)/(now-time15)));
}
else
{
@@ -251,7 +251,7 @@ void report_stats_interfaces(FILE *file, int now)
}
if((received!=0)&&(received1!=0))
{
- fprintf(file,"netloadin1[%s] %f\n", interfaces[i].interface, (float)((received-received1)/(now-time1)));
+ fprintf(file,"netloadin1[%s] " ZBX_FS_DBL "\n", interfaces[i].interface, (double)((received-received1)/(now-time1)));
}
else
{
@@ -259,7 +259,7 @@ void report_stats_interfaces(FILE *file, int now)
}
if((received!=0)&&(received5!=0))
{
- fprintf(file,"netloadin5[%s] %f\n", interfaces[i].interface, (float)((received-received5)/(now-time5)));
+ fprintf(file,"netloadin5[%s] " ZBX_FS_DBL "\n", interfaces[i].interface, (double)((received-received5)/(now-time5)));
}
else
{
@@ -267,7 +267,7 @@ void report_stats_interfaces(FILE *file, int now)
}
if((received!=0)&&(received15!=0))
{
- fprintf(file,"netloadin15[%s] %f\n", interfaces[i].interface, (float)((received-received15)/(now-time15)));
+ fprintf(file,"netloadin15[%s] " ZBX_FS_DBL "\n", interfaces[i].interface, (double)((received-received15)/(now-time15)));
}
else
{
@@ -278,13 +278,13 @@ void report_stats_interfaces(FILE *file, int now)
}
-void add_values_interfaces(int now,char *interface,float value_sent,float value_received)
+void add_values_interfaces(int now,char *interface,double value_sent,double value_received)
{
int i,j;
int bounced;
-/* printf("Add_values [%s] [%f] [%f]\n",interface,value_sent,value_received);*/
+/* printf("Add_values [%s] [" ZBX_FS_DBL "] [" ZBX_FS_DBL "]\n",interface,value_sent,value_received);*/
for(i=0;i<MAX_INTERFACE;i++)
{
@@ -341,7 +341,7 @@ void collect_stats_interfaces(FILE *outfile)
int i1,j1;
char interface[MAX_STRING_LEN];
int now;
- float received=0,sent;
+ double received=0,sent;
/* Must be static */
static int initialised=0;
diff --git a/src/zabbix_agent/interfaces.h b/src/zabbix_agent/interfaces.h
index 0b72074f..fa2867ff 100644
--- a/src/zabbix_agent/interfaces.h
+++ b/src/zabbix_agent/interfaces.h
@@ -27,8 +27,8 @@ typedef struct s_single_interface_data
{
char *name;
int clock[60*15];
- float sent[60*15];
- float received[60*15];
+ double sent[60*15];
+ double received[60*15];
} ZBX_SINGLE_INTERFACE_DATA;
typedef struct s_interfaces_data
@@ -46,8 +46,8 @@ INTERFACE
{
char *interface;
int clock[60*15];
- float sent[60*15];
- float received[60*15];
+ double sent[60*15];
+ double received[60*15];
};
void collect_stats_interfaces(FILE *outfile);
diff --git a/src/zabbix_agent/listener.c b/src/zabbix_agent/listener.c
index 47ad9455..4f0071e3 100644
--- a/src/zabbix_agent/listener.c
+++ b/src/zabbix_agent/listener.c
@@ -36,14 +36,14 @@
static void process_listener(ZBX_SOCKET sock)
{
+ register char *p;
+
AGENT_RESULT result;
char command[MAX_STRING_LEN];
- char value[MAX_STRING_LEN];
+ char **value = NULL;
int ret = 0;
- init_result(&result);
-
memset(&command, 0, MAX_STRING_LEN);
ret = zbx_sock_read(sock, (void *)command, MAX_STRING_LEN, CONFIG_TIMEOUT);
@@ -59,24 +59,24 @@ static void process_listener(ZBX_SOCKET sock)
return;
}
- /*command[ret-2] = '\0'; *//* remove '\r\n' sumbols from recived command (_WINDOWS) !!!TODO!!! correct win32 agent !!!TODO!!! */
- command[ret-1] = '\0'; /* remove '\n' sumbols from recived command (LINUX) !!!TODO!!! */
+ for(p = &command[ret - 1]; p >= &command[0] && ('\0' == *p || '\r' == *p || '\n' == *p); p--) *p = '\0'; /* rtrim(\r\n) */
zabbix_log(LOG_LEVEL_DEBUG, "Requested [%s]", command);
- process(command, 0, &result);
+ init_result(&result);
- if(result.type & AR_DOUBLE) zbx_snprintf(value, sizeof(value), "%f", result.dbl);
- else if(result.type & AR_UINT64) zbx_snprintf(value, sizeof(value), ZBX_FS_UI64, result.ui64);
- else if(result.type & AR_STRING) zbx_snprintf(value, sizeof(value), "%s", result.str);
- else if(result.type & AR_TEXT) zbx_snprintf(value, sizeof(value), "%s", result.text);
- else if(result.type & AR_MESSAGE) zbx_snprintf(value, sizeof(value), "%s", result.msg);
+ process(command, 0, &result);
- free_result(&result);
+ if( NULL == (value = GET_TEXT_RESULT(&result)) )
+ value = GET_MSG_RESULT(&result);
- zabbix_log(LOG_LEVEL_DEBUG, "Sending back [%s]", value);
+ if(value)
+ {
+ zabbix_log(LOG_LEVEL_DEBUG, "Sending back [%s]", *value);
+ ret = zbx_sock_write(sock, *value, (int)strlen(*value));
+ }
- ret = zbx_sock_write(sock, value, (int)strlen(value));
+ free_result(&result);
if(ret == SOCKET_ERROR)
{
diff --git a/src/zabbix_agent/stats.c b/src/zabbix_agent/stats.c
index 883df153..c158e382 100644
--- a/src/zabbix_agent/stats.c
+++ b/src/zabbix_agent/stats.c
@@ -30,11 +30,11 @@
#include "log.h"
#include "cfg.h"
-#if defined(ZABBIX_SERVICE)
+#if defined(_WINDOWS)
# include "service.h"
-#elif defined(ZABBIX_DAEMON) /* ZABBIX_SERVICE */
+#else
# include "daemon.h"
-#endif /* ZABBIX_DAEMON */
+#endif /* _WINDOWS */
ZBX_COLLECTOR_DATA *collector = NULL;
@@ -194,4 +194,3 @@ ZBX_THREAD_ENTRY(collector_thread, args)
zbx_tread_exit(0);
}
-
diff --git a/src/zabbix_agent/stats.h b/src/zabbix_agent/stats.h
index e49cf9b6..d750e704 100644
--- a/src/zabbix_agent/stats.h
+++ b/src/zabbix_agent/stats.h
@@ -34,7 +34,6 @@ typedef struct s_collector_data
extern ZBX_COLLECTOR_DATA *collector;
-
ZBX_THREAD_ENTRY(collector_thread, pSemColectorStarted);
void init_collector_data(void);
diff --git a/src/zabbix_agent/zabbix_agent.c b/src/zabbix_agent/zabbix_agent.c
index e115a889..9e4a699b 100644
--- a/src/zabbix_agent/zabbix_agent.c
+++ b/src/zabbix_agent/zabbix_agent.c
@@ -200,7 +200,7 @@ int main(int argc, char **argv)
process(s, 0, &result);
if(result.type & AR_DOUBLE)
- zbx_snprintf(value, sizeof(value), "%f", result.dbl);
+ zbx_snprintf(value, sizeof(value), ZBX_FS_DBL, result.dbl);
else if(result.type & AR_UINT64)
zbx_snprintf(value, sizeof(value), ZBX_FS_UI64, result.ui64);
else if(result.type & AR_STRING)
diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c
index 3abf07b0..e76fab38 100644
--- a/src/zabbix_agent/zabbix_agentd.c
+++ b/src/zabbix_agent/zabbix_agentd.c
@@ -238,7 +238,9 @@ static ZBX_SOCKET tcp_listen(void)
if (bind(sock,(struct sockaddr *)&serv_addr,sizeof(ZBX_SOCKADDR)) == SOCKET_ERROR)
{
zabbix_log(LOG_LEVEL_CRIT, "Cannot bind to port %u for server %s. Error [%s]. Another zabbix_agentd already running ?",
- CONFIG_LISTEN_PORT, CONFIG_LISTEN_IP, strerror_from_system(zbx_sock_last_error()));
+ CONFIG_LISTEN_PORT,
+ CONFIG_LISTEN_IP ? CONFIG_LISTEN_IP : "[ANY]",
+ strerror_from_system(zbx_sock_last_error()));
exit(1);
}
@@ -432,11 +434,30 @@ int main(int argc, char **argv)
#else /* ZABBIX_TEST */
-#include "messages.h"
+#if defined(_WINDOWS)
+# include "messages.h"
+#endif /* _WINDOWS */
int main()
{
#if ON
+ AGENT_RESULT result;
+
+ SET_UI64_RESULT(&result, 123456789123456789123456789ull);
+ printf("UI: '" ZBX_FS_UI64 "'\n", result.ui64);
+
+ printf("UI_TO_DBL: '" ZBX_FS_DBL "'\n", *GET_DBL_RESULT(&result));
+
+ UNSET_RESULT_EXCLUDING(&result, AR_UINT64);
+ printf("UI_TO_STR: '%s'\n", *GET_STR_RESULT(&result));
+
+ UNSET_RESULT_EXCLUDING(&result, AR_UINT64);
+ printf("UI_TO_TEXT: '%s'\n", *GET_TEXT_RESULT(&result));
+
+ UNSET_RESULT_EXCLUDING(&result, AR_UINT64);
+ printf("UI_TO_UI64: '" ZBX_FS_UI64 "'\n", *GET_UI64_RESULT(&result));
+
+#elif OFF
int res, val;
if(FAIL == zbx_sock_init())
diff --git a/src/zabbix_agent/zbxconf.c b/src/zabbix_agent/zbxconf.c
index a74acf7d..7ad90182 100644
--- a/src/zabbix_agent/zbxconf.c
+++ b/src/zabbix_agent/zbxconf.c
@@ -99,7 +99,8 @@ void load_config(int exit_on_error)
{0}
};
- AGENT_RESULT result;
+ AGENT_RESULT result;
+ char **value = NULL;
memset(&result, 0, sizeof(AGENT_RESULT));
@@ -121,9 +122,9 @@ void load_config(int exit_on_error)
{
if(SUCCEED == process("system.hostname", 0, &result))
{
- if(result.type & AR_STRING)
+ if( NULL != (value = GET_STR_RESULT(&result)) )
{
- CONFIG_HOSTNAME = strdup(result.str);
+ CONFIG_HOSTNAME = strdup(*value);
}
}
free_result(&result);
diff --git a/src/zabbix_get/zabbix_get.c b/src/zabbix_get/zabbix_get.c
index c8298d0e..e93a5580 100644
--- a/src/zabbix_get/zabbix_get.c
+++ b/src/zabbix_get/zabbix_get.c
@@ -148,11 +148,8 @@ static int get_value(char *server,int port,char *key,char *value)
servaddr_in.sin_family=AF_INET;
- if(NULL == (hp = zbx_gethost(server)));
- {
- zbx_error("Error on gethost(). [%s]", strerror(errno));
+ if(NULL == (hp = zbx_gethost(server)))
return FAIL;
- }
servaddr_in.sin_addr.s_addr=((struct in_addr *)(hp->h_addr))->s_addr;
diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am
index 2bdd884b..0f47d026 100644
--- a/src/zabbix_server/Makefile.am
+++ b/src/zabbix_server/Makefile.am
@@ -38,8 +38,10 @@ zabbix_server_LDADD = \
utils/libzbxutils.a \
httppoller/libzbxhttppoller.a \
watchdog/libzbxwatchdog.a \
- $(top_srcdir)/src/libs/zbxsysinfo/libzbxsysinfo.a \
- $(top_srcdir)/src/libs/zbxsysinfo/$(ARCH)/libzbxsysinfo2.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/$(ARCH)/libspecsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
$(top_srcdir)/src/libs/zbxlog/libzbxlog.a \
$(top_srcdir)/src/libs/zbxnix/libzbxnix.a \
$(top_srcdir)/src/libs/zbxsys/libzbxsys.a \
@@ -54,6 +56,4 @@ zabbix_server_LDADD = \
$(top_srcdir)/src/libs/zbxcomms/libzbxcomms.a \
$(JABBER_LDADD)
-zabbix_server_CPPFLAGS = -DZABBIX_DAEMON $(DB_CPPFLAGS) $(SNMP_CPPFLAGS) $(LDAP_CPPFLAGS) $(LIBCURL_CPPFLAGS) $(JABBER_CPPFLAGS)
-
-zabbix_server_LDFLAGS = $(DB_LDFLAGS) $(SNMP_LDFLAGS) $(LDAP_LDFLAGS) $(LIBCURL_LDFLAGS) $(JABBER_LDFLAGS)
+zabbix_server_CPPFLAGS = -DZABBIX_DAEMON
diff --git a/src/zabbix_server/alerter/Makefile.am b/src/zabbix_server/alerter/Makefile.am
index 4b94062e..e5b907d8 100644
--- a/src/zabbix_server/alerter/Makefile.am
+++ b/src/zabbix_server/alerter/Makefile.am
@@ -3,5 +3,3 @@
noinst_LIBRARIES = libzbxalerter.a
libzbxalerter_a_SOURCES = alerter.c alerter.h
-
-libzbxalerter_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/alerter/alerter.h b/src/zabbix_server/alerter/alerter.h
index 1b2f69d7..416d8823 100644
--- a/src/zabbix_server/alerter/alerter.h
+++ b/src/zabbix_server/alerter/alerter.h
@@ -20,6 +20,8 @@
#ifndef ZABBIX_ALERTER_H
#define ZABBIX_ALERTER_H
+#include "db.h"
+
extern int CONFIG_SENDER_FREQUENCY;
extern char *CONFIG_DBHOST;
extern char *CONFIG_DBNAME;
@@ -34,4 +36,6 @@ extern void signal_handler( int sig );
int main_alerter_loop();
+int execute_action(DB_ALERT *alert,DB_MEDIATYPE *mediatype, char *error, int max_error_len);
+
#endif
diff --git a/src/zabbix_server/evalfunc.c b/src/zabbix_server/evalfunc.c
index ee6574e8..542f6338 100644
--- a/src/zabbix_server/evalfunc.c
+++ b/src/zabbix_server/evalfunc.c
@@ -17,27 +17,6 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <netdb.h>
-
-#include <signal.h>
-
-#include <string.h>
-
-#include <time.h>
-
-#include <sys/socket.h>
-#include <errno.h>
-
-/* Functions: pow(), round() */
-#include <math.h>
-
#include "common.h"
#include "db.h"
#include "log.h"
@@ -310,7 +289,7 @@ static int evaluate_SUM(char *value, DB_ITEM *item, int parameter, int flag)
sum+=atof(row[0]);
rows++;
}
- if(rows>0) zbx_snprintf(value,MAX_STRING_LEN,"%f", sum);
+ if(rows>0) zbx_snprintf(value,MAX_STRING_LEN, ZBX_FS_DBL, sum);
}
if(0 == rows)
{
@@ -414,7 +393,7 @@ static int evaluate_AVG(char *value,DB_ITEM *item,int parameter,int flag)
}
else
{
- zbx_snprintf(value,MAX_STRING_LEN,"%f", sum/(double)rows);
+ zbx_snprintf(value,MAX_STRING_LEN, ZBX_FS_DBL, sum/(double)rows);
}
}
else
@@ -532,7 +511,7 @@ static int evaluate_MIN(char *value,DB_ITEM *item,int parameter, int flag)
}
else
{
- zbx_snprintf(value,MAX_STRING_LEN,"%f", min);
+ zbx_snprintf(value,MAX_STRING_LEN, ZBX_FS_DBL, min);
}
}
}
@@ -659,7 +638,7 @@ static int evaluate_MAX(char *value,DB_ITEM *item,int parameter,int flag)
}
else
{
- zbx_snprintf(value,MAX_STRING_LEN,"%f", max);
+ zbx_snprintf(value,MAX_STRING_LEN, ZBX_FS_DBL, max);
}
}
}
@@ -759,7 +738,7 @@ static int evaluate_DELTA(char *value,DB_ITEM *item,int parameter, int flag)
}
else
{
- zbx_snprintf(value,MAX_STRING_LEN,"%f", max-min);
+ zbx_snprintf(value,MAX_STRING_LEN, ZBX_FS_DBL, max-min);
}
}
else
@@ -854,7 +833,7 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
{
switch (item->value_type) {
case ITEM_VALUE_TYPE_FLOAT:
- zbx_snprintf(value,MAX_STRING_LEN,"%f",item->lastvalue_dbl);
+ zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_DBL,item->lastvalue_dbl);
del_zeroes(value);
break;
case ITEM_VALUE_TYPE_UINT64:
@@ -876,7 +855,7 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
{
switch (item->value_type) {
case ITEM_VALUE_TYPE_FLOAT:
- zbx_snprintf(value,MAX_STRING_LEN,"%f",item->prevvalue_dbl);
+ zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_DBL,item->prevvalue_dbl);
del_zeroes(value);
break;
case ITEM_VALUE_TYPE_UINT64:
@@ -886,15 +865,6 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
strcpy(value,item->prevvalue_str);
break;
}
-/* if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) || (item->value_type==ITEM_VALUE_TYPE_UINT64))
- {
- zbx_snprintf(value,MAX_STRING_LEN,"%f",item->prevvalue);
- del_zeroes(value);
- }
- else
- {
- strcpy(value,item->prevvalue_str);
- }*/
}
}
else if(strcmp(function,"min")==0)
@@ -971,7 +941,7 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
{
switch (item->value_type) {
case ITEM_VALUE_TYPE_FLOAT:
- zbx_snprintf(value,MAX_STRING_LEN,"%f",
+ zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_DBL,
(double)abs(item->lastvalue_dbl-item->prevvalue_dbl));
del_zeroes(value);
break;
@@ -989,22 +959,6 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
}
break;
}
-/* if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) || (item->value_type==ITEM_VALUE_TYPE_UINT64))
- {
- zbx_snprintf(value,MAX_STRING_LEN,"%f",(float)abs(item->lastvalue-item->prevvalue));
- del_zeroes(value);
- }
- else
- {
- if(strcmp(item->lastvalue_str, item->prevvalue_str) == 0)
- {
- strcpy(value,"0");
- }
- else
- {
- strcpy(value,"1");
- }
- }*/
}
}
else if(strcmp(function,"change")==0)
@@ -1017,7 +971,7 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
{
switch (item->value_type) {
case ITEM_VALUE_TYPE_FLOAT:
- zbx_snprintf(value,MAX_STRING_LEN,"%f",
+ zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_DBL,
item->lastvalue_dbl-item->prevvalue_dbl);
del_zeroes(value);
break;
@@ -1035,22 +989,6 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
}
break;
}
-/* if(item->value_type==ITEM_VALUE_TYPE_FLOAT)
- {
- zbx_snprintf(value,MAX_STRING_LEN,"%f",item->lastvalue-item->prevvalue);
- del_zeroes(value);
- }
- else
- {
- if(strcmp(item->lastvalue_str, item->prevvalue_str) == 0)
- {
- strcpy(value,"0");
- }
- else
- {
- strcpy(value,"1");
- }
- }*/
}
}
else if(strcmp(function,"diff")==0)
@@ -1236,8 +1174,8 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
******************************************************************************/
int add_value_suffix(char *value, DB_ITEM *item)
{
- float value_float;
- float value_float_abs;
+ double value_double;
+ double value_double_abs;
char suffix[MAX_STRING_LEN];
@@ -1249,46 +1187,46 @@ int add_value_suffix(char *value, DB_ITEM *item)
(strlen(item->units)>0))
) return FAIL;
- value_float=atof(value);
+ value_double=atof(value);
/* Custom multiplier? */
/*
if(item->multiplier == 1)
{
- value_float=value_float*atof(item->formula);
+ value_double=value_double*atof(item->formula);
}*/
- value_float_abs=abs(value_float);
+ value_double_abs=abs(value_double);
- if(value_float_abs<1024)
+ if(value_double_abs<1024)
{
strscpy(suffix,"");
}
- else if(value_float_abs<1024*1024)
+ else if(value_double_abs<1024*1024)
{
strscpy(suffix,"K");
- value_float=value_float/1024;
+ value_double=value_double/1024;
}
- else if(value_float_abs<1024*1024*1024)
+ else if(value_double_abs<1024*1024*1024)
{
strscpy(suffix,"M");
- value_float=value_float/(1024*1024);
+ value_double=value_double/(1024*1024);
}
else
{
strscpy(suffix,"G");
- value_float=value_float/(1024*1024*1024);
+ value_double=value_double/(1024*1024*1024);
}
-/* if(cmp_double((double)round(value_float), value_float) == 0) */
- if(cmp_double((int)(value_float+0.5), value_float) == 0)
+/* if(cmp_double((double)round(value_double), value_double) == 0) */
+ if(cmp_double((int)(value_double+0.5), value_double) == 0)
{
- zbx_snprintf(value, MAX_STRING_LEN, "%.0f %s%s", value_float, suffix, item->units);
+ zbx_snprintf(value, MAX_STRING_LEN, ZBX_FS_DBL_EXT(0) " %s%s", value_double, suffix, item->units);
}
else
{
- zbx_snprintf(value, MAX_STRING_LEN, "%.2f %s%s", value_float, suffix, item->units);
+ zbx_snprintf(value, MAX_STRING_LEN, ZBX_FS_DBL_EXT(2) " %s%s", value_double, suffix, item->units);
}
- zabbix_log(LOG_LEVEL_DEBUG, "Value [%s] [%f] Suffix [%s] Units [%s]",value,value_float,suffix,item->units);
+ zabbix_log(LOG_LEVEL_DEBUG, "Value [%s] [" ZBX_FS_DBL "] Suffix [%s] Units [%s]",value,value_double,suffix,item->units);
return SUCCEED;
}
@@ -1384,7 +1322,6 @@ int evaluate_function2(char *value,char *host,char *key,char *function,char *par
DBget_item_from_db(&item,row);
-/* res = evaluate_FUNCTION(value,&item,function,parameter, EVALUATE_FUNCTION_SUFFIX); */
res = evaluate_function(value,&item,function,parameter);
if(replace_value_by_map(value, item.valuemapid) != SUCCEED)
diff --git a/src/zabbix_server/expression.c b/src/zabbix_server/expression.c
index d869a48a..2f21290d 100644
--- a/src/zabbix_server/expression.c
+++ b/src/zabbix_server/expression.c
@@ -113,7 +113,7 @@ void delete_spaces(char *c)
* *
* Author: Alexei Vladishev *
* *
- * Comments: format: <float> or <float> <operator> <float> *
+ * Comments: format: <double> or <double> <operator> <double> *
* *
* It is recursive function! *
* *
@@ -255,7 +255,7 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
{
*result=0;
}
- zabbix_log(LOG_LEVEL_DEBUG, "Result [%f]",*result );
+ zabbix_log(LOG_LEVEL_DEBUG, "Result [" ZBX_FS_DBL "]",*result );
return SUCCEED;
}
if( (p = strstr(exp,"*")) != NULL )
diff --git a/src/zabbix_server/functions.c b/src/zabbix_server/functions.c
index 6bc9788a..fece277e 100644
--- a/src/zabbix_server/functions.c
+++ b/src/zabbix_server/functions.c
@@ -538,40 +538,37 @@ static int add_history(DB_ITEM *item, AGENT_RESULT *value, int now)
{
if(item->value_type==ITEM_VALUE_TYPE_UINT64)
{
- if(value->type & AR_UINT64)
+ if(GET_UI64_RESULT(value))
DBadd_history_uint(item->itemid,value->ui64,now);
}
else if(item->value_type==ITEM_VALUE_TYPE_FLOAT)
{
- if(value->type & AR_DOUBLE)
+ if(GET_DBL_RESULT(value))
DBadd_history(item->itemid,value->dbl,now);
- else if(value->type & AR_UINT64)
- DBadd_history(item->itemid,(double)value->ui64,now);
}
}
/* Delta as speed of change */
else if(item->delta == ITEM_STORE_SPEED_PER_SECOND)
{
/* Save delta */
- if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_DOUBLE))
+ if( ITEM_VALUE_TYPE_FLOAT == item->value_type )
{
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl))
+ if(GET_DBL_RESULT(value) && (item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl))
{
- DBadd_history(item->itemid, (value->dbl - item->prevorgvalue_dbl)/(now-item->lastclock), now);
+ DBadd_history(
+ item->itemid,
+ (value->dbl - item->prevorgvalue_dbl)/(now-item->lastclock),
+ now);
}
}
- else if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_UINT64))
+ else if( ITEM_VALUE_TYPE_UINT64 == item->value_type )
{
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= (double)value->ui64))
+ if(GET_UI64_RESULT(value) && (item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64))
{
- DBadd_history(item->itemid, ((double)value->ui64 - item->prevorgvalue_dbl)/(now-item->lastclock), now);
- }
- }
- else if((item->value_type==ITEM_VALUE_TYPE_UINT64) && (value->type & AR_UINT64))
- {
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64))
- {
- DBadd_history_uint(item->itemid, (zbx_uint64_t)(value->ui64 - item->prevorgvalue_uint64)/(now-item->lastclock), now);
+ DBadd_history_uint(
+ item->itemid,
+ (zbx_uint64_t)(value->ui64 - item->prevorgvalue_uint64)/(now-item->lastclock),
+ now);
}
}
}
@@ -579,23 +576,16 @@ static int add_history(DB_ITEM *item, AGENT_RESULT *value, int now)
else if(item->delta == ITEM_STORE_SIMPLE_CHANGE)
{
/* Save delta */
- if((item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_DOUBLE))
+ if( ITEM_VALUE_TYPE_FLOAT == item->value_type )
{
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl) )
+ if(GET_DBL_RESULT(value) && (item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl) )
{
DBadd_history(item->itemid, (value->dbl - item->prevorgvalue_dbl), now);
}
}
- else if((item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_UINT64))
- {
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= (double)value->ui64) )
- {
- DBadd_history(item->itemid, ((double)value->ui64 - item->prevorgvalue_dbl), now);
- }
- }
- else if((item->value_type==ITEM_VALUE_TYPE_UINT64) && (value->type & AR_UINT64))
+ else if(item->value_type==ITEM_VALUE_TYPE_UINT64)
{
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64) )
+ if(GET_UI64_RESULT(value) && (item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64) )
{
DBadd_history_uint(item->itemid, value->ui64 - item->prevorgvalue_uint64, now);
}
@@ -610,19 +600,19 @@ static int add_history(DB_ITEM *item, AGENT_RESULT *value, int now)
}
else if(item->value_type==ITEM_VALUE_TYPE_STR)
{
- if(value->type & AR_STRING)
+ if(GET_STR_RESULT(value))
DBadd_history_str(item->itemid,value->str,now);
}
else if(item->value_type==ITEM_VALUE_TYPE_LOG)
{
- if(value->type & AR_STRING)
+ if(GET_STR_RESULT(value))
DBadd_history_log(item->itemid,value->str,now,item->timestamp,item->eventlog_source,item->eventlog_severity);
DBexecute("update items set lastlogsize=%d where itemid=" ZBX_FS_UI64,
item->lastlogsize,item->itemid);
}
else if(item->value_type==ITEM_VALUE_TYPE_TEXT)
{
- if(value->type & AR_TEXT)
+ if(GET_TEXT_RESULT(value))
DBadd_history_text(item->itemid,value->text,now);
}
else
@@ -647,234 +637,146 @@ static int add_history(DB_ITEM *item, AGENT_RESULT *value, int now)
* value - new value of the item *
* now - current timestamp *
* *
- * Author: Alexei Vladishev *
+ * Author: Alexei Vladishev, Eugene Grigorjev *
* *
* Comments: *
* *
******************************************************************************/
static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now)
{
- char value_esc[MAX_STRING_LEN];
- char value_str[MAX_STRING_LEN];
- int ret = SUCCEED;
+ char value_esc[MAX_STRING_LEN];
zabbix_log( LOG_LEVEL_DEBUG, "In update_item()");
- value_str[0] = '\0';
value_esc[0] = '\0';
- if(value->type & AR_UINT64)
- {
- zbx_snprintf(value_str, sizeof(value_str),ZBX_FS_UI64, value->ui64);
- }
- if(value->type & AR_DOUBLE)
- {
- zbx_snprintf(value_str,sizeof(value_str),"%f", value->dbl);
- }
- if(value->type & AR_STRING)
- {
- strscpy(value_str, value->str);
- }
- if(value->type & AR_TEXT)
- {
- strscpy(value_str, value->text);
- }
-
if(item->delta == ITEM_STORE_AS_IS)
{
- switch(value->type) {
- case AR_DOUBLE:
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay, item->delay_flex, now),
- value->dbl,
- (int)now,
- item->itemid);
- break;
- case AR_UINT64:
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,lastvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay, item->delay_flex, now),
- value->ui64,
- (int)now,
- item->itemid);
- break;
- case AR_STRING:
- DBescape_string(value_str,value_esc,MAX_STRING_LEN);
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,lastvalue='%s',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay, item->delay_flex, now),
- value_esc,
- (int)now,
- item->itemid);
- break;
- case AR_TEXT:
- DBescape_string(value_str,value_esc,MAX_STRING_LEN);
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,lastvalue='%s',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay, item->delay_flex, now),
- value_esc,
- (int)now,
- item->itemid);
- break;
- default:
- break;
+ if(GET_STR_RESULT(value))
+ {
+ DBescape_string(value->str, value_esc, sizeof(value_esc));
}
+
+ DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,lastvalue='%s',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay, item->delay_flex, now),
+ value_esc,
+ (int)now,
+ item->itemid);
}
/* Logic for delta as speed of change */
else if(item->delta == ITEM_STORE_SPEED_PER_SECOND)
{
- if((value->type & AR_DOUBLE) && (item->value_type == ITEM_VALUE_TYPE_FLOAT))
+ if(item->value_type == ITEM_VALUE_TYPE_FLOAT)
{
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl) )
- {
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='%f',lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->dbl,
- (value->dbl - item->prevorgvalue_dbl)/(now-item->lastclock),
- (int)now,
- item->itemid);
- }
- else
+ if(GET_DBL_RESULT(value))
{
- DBexecute("update items set nextcheck=%d,prevorgvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->dbl,
- (int)now,
- item->itemid);
- }
- }
- else if((value->type & AR_DOUBLE) && (item->value_type == ITEM_VALUE_TYPE_UINT64))
- {
- if((item->prevorgvalue_null == 0) && ((double)item->prevorgvalue_uint64 <= value->dbl) )
- {
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='%f',lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->dbl,
- (value->dbl - (double)(item->prevorgvalue_uint64))/(now-item->lastclock),
- (int)now,
- item->itemid);
- }
- else
- {
- DBexecute("update items set nextcheck=%d,prevorgvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->dbl,
- (int)now,
- item->itemid);
+ if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl) )
+ {
+ DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='" ZBX_FS_DBL "',"
+ "lastvalue='" ZBX_FS_DBL "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
+ value->dbl,
+ (value->dbl - item->prevorgvalue_dbl)/(now-item->lastclock),
+ (int)now,
+ item->itemid);
+ }
+ else
+ {
+ DBexecute("update items set nextcheck=%d,prevorgvalue='" ZBX_FS_DBL "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
+ value->dbl,
+ (int)now,
+ item->itemid);
+ }
}
}
- else if((value->type & AR_UINT64) && (item->value_type == ITEM_VALUE_TYPE_UINT64))
+ else if(item->value_type == ITEM_VALUE_TYPE_UINT64)
{
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64) )
+ if(GET_UI64_RESULT(value))
{
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='" ZBX_FS_UI64 "',lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->ui64,
- ((double)(value->ui64 - item->prevorgvalue_uint64))/(now-item->lastclock),
- (int)now,
- item->itemid);
- }
- else
- {
- DBexecute("update items set nextcheck=%d,prevorgvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->ui64,
- (int)now,
- item->itemid);
+ if((item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64) )
+ {
+ DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='" ZBX_FS_UI64 "',"
+ "lastvalue='" ZBX_FS_DBL "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
+ value->ui64,
+ ((double)(value->ui64 - item->prevorgvalue_uint64))/(now-item->lastclock),
+ (int)now,
+ item->itemid);
+ }
+ else
+ {
+ DBexecute("update items set nextcheck=%d,prevorgvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
+ value->ui64,
+ (int)now,
+ item->itemid);
+ }
}
}
}
/* Real delta: simple difference between values */
else if(item->delta == ITEM_STORE_SIMPLE_CHANGE)
{
- if((value->type & AR_DOUBLE) && (item->value_type == ITEM_VALUE_TYPE_FLOAT))
- {
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl))
- {
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='%f',lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->dbl,
- (value->dbl - item->prevorgvalue_dbl),
- (int)now,
- item->itemid);
- }
- else
- {
- DBexecute("update items set nextcheck=%d,prevorgvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex, now),
- value->dbl,
- (int)now,
- item->itemid);
- }
- }
- else if((value->type & AR_DOUBLE) && (item->value_type == ITEM_VALUE_TYPE_UINT64))
+ if(item->value_type == ITEM_VALUE_TYPE_FLOAT)
{
- if((item->prevorgvalue_null == 0) && ((double)item->prevorgvalue_uint64 <= value->dbl))
+ if(GET_DBL_RESULT(value))
{
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='%f',lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->dbl,
- (value->dbl - (double)item->prevorgvalue_uint64),
- (int)now,
- item->itemid);
- }
- else
- {
- DBexecute("update items set nextcheck=%d,prevorgvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex, now),
- value->dbl,
- (int)now,
- item->itemid);
- }
- }
- else if((value->type & AR_UINT64) && (item->value_type == ITEM_VALUE_TYPE_UINT64))
- {
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64))
- {
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='" ZBX_FS_UI64 "',lastvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->ui64,
- (value->ui64 - item->prevorgvalue_uint64),
- (int)now,
- item->itemid);
- }
- else
- {
- DBexecute("update items set nextcheck=%d,prevorgvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex, now),
- value->ui64,
- (int)now,
- item->itemid);
+ if((item->prevorgvalue_null == 0) && (item->prevorgvalue_dbl <= value->dbl))
+ {
+ DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='" ZBX_FS_DBL "',"
+ "lastvalue='" ZBX_FS_DBL "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
+ value->dbl,
+ (value->dbl - item->prevorgvalue_dbl),
+ (int)now,
+ item->itemid);
+ }
+ else
+ {
+ DBexecute("update items set nextcheck=%d,prevorgvalue='" ZBX_FS_DBL "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex, now),
+ value->dbl,
+ (int)now,
+ item->itemid);
+ }
}
}
- else if((value->type & AR_UINT64) && (item->value_type == ITEM_VALUE_TYPE_FLOAT))
+ else if(item->value_type == ITEM_VALUE_TYPE_UINT64)
{
- if((item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64))
- {
- DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='" ZBX_FS_UI64 "',lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
- value->ui64,
- ((double)value->ui64 - item->prevorgvalue_uint64),
- (int)now,
- item->itemid);
- }
- else
+ if(GET_UI64_RESULT(value))
{
- DBexecute("update items set nextcheck=%d,prevorgvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
- calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex, now),
- value->ui64,
- (int)now,
- item->itemid);
+ if((item->prevorgvalue_null == 0) && (item->prevorgvalue_uint64 <= value->ui64))
+ {
+ DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue='" ZBX_FS_UI64 "',"
+ "lastvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now),
+ value->ui64,
+ (value->ui64 - item->prevorgvalue_uint64),
+ (int)now,
+ item->itemid);
+ }
+ else
+ {
+ DBexecute("update items set nextcheck=%d,prevorgvalue='" ZBX_FS_UI64 "',lastclock=%d where itemid=" ZBX_FS_UI64,
+ calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex, now),
+ value->ui64,
+ (int)now,
+ item->itemid);
+ }
}
}
}
- item->prevvalue_str=item->lastvalue_str;
- item->prevvalue_dbl=item->lastvalue_dbl;
- item->prevvalue_uint64=item->lastvalue_uint64;
- item->prevvalue_null=item->lastvalue_null;
+ item->prevvalue_str = item->lastvalue_str;
+ item->prevvalue_dbl = item->lastvalue_dbl;
+ item->prevvalue_uint64 = item->lastvalue_uint64;
+ item->prevvalue_null = item->lastvalue_null;
- item->lastvalue_uint64=value->ui64;
- item->lastvalue_dbl=value->dbl;
- item->lastvalue_str=value->str;
- item->lastvalue_null=0;
+ item->lastvalue_uint64 = value->ui64;
+ item->lastvalue_dbl = value->dbl;
+ item->lastvalue_str = value->str;
+ item->lastvalue_null = 0;
/* Update item status if required */
if(item->status == ITEM_STATUS_NOTSUPPORTED)
@@ -882,8 +784,7 @@ static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now)
zabbix_log( LOG_LEVEL_WARNING, "Parameter [%s] became supported by agent on host [%s]", item->key, item->host_name);
zabbix_syslog("Parameter [%s] became supported by agent on host [%s]", item->key, item->host_name);
item->status = ITEM_STATUS_ACTIVE;
- DBexecute("update items set status=%d where itemid=" ZBX_FS_UI64,
- ITEM_STATUS_ACTIVE, item->itemid);
+ DBexecute("update items set status=%d where itemid=" ZBX_FS_UI64, ITEM_STATUS_ACTIVE, item->itemid);
}
/* Required for nodata() */
@@ -891,7 +792,7 @@ static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now)
zabbix_log( LOG_LEVEL_DEBUG, "End update_item()");
- return ret;
+ return SUCCEED;
}
/******************************************************************************
@@ -911,40 +812,34 @@ static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now)
void process_new_value(DB_ITEM *item, AGENT_RESULT *value)
{
time_t now;
- double multiplier;
- char *e;
zabbix_log( LOG_LEVEL_DEBUG, "In process_new_value(%s)", item->key);
now = time(NULL);
- if(item->multiplier == ITEM_MULTIPLIER_USE)
+ if( ITEM_MULTIPLIER_USE == item->multiplier )
{
- if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_DOUBLE))
+ if( ITEM_VALUE_TYPE_FLOAT == item->value_type )
{
- multiplier = strtod(item->formula,&e);
- SET_DBL_RESULT(value, value->dbl * multiplier);
- }
- if( (item->value_type==ITEM_VALUE_TYPE_FLOAT) && (value->type & AR_UINT64))
- {
- multiplier = strtod(item->formula,&e);
- UNSET_UI64_RESULT(value);
- SET_DBL_RESULT(value, (double)value->ui64 * multiplier);
- }
- if( (item->value_type==ITEM_VALUE_TYPE_UINT64) && (value->type & AR_UINT64))
- {
- if(is_uint(item->formula) == SUCCEED)
+ if(GET_DBL_RESULT(value))
{
-#ifdef HAVE_ATOLL
- SET_UI64_RESULT(value, value->ui64 * (zbx_uint64_t)atoll(item->formula));
-#else
- SET_UI64_RESULT(value, value->ui64 * (zbx_uint64_t)atol(item->formula));
-#endif
+ UNSET_RESULT_EXCLUDING(value, AR_DOUBLE);
+ SET_DBL_RESULT(value, value->dbl * strtod(item->formula, NULL));
}
- else
+ }
+ else if( ITEM_VALUE_TYPE_UINT64 == item->value_type )
+ {
+ if(GET_UI64_RESULT(value))
{
- multiplier = strtod(item->formula,&e);
- SET_UI64_RESULT(value, (zbx_uint64_t)((double)value->ui64 * multiplier));
+ UNSET_RESULT_EXCLUDING(value, AR_UINT64);
+ if(is_uint(item->formula) == SUCCEED)
+ {
+ SET_UI64_RESULT(value, value->ui64 * zbx_atoui64((item->formula)));
+ }
+ else
+ {
+ SET_UI64_RESULT(value, (zbx_uint64_t)((double)value->ui64 * strtod(item->formula, NULL)));
+ }
}
}
}
diff --git a/src/zabbix_server/functions.h b/src/zabbix_server/functions.h
index 8978fc1a..3b298541 100644
--- a/src/zabbix_server/functions.h
+++ b/src/zabbix_server/functions.h
@@ -23,6 +23,7 @@
#include "common.h"
#include "comms.h"
#include "db.h"
+#include "sysinfo.h"
void update_services(zbx_uint64_t triggerid, int status);
void update_triggers (zbx_uint64_t itemid);
diff --git a/src/zabbix_server/housekeeper/Makefile.am b/src/zabbix_server/housekeeper/Makefile.am
index 0e241556..315f0d24 100644
--- a/src/zabbix_server/housekeeper/Makefile.am
+++ b/src/zabbix_server/housekeeper/Makefile.am
@@ -3,5 +3,3 @@
noinst_LIBRARIES = libzbxhousekeeper.a
libzbxhousekeeper_a_SOURCES = housekeeper.c housekeeper.h
-
-libzbxhousekeeper_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/httppoller/Makefile.am b/src/zabbix_server/httppoller/Makefile.am
index ef6b8432..07706687 100644
--- a/src/zabbix_server/httppoller/Makefile.am
+++ b/src/zabbix_server/httppoller/Makefile.am
@@ -6,5 +6,3 @@ libzbxhttppoller_a_SOURCES = \
httpmacro.c httpmacro.h \
httptest.c httptest.h \
httppoller.c httppoller.h
-
-libzbxhttppoller_a_CPPFLAGS = $(DB_CPPFLAGS) $(SNMP_CPPFLAGS)
diff --git a/src/zabbix_server/httppoller/httptest.c b/src/zabbix_server/httppoller/httptest.c
index 2d51024e..08b74032 100644
--- a/src/zabbix_server/httppoller/httptest.c
+++ b/src/zabbix_server/httppoller/httptest.c
@@ -123,7 +123,7 @@ static void process_test_data(DB_HTTPTEST *httptest, S_ZBX_HTTPSTAT *stat)
AGENT_RESULT value;
- zabbix_log(LOG_LEVEL_DEBUG, "In process_test_data(test:%s,time:%f,last step:%d)",
+ zabbix_log(LOG_LEVEL_DEBUG, "In process_test_data(test:%s,time:" ZBX_FS_DBL ",last step:%d)",
httptest->name, stat->test_total_time, stat->test_last_step);
result = DBselect("select httptestitemid,httptestid,itemid,type from httptestitem where httptestid=" ZBX_FS_UI64,
@@ -169,7 +169,7 @@ static void process_step_data(DB_HTTPTEST *httptest, DB_HTTPSTEP *httpstep, S_ZB
AGENT_RESULT value;
- zabbix_log(LOG_LEVEL_DEBUG, "In process_step_data(step:%s,url:%s,rsp:%d,time:%f,speed:%f)",
+ zabbix_log(LOG_LEVEL_DEBUG, "In process_step_data(step:%s,url:%s,rsp:%d,time:" ZBX_FS_DBL ",speed:" ZBX_FS_DBL ")",
httpstep->name, httpstep->url, stat->rspcode, stat->total_time, stat->speed_download);
result = DBselect("select httpstepitemid,httpstepid,itemid,type from httpstepitem where httpstepid=" ZBX_FS_UI64,
@@ -414,7 +414,7 @@ zabbix_log(LOG_LEVEL_DEBUG, "[%s]", page.data);
(void)curl_easy_cleanup(easyhandle);
- DBexecute("update httptest set curstep=0,curstate=%d,nextcheck=%d+delay,lastfailedstep=%d,time=%f where httptestid=" ZBX_FS_UI64,
+ DBexecute("update httptest set curstep=0,curstate=%d,nextcheck=%d+delay,lastfailedstep=%d,time=" ZBX_FS_DBL " where httptestid=" ZBX_FS_UI64,
HTTPTEST_STATE_IDLE,
now,
lastfailedstep,
@@ -426,7 +426,7 @@ zabbix_log(LOG_LEVEL_DEBUG, "[%s]", page.data);
process_test_data(httptest, &stat);
- zabbix_log(LOG_LEVEL_DEBUG, "End process_httptest(total time:%f)",
+ zabbix_log(LOG_LEVEL_DEBUG, "End process_httptest(total time:" ZBX_FS_DBL ")",
httptest->time);
return ret;
diff --git a/src/zabbix_server/nodewatcher/Makefile.am b/src/zabbix_server/nodewatcher/Makefile.am
index cc6a6006..2ceb2bab 100644
--- a/src/zabbix_server/nodewatcher/Makefile.am
+++ b/src/zabbix_server/nodewatcher/Makefile.am
@@ -8,5 +8,3 @@ libzbxnodewatcher_a_SOURCES = \
nodecomms.c nodecomms.h \
events.c events.h \
history.c history.h
-
-libzbxnodewatcher_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/pinger/Makefile.am b/src/zabbix_server/pinger/Makefile.am
index cd7d6561..589d6d19 100644
--- a/src/zabbix_server/pinger/Makefile.am
+++ b/src/zabbix_server/pinger/Makefile.am
@@ -3,5 +3,3 @@
noinst_LIBRARIES = libzbxpinger.a
libzbxpinger_a_SOURCES = pinger.c pinger.h
-
-libzbxpinger_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/poller/Makefile.am b/src/zabbix_server/poller/Makefile.am
index 9148464d..f28cabf9 100644
--- a/src/zabbix_server/poller/Makefile.am
+++ b/src/zabbix_server/poller/Makefile.am
@@ -9,5 +9,3 @@ libzbxpoller_a_SOURCES = \
checks_snmp.c checks_snmp.h \
checks_aggregate.c checks_aggregate.h \
poller.c poller.h
-
-libzbxpoller_a_CPPFLAGS = $(DB_CPPFLAGS) $(SNMP_CPPFLAGS)
diff --git a/src/zabbix_server/poller/checks_agent.h b/src/zabbix_server/poller/checks_agent.h
index d8492ecc..f890eee7 100644
--- a/src/zabbix_server/poller/checks_agent.h
+++ b/src/zabbix_server/poller/checks_agent.h
@@ -20,24 +20,10 @@
#ifndef ZABBIX_CHECKS_AGENT_H
#define ZABBIX_CHECKS_AGENT_H
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "config.h"
-
-#ifdef HAVE_NETDB_H
- #include <netdb.h>
-#endif
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
#include "common.h"
#include "db.h"
#include "log.h"
+#include "sysinfo.h"
extern int CONFIG_NOTIMEWAIT;
diff --git a/src/zabbix_server/poller/checks_aggregate.c b/src/zabbix_server/poller/checks_aggregate.c
index 35ca47f4..1b1ab3e1 100644
--- a/src/zabbix_server/poller/checks_aggregate.c
+++ b/src/zabbix_server/poller/checks_aggregate.c
@@ -27,15 +27,11 @@ static int evaluate_one(double *result, int *num, char *grpfunc, char const *val
if(valuetype == ITEM_VALUE_TYPE_FLOAT)
{
- value = atof(value_str);
+ value = zbx_atod(value_str);
}
else if(valuetype == ITEM_VALUE_TYPE_UINT64)
{
-#ifdef HAVE_ATOLL
- value = (double)atoll(value_str);
-#else
- value = (double)atol(value_str);
-#endif
+ value = (double)zbx_atoui64(value_str);
}
if(strcmp(grpfunc,"grpsum") == 0)
@@ -188,7 +184,7 @@ static int evaluate_aggregate(AGENT_RESULT *res,char *grpfunc, char *hostgroup,
SET_DBL_RESULT(res, d);
}
- zabbix_log( LOG_LEVEL_DEBUG, "Result([%f])",d);
+ zabbix_log( LOG_LEVEL_DEBUG, "Result([" ZBX_FS_DBL "])",d);
return SUCCEED;
}
diff --git a/src/zabbix_server/poller/checks_aggregate.h b/src/zabbix_server/poller/checks_aggregate.h
index f218ec08..5299b564 100644
--- a/src/zabbix_server/poller/checks_aggregate.h
+++ b/src/zabbix_server/poller/checks_aggregate.h
@@ -20,14 +20,11 @@
#ifndef ZABBIX_CHECKS_AGGREGATE_H
#define ZABBIX_CHECKS_AGGREGATE_H
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "common.h"
#include "config.h"
#include "db.h"
#include "log.h"
+#include "sysinfo.h"
extern int CONFIG_NODEID;
diff --git a/src/zabbix_server/poller/checks_internal.h b/src/zabbix_server/poller/checks_internal.h
index 5dac56b3..471b9eb0 100644
--- a/src/zabbix_server/poller/checks_internal.h
+++ b/src/zabbix_server/poller/checks_internal.h
@@ -20,14 +20,11 @@
#ifndef ZABBIX_CHECKS_INTERNAL_H
#define ZABBIX_CHECKS_INTERNAL_H
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "common.h"
#include "config.h"
#include "db.h"
#include "log.h"
+#include "sysinfo.h"
extern int get_value_internal(DB_ITEM *item, AGENT_RESULT *result);
diff --git a/src/zabbix_server/poller/checks_snmp.c b/src/zabbix_server/poller/checks_snmp.c
index 9ca48a46..4b512d40 100644
--- a/src/zabbix_server/poller/checks_snmp.c
+++ b/src/zabbix_server/poller/checks_snmp.c
@@ -288,28 +288,19 @@ int get_value_snmp(DB_ITEM *item, AGENT_RESULT *value)
)
{
SET_UI64_RESULT(value, (zbx_uint64_t)*vars->val.integer);
-/* *result=(long)*vars->val.integer;
- zbx_snprintf(result_str,sizeof(result_str),"%ld",(long)*vars->val.integer);*/
}
#ifdef OPAQUE_SPECIAL_TYPES
else if(vars->type == ASN_FLOAT)
{
-/* *result=(double)*vars->val.floatVal;
- zbx_snprintf(result_str,sizeof(result_str),"%f",(double)*vars->val.floatVal);*/
-
SET_DBL_RESULT(value, *vars->val.floatVal);
}
else if(vars->type == ASN_DOUBLE)
{
-/* *result=(double)*vars->val.doubleVal;
- zbx_snprintf(result_str,sizeof(result_str),"%lf",(double)*vars->val.doubleVal);*/
SET_DBL_RESULT(value, *vars->val.doubleVal);
}
#endif
else if(vars->type == ASN_OCTET_STR)
{
-/* memcpy(result_str,vars->val.string,vars->val_len);
- result_str[vars->val_len] = '\0';*/
if(item->value_type == ITEM_VALUE_TYPE_FLOAT)
{
p = malloc(vars->val_len+1);
diff --git a/src/zabbix_server/poller/checks_snmp.h b/src/zabbix_server/poller/checks_snmp.h
index dcf96aa7..c574c874 100644
--- a/src/zabbix_server/poller/checks_snmp.h
+++ b/src/zabbix_server/poller/checks_snmp.h
@@ -20,36 +20,11 @@
#ifndef ZABBIX_CHECKS_SNMP_H
#define ZABBIX_CHECKS_SNMP_H
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
#include "common.h"
-#include "config.h"
#include "log.h"
#include "db.h"
+#include "sysinfo.h"
-/* NET-SNMP is used */
-#ifdef HAVE_NETSNMP
- #include <net-snmp/net-snmp-config.h>
- #include <net-snmp/net-snmp-includes.h>
-#endif
-
-/* Required for SNMP support*/
-#ifdef HAVE_UCDSNMP
- #include <ucd-snmp/ucd-snmp-config.h>
- #include <ucd-snmp/ucd-snmp-includes.h>
- #include <ucd-snmp/system.h>
-/* For usmHMACMD5AuthProtocol */
- #include <ucd-snmp/transform_oids.h>
-/* For generate_Ku() */
- #include <ucd-snmp/keytools.h>
-#endif
-
-
-/*int get_value_SNMP(int version,double *result,char *result_str,DB_ITEM *item);*/
-/*int get_value_snmp(double *result,char *result_str,DB_ITEM *item,char *error, int max_error_len);*/
int get_value_snmp(DB_ITEM *item, AGENT_RESULT *value);
#endif
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index ce2d05ab..14a7599e 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -227,32 +227,6 @@ void init_config(void)
}
-/*
-void trend(void)
-{
- char sql[MAX_STRING_LEN];
-
- DB_RESULT result;
- DB_RESULT result2;
-
- int i,j;
-
- result2 = DBselect("select itemid from items");
- for(i=0;i<DBnum_rows(result2);i++)
- {
- result = DBselect("select clock-clock%%3600, count(*),min(value),avg(value),max(value) from history where itemid=%d group by 1",atoi(DBget_field(result2,i,0)));
-
- for(j=0;j<DBnum_rows(result);j++)
- {
- zbx_snprintf(sql,sizeof(sql),"insert into trends (itemid, clock, num, value_min, value_avg, value_max) values (%d,%d,%d,%f,%f,%f)",atoi(DBget_field(result2,i,0)), atoi(DBget_field(result,j,0)),atoi(DBget_field(result,j,1)),atof(DBget_field(result,j,2)),atof(DBget_field(result,j,3)),atof(DBget_field(result,j,4)));
- DBexecute(sql);
- }
- DBfree_result(result);
- }
- DBfree_result(result2);
-}
-*/
-
int tcp_listen(const char *host, int port, socklen_t *addrlenp)
{
int sockfd;
diff --git a/src/zabbix_server/timer/Makefile.am b/src/zabbix_server/timer/Makefile.am
index 985bdb34..09dc9fe8 100644
--- a/src/zabbix_server/timer/Makefile.am
+++ b/src/zabbix_server/timer/Makefile.am
@@ -3,5 +3,3 @@
noinst_LIBRARIES = libzbxtimer.a
libzbxtimer_a_SOURCES = timer.c timer.h
-
-libzbxtimer_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/trapper/Makefile.am b/src/zabbix_server/trapper/Makefile.am
index f5d7255c..8a196181 100644
--- a/src/zabbix_server/trapper/Makefile.am
+++ b/src/zabbix_server/trapper/Makefile.am
@@ -9,5 +9,3 @@ libzbxtrapper_a_SOURCES = \
nodesync.c nodesync.h \
nodeevents.c nodeevents.h \
nodehistory.c nodehistory.h
-
-libzbxtrapper_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c
index 58a5e674..f5ab9b44 100644
--- a/src/zabbix_server/trapper/trapper.c
+++ b/src/zabbix_server/trapper/trapper.c
@@ -240,7 +240,7 @@ void process_trapper_child(zbx_sock_t *sock)
/* alarm(0);*/
gettimeofday(&tv, NULL);
- zabbix_log( LOG_LEVEL_DEBUG, "Trap processed in %f seconds", (float)(tv.tv_usec-msec)/1000000 );
+ zabbix_log( LOG_LEVEL_DEBUG, "Trap processed in " ZBX_FS_DBL " seconds", (double)(tv.tv_usec-msec)/1000000 );
}
void child_trapper_main(int i,int listenfd, int addrlen)
diff --git a/src/zabbix_server/utils/Makefile.am b/src/zabbix_server/utils/Makefile.am
index 251ded7c..018c29fd 100644
--- a/src/zabbix_server/utils/Makefile.am
+++ b/src/zabbix_server/utils/Makefile.am
@@ -3,5 +3,3 @@
noinst_LIBRARIES = libzbxutils.a
libzbxutils_a_SOURCES = nodechange.c nodechange.h
-
-libzbxutils_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/watchdog/Makefile.am b/src/zabbix_server/watchdog/Makefile.am
index daf4f27c..f1dfaf08 100644
--- a/src/zabbix_server/watchdog/Makefile.am
+++ b/src/zabbix_server/watchdog/Makefile.am
@@ -3,5 +3,3 @@
noinst_LIBRARIES = libzbxwatchdog.a
libzbxwatchdog_a_SOURCES = watchdog.c watchdog.h
-
-libzbxwatchdog_a_CPPFLAGS = $(DB_CPPFLAGS)
diff --git a/src/zabbix_server/watchdog/watchdog.c b/src/zabbix_server/watchdog/watchdog.c
index 9fa20693..1a645641 100644
--- a/src/zabbix_server/watchdog/watchdog.c
+++ b/src/zabbix_server/watchdog/watchdog.c
@@ -25,6 +25,8 @@
#include "log.h"
#include "zlog.h"
+#include "../alerter/alerter.h"
+
#include "common.h"
#include "zlog.h"
#include "watchdog.h"