diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-06-05 16:00:45 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-06-05 16:00:45 +0000 |
| commit | 8d184cb22cb44985179408d0fcfc5f2b0b4e3161 (patch) | |
| tree | 70761d5ce1db16619a957d696c3fb146aca4b46a /include | |
| parent | 2ea9a690585b30627861b7327bd1eedb8f16dbf4 (diff) | |
| download | zabbix-8d184cb22cb44985179408d0fcfc5f2b0b4e3161.tar.gz zabbix-8d184cb22cb44985179408d0fcfc5f2b0b4e3161.tar.xz zabbix-8d184cb22cb44985179408d0fcfc5f2b0b4e3161.zip | |
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@1824 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include')
| -rw-r--r-- | include/db.c | 24 | ||||
| -rw-r--r-- | include/db.h | 12 | ||||
| -rw-r--r-- | include/functions.c | 22 |
3 files changed, 55 insertions, 3 deletions
diff --git a/include/db.c b/include/db.c index ade65421..69bd9bbb 100644 --- a/include/db.c +++ b/include/db.c @@ -547,7 +547,7 @@ int DBupdate_trigger_value(DB_TRIGGER *trigger, int new_value, int now) ((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); + apply_actions(trigger,alarmid,new_value); if(new_value == TRIGGER_VALUE_TRUE) { update_services(trigger->triggerid, trigger->priority); @@ -1359,3 +1359,25 @@ void DBget_item_from_db(DB_ITEM *item,DB_RESULT *result, int row) item->host_available=atoi(DBget_field(result,i,30)); } +int DBget_default_escalation_id() +{ + DB_RESULT *dbresult; + int res = SUCCEED; + + char sql[MAX_STRING_LEN]; + +/* 0 is added to distinguish between lastvalue==NULL and empty result */ + snprintf( sql, sizeof(sql)-1, "select escalationid from escalations where dflt=1"); + dbresult = DBselect(sql); + + if(DBnum_rows(dbresult) == 0) + { + zabbix_log(LOG_LEVEL_WARNING, "No default escalation defined"); + zabbix_syslog("No default escalation defined"); + res = FAIL; + } + res = atoi(DBget_field(dbresult,0,0)); + DBfree_result(dbresult); + + return res; +} diff --git a/include/db.h b/include/db.h index 9a9c64de..630329b7 100644 --- a/include/db.h +++ b/include/db.h @@ -199,6 +199,17 @@ DB_ALERT int retries; }; +DB_ESCALATION_LOG +{ + int triggerid; + int alarmid; + int escalationid; + int level; + int adminlevel; + int nextcheck; + int status; +}; + void DBconnect(void); void DBclose(void); @@ -224,6 +235,7 @@ 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(DB_TRIGGER *trigger, int new_value, int now); +int DBget_default_escalation_id(); void DBdelete_item(int itemid); void DBdelete_host(int hostid); diff --git a/include/functions.c b/include/functions.c index 3038f9b4..9e9535d7 100644 --- a/include/functions.c +++ b/include/functions.c @@ -742,11 +742,29 @@ void send_to_user(DB_TRIGGER *trigger,DB_ACTION *action) } } +void apply_actions(DB_TRIGGER *trigger,int alarmid,int trigger_value) +{ + int escalationid; + char sql[MAX_STRING_LEN]; + + zabbix_log( LOG_LEVEL_WARNING, "In apply_actions(triggerid:%d,alarmid:%d,trigger_value:%d)",trigger->triggerid, alarmid, trigger_value); + + if((escalationid=DBget_default_escalation_id())>0) + { + snprintf(sql,sizeof(sql)-1,"insert into escalation_log (triggerid,alarmid,escalationid,level,adminlevel,nextcheck,nextcheck) values (%d,%d,%d,%d,%d,%d,%d)", trigger->triggerid, alarmid, escalationid, 0, 0, 0, 0); + DBexecute(sql); + } + else + { + zabbix_log( LOG_LEVEL_WARNING, "No default escalation defined"); + } +} + /* * Apply actions if any. */ /*void apply_actions(int triggerid,int good)*/ -void apply_actions(DB_TRIGGER *trigger,int trigger_value) +void apply_actions_old(DB_TRIGGER *trigger,int alarmid,int trigger_value) { DB_RESULT *result,*result2,*result3; @@ -757,7 +775,7 @@ void apply_actions(DB_TRIGGER *trigger,int trigger_value) int i,j; int now; - zabbix_log( LOG_LEVEL_DEBUG, "In apply_actions(%d,%d)",trigger->triggerid, trigger_value); + zabbix_log( LOG_LEVEL_WARNING, "In apply_actions(triggerid:%d,alarmid:%d,trigger_value:%d)",trigger->triggerid, alarmid, trigger_value); if(TRIGGER_VALUE_TRUE == trigger_value) { |
