summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2002-06-03 21:04:18 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2002-06-03 21:04:18 +0000
commitca309d601413e7615cd322b235c41591e149dcb9 (patch)
tree62268cb37013566bd0a3b48ade94b1b3c18dc9ac /include
parent071a071414485ad4edb14e071ad141afadbfc9e9 (diff)
downloadzabbix-ca309d601413e7615cd322b235c41591e149dcb9.tar.gz
zabbix-ca309d601413e7615cd322b235c41591e149dcb9.tar.xz
zabbix-ca309d601413e7615cd322b235c41591e149dcb9.zip
- added column alarms.value (Alexei)
- removed column alarms.istrue (Alexei) - added columns triggers.status (Alexei) - added columns triggers.value (Alexei) - removed column triggers.istrue (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@401 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include')
-rw-r--r--include/common.h13
-rw-r--r--include/db.c16
-rw-r--r--include/db.h3
-rw-r--r--include/functions.c26
4 files changed, 34 insertions, 24 deletions
diff --git a/include/common.h b/include/common.h
index f2e8745b..fc934949 100644
--- a/include/common.h
+++ b/include/common.h
@@ -27,11 +27,20 @@
#define HOST_STATUS_UNREACHABLE 2
/* Trigger statuses */
-#define TRIGGER_STATUS_FALSE 0
+/*#define TRIGGER_STATUS_FALSE 0
#define TRIGGER_STATUS_TRUE 1
#define TRIGGER_STATUS_DISABLED 2
#define TRIGGER_STATUS_UNKNOWN 3
-#define TRIGGER_STATUS_NOTSUPPORTED 4
+#define TRIGGER_STATUS_NOTSUPPORTED 4*/
+
+/* Trigger statuses */
+#define TRIGGER_STATUS_ENABLED 0
+#define TRIGGER_STATUS_DISABLED 1
+
+/* Trigger values */
+#define TRIGGER_VALUE_FALSE 0
+#define TRIGGER_VALUE_TRUE 1
+#define TRIGGER_VALUE_UNKNOWN 2
/* Media statuses */
#define MEDIA_STATUS_ACTIVE 0
diff --git a/include/db.c b/include/db.c
index 95d4b2e2..2e75c08b 100644
--- a/include/db.c
+++ b/include/db.c
@@ -250,7 +250,7 @@ int latest_alarm(int triggerid, int status)
zabbix_log(LOG_LEVEL_DEBUG,"In latest_alarm(1)");
DBfree_result(result);
- sprintf(sql,"select istrue from alarms where triggerid=%d and clock=%d",triggerid,clock);
+ sprintf(sql,"select value from alarms where triggerid=%d and clock=%d",triggerid,clock);
zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
result = DBselect(sql);
if(DBnum_rows(result)==1)
@@ -280,7 +280,7 @@ int DBadd_alarm(int triggerid, int status)
}
now=time(NULL);
- sprintf(sql,"insert into alarms(triggerid,clock,istrue) values(%d,%d,%d)",triggerid,now,status);
+ sprintf(sql,"insert into alarms(triggerid,clock,value) values(%d,%d,%d)",triggerid,now,status);
zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
DBexecute(sql);
@@ -289,18 +289,18 @@ int DBadd_alarm(int triggerid, int status)
return SUCCEED;
}
-int update_trigger_status(int triggerid,int status)
+int update_trigger_value(int triggerid,int value)
{
char sql[MAX_STRING_LEN+1];
- zabbix_log(LOG_LEVEL_DEBUG,"In update_trigger_status()");
- DBadd_alarm(triggerid,status);
+ zabbix_log(LOG_LEVEL_DEBUG,"In update_trigger_value()");
+ DBadd_alarm(triggerid,value);
- sprintf(sql,"update triggers set istrue=%d where triggerid=%d",status,triggerid);
+ sprintf(sql,"update triggers set value=%d where triggerid=%d",value,triggerid);
zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
DBexecute(sql);
- zabbix_log(LOG_LEVEL_DEBUG,"End of update_trigger_status()");
+ zabbix_log(LOG_LEVEL_DEBUG,"End of update_trigger_value()");
return SUCCEED;
}
@@ -328,7 +328,7 @@ int update_triggers_status_to_unknown(int hostid)
for(i=0;i<DBnum_rows(result);i++)
{
triggerid=atoi(DBget_field(result,i,0));
- update_trigger_status(triggerid,TRIGGER_STATUS_UNKNOWN);
+ update_trigger_value(triggerid,TRIGGER_VALUE_UNKNOWN);
}
DBfree_result(result);
diff --git a/include/db.h b/include/db.h
index 72fbb329..440f9eb7 100644
--- a/include/db.h
+++ b/include/db.h
@@ -82,7 +82,8 @@ DB_TRIGGER
int triggerid;
char *expression;
char *description;
- int istrue;
+ int status;
+ int value;
int priority;
};
diff --git a/include/functions.c b/include/functions.c
index b78a8718..7599b3f2 100644
--- a/include/functions.c
+++ b/include/functions.c
@@ -476,7 +476,7 @@ void apply_actions(int triggerid,int good)
{
zabbix_log( LOG_LEVEL_DEBUG, "Check dependencies");
- sprintf(sql,"select count(*) from trigger_depends d,triggers t where d.triggerid_down=%d and d.triggerid_up=t.triggerid and t.istrue=%d",triggerid, TRIGGER_STATUS_TRUE);
+ sprintf(sql,"select count(*) from trigger_depends d,triggers t where d.triggerid_down=%d and d.triggerid_up=t.triggerid and t.value=%d",triggerid, TRIGGER_VALUE_TRUE);
result = DBselect(sql);
if(DBis_empty(result) == FAIL)
{
@@ -620,11 +620,11 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock )
{
now=time(NULL);
/* Added table hosts to eliminate unnecessary update of triggers */
- sprintf(sql,"select t.triggerid,t.expression,t.istrue,t.dep_level,t.priority from triggers t,functions f,items i,hosts h where i.hostid=h.hostid and i.status<>3 and i.itemid=f.itemid and i.lastclock<=%d and t.istrue!=2 and f.triggerid=t.triggerid and f.itemid%%%d=%d and (h.status=0 or (h.status=2 and h.disable_until<%d)) group by t.triggerid,t.expression,t.istrue,t.dep_level",lastclock,suckers-1,sucker_num-1,now);
+ sprintf(sql,"select t.triggerid,t.expression,t.status,t.dep_level,t.priority,t.value from triggers t,functions f,items i,hosts h where i.hostid=h.hostid and i.status<>3 and i.itemid=f.itemid and i.lastclock<=%d and t.status=%d and f.triggerid=t.triggerid and f.itemid%%%d=%d and (h.status=0 or (h.status=2 and h.disable_until<%d)) group by t.triggerid,t.expression,t.dep_level",lastclock,TRIGGER_STATUS_ENABLED,suckers-1,sucker_num-1,now);
}
else
{
- sprintf(sql,"select t.triggerid,t.expression,t.istrue,t.dep_level,t.priority from triggers t,functions f,items i where i.status<>3 and i.itemid=f.itemid and t.istrue!=2 and f.triggerid=t.triggerid and f.itemid=%d group by t.triggerid,t.expression,t.istrue,t.dep_level",sucker_num);
+ sprintf(sql,"select t.triggerid,t.expression,t.status,t.dep_level,t.priority,t.value from triggers t,functions f,items i where i.status<>3 and i.itemid=f.itemid and t.status=%d and f.triggerid=t.triggerid and f.itemid=%d group by t.triggerid,t.expression,t.dep_level",TRIGGER_STATUS_ENABLED,sucker_num);
}
result = DBselect(sql);
@@ -638,11 +638,11 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock )
for(i=0;i<DBnum_rows(result);i++)
{
- zabbix_log( LOG_LEVEL_DEBUG, "Fetched: TrId[%s] Exp[%s] IsTrue[%s]\n", DBget_field(result,i,0),DBget_field(result,i,1),DBget_field(result,i,2));
trigger.triggerid=atoi(DBget_field(result,i,0));
trigger.expression=DBget_field(result,i,1);
- trigger.istrue=atoi(DBget_field(result,i,2));
+ trigger.status=atoi(DBget_field(result,i,2));
trigger.priority=atoi(DBget_field(result,i,4));
+ trigger.value=atoi(DBget_field(result,i,5));
strncpy(exp, trigger.expression, MAX_STRING_LEN);
if( evaluate_expression(&b, exp) != 0 )
{
@@ -652,15 +652,15 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock )
if(b==1)
{
- if(trigger.istrue!=TRIGGER_STATUS_TRUE)
+ if(trigger.value != TRIGGER_VALUE_TRUE)
{
now = time(NULL);
- sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_TRUE,now,trigger.triggerid);
+ sprintf(sql,"update triggers set value=%d, lastchange=%d where triggerid=%d",TRIGGER_VALUE_TRUE,now,trigger.triggerid);
DBexecute(sql);
- DBadd_alarm(trigger.triggerid, TRIGGER_STATUS_FALSE);
+ DBadd_alarm(trigger.triggerid, TRIGGER_VALUE_FALSE);
}
- if(trigger.istrue==TRIGGER_STATUS_FALSE)
+ if(trigger.value == TRIGGER_VALUE_FALSE)
{
now = time(NULL);
apply_actions(trigger.triggerid,1);
@@ -674,16 +674,16 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock )
if(b==0)
{
- if(trigger.istrue!=TRIGGER_STATUS_FALSE)
+ if(trigger.value != TRIGGER_VALUE_FALSE)
{
now = time(NULL);
- sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_FALSE,now,trigger.triggerid);
+ sprintf(sql,"update triggers set value=%d, lastchange=%d where triggerid=%d",TRIGGER_VALUE_FALSE,now,trigger.triggerid);
DBexecute(sql);
- DBadd_alarm(trigger.triggerid, TRIGGER_STATUS_FALSE);
+ DBadd_alarm(trigger.triggerid, TRIGGER_VALUE_FALSE);
}
- if(trigger.istrue==TRIGGER_STATUS_TRUE)
+ if(trigger.value == TRIGGER_VALUE_TRUE)
{
apply_actions(trigger.triggerid,0);