diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-04-19 18:45:46 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-04-19 18:45:46 +0000 |
| commit | dee8365629f019dc407cf19d9f489d4567b39bcc (patch) | |
| tree | a015f26990dc0c585b1627584689387a7e073d4a /src | |
| parent | 979fcceb99e555800fdfbc2cecf4ba585e780b73 (diff) | |
- removed unused escalator (Alexei)
- removed escalation tables (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2745 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
| -rw-r--r-- | src/zabbix_server/Makefile.am | 4 | ||||
| -rw-r--r-- | src/zabbix_server/escalator/Makefile.am | 4 | ||||
| -rw-r--r-- | src/zabbix_server/escalator/escalator.c | 223 | ||||
| -rw-r--r-- | src/zabbix_server/escalator/escalator.h | 25 | ||||
| -rw-r--r-- | src/zabbix_server/poller/poller.c | 12 | ||||
| -rw-r--r-- | src/zabbix_server/server.c | 11 |
6 files changed, 13 insertions, 266 deletions
diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am index c35a813b..57ce3cbb 100644 --- a/src/zabbix_server/Makefile.am +++ b/src/zabbix_server/Makefile.am @@ -1,8 +1,8 @@ -SUBDIRS = alerter escalator housekeeper pinger poller timer trapper +SUBDIRS = alerter housekeeper pinger poller timer trapper INCLUDES=-I@top_srcdir@/include @MYSQL_INCLUDE@ @SNMP_INCLUDE@ bin_PROGRAMS = zabbix_server zabbix_server_SOURCES = evalfunc.c expression.c actions.c zlog.c functions.c server.c zabbix_server_LDADD = ../libs/zbxsysinfo/libzbxsysinfo.a ../libs/zbxsysinfo/@ARCH@/libzbxsysinfo2.a \ -../libs/zbxlog/libzbxlog.a ../libs/zbxpid/libzbxpid.a ../libs/zbxconf/libzbxconf.a ../libs/zbxcrypto/libzbxcrypto.a ../libs/zbxnet/libzbxnet.a pinger/libzbxpinger.a poller/libzbxpoller.a escalator/libzbxescalator.a housekeeper/libzbxhousekeeper.a alerter/libzbxalerter.a timer/libzbxtimer.a trapper/libzbxtrapper.a ../libs/zbxemail/libzbxemail.a ../libs/zbxdbhigh/libzbxdbhigh.a ../libs/zbxcommon/libzbxcommon.a @MYSQL_LIBS@ @PGSQL_LIBS@ @LDAP_LIBS@ @SNMP_LIBS@ +../libs/zbxlog/libzbxlog.a ../libs/zbxpid/libzbxpid.a ../libs/zbxconf/libzbxconf.a ../libs/zbxcrypto/libzbxcrypto.a ../libs/zbxnet/libzbxnet.a pinger/libzbxpinger.a poller/libzbxpoller.a housekeeper/libzbxhousekeeper.a alerter/libzbxalerter.a timer/libzbxtimer.a trapper/libzbxtrapper.a ../libs/zbxemail/libzbxemail.a ../libs/zbxdbhigh/libzbxdbhigh.a ../libs/zbxcommon/libzbxcommon.a @MYSQL_LIBS@ @PGSQL_LIBS@ @LDAP_LIBS@ @SNMP_LIBS@ zabbix_server_LDFLAGS=@MYSQL_LFLAGS@ @PGSQL_LFLAGS@ @LDAP_LFLAGS@ @SNMP_LFLAGS@ diff --git a/src/zabbix_server/escalator/Makefile.am b/src/zabbix_server/escalator/Makefile.am deleted file mode 100644 index 5071f2c2..00000000 --- a/src/zabbix_server/escalator/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -SUBDIRS= -INCLUDES=-I@top_srcdir@/include @MYSQL_INCLUDE@ -lib_LIBRARIES=libzbxescalator.a -libzbxescalator_a_SOURCES=escalator.c diff --git a/src/zabbix_server/escalator/escalator.c b/src/zabbix_server/escalator/escalator.c deleted file mode 100644 index 4bdb65d6..00000000 --- a/src/zabbix_server/escalator/escalator.c +++ /dev/null @@ -1,223 +0,0 @@ -/* -** ZABBIX -** Copyright (C) 2000-2005 SIA Zabbix -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -**/ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <netinet/in.h> - -#include <sys/wait.h> - -#include <string.h> - -#ifdef HAVE_NETDB_H - #include <netdb.h> -#endif - -/* Required for getpwuid */ -#include <pwd.h> - -#include <signal.h> -#include <errno.h> - -#include <time.h> - -#include "common.h" -#include "cfg.h" -#include "db.h" -#include "../functions.h" -#include "log.h" -#include "zlog.h" -#include "email.h" - -#include "escalator.h" - -extern void apply_actions(DB_TRIGGER *trigger,int alarmid,int trigger_value); - -static int process_escalation(DB_ESCALATION_LOG *escalation_log) -{ - int i,now; - char sql[MAX_STRING_LEN]; - - DB_RESULT *result; - DB_ESCALATION_RULE escalation_rule; - - DB_TRIGGER trigger; - - zabbix_log( LOG_LEVEL_WARNING, "In process_escalation()"); - - snprintf(sql,sizeof(sql)-1,"select escalationruleid, escalationid,level,period,delay,actiontype from escalation_rules where escalationid=%d and level>=%d order by level", escalation_log->escalationid, escalation_log->level); - zabbix_log( LOG_LEVEL_WARNING, "SQL [%s]", sql); - result = DBselect(sql); - - for(i=0;i<DBnum_rows(result);i++) - { - escalation_rule.escalationruleid=atoi(DBget_field(result,i,0)); - escalation_rule.escalationid=atoi(DBget_field(result,i,1)); - escalation_rule.level=atoi(DBget_field(result,i,2)); - escalation_rule.period=DBget_field(result,i,3); - escalation_rule.delay=atoi(DBget_field(result,i,4)); - escalation_rule.actiontype=atoi(DBget_field(result,i,5)); - - zabbix_log( LOG_LEVEL_WARNING, "Selected escalationrule ID [%d]", escalation_rule.escalationruleid); - now=time(NULL); - if(escalation_log->nextcheck <= now) - { - if(escalation_log->nextcheck==0 && escalation_rule.delay!=0) - { - escalation_log->nextcheck = escalation_rule.delay+now; - escalation_log->level = escalation_rule.level; - snprintf(sql,sizeof(sql)-1,"update escalation_log set nextcheck=%d,level=%d,actiontype=%d where escalationlogid=%d", escalation_log->nextcheck, escalation_log->level, escalation_rule.actiontype, escalation_log->escalationlogid); - zabbix_log( LOG_LEVEL_WARNING, "SQL [%s]", sql); - DBexecute(sql); - break; - } - - switch (escalation_rule.actiontype) - { - case ESCALATION_ACTION_NOTHING: - zabbix_log( LOG_LEVEL_WARNING, "ESCALATION_ACTION_NOTHING"); - break; - case ESCALATION_ACTION_EXEC_ACTION: - zabbix_log( LOG_LEVEL_WARNING, "ESCALATION_ACTION_EXEC_ACTION"); - if(DBget_trigger_by_triggerid(escalation_log->triggerid,&trigger) == SUCCEED) - { - apply_actions(&trigger,escalation_log->alarmid,TRIGGER_VALUE_TRUE); - } - else - { - zabbix_log( LOG_LEVEL_WARNING, "Cannot execute actions. No trigger with triggerid [%d]", escalation_log->triggerid); - } - break; - case ESCALATION_ACTION_INC_SEVERITY: - zabbix_log( LOG_LEVEL_WARNING, "ESCALATION_ACTION_INC_SEVERITY"); - DBexecute(sql); - break; - case ESCALATION_ACTION_INC_ADMIN: - zabbix_log( LOG_LEVEL_WARNING, "ESCALATION_ACTION_INC_ADMIN"); - DBexecute(sql); - break; - default: - zabbix_log( LOG_LEVEL_ERR, "Unknow escalation action type [%d]", escalation_rule.actiontype); - } - snprintf(sql,sizeof(sql)-1,"update escalation_log set status=1 where escalationlogid=%d", escalation_log->escalationlogid); - zabbix_log( LOG_LEVEL_WARNING, "SQL [%s]", sql); - DBexecute(sql); - - snprintf(sql,sizeof(sql)-1,"insert into escalation_log (triggerid,alarmid,escalationid,level,adminlevel,nextcheck,status,actiontype) values (%d,%d,%d,%d,%d,%d,%d,%d)", escalation_log->triggerid, escalation_log->alarmid, escalation_log->escalationid, escalation_rule.level+1, escalation_log->adminlevel, 0, 0, ESCALATION_ACTION_NOTHING); - zabbix_log( LOG_LEVEL_WARNING, "SQL [%s]", sql); - DBexecute(sql); - break; - } - else - { - zabbix_log( LOG_LEVEL_WARNING, "Not ready yet esc_log id [%d]", escalation_log->escalationlogid); - break; - } - } - - if(DBnum_rows(result)==0) - { - zabbix_log( LOG_LEVEL_WARNING, "No more escalation levels"); - snprintf(sql,sizeof(sql)-1,"update escalation_log set status=1 where escalationlogid=%d", escalation_log->escalationlogid); - zabbix_log( LOG_LEVEL_WARNING, "SQL [%s]", sql); - DBexecute(sql); - } - DBfree_result(result); - - return SUCCEED; -} - -/*----------------------------------------------------------------------------- - * - * Function : main_escalator_loop - * - * Purpose : periodically process active escalations - * - * Parameters : - * - * Returns : - * - * Author : Alexei Vladishev - * - * Comments : Never returns - * - ----------------------------------------------------------------------------*/ -void main_escalator_loop() -{ - char sql[MAX_STRING_LEN]; - - int i,res; - int now; - - DB_RESULT *result; - - DB_ESCALATION_LOG escalation_log; - - for(;;) - { - zabbix_log( LOG_LEVEL_DEBUG, "Selecting data from escalation_log"); -#ifdef HAVE_FUNCTION_SETPROCTITLE - setproctitle("connecting to the database"); -#endif - - DBconnect(); - - 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++) - { - 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_WARNING, "Processing escalation_log ID [%d]", escalation_log.escalationlogid); - } - else - { - zabbix_log( LOG_LEVEL_WARNING, "Processing escalation_log ID [%d] failed", escalation_log.escalationlogid); - } - - } - DBfree_result(result); - - DBclose(); -#ifdef HAVE_FUNCTION_SETPROCTITLE - setproctitle("escalator [sleeping for %d seconds]", 10); -#endif - - sleep(10); - } -} diff --git a/src/zabbix_server/escalator/escalator.h b/src/zabbix_server/escalator/escalator.h deleted file mode 100644 index 0214ea65..00000000 --- a/src/zabbix_server/escalator/escalator.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -** ZABBIX -** Copyright (C) 2000-2005 SIA Zabbix -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -**/ - -#ifndef ZABBIX_ESCALATOR_H -#define ZABBIX_ESCALATOR_H - -void main_escalator_loop(); - -#endif diff --git a/src/zabbix_server/poller/poller.c b/src/zabbix_server/poller/poller.c index 6a3f2443..3c04fc5b 100644 --- a/src/zabbix_server/poller/poller.c +++ b/src/zabbix_server/poller/poller.c @@ -111,7 +111,7 @@ static int get_minnextcheck(int now) /* Host status 0 == MONITORED 1 == NOT MONITORED 2 == UNREACHABLE */ - if(server_num == 5) + if(server_num == 4) { snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from!=0 and h.hostid=i.hostid and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } @@ -119,11 +119,11 @@ static int get_minnextcheck(int now) { if(CONFIG_REFRESH_UNSUPPORTED != 0) { - snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-6,server_num-6,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); + snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } else { - snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-6,server_num-6,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); + snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.errors_from=0 and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } } @@ -221,7 +221,7 @@ int get_values(void) now = time(NULL); /* Poller for unreachable hosts */ - if(server_num == 5) + if(server_num == 4) { snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from!=0 and h.hostid=i.hostid and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } @@ -229,11 +229,11 @@ int get_values(void) { if(CONFIG_REFRESH_UNSUPPORTED != 0) { - snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d,%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_SUCKERD_FORKS-6,server_num-6,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); + snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d,%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } else { - snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_SUCKERD_FORKS-6,server_num-6,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); + snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.errors_from=0 and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } } result = DBselect(sql); diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c index b296013b..0bb244c5 100644 --- a/src/zabbix_server/server.c +++ b/src/zabbix_server/server.c @@ -52,7 +52,6 @@ #include "sysinfo.h" #include "alerter/alerter.h" -#include "escalator/escalator.h" #include "housekeeper/housekeeper.h" #include "pinger/pinger.h" #include "poller/poller.h" @@ -313,7 +312,7 @@ void init_config(void) static struct cfg_line cfg[]= { /* PARAMETER ,VAR ,FUNC, TYPE(0i,1s),MANDATORY,MIN,MAX */ - {"StartSuckers",&CONFIG_SUCKERD_FORKS,0,TYPE_INT,PARM_OPT,7,255}, + {"StartSuckers",&CONFIG_SUCKERD_FORKS,0,TYPE_INT,PARM_OPT,6,255}, {"HousekeepingFrequency",&CONFIG_HOUSEKEEPING_FREQUENCY,0,TYPE_INT,PARM_OPT,1,24}, {"SenderFrequency",&CONFIG_SENDER_FREQUENCY,0,TYPE_INT,PARM_OPT,5,3600}, {"PingerFrequency",&CONFIG_PINGER_FREQUENCY,0,TYPE_INT,PARM_OPT,1,3600}, @@ -645,13 +644,13 @@ int main(int argc, char **argv) zabbix_log( LOG_LEVEL_WARNING, "server #%d started [ICMP pinger]",server_num); main_pinger_loop(); } - else if(server_num == 4) +/* Fifth instance of zabbix_server escalates notifications */ +/* else if(server_num == 4) { -/* Fourth instance of zabbix_server escalates notifications */ zabbix_log( LOG_LEVEL_WARNING, "server #%d started [Escalator]",server_num); main_escalator_loop(); - } - else if(server_num == 5) + }*/ + else if(server_num == 4) { #ifdef HAVE_SNMP init_snmp("zabbix_server"); |
