summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-07-29 09:43:53 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-07-29 09:43:53 +0000
commitf7cd0be8cdcedcc34656ced6982dd7abadca01fc (patch)
treea6aa538b83fd84824e8a8431bd9c2ecc694dafc3 /include
parente3248ce4bc1b34d8623359d5333cfa9712b5eb73 (diff)
downloadzabbix-f7cd0be8cdcedcc34656ced6982dd7abadca01fc.tar.gz
zabbix-f7cd0be8cdcedcc34656ced6982dd7abadca01fc.tar.xz
zabbix-f7cd0be8cdcedcc34656ced6982dd7abadca01fc.zip
- [DEV-196] improved performance of server module
git-svn-id: svn://svn.zabbix.com/trunk@5848 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include')
-rw-r--r--include/db.h36
-rw-r--r--include/dbcache.h84
-rw-r--r--include/zbxserver.h2
3 files changed, 73 insertions, 49 deletions
diff --git a/include/db.h b/include/db.h
index 7f6f8b66..158cc489 100644
--- a/include/db.h
+++ b/include/db.h
@@ -39,6 +39,7 @@ extern int CONFIG_MASTER_NODEID;
extern int CONFIG_DBSYNCER_FORKS;
extern int CONFIG_NODE_NOHISTORY;
extern int CONFIG_REFRESH_UNSUPPORTED;
+extern int CONFIG_UNAVAILABLE_DELAY;
typedef enum {
GRAPH_TYPE_NORMAL = 0,
@@ -104,7 +105,8 @@ typedef enum {
#define DB_HTTPTESTITEM struct zbx_httptestitem_type
#define DB_ESCALATION struct zbx_escalation_type
-#define MAX_HISTORY_STR_LEN 255
+#define HISTORY_STR_VALUE_LEN 255
+#define HISTORY_STR_VALUE_LEN_MAX HISTORY_STR_VALUE_LEN+1
/* Trigger related defines */
#define TRIGGER_DESCRIPTION_LEN 255
@@ -134,6 +136,10 @@ typedef enum {
#define ITEM_KEY_LEN 255
#define ITEM_KEY_LEN_MAX ITEM_KEY_LEN+1
+#define ITEM_LASTVALUE_LEN 255
+#define ITEM_LASTVALUE_LEN_MAX ITEM_LASTVALUE_LEN+1
+#define ITEM_ERROR_LEN 128
+#define ITEM_ERROR_LEN_MAX ITEM_ERROR_LEN+1
#define GRAPH_NAME_LEN 128
#define GRAPH_NAME_LEN_MAX GRAPH_NAME_LEN+1
@@ -153,7 +159,10 @@ typedef enum {
#define HTTPSTEP_REQUIRED_LEN 255
#define HTTPSTEP_REQUIRED_LEN_MAX HTTPSTEP_REQUIRED_LEN+1
-#define ZBX_SQL_ITEM_SELECT "i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.errors_from,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status,i.trapper_hosts,i.logtimefmt,i.valuemapid,i.delay_flex,h.dns,i.params from hosts h, items i"
+#define ZBX_SQL_ITEM_FIELDS "i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.errors_from,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status,i.trapper_hosts,i.logtimefmt,i.valuemapid,i.delay_flex,h.dns,i.params"
+#define ZBX_SQL_ITEM_TABLES "hosts h, items i"
+#define ZBX_SQL_ITEM_FIELDS_NUM 38
+#define ZBX_SQL_ITEM_SELECT ZBX_SQL_ITEM_FIELDS " from " ZBX_SQL_ITEM_TABLES
#define ZBX_MAX_SQL_LEN 65535
@@ -514,13 +523,14 @@ void DBrollback();
const ZBX_TABLE *DBget_table(const char *tablename);
const ZBX_FIELD *DBget_field(const ZBX_TABLE *table, const char *fieldname);
-zbx_uint64_t DBget_maxid(char *table, char *field);
+#define DBget_maxid(table, field) DBget_maxid_num(table, field, 1)
+zbx_uint64_t DBget_maxid_num(char *table, char *field, int num);
int DBget_function_result(char **result,char *functionid);
-void DBupdate_host_availability(zbx_uint64_t hostid,int available,int clock,char *error);
-void DBproxy_update_host_availability(zbx_uint64_t hostid, int available, int clock);
-int DBupdate_item_status_to_notsupported(zbx_uint64_t itemid, const char *error);
-int DBproxy_update_item_status_to_notsupported(zbx_uint64_t itemid);
+void DBupdate_host_availability(DB_ITEM *item, int available, int clock, const char *error);
+void DBproxy_update_host_availability(DB_ITEM *item, int available, int clock);
+int DBupdate_item_status_to_notsupported(DB_ITEM *item, int clock, const char *error);
+/*int DBproxy_update_item_status_to_notsupported(DB_ITEM *item, int clock);*/
int DBadd_service_alarm(zbx_uint64_t serviceid,int status,int clock);
int DBadd_alert(zbx_uint64_t actionid, zbx_uint64_t eventid, zbx_uint64_t userid, zbx_uint64_t mediatypeid, char *sendto, char *subject, char *message);
int DBstart_escalation(zbx_uint64_t actionid, zbx_uint64_t triggerid, zbx_uint64_t eventid);
@@ -594,15 +604,15 @@ void DBupdate_services(
/* History related functions */
int DBadd_history(zbx_uint64_t itemid, double value, int clock);
-int DBadd_history_log(zbx_uint64_t id, zbx_uint64_t itemid, char *value, int clock, int timestamp, char *source, int severity);
+int DBadd_history_log(zbx_uint64_t itemid, char *value, int clock, int timestamp, char *source, int severity, int lastlogsize);
int DBadd_history_str(zbx_uint64_t itemid, char *value, int clock);
int DBadd_history_text(zbx_uint64_t itemid, char *value, int clock);
int DBadd_history_uint(zbx_uint64_t itemid, zbx_uint64_t value, int clock);
-int DBproxy_add_history(const char *host, const char *key, int clock, double value);
-int DBproxy_add_history_uint(const char *host, const char *key, int clock, zbx_uint64_t value);
-int DBproxy_add_history_str(const char *host, const char *key, int clock, char *value);
-int DBproxy_add_history_text(const char *host, const char *key, int clock, char *value);
-int DBproxy_add_history_log(const char *host, const char *key, int clock, int timestamp, char *source, int severity, char *value);
+void DBproxy_add_history(zbx_uint64_t itemid, double value, int clock);
+void DBproxy_add_history_uint(zbx_uint64_t itemid, zbx_uint64_t value, int clock);
+void DBproxy_add_history_str(zbx_uint64_t itemid, char *value, int clock);
+void DBproxy_add_history_text(zbx_uint64_t itemid, char *value, int clock);
+void DBproxy_add_history_log(zbx_uint64_t itemid, char *value, int clock, int timestamp, char *source, int severity, int lastlogsize);
#endif
diff --git a/include/dbcache.h b/include/dbcache.h
index dfbc6f26..a0dee28f 100644
--- a/include/dbcache.h
+++ b/include/dbcache.h
@@ -23,72 +23,84 @@
#define ZBX_DC_CACHE struct zbx_dc_cache_type
#define ZBX_DC_HISTORY struct zbx_dc_history_type
-#define ZBX_DC_ITEM struct zbx_dc_item_type
-#define ZBX_DC_POOL struct zbx_dc_pool_type
#define ZBX_DC_TREND struct zbx_dc_trend_type
+#define ZBX_DC_NEXTCHECK struct zbx_dc_nextcheck_type
#define ZBX_HISTORY_SIZE 100000
+/* Must be less than ZBX_HISTORY_SIZE */
+#define ZBX_SYNC_MAX 1000
#define ZBX_TREND_SIZE 100000
-#define ZBX_ITEMS_SIZE 10000
+#define ZBX_TEXTBUFFER_SIZE 16384*1024
-#define ZBX_TREND_OP_UPDATE 0
-#define ZBX_TREND_OP_INSERT 1
+#define ZBX_SYNC_PARTIAL 0
+#define ZBX_SYNC_FULL 1
extern char *CONFIG_FILE;
+typedef union{
+ double value_float;
+ zbx_uint64_t value_uint64;
+ char *value_str;/*[HISTORY_STR_VALUE_LEN_MAX];*/
+} history_value_t;
+
+typedef union {
+ double value_float;
+ zbx_uint64_t value_uint64;
+} trend_value_t;
+
ZBX_DC_HISTORY
{
zbx_uint64_t itemid;
int clock;
int value_type;
- union
- {
- double value_float;
- zbx_uint64_t value_uint64;
- char value_str[MAX_HISTORY_STR_LEN+1];
- } value;
+ history_value_t value;
+ int timestamp;
+ char *source;
+ int severity;
+ int lastlogsize;
};
ZBX_DC_TREND
{
- int operation;
zbx_uint64_t itemid;
int clock;
int num;
- double value_min;
- double value_max;
- double value_avg;
-};
-
-ZBX_DC_ITEM
-{
- zbx_uint64_t itemid;
- ZBX_DC_TREND trend;
+ int value_type;
+ trend_value_t value_min;
+ trend_value_t value_avg;
+ trend_value_t value_max;
};
-ZBX_DC_POOL
+ZBX_DC_CACHE
{
- int history_count;
+ int history_first;
+ int history_num;
+ int trends_num;
ZBX_DC_HISTORY history[ZBX_HISTORY_SIZE];
- int trends_count;
ZBX_DC_TREND trends[ZBX_TREND_SIZE];
+ char text[ZBX_TEXTBUFFER_SIZE];
+ char *last_text;
};
-ZBX_DC_CACHE
+ZBX_DC_NEXTCHECK
{
- int items_count;
- ZBX_DC_ITEM items[ZBX_ITEMS_SIZE];
- ZBX_DC_POOL pool;
+ zbx_uint64_t itemid;
+ time_t clock;
+ /* for not supported items */
+ char *error_msg;
};
-int DCadd_trend(zbx_uint64_t itemid, double value, int clock);
-int DCadd_history(zbx_uint64_t itemid, double value, int clock);
-int DCadd_history_uint(zbx_uint64_t itemid, zbx_uint64_t value, int clock);
-int DCadd_history_str(zbx_uint64_t itemid, char *value, int clock);
-void DCshow(void);
-void DCsync(void);
-void DCsync_all(void);
-void init_database_cache(void);
+void DCadd_history(zbx_uint64_t itemid, double value, int clock);
+void DCadd_history_uint(zbx_uint64_t itemid, zbx_uint64_t value, int clock);
+void DCadd_history_str(zbx_uint64_t itemid, char *value, int clock);
+void DCadd_history_text(zbx_uint64_t itemid, char *value, int clock);
+void DCadd_history_log(zbx_uint64_t itemid, char *value, int clock, int timestamp, char *source, int severity, int lastlogsize);
+int DCsync_history(int sync_type);
+void init_database_cache(zbx_process_t p);
void free_database_cache(void);
+void DCinit_nextchecks();
+void DCadd_nextcheck(DB_ITEM *item, time_t now, const char *error_msg);
+void DCflush_nextchecks();
+
#endif
diff --git a/include/zbxserver.h b/include/zbxserver.h
index a1b14607..02a88afd 100644
--- a/include/zbxserver.h
+++ b/include/zbxserver.h
@@ -30,6 +30,7 @@
#define MACRO_TYPE_MESSAGE_BODY 4
#define MACRO_TYPE_TRIGGER_EXPRESSION 5
+int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter);
void update_triggers (zbx_uint64_t itemid);
void update_functions(DB_ITEM *item);
void process_new_value(DB_ITEM *item, AGENT_RESULT *value, time_t now);
@@ -38,4 +39,5 @@ void proxy_process_new_value(DB_ITEM *item, AGENT_RESULT *value, time_t now);
void substitute_simple_macros(DB_EVENT *event, DB_ACTION *action, char **data, int macro_type);
void substitute_macros(DB_EVENT *event, DB_ACTION *action, char **data);
+int evaluate_expression(int *result,char **expression, DB_TRIGGER *triggger, char *error, int maxerrlen);
#endif