summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-06-08 14:36:48 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-06-08 14:36:48 +0000
commita485607e0910336acb48b076d9d1953721ff80db (patch)
tree2f95edc9a29a959b9f2ba874cea774447ad66703
parent6bac378fe506204e81b24abc5f30cf3463f14118 (diff)
downloadzabbix-a485607e0910336acb48b076d9d1953721ff80db.tar.gz
zabbix-a485607e0910336acb48b076d9d1953721ff80db.tar.xz
zabbix-a485607e0910336acb48b076d9d1953721ff80db.zip
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@1829 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--TODO1
-rw-r--r--create/mysql/schema.sql1
-rw-r--r--include/db.h1
-rw-r--r--misc/conf/zabbix_server.conf4
-rw-r--r--src/zabbix_server/escalator.c61
-rw-r--r--src/zabbix_server/server.c10
6 files changed, 33 insertions, 45 deletions
diff --git a/TODO b/TODO
index a06d5ad7..d3a97845 100644
--- a/TODO
+++ b/TODO
@@ -12,6 +12,7 @@
- procload for AIX. See email from Juha
- fix templates for complex triggers
- support of automake
+ - rename sucker to poller. Make seperate poller.c
ZABBIX 1.1:
diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql
index 9639539e..9bebb9a3 100644
--- a/create/mysql/schema.sql
+++ b/create/mysql/schema.sql
@@ -646,6 +646,7 @@ CREATE TABLE escalation_rules (
--
CREATE TABLE escalation_log (
+ escalationlogid int(4) NOT NULL auto_increment,
triggerid int(4) DEFAULT '0' NOT NULL,
alarmid int(4) DEFAULT '0' NOT NULL,
escalationid int(4) DEFAULT '0' NOT NULL,
diff --git a/include/db.h b/include/db.h
index f231919c..60638fca 100644
--- a/include/db.h
+++ b/include/db.h
@@ -202,6 +202,7 @@ DB_ALERT
DB_ESCALATION_LOG
{
+ int escalationlogid;
int triggerid;
int alarmid;
int escalationid;
diff --git a/misc/conf/zabbix_server.conf b/misc/conf/zabbix_server.conf
index 1a17fbce..7606e034 100644
--- a/misc/conf/zabbix_server.conf
+++ b/misc/conf/zabbix_server.conf
@@ -5,9 +5,9 @@
############ GENERAL PARAMETERS #################
# Number of pre-forked instances of pollers
-# Default value is 5
+# Default value is 6
# This parameter must be between 5 and 255
-StartSuckers=5
+StartSuckers=6
# Number of pre-forked instances of trappers
# Default value is 5
diff --git a/src/zabbix_server/escalator.c b/src/zabbix_server/escalator.c
index 2854a0be..7035f8bb 100644
--- a/src/zabbix_server/escalator.c
+++ b/src/zabbix_server/escalator.c
@@ -53,6 +53,11 @@
#include "escalator.h"
+int process_escalation(DB_ESCALATION_LOG *escalation_log)
+{
+ return SUCCEED;
+}
+
int main_escalator_loop()
{
char sql[MAX_STRING_LEN];
@@ -60,65 +65,45 @@ int main_escalator_loop()
char error_esc[MAX_STRING_LEN];
int i,res;
+ int now;
struct sigaction phan;
- DB_RESULT *result;
- DB_ALERT alert;
- DB_MEDIATYPE mediatype;
+ DB_ESCALATION_LOG escalation_log;
for(;;)
{
+ zabbix_log( LOG_LEVEL_WARNING, "Selecting data from escalation_log]");
#ifdef HAVE_FUNCTION_SETPROCTITLE
setproctitle("connecting to the database");
#endif
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 escalationlogid,triggerid, alarmid, escalationid, level, adminlevel, nextcheck, status from escalation_log where status=0 and nextcheck<=%d", now);
result = DBselect(sql);
for(i=0;i<DBnum_rows(result);i++)
{
- alert.alertid=atoi(DBget_field(result,i,0));
- alert.mediatypeid=atoi(DBget_field(result,i,1));
- alert.sendto=DBget_field(result,i,2);
- alert.subject=DBget_field(result,i,3);
- alert.message=DBget_field(result,i,4);
- alert.status=atoi(DBget_field(result,i,5));
- alert.retries=atoi(DBget_field(result,i,6));
-
- mediatype.mediatypeid=atoi(DBget_field(result,i,7));
- mediatype.type=atoi(DBget_field(result,i,8));
- mediatype.description=DBget_field(result,i,9);
- mediatype.smtp_server=DBget_field(result,i,10);
- mediatype.smtp_helo=DBget_field(result,i,11);
- mediatype.smtp_email=DBget_field(result,i,12);
- mediatype.exec_path=DBget_field(result,i,13);
-
- phan.sa_handler = &signal_handler;
- sigemptyset(&phan.sa_mask);
- phan.sa_flags = 0;
- sigaction(SIGALRM, &phan, NULL);
-
- /* Hardcoded value */
- alarm(10);
- res=send_alert(&alert,&mediatype,error,sizeof(error));
- alarm(0);
+ escalation_log.escalationlogid=atoi(DBget_field(result,i,0));
+ escalation_log.triggerid=atoi(DBget_field(result,i,1));
+ escalation_log.alarmid=atoi(DBget_field(result,i,2));
+ escalation_log.escalationid=atoi(DBget_field(result,i,3));
+ escalation_log.level=atoi(DBget_field(result,i,4));
+ escalation_log.adminlevel=atoi(DBget_field(result,i,5));
+ escalation_log.nextcheck=atoi(DBget_field(result,i,6));
+ escalation_log.status=atoi(DBget_field(result,i,7));
+
+ res=process_escalation(&escalation_log);
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);
- DBexecute(sql);
+ zabbix_log( LOG_LEVEL_WARNING, "Processing escalation_log ID [%d]", escalation_log.escalationlogid);
}
else
{
- zabbix_log( LOG_LEVEL_DEBUG, "Error sending alert ID [%d]", alert.alertid);
- zabbix_syslog("Error sending alert ID [%d]", alert.alertid);
- DBescape_string(error,error_esc,MAX_STRING_LEN);
- snprintf(sql,sizeof(sql)-1,"update alerts set retries=retries+1,error='%s' where alertid=%d", error_esc, alert.alertid);
- DBexecute(sql);
+ zabbix_log( LOG_LEVEL_WARNING, "Processing escalation_log ID [%d] failed", escalation_log.escalationlogid);
}
}
@@ -126,7 +111,7 @@ int main_escalator_loop()
DBclose();
#ifdef HAVE_FUNCTION_SETPROCTITLE
- setproctitle("sender [sleeping for %d seconds]", CONFIG_SENDER_FREQUENCY);
+ setproctitle("escalator [sleeping for %d seconds]", CONFIG_SENDER_FREQUENCY);
#endif
sleep(CONFIG_SENDER_FREQUENCY);
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index 6f34a283..f471fa06 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -776,31 +776,31 @@ int main(int argc, char **argv)
pids[i-i] = child_trapper_make(i, listenfd, addrlen);
}
-/* First instance of zabbix_suckerd performs housekeeping procedures */
+/* First instance of zabbix_server performs housekeeping procedures */
zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Housekeeper]",sucker_num);
main_housekeeper_loop();
}
else if(sucker_num == 1)
{
-/* Second instance of zabbix_suckerd sends alerts to users */
+/* Second instance of zabbix_server sends alerts to users */
zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Alerter]",sucker_num);
main_alerter_loop();
}
else if(sucker_num == 2)
{
-/* Third instance of zabbix_suckerd periodically re-calculates 'nodata' functions */
+/* Third instance of zabbix_server periodically re-calculates 'nodata' functions */
zabbix_log( LOG_LEVEL_WARNING, "server #%d started [nodata() calculator]",sucker_num);
main_nodata_loop();
}
else if(sucker_num == 3)
{
-/* Fourth instance of zabbix_suckerd periodically pings hosts */
+/* Fourth instance of zabbix_server periodically pings hosts */
zabbix_log( LOG_LEVEL_WARNING, "server #%d started [ICMP pinger]",sucker_num);
main_pinger_loop();
}
else if(sucker_num == 4)
{
-/* Fourth instance of zabbix_suckerd periodically pings hosts */
+/* Fourth instance of zabbix_server escalates notifications */
zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Escalator]",sucker_num);
main_pinger_loop();
}