summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/zbxcommon/misc.c3
-rw-r--r--src/zabbix_server/actions.c97
-rw-r--r--src/zabbix_server/discoverer/discoverer.c2
3 files changed, 31 insertions, 71 deletions
diff --git a/src/libs/zbxcommon/misc.c b/src/libs/zbxcommon/misc.c
index eed58b2e..a05dbad4 100644
--- a/src/libs/zbxcommon/misc.c
+++ b/src/libs/zbxcommon/misc.c
@@ -272,8 +272,6 @@ int ip_in_list(char *list, char *ip)
end[0]='\0';
}
- zabbix_log(LOG_LEVEL_WARNING,"Next [%s]", start);
-
if(sscanf(start,"%d.%d.%d.%d-%d",&i1,&i2,&i3,&i4,&i5) == 5)
{
zbx_snprintf(tmp_ip,sizeof(tmp_ip)-1,"%d.%d.%d.%d",i1,i2,i3,i4);
@@ -348,7 +346,6 @@ int int_in_list(char *list, int value)
end[0]='\0';
}
- zabbix_log(LOG_LEVEL_WARNING,"Next [%s]", start);
if(sscanf(start,"%d-%d",&i1,&i2) == 2)
{
if(value>=i1 && value<=i2)
diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c
index 467c2e80..1f3fdbf8 100644
--- a/src/zabbix_server/actions.c
+++ b/src/zabbix_server/actions.c
@@ -293,14 +293,23 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
}
}
else if(event->source == EVENT_SOURCE_DISCOVERY &&
- event->object == EVENT_OBJECT_DHOST &&
+ (event->object == EVENT_OBJECT_DHOST || event->object == EVENT_OBJECT_DSERVICE) &&
condition->conditiontype == CONDITION_TYPE_DHOST_IP)
{
zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_DHOST_IP [%d:%s]",
event->value,
condition->value);
- result = DBselect("select ip from dhosts where dhostid=" ZBX_FS_UI64,
- event->objectid);
+
+ if(event->object == EVENT_OBJECT_DHOST)
+ {
+ result = DBselect("select ip from dhosts where dhostid=" ZBX_FS_UI64,
+ event->objectid);
+ }
+ else
+ {
+ result = DBselect("select h.ip from dhosts h,dservices s where h.dhostid=s.dhostid and s.dserviceid=" ZBX_FS_UI64,
+ event->objectid);
+ }
row = DBfetch(result);
if(row && DBis_null(row[0]) != SUCCEED)
{
@@ -346,45 +355,23 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
DBfree_result(result);
}
else if(event->source == EVENT_SOURCE_DISCOVERY &&
- event->object == EVENT_OBJECT_DHOST &&
+ (event->object == EVENT_OBJECT_DHOST || event->object == EVENT_OBJECT_DSERVICE) &&
condition->conditiontype == CONDITION_TYPE_DSTATUS)
{
zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_DSTATUS [%d:%s]",
event->value,
condition->value);
value_int = atoi(condition->value);
- result = DBselect("select status from dhosts where dhostid=" ZBX_FS_UI64,
- event->objectid);
- row = DBfetch(result);
- if(row && DBis_null(row[0]) != SUCCEED)
+ if(event->object == EVENT_OBJECT_DHOST)
{
- if(condition->operator == CONDITION_OPERATOR_EQUAL)
- {
- if(value_int == atoi(row[0])) ret = SUCCEED;
- }
- else if(condition->operator == CONDITION_OPERATOR_NOT_EQUAL)
- {
- if(atoi(row[0]) != value_int) ret = SUCCEED;
- }
- else
- {
- zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
- condition->operator,
- condition->conditionid);
- }
+ result = DBselect("select status from dhosts where dhostid=" ZBX_FS_UI64,
+ event->objectid);
+ }
+ else
+ {
+ result = DBselect("select status from dservices where dserviceid=" ZBX_FS_UI64,
+ event->objectid);
}
- DBfree_result(result);
- }
- else if(event->source == EVENT_SOURCE_DISCOVERY &&
- event->object == EVENT_OBJECT_DSERVICE &&
- condition->conditiontype == CONDITION_TYPE_DSTATUS)
- {
- zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_DSERVICE [%d:%s]",
- event->value,
- condition->value);
- value_int = atoi(condition->value);
- result = DBselect("select status from dservices where dserviceid=" ZBX_FS_UI64,
- event->objectid);
row = DBfetch(result);
if(row && DBis_null(row[0]) != SUCCEED)
{
@@ -406,47 +393,23 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
DBfree_result(result);
}
else if(event->source == EVENT_SOURCE_DISCOVERY &&
- event->object == EVENT_OBJECT_DHOST &&
+ (event->object == EVENT_OBJECT_DHOST || event->object == EVENT_OBJECT_DSERVICE) &&
condition->conditiontype == CONDITION_TYPE_DUPTIME)
{
zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_DUPTIME [%d:%s]",
event->value,
condition->value);
value_int = atoi(condition->value);
- result = DBselect("select status,lastup,lastdown from dhosts where dhostid=" ZBX_FS_UI64,
- event->objectid);
- row = DBfetch(result);
- if(row && DBis_null(row[0]) != SUCCEED)
+ if(event->object == EVENT_OBJECT_DHOST)
{
- tmp_int = (atoi(row[0]) == DOBJECT_STATUS_UP)?atoi(row[1]):atoi(row[2]);
- now = time(NULL);
- if(condition->operator == CONDITION_OPERATOR_LESS_EQUAL)
- {
- if(tmp_int != 0 && (now-value_int)<=value_int) ret = SUCCEED;
- }
- else if(condition->operator == CONDITION_OPERATOR_MORE_EQUAL)
- {
- if(tmp_int != 0 && (now-value_int)>=value_int) ret = SUCCEED;
- }
- else
- {
- zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
- condition->operator,
- condition->conditionid);
- }
+ result = DBselect("select status,lastup,lastdown from dhosts where dhostid=" ZBX_FS_UI64,
+ event->objectid);
+ }
+ else
+ {
+ result = DBselect("select status,lastup,lastdown from dservices where dserviceid=" ZBX_FS_UI64,
+ event->objectid);
}
- DBfree_result(result);
- }
- else if(event->source == EVENT_SOURCE_DISCOVERY &&
- event->object == EVENT_OBJECT_DSERVICE &&
- condition->conditiontype == CONDITION_TYPE_DUPTIME)
- {
- zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_DUPTIME [%d:%s]",
- event->value,
- condition->value);
- value_int = atoi(condition->value);
- result = DBselect("select status,lastup,lastdown from dservices where dserviceid=" ZBX_FS_UI64,
- event->objectid);
row = DBfetch(result);
if(row && DBis_null(row[0]) != SUCCEED)
{
diff --git a/src/zabbix_server/discoverer/discoverer.c b/src/zabbix_server/discoverer/discoverer.c
index 3babb25c..7900e466 100644
--- a/src/zabbix_server/discoverer/discoverer.c
+++ b/src/zabbix_server/discoverer/discoverer.c
@@ -617,10 +617,10 @@ static void process_rule(DB_DRULE *rule)
for(i=first;i<=last;i++)
{
- zabbix_log(LOG_LEVEL_WARNING, "IP [%d]", i);
zbx_snprintf(ip,sizeof(ip)-1,"%s.%d",
ip1,
i);
+ zabbix_log(LOG_LEVEL_WARNING, "IP [%s]", ip);
result = DBselect("select dcheckid,druleid,type,ports from dchecks where druleid=" ZBX_FS_UI64,
rule->druleid);
while((row=DBfetch(result)))