summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-06-05 10:49:24 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-06-05 10:49:24 +0000
commitf828f64b9d1894d8de5729bec7598218c3787886 (patch)
tree08c149254f62ccc4932cb98320193f3590a5e8f2 /include
parentde821d752713e82471fcb70c7c9e694decee3889 (diff)
downloadzabbix-f828f64b9d1894d8de5729bec7598218c3787886.tar.gz
zabbix-f828f64b9d1894d8de5729bec7598218c3787886.tar.xz
zabbix-f828f64b9d1894d8de5729bec7598218c3787886.zip
- simplified code for trigger status updated (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1821 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include')
-rw-r--r--include/db.c92
-rw-r--r--include/db.h4
-rw-r--r--include/email.c44
-rw-r--r--include/functions.c23
4 files changed, 116 insertions, 47 deletions
diff --git a/include/db.c b/include/db.c
index 1c6cb750..ade65421 100644
--- a/include/db.c
+++ b/include/db.c
@@ -227,6 +227,19 @@ char *DBget_field(DB_RESULT *result, int rownum, int fieldnum)
}
/*
+ * Get value of autoincrement field for last insert or update statement
+ */
+int DBinsert_id()
+{
+#ifdef HAVE_MYSQL
+ return mysql_insert_id(&mysql);
+#endif
+#ifdef HAVE_PGSQL
+ NOT IMPLEMENTED YET
+#endif
+}
+
+/*
* Return SUCCEED if result conains no records
*/
/*int DBis_empty(DB_RESULT *result)
@@ -461,22 +474,28 @@ int latest_service_alarm(int serviceid, int status)
return ret;
}
-int add_alarm(int triggerid,int status,int clock)
+/* Returns alarmid or 0 */
+int add_alarm(int triggerid,int status,int clock,int *alarmid)
{
char sql[MAX_STRING_LEN];
+ *alarmid=0;
+
zabbix_log(LOG_LEVEL_DEBUG,"In add_alarm()");
/* Latest alarm has the same status? */
if(latest_alarm(triggerid,status) == SUCCEED)
{
- return SUCCEED;
+ zabbix_log(LOG_LEVEL_WARNING,"Alarm for triggerid [%d] status [%d] already exists",triggerid,status);
+ return FAIL;
}
snprintf(sql,sizeof(sql)-1,"insert into alarms(triggerid,clock,value) values(%d,%d,%d)", triggerid, clock, status);
zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
DBexecute(sql);
+ *alarmid=DBinsert_id();
+
zabbix_log(LOG_LEVEL_DEBUG,"End of add_alarm()");
return SUCCEED;
@@ -502,6 +521,53 @@ int DBadd_service_alarm(int serviceid,int status,int clock)
return SUCCEED;
}
+int DBupdate_trigger_value(DB_TRIGGER *trigger, int new_value, int now)
+{
+ char sql[MAX_STRING_LEN];
+ int alarmid;
+ int ret = SUCCEED;
+
+ zabbix_log(LOG_LEVEL_DEBUG,"In update_trigger_value[%d,%d,%d]", trigger->triggerid, new_value, now);
+
+ if(trigger->value != new_value)
+ {
+ trigger->prevvalue=DBget_prev_trigger_value(trigger->triggerid);
+ if(add_alarm(trigger->triggerid,new_value,now,&alarmid) == SUCCEED)
+ {
+ snprintf(sql,sizeof(sql)-1,"update triggers set value=%d,lastchange=%d where triggerid=%d",new_value,now,trigger->triggerid);
+ DBexecute(sql);
+ if(TRIGGER_VALUE_UNKNOWN == new_value)
+ {
+ snprintf(sql,sizeof(sql)-1,"update functions set lastvalue=NULL where triggerid=%d",trigger->triggerid);
+ DBexecute(sql);
+ }
+ if( ((trigger->value == TRIGGER_VALUE_TRUE) && (new_value == TRIGGER_VALUE_FALSE)) ||
+ ((trigger->value == TRIGGER_VALUE_FALSE) && (new_value == TRIGGER_VALUE_TRUE)) ||
+ ((trigger->prevvalue == TRIGGER_VALUE_FALSE) && (trigger->value == TRIGGER_VALUE_UNKNOWN) && (new_value == TRIGGER_VALUE_TRUE)) ||
+ ((trigger->prevvalue == TRIGGER_VALUE_TRUE) && (trigger->value == TRIGGER_VALUE_UNKNOWN) && (new_value == TRIGGER_VALUE_FALSE)))
+ {
+ zabbix_log(LOG_LEVEL_DEBUG,"In update_trigger_value. Before apply_actions. Triggerid [%d]", trigger->triggerid);
+ apply_actions(trigger,new_value);
+ if(new_value == TRIGGER_VALUE_TRUE)
+ {
+ update_services(trigger->triggerid, trigger->priority);
+ }
+ else
+ {
+ update_services(trigger->triggerid, 0);
+ }
+ }
+ }
+ else
+ {
+ zabbix_log(LOG_LEVEL_WARNING,"Alarm not added for triggerid [%d]", trigger->triggerid);
+ ret = FAIL;
+ }
+ }
+ return ret;
+}
+
+/*
int DBupdate_trigger_value(int triggerid,int value,int clock)
{
char sql[MAX_STRING_LEN];
@@ -521,26 +587,28 @@ int DBupdate_trigger_value(int triggerid,int value,int clock)
zabbix_log(LOG_LEVEL_DEBUG,"End of update_trigger_value()");
return SUCCEED;
}
+*/
void update_triggers_status_to_unknown(int hostid,int clock)
{
int i;
char sql[MAX_STRING_LEN];
- int triggerid;
DB_RESULT *result;
+ DB_TRIGGER trigger;
zabbix_log(LOG_LEVEL_DEBUG,"In update_triggers_status_to_unknown()");
/* snprintf(sql,sizeof(sql)-1,"select distinct t.triggerid from hosts h,items i,triggers t,functions f where f.triggerid=t.triggerid and f.itemid=i.itemid and h.hostid=i.hostid and h.hostid=%d and i.key_<>'%s'",hostid,SERVER_STATUS_KEY);*/
- snprintf(sql,sizeof(sql)-1,"select distinct t.triggerid from hosts h,items i,triggers t,functions f where f.triggerid=t.triggerid and f.itemid=i.itemid and h.hostid=i.hostid and h.hostid=%d and i.key_ not in ('%s','%s','%s')",hostid,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY);
+ snprintf(sql,sizeof(sql)-1,"select distinct t.triggerid,t.value from hosts h,items i,triggers t,functions f where f.triggerid=t.triggerid and f.itemid=i.itemid and h.hostid=i.hostid and h.hostid=%d and i.key_ not in ('%s','%s','%s')",hostid,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY);
zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
result = DBselect(sql);
for(i=0;i<DBnum_rows(result);i++)
{
- triggerid=atoi(DBget_field(result,i,0));
- DBupdate_trigger_value(triggerid,TRIGGER_VALUE_UNKNOWN,clock);
+ trigger.triggerid=atoi(DBget_field(result,i,0));
+ trigger.value=atoi(DBget_field(result,i,1));
+ DBupdate_trigger_value(&trigger,TRIGGER_VALUE_UNKNOWN,clock);
}
DBfree_result(result);
@@ -721,25 +789,27 @@ void DBupdate_triggers_status_after_restart(void)
{
int i;
char sql[MAX_STRING_LEN];
- int triggerid, lastchange;
+ int lastchange;
int now;
DB_RESULT *result;
DB_RESULT *result2;
+ DB_TRIGGER trigger;
zabbix_log(LOG_LEVEL_DEBUG,"In DBupdate_triggers_after_restart()");
now=time(NULL);
- snprintf(sql,sizeof(sql)-1,"select distinct t.triggerid from hosts h,items i,triggers t,functions f where f.triggerid=t.triggerid and f.itemid=i.itemid and h.hostid=i.hostid and i.nextcheck+i.delay<%d and i.key_<>'%s' and h.status not in (%d,%d)",now,SERVER_STATUS_KEY, HOST_STATUS_DELETED, HOST_STATUS_TEMPLATE);
+ snprintf(sql,sizeof(sql)-1,"select distinct t.triggerid,t.value from hosts h,items i,triggers t,functions f where f.triggerid=t.triggerid and f.itemid=i.itemid and h.hostid=i.hostid and i.nextcheck+i.delay<%d and i.key_<>'%s' and h.status not in (%d,%d)",now,SERVER_STATUS_KEY, HOST_STATUS_DELETED, HOST_STATUS_TEMPLATE);
zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
result = DBselect(sql);
for(i=0;i<DBnum_rows(result);i++)
{
- triggerid=atoi(DBget_field(result,i,0));
+ trigger.triggerid=atoi(DBget_field(result,i,0));
+ trigger.value=atoi(DBget_field(result,i,1));
- snprintf(sql,sizeof(sql)-1,"select min(i.nextcheck+i.delay) from hosts h,items i,triggers t,functions f where f.triggerid=t.triggerid and f.itemid=i.itemid and h.hostid=i.hostid and i.nextcheck<>0 and t.triggerid=%d and i.type<>%d",triggerid,ITEM_TYPE_TRAPPER);
+ snprintf(sql,sizeof(sql)-1,"select min(i.nextcheck+i.delay) from hosts h,items i,triggers t,functions f where f.triggerid=t.triggerid and f.itemid=i.itemid and h.hostid=i.hostid and i.nextcheck<>0 and t.triggerid=%d and i.type<>%d",trigger.triggerid,ITEM_TYPE_TRAPPER);
zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
result2 = DBselect(sql);
if( DBnum_rows(result2) == 0 )
@@ -752,7 +822,7 @@ void DBupdate_triggers_status_after_restart(void)
lastchange=atoi(DBget_field(result2,0,0));
DBfree_result(result2);
- DBupdate_trigger_value(triggerid,TRIGGER_VALUE_UNKNOWN,lastchange);
+ DBupdate_trigger_value(&trigger,TRIGGER_VALUE_UNKNOWN,lastchange);
}
DBfree_result(result);
diff --git a/include/db.h b/include/db.h
index 26ce05c4..9a9c64de 100644
--- a/include/db.h
+++ b/include/db.h
@@ -166,6 +166,7 @@ DB_TRIGGER
char *description;
int status;
int value;
+ int prevvalue;
int priority;
};
@@ -221,7 +222,8 @@ int DBadd_service_alarm(int serviceid,int status,int clock);
int DBadd_alert(int actionid, int mediatypeid, char *sendto, char *subject, char *message);
void DBupdate_triggers_status_after_restart(void);
int DBget_prev_trigger_value(int triggerid);
-int DBupdate_trigger_value(int triggerid,int value,int clock);
+/*int DBupdate_trigger_value(int triggerid,int value,int clock);*/
+int DBupdate_trigger_value(DB_TRIGGER *trigger, int new_value, int now);
void DBdelete_item(int itemid);
void DBdelete_host(int hostid);
diff --git a/include/email.c b/include/email.c
index 9dddbf51..062dddaa 100644
--- a/include/email.c
+++ b/include/email.c
@@ -69,7 +69,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL2");
if(hp==NULL)
{
- zabbix_log(LOG_LEVEL_ERR, "Cannot get IP for mailserver [%s]",smtp_server);
+ zabbix_log(LOG_LEVEL_DEBUG, "Cannot get IP for mailserver [%s]",smtp_server);
zabbix_syslog("Cannot get IP for mailserver [%s]",smtp_server);
snprintf(error,max_error_len-1,"Cannot get IP for mailserver [%s]",smtp_server);
return FAIL;
@@ -93,7 +93,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL4");
if(s == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Cannot create socket [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Cannot create socket [%s]", strerror(errno));
zabbix_syslog("Cannot create socket [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Cannot create socket [%s]",strerror(errno));
return FAIL;
@@ -105,7 +105,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
if( connect(s,(struct sockaddr *)&servaddr_in,sizeof(struct sockaddr_in)) == -1 )
{
- zabbix_log(LOG_LEVEL_ERR, "Cannot connect to SMTP server [%s] Error [%s]",smtp_server, strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Cannot connect to SMTP server [%s] Error [%s]",smtp_server, strerror(errno));
zabbix_syslog("Cannot connect to SMTP server [%s] Error [%s]",smtp_server, strerror(errno));
snprintf(error,max_error_len-1,"Cannot connect to SMTP server [%s] [%s]", smtp_server, strerror(errno));
close(s);
@@ -120,7 +120,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL6");
if(i == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error receiving initial string from SMTP server [%m]");
+ zabbix_log(LOG_LEVEL_DEBUG, "Error receiving initial string from SMTP server [%m]");
zabbix_syslog("Error receiving initial string from SMTP server [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error receiving initial string from SMTP server [%s]", strerror(errno));
close(s);
@@ -128,7 +128,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
}
if(strncmp(OK_220,c,strlen(OK_220)) != 0)
{
- zabbix_log(LOG_LEVEL_ERR, "No welcome message 220* from SMTP server [%s]", c);
+ zabbix_log(LOG_LEVEL_DEBUG, "No welcome message 220* from SMTP server [%s]", c);
zabbix_syslog("No welcome message 220* from SMTP server [%s]", c);
snprintf(error,max_error_len-1,"No welcome message 220* from SMTP server [%s]", c);
close(s);
@@ -144,7 +144,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL7");
if(e == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error sending HELO to mailserver [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error sending HELO to mailserver [%s]", strerror(errno));
zabbix_syslog("Error sending HELO to mailserver [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error sending HELO to mailserver [%s]", strerror(errno));
close(s);
@@ -158,7 +158,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL8");
if(i == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error receiving answer on HELO request [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error receiving answer on HELO request [%s]", strerror(errno));
zabbix_syslog("Error receiving answer on HELO request [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error receiving answer on HELO request [%s]", strerror(errno));
close(s);
@@ -166,7 +166,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
}
if(strncmp(OK_250,c,strlen(OK_250)) != 0)
{
- zabbix_log(LOG_LEVEL_ERR, "Wrong answer on HELO [%s]",c);
+ zabbix_log(LOG_LEVEL_DEBUG, "Wrong answer on HELO [%s]",c);
zabbix_syslog("Wrong answer on HELO [%s]",c);
snprintf(error,max_error_len-1,"Wrong answer on HELO [%s]", c);
close(s);
@@ -182,7 +182,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL9");
if(e == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error sending MAIL FROM to mailserver [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error sending MAIL FROM to mailserver [%s]", strerror(errno));
zabbix_syslog("Error sending MAIL FROM to mailserver [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error sending MAIL FROM to mailserver [%s]", strerror(errno));
close(s);
@@ -196,7 +196,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL10");
if(i == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error receiving answer on MAIL FROM request [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error receiving answer on MAIL FROM request [%s]", strerror(errno));
zabbix_syslog("Error receiving answer on MAIL FROM request [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error receiving answer on MAIL FROM request [%s]", strerror(errno));
close(s);
@@ -204,7 +204,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
}
if(strncmp(OK_250,c,strlen(OK_250)) != 0)
{
- zabbix_log(LOG_LEVEL_ERR, "Wrong answer on MAIL FROM [%s]", c);
+ zabbix_log(LOG_LEVEL_DEBUG, "Wrong answer on MAIL FROM [%s]", c);
zabbix_syslog("Wrong answer on MAIL FROM [%s]", c);
snprintf(error,max_error_len-1,"Wrong answer on MAIL FROM [%s]", c);
close(s);
@@ -218,7 +218,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL11");
if(e == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error sending RCPT TO to mailserver [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error sending RCPT TO to mailserver [%s]", strerror(errno));
zabbix_syslog("Error sending RCPT TO to mailserver [%s]", strerror(errno) );
snprintf(error,max_error_len-1,"Error sending RCPT TO to mailserver [%s]", strerror(errno));
close(s);
@@ -231,7 +231,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL12");
if(i == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error receiving answer on RCPT TO request [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error receiving answer on RCPT TO request [%s]", strerror(errno));
zabbix_syslog("Error receiving answer on RCPT TO request [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error receiving answer on RCPT TO request [%s]", strerror(errno));
close(s);
@@ -240,7 +240,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
/* May return 251 as well: User not local; will forward to <forward-path>. See RFC825 */
if( strncmp(OK_250,c,strlen(OK_250)) != 0 && strncmp(OK_251,c,strlen(OK_251)) != 0)
{
- zabbix_log(LOG_LEVEL_ERR, "Wrong answer on RCPT TO [%s]", c);
+ zabbix_log(LOG_LEVEL_DEBUG, "Wrong answer on RCPT TO [%s]", c);
zabbix_syslog("Wrong answer on RCPT TO [%s]", c);
snprintf(error,max_error_len-1,"Wrong answer on RCPT TO [%s]", c);
close(s);
@@ -254,7 +254,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL13");
if(e == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error sending DATA to mailserver [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error sending DATA to mailserver [%s]", strerror(errno));
zabbix_syslog("Error sending DATA to mailserver [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error sending DATA to mailserver [%s]", strerror(errno));
close(s);
@@ -267,7 +267,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL14");
if(i == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error receivng answer on DATA request [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error receivng answer on DATA request [%s]", strerror(errno));
zabbix_syslog("Error receivng answer on DATA request [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error receivng answer on DATA request [%s]", strerror(errno));
close(s);
@@ -275,7 +275,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
}
if(strncmp(OK_354,c,strlen(OK_354)) != 0)
{
- zabbix_log(LOG_LEVEL_ERR, "Wrong answer on DATA [%s]", c);
+ zabbix_log(LOG_LEVEL_DEBUG, "Wrong answer on DATA [%s]", c);
zabbix_syslog("Wrong answer on DATA [%s]", c);
snprintf(error,max_error_len-1,"Wrong answer on DATA [%s]", c);
close(s);
@@ -293,7 +293,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
e=write(s,c,strlen(c));
if(e == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error sending mail subject and body to mailserver [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error sending mail subject and body to mailserver [%s]", strerror(errno));
zabbix_syslog("Error sending mail subject and body to mailserver [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error sending mail subject and body to mailserver [%s]", strerror(errno));
close(s);
@@ -307,7 +307,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL15");
if(e == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error sending . to mailserver [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error sending . to mailserver [%s]", strerror(errno));
zabbix_syslog("Error sending . to mailserver [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error sending . to mailserver [%s]", strerror(errno));
close(s);
@@ -320,7 +320,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL16");
if(i == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error receivng answer on . request [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error receivng answer on . request [%s]", strerror(errno));
zabbix_syslog("Error receivng answer on . request [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error receivng answer on . request [%s]", strerror(errno));
close(s);
@@ -328,7 +328,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
}
if(strncmp(OK_250,c,strlen(OK_250)) != 0)
{
- zabbix_log(LOG_LEVEL_ERR, "Wrong answer on end of data [%s]", c);
+ zabbix_log(LOG_LEVEL_DEBUG, "Wrong answer on end of data [%s]", c);
zabbix_syslog("Wrong answer on end of data [%s]", c);
snprintf(error,max_error_len-1,"Wrong answer on end of data [%s]", c);
close(s);
@@ -342,7 +342,7 @@ int send_email(char *smtp_server,char *smtp_helo,char *smtp_email,char *mailto,c
zabbix_log( LOG_LEVEL_DEBUG, "SENDING MAIL18");
if(e == -1)
{
- zabbix_log(LOG_LEVEL_ERR, "Error sending QUIT to mailserver [%s]", strerror(errno));
+ zabbix_log(LOG_LEVEL_DEBUG, "Error sending QUIT to mailserver [%s]", strerror(errno));
zabbix_syslog("Error sending QUIT to mailserver [%s]", strerror(errno));
snprintf(error,max_error_len-1,"Error sending QUIT to mailserver [%s]", strerror(errno));
close(s);
diff --git a/include/functions.c b/include/functions.c
index 9de1cfac..3038f9b4 100644
--- a/include/functions.c
+++ b/include/functions.c
@@ -784,6 +784,7 @@ void apply_actions(DB_TRIGGER *trigger,int trigger_value)
/* snprintf(sql,sizeof(sql)-1,"select actionid,userid,delay,subject,message,scope,severity,recipient,good from actions where (scope=%d and triggerid=%d and good=%d and nextcheck<=%d) or (scope=%d and good=%d) or (scope=%d and good=%d)",ACTION_SCOPE_TRIGGER,trigger->triggerid,trigger_value,now,ACTION_SCOPE_HOST,trigger_value,ACTION_SCOPE_HOSTS,trigger_value);*/
snprintf(sql,sizeof(sql)-1,"select actionid,userid,delay,subject,message,scope,severity,recipient,good from actions where (scope=%d and triggerid=%d and (good=%d or good=2) and nextcheck<=%d) or (scope=%d and (good=%d or good=2)) or (scope=%d and (good=%d or good=2))",ACTION_SCOPE_TRIGGER,trigger->triggerid,trigger_value,now,ACTION_SCOPE_HOST,trigger_value,ACTION_SCOPE_HOSTS,trigger_value);
result = DBselect(sql);
+ zabbix_log( LOG_LEVEL_DEBUG, "SQL [%s]", sql);
for(i=0;i<DBnum_rows(result);i++)
{
@@ -1032,7 +1033,6 @@ void update_triggers(int itemid)
DB_RESULT *result;
int i;
- int prevvalue;
zabbix_log( LOG_LEVEL_DEBUG, "In update_triggers [%d]", itemid);
@@ -1061,11 +1061,14 @@ void update_triggers(int itemid)
}
/* Oprimise a little bit */
- prevvalue=DBget_prev_trigger_value(trigger.triggerid);
+/* trigger.prevvalue=DBget_prev_trigger_value(trigger.triggerid);*/
- zabbix_log( LOG_LEVEL_DEBUG, "exp_value trigger.value prevvalue [%d] [%d] [%d]", exp_value, trigger.value, prevvalue);
+ zabbix_log( LOG_LEVEL_DEBUG, "exp_value trigger.value trigger.prevvalue [%d] [%d] [%d]", exp_value, trigger.value, trigger.prevvalue);
- if(TRIGGER_VALUE_TRUE == exp_value)
+ now = time(NULL);
+ DBupdate_trigger_value(&trigger, exp_value, now);
+
+/* if(TRIGGER_VALUE_TRUE == exp_value)
{
if(trigger.value != TRIGGER_VALUE_TRUE)
{
@@ -1076,14 +1079,11 @@ void update_triggers(int itemid)
||
(
(trigger.value == TRIGGER_VALUE_UNKNOWN) &&
-/* Optimise a little bit. This optimisation does not work because DBupdate_trigger_value may add alarm! */
- (prevvalue == TRIGGER_VALUE_FALSE)
-/* (DBget_prev_trigger_value(trigger.triggerid) == TRIGGER_VALUE_FALSE)*/
+ (trigger.prevvalue == TRIGGER_VALUE_FALSE)
))
{
apply_actions(&trigger,1);
- /* Why? */
snprintf(sql,sizeof(sql)-1,"update actions set nextcheck=0 where triggerid=%d and good=0",trigger.triggerid);
DBexecute(sql);
@@ -1102,20 +1102,17 @@ void update_triggers(int itemid)
||
(
(trigger.value == TRIGGER_VALUE_UNKNOWN) &&
-/* Optimise a little bit. This optimisation does not work because DBupdate_trigger_value may add alarm! */
- (prevvalue == TRIGGER_VALUE_TRUE)
-/* (DBget_prev_trigger_value(trigger.triggerid) == TRIGGER_VALUE_TRUE)*/
+ (trigger.prevvalue == TRIGGER_VALUE_TRUE)
))
{
apply_actions(&trigger,0);
- /* Why? */
snprintf(sql,sizeof(sql)-1,"update actions set nextcheck=0 where triggerid=%d and good=1",trigger.triggerid);
DBexecute(sql);
update_services(trigger.triggerid, 0);
}
- }
+ }*/
}
DBfree_result(result);
}