summaryrefslogtreecommitdiffstats
path: root/include
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 /include
parente929cc4053168b46b81475715e98230eed01badc (diff)
- 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 'include')
-rw-r--r--include/common.h123
-rw-r--r--include/sysinc.h17
-rw-r--r--include/sysinfo.h204
-rw-r--r--include/zbxtypes.h3
4 files changed, 178 insertions, 169 deletions
diff --git a/include/common.h b/include/common.h
index dadc78e1..86ca77f3 100644
--- a/include/common.h
+++ b/include/common.h
@@ -56,6 +56,14 @@
#define vsprintf ERROR_DO_NOT_USE_VSPRINTF_FUNCTION_TRY_TO_USE_VSNPRINTF
/*#define strncat ERROR_DO_NOT_USE_STRNCAT_FUNCTION_TRY_TO_USE_ZBX_STRLCAT*/
+#ifdef HAVE_ATOLL
+# define zbx_atoui64(str) ((zbx_uint64_t)atoll(str))
+#else
+# define zbx_atoui64(str) ((zbx_uint64_t)atol(str))
+#endif
+
+#define zbx_atod(str) strtod(str, (char **)NULL)
+
#define ON 1
#define OFF 0
@@ -79,8 +87,6 @@
#define ZBX_UNUSED(a) ((void)0)(a)
-#define ZBX_FS_DBL "%f"
-
#define MAX_LOG_FILE_LEN (1024*1024)
#define SUCCEED 0
@@ -346,116 +352,10 @@ void *zbx_malloc(size_t size);
#define zbx_fclose(f) { if(f){ fclose(f); f = NULL; } }
-/* list structure as item of agent return vaile */
-#define ZBX_LIST_ITEM struct zbx_list_item_s
-ZBX_LIST_ITEM {
- char text[MAX_STRING_LEN];
-};
-
-#define ZBX_LIST struct zbx_list_s
-ZBX_LIST {
- int cnt;
- ZBX_LIST_ITEM *item;
-};
-
-/* agent return value */
-#define AGENT_RESULT struct zbx_result_s
-AGENT_RESULT {
- int type;
- zbx_uint64_t ui64;
- double dbl;
- char *str;
- char *text;
- char *msg;
- ZBX_LIST list;
-};
-
#define ZBX_COND_NODEID " %s>=100000000000000*%d and %s<=(100000000000000*%d+99999999999999) "
#define LOCAL_NODE(fieldid) fieldid, CONFIG_NODEID, fieldid, CONFIG_NODEID
#define ZBX_NODE(fieldid,nodeid) fieldid, nodeid, fieldid, nodeid
-/* agent result types */
-#define AR_UINT64 1
-#define AR_DOUBLE 2
-#define AR_STRING 4
-#define AR_MESSAGE 8
-#define AR_LIST 16
-#define AR_TEXT 32
-
-
-/* SET RESULT */
-
-#define SET_DBL_RESULT(res, val) \
- { \
- (res)->type |= AR_DOUBLE; \
- (res)->dbl = (double)(val); \
- }
-
-#define SET_UI64_RESULT(res, val) \
- { \
- (res)->type |= AR_UINT64; \
- (res)->ui64 = (zbx_uint64_t)(val); \
- }
-
-#define SET_STR_RESULT(res, val) \
- { \
- (res)->type |= AR_STRING; \
- (res)->str = (char*)(val); \
- }
-
-#define SET_TEXT_RESULT(res, val) \
- { \
- (res)->type |= AR_TEXT; \
- (res)->text = (char*)(val); \
- }
-
-#define SET_MSG_RESULT(res, val) \
- { \
- (res)->type |= AR_MESSAGE; \
- (res)->msg = (char*)(val); \
- }
-
-/* UNSER RESULT */
-
-#define UNSET_DBL_RESULT(res) \
- { \
- (res)->type &= ~AR_DOUBLE; \
- (res)->dbl = (double)(0); \
- }
-
-#define UNSET_UI64_RESULT(res) \
- { \
- (res)->type &= ~AR_UINT64; \
- (res)->ui64 = (zbx_uint64_t)(0); \
- }
-
-#define UNSET_STR_RESULT(res) \
- { \
- if((res)->type & AR_STRING){ \
- free((res)->str); \
- (res)->str = NULL; \
- (res)->type &= ~AR_STRING; \
- } \
- }
-
-#define UNSET_TEXT_RESULT(res) \
- { \
- if((res)->type & AR_TEXT){ \
- free((res)->text); \
- (res)->text = NULL; \
- (res)->type &= ~AR_TEXT; \
- } \
- }
-
-#define UNSET_MSG_RESULT(res) \
- { \
- if((res)->type & AR_MESSAGE){ \
- free((res)->msg); \
- (res)->msg = NULL; \
- (res)->type &= ~AR_MESSAGE; \
- } \
- }
-
extern char *progname;
extern char title_message[];
@@ -484,10 +384,6 @@ typedef enum
ZBX_TASK_CHANGE_NODEID
} zbx_task_t;
-void init_result(AGENT_RESULT *result);
-int copy_result(AGENT_RESULT *src, AGENT_RESULT *dist);
-void free_result(AGENT_RESULT *result);
-
char *string_replace(char *str, const char *sub_str1, const char *sub_str2);
void del_zeroes(char *s);
int find_char(char *str,char c);
@@ -513,7 +409,6 @@ int zbx_snprintf(char* str, size_t count, const char *fmt, ...);
int zbx_vsnprintf(char* str, size_t count, const char *fmt, va_list args);
void zbx_snprintf_alloc(char **str, int *alloc_len, int *offset, int max_len, const char *fmt, ...);
-int set_result_type(AGENT_RESULT *result, int value_type, char *c);
size_t zbx_strlcpy(char *dst, const char *src, size_t siz);
size_t zbx_strlcat(char *dst, const char *src, size_t siz);
@@ -542,8 +437,6 @@ void zbx_on_exit();
int get_nodeid_by_id(zbx_uint64_t id);
-int SYSTEM_LOCALTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-
int MAIN_ZABBIX_ENTRY(void);
diff --git a/include/sysinc.h b/include/sysinc.h
index d3e64e5d..190f2634 100644
--- a/include/sysinc.h
+++ b/include/sysinc.h
@@ -342,4 +342,21 @@
# include <curl/curl.h>
#endif
+/* 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
+
#endif
diff --git a/include/sysinfo.h b/include/sysinfo.h
index bed63b99..35f8aaab 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -21,13 +21,134 @@
#ifndef ZABBIX_SYSINFO_H
#define ZABBIX_SYSINFO_H
+#include "common.h"
+
+/* agent return value */
+typedef struct zbx_result_s {
+ int type;
+ zbx_uint64_t ui64;
+ double dbl;
+ char *str;
+ char *text;
+ char *msg;
+} AGENT_RESULT;
+
+/* agent result types */
+#define AR_UINT64 1
+#define AR_DOUBLE 2
+#define AR_STRING 4
+#define AR_MESSAGE 8
+#define AR_TEXT 16
+
+
+/* SET RESULT */
+
+#define SET_DBL_RESULT(res, val) \
+ { \
+ (res)->type |= AR_DOUBLE; \
+ (res)->dbl = (double)(val); \
+ }
+
+#define SET_UI64_RESULT(res, val) \
+ { \
+ (res)->type |= AR_UINT64; \
+ (res)->ui64 = (zbx_uint64_t)(val); \
+ }
+
+#define SET_STR_RESULT(res, val) \
+ { \
+ (res)->type |= AR_STRING; \
+ (res)->str = (char*)(val); \
+ }
+
+#define SET_TEXT_RESULT(res, val) \
+ { \
+ (res)->type |= AR_TEXT; \
+ (res)->text = (char*)(val); \
+ }
+
+#define SET_MSG_RESULT(res, val) \
+ { \
+ (res)->type |= AR_MESSAGE; \
+ (res)->msg = (char*)(val); \
+ }
+
+/* CHECK RESULT */
+
+#define ISSET_UI64(res) ((res)->type & AR_UINT64)
+#define ISSET_DBL(res) ((res)->type & AR_DOUBLE)
+#define ISSET_STR(res) ((res)->type & AR_STRING)
+#define ISSET_TEXT(res) ((res)->type & AR_TEXT)
+#define ISSET_MSG(res) ((res)->type & AR_MESSAGE)
+
+/* UNSER RESULT */
+
+#define UNSET_DBL_RESULT(res) \
+ { \
+ (res)->type &= ~AR_DOUBLE; \
+ (res)->dbl = (double)(0); \
+ }
+
+#define UNSET_UI64_RESULT(res) \
+ { \
+ (res)->type &= ~AR_UINT64; \
+ (res)->ui64 = (zbx_uint64_t)(0); \
+ }
+
+#define UNSET_STR_RESULT(res) \
+ { \
+ if((res)->type & AR_STRING){ \
+ zbx_free((res)->str); \
+ (res)->type &= ~AR_STRING; \
+ } \
+ }
+
+#define UNSET_TEXT_RESULT(res) \
+ { \
+ if((res)->type & AR_TEXT){ \
+ zbx_free((res)->text); \
+ (res)->type &= ~AR_TEXT; \
+ } \
+ }
+
+#define UNSET_MSG_RESULT(res) \
+ { \
+ if((res)->type & AR_MESSAGE){ \
+ zbx_free((res)->msg); \
+ (res)->type &= ~AR_MESSAGE; \
+ } \
+ }
+
+#define UNSET_RESULT_EXCLUDING(res, exc_type) \
+ { \
+ if(!(exc_type & AR_DOUBLE)) UNSET_DBL_RESULT(res) \
+ if(!(exc_type & AR_UINT64)) UNSET_UI64_RESULT(res) \
+ if(!(exc_type & AR_STRING)) UNSET_STR_RESULT(res) \
+ if(!(exc_type & AR_TEXT)) UNSET_TEXT_RESULT(res) \
+ if(!(exc_type & AR_MESSAGE)) UNSET_MSG_RESULT(res) \
+ }
+
+
+
+/* RETRIVE RESULT VALUE */
+
+#define GET_UI64_RESULT(res) ((zbx_uint64_t*)get_result_value_by_type(res, AR_UINT64))
+#define GET_DBL_RESULT(res) ((double*)get_result_value_by_type(res, AR_DOUBLE))
+#define GET_STR_RESULT(res) ((char**)get_result_value_by_type(res, AR_STRING))
+#define GET_TEXT_RESULT(res) ((char**)get_result_value_by_type(res, AR_TEXT))
+#define GET_MSG_RESULT(res) ((char**)get_result_value_by_type(res, AR_MESSAGE))
+
+void *get_result_value_by_type(AGENT_RESULT *result, int require_type);
+
extern int CONFIG_ENABLE_REMOTE_COMMANDS;
/* #define TEST_PARAMETERS */
-#define SYSINFO_RET_OK 0
-#define SYSINFO_RET_FAIL 1
-#define SYSINFO_RET_TIMEOUT 2
+typedef enum {
+ SYSINFO_RET_OK = 0,
+ SYSINFO_RET_FAIL = 1,
+ SYSINFO_RET_TIMEOUT = 2
+} ZBX_SYSINFO_RET;
typedef struct zbx_metric_type
{
@@ -38,7 +159,6 @@ typedef struct zbx_metric_type
char *test_param;
} ZBX_METRIC;
-
/* flags for command */
#define CF_USEUPARAM 1 /* use user param */
@@ -47,35 +167,22 @@ typedef struct zbx_metric_type
#define PROCESS_TEST 1
#define PROCESS_USE_TEST_PARAM 2
-int process(const char *in_command, unsigned flags, AGENT_RESULT *result);
void init_metrics();
+int process(const char *in_command, unsigned flags, AGENT_RESULT *result);
+
void add_user_parameter(char *key,char *command);
void test_parameters(void);
void test_parameter(char* key);
-int check_ntp(char *host, unsigned short port, int *value_int);
-
-int get_stat(const char *key, unsigned flags, AGENT_RESULT *result);
+void init_result(AGENT_RESULT *result);
+int copy_result(AGENT_RESULT *src, AGENT_RESULT *dist);
+void free_result(AGENT_RESULT *result);
-#ifdef HAVE_PROC
-int getPROC(char *file, int lineno, int fieldno, unsigned flags, AGENT_RESULT *result);
-int getPROC2(char *file, char *param, int fieldno, unsigned flags, int type, AGENT_RESULT *result);
-#endif
+int set_result_type(AGENT_RESULT *result, int value_type, char *c);
/* external system functions */
-int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-int OLD_KERNEL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-#define OLD_MEMORY VM_MEMORY_SIZE
-int OLD_SYSTEM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-int OLD_SENSOR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-int OLD_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-
-int AGENT_PING(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-int AGENT_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int KERNEL_MAXFILES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int KERNEL_MAXPROC(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
@@ -85,23 +192,23 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RES
int NET_IF_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_CPU_LOAD(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_CPU_UTIL(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);
+//int SYSTEM_HOSTNAME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_SWAP_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_SWAP_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_SWAP_SIZE(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_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_UNUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_BOOTTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int VFS_DEV_WRITE(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);
-int VFS_FILE_EXISTS(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_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_CKSUM(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_MD5SUM(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_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_TIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int VFS_FS_INODE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int VFS_FS_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
@@ -109,21 +216,21 @@ int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT
int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-int TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
+//int TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
int NET_TCP_LISTEN(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);
-int CHECK_SERVICE_PERF(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);
-int RUN_COMMAND(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);
+//int CHECK_SERVICE_PERF(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);
+//int RUN_COMMAND(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
/* internal system functions */
-int EXECUTE_INT(const char *cmd, const char *param, 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 *param, unsigned flags, AGENT_RESULT *result);
+//int EXECUTE_STR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
-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);
+//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);
#if defined(_WINDOWS)
int PERF_MONITOR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
@@ -131,15 +238,4 @@ int SERVICE_STATE(const char *cmd, const char *param, unsigned flags, AGENT_RESU
int PROC_INFO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result);
#endif /* _WINDOWS */
-#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 */
-
#endif
diff --git a/include/zbxtypes.h b/include/zbxtypes.h
index 8232e366..f4a9336a 100644
--- a/include/zbxtypes.h
+++ b/include/zbxtypes.h
@@ -20,6 +20,9 @@
#ifndef ZABBIX_TYPES_H
#define ZABBIX_TYPES_H
+#define ZBX_FS_DBL "%lf"
+#define ZBX_FS_DBL_EXT(p) "%." #p "lf"
+
#if defined(_WINDOWS)
#ifndef __UINT64_C