diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-10-10 20:29:02 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-10-10 20:29:02 +0000 |
| commit | fb3ee196653fb0009d52f6051c162956e585139b (patch) | |
| tree | f2c163fa2f8cd680561eabd7080317ed1c2fa103 /src/zabbix_server/alerter | |
| parent | 167fb59d3fcd95e81337e6ba2ea1698887f1e4b1 (diff) | |
| download | zabbix-fb3ee196653fb0009d52f6051c162956e585139b.tar.gz zabbix-fb3ee196653fb0009d52f6051c162956e585139b.tar.xz zabbix-fb3ee196653fb0009d52f6051c162956e585139b.zip | |
- added columns alerts.[triggerid,repeats,maxrepeats,nextcheck] (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2164 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_server/alerter')
| -rw-r--r-- | src/zabbix_server/alerter/alerter.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/zabbix_server/alerter/alerter.c b/src/zabbix_server/alerter/alerter.c index b3ce8afd..48ecd8ca 100644 --- a/src/zabbix_server/alerter/alerter.c +++ b/src/zabbix_server/alerter/alerter.c @@ -182,7 +182,7 @@ int main_alerter_loop() char error[MAX_STRING_LEN]; char error_esc[MAX_STRING_LEN]; - int i,res; + int i,res, now; struct sigaction phan; @@ -198,7 +198,10 @@ int main_alerter_loop() DBconnect(); - snprintf(sql,sizeof(sql)-1,"select a.alertid,a.mediatypeid,a.sendto,a.subject,a.message,a.status,a.retries,mt.mediatypeid,mt.type,mt.description,mt.smtp_server,mt.smtp_helo,mt.smtp_email,mt.exec_path from alerts a,media_type mt where a.status=0 and a.retries<3 and a.mediatypeid=mt.mediatypeid order by a.clock"); + now = time(NULL); + +/* snprintf(sql,sizeof(sql)-1,"select a.alertid,a.mediatypeid,a.sendto,a.subject,a.message,a.status,a.retries,mt.mediatypeid,mt.type,mt.description,mt.smtp_server,mt.smtp_helo,mt.smtp_email,mt.exec_path from alerts a,media_type mt where a.status=0 and a.retries<3 and a.mediatypeid=mt.mediatypeid order by a.clock"); */ + snprintf(sql,sizeof(sql)-1,"select a.alertid,a.mediatypeid,a.sendto,a.subject,a.message,a.status,a.retries,mt.mediatypeid,mt.type,mt.description,mt.smtp_server,mt.smtp_helo,mt.smtp_email,mt.exec_path,a.delay from alerts a,media_type mt where a.status=%d and a.retries<3 and a.repeats<=a.maxrepeats and a.nextcheck>=%d and a.mediatypeid=mt.mediatypeid order by a.clock", ALERT_STATUS_NOT_SENT, now); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) @@ -219,6 +222,8 @@ int main_alerter_loop() mediatype.smtp_email=DBget_field(result,i,12); mediatype.exec_path=DBget_field(result,i,13); + alert.delay=atoi(DBget_field(result,i,14)); + phan.sa_handler = &signal_handler; sigemptyset(&phan.sa_mask); phan.sa_flags = 0; @@ -232,7 +237,9 @@ int main_alerter_loop() if(res==SUCCEED) { zabbix_log( LOG_LEVEL_DEBUG, "Alert ID [%d] was sent successfully", alert.alertid); - snprintf(sql,sizeof(sql)-1,"update alerts set status=1 where alertid=%d", alert.alertid); + snprintf(sql,sizeof(sql)-1,"update alerts set repeats=repeats+1, nextcheck=%d where alertid=%d", now+alert.delay, alert.alertid); + DBexecute(sql); + snprintf(sql,sizeof(sql)-1,"update alerts set status=%d where alertid=%d and repeats>maxrepeats", ALERT_STATUS_SENT, alert.alertid); DBexecute(sql); } else |
