diff options
author | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-04-14 13:18:39 +0000 |
---|---|---|
committer | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-04-14 13:18:39 +0000 |
commit | d3d82cbda23c24503fd4b47902f308da6de632a3 (patch) | |
tree | 36cab73a9b5f921e4c732603d19a8d5dcaf4c84a | |
parent | 85eb904a1fd41b28292bc5bdb033ee568a7389b8 (diff) | |
download | zabbix-d3d82cbda23c24503fd4b47902f308da6de632a3.tar.gz zabbix-d3d82cbda23c24503fd4b47902f308da6de632a3.tar.xz zabbix-d3d82cbda23c24503fd4b47902f308da6de632a3.zip |
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@4014 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | src/libs/zbxcommon/misc.c | 32 | ||||
-rw-r--r-- | src/zabbix_server/actions.c | 9 | ||||
-rw-r--r-- | src/zabbix_server/discoverer/discoverer.c | 6 |
3 files changed, 28 insertions, 19 deletions
diff --git a/src/libs/zbxcommon/misc.c b/src/libs/zbxcommon/misc.c index ba448312..eed58b2e 100644 --- a/src/libs/zbxcommon/misc.c +++ b/src/libs/zbxcommon/misc.c @@ -251,24 +251,30 @@ int calculate_item_nextcheck(zbx_uint64_t itemid, int item_type, int delay, char ******************************************************************************/ int ip_in_list(char *list, char *ip) { - char tmp[MAX_STRING_LEN]; char tmp_ip[MAX_STRING_LEN]; - char *s; + char c; int i1,i2,i3,i4,i5; int ret = FAIL; + char *start, *end; zabbix_log( LOG_LEVEL_WARNING, "In ip_in_list(list:%s,ip:%s)", list, ip); - strscpy(tmp,list); - s=(char *)strtok(tmp,","); - while(s!=NULL) + for(start = list; start[0] != '\0';) { - zabbix_log(LOG_LEVEL_WARNING,"Next [%s]", s); + end=strchr(start, ','); + + if(end != NULL) + { + c=end[0]; + end[0]='\0'; + } + + zabbix_log(LOG_LEVEL_WARNING,"Next [%s]", start); - if(sscanf(s,"%d.%d.%d.%d-%d",&i1,&i2,&i3,&i4,&i5) == 5) + 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); if(strcmp(ip,tmp_ip)>=0) @@ -281,7 +287,7 @@ int ip_in_list(char *list, char *ip) } } } - else if(sscanf(s,"%d.%d.%d.%d",&i1,&i2,&i3,&i4) == 4) + else if(sscanf(start,"%d.%d.%d.%d",&i1,&i2,&i3,&i4) == 4) { zbx_snprintf(tmp_ip,sizeof(tmp_ip)-1,"%d.%d.%d.%d",i1,i2,i3,i4); if(strcmp(ip,tmp_ip) == 0) @@ -291,7 +297,15 @@ int ip_in_list(char *list, char *ip) } } - s=(char *)strtok(NULL,","); + if(end != NULL) + { + end[0]=c; + start=end+1; + } + else + { + break; + } } zabbix_log( LOG_LEVEL_WARNING, "End ip_in_list(ret:%s)", ret == SUCCEED?"SUCCEED":"FAIL"); diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c index e4ec28a1..467c2e80 100644 --- a/src/zabbix_server/actions.c +++ b/src/zabbix_server/actions.c @@ -306,11 +306,11 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition) { if(condition->operator == CONDITION_OPERATOR_EQUAL) { - if(ip_in_list(row[0], condition->value) == SUCCEED) ret = SUCCEED; + if(ip_in_list(condition->value, row[0]) == SUCCEED) ret = SUCCEED; } else if(condition->operator == CONDITION_OPERATOR_NOT_EQUAL) { - if(ip_in_list(row[0], condition->value) == FAIL) ret = SUCCEED; + if(ip_in_list(condition->value, row[0]) == FAIL) ret = SUCCEED; } else { @@ -476,7 +476,6 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition) zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_DSERVICE_PORT [%d:%s]", event->value, condition->value); - value_int = atoi(condition->value); result = DBselect("select port from dservices where dserviceid=" ZBX_FS_UI64, event->objectid); row = DBfetch(result); @@ -484,11 +483,11 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition) { if(condition->operator == CONDITION_OPERATOR_EQUAL) { - if(int_in_list(row[0], value_int) == SUCCEED) ret = SUCCEED; + if(int_in_list(condition->value, atoi(row[0])) == SUCCEED) ret = SUCCEED; } else if(condition->operator == CONDITION_OPERATOR_NOT_EQUAL) { - if(int_in_list(row[0], value_int) == FAIL) ret = SUCCEED; + if(int_in_list(condition->value, atoi(row[0])) == FAIL) ret = SUCCEED; } else { diff --git a/src/zabbix_server/discoverer/discoverer.c b/src/zabbix_server/discoverer/discoverer.c index 2a39ac67..3babb25c 100644 --- a/src/zabbix_server/discoverer/discoverer.c +++ b/src/zabbix_server/discoverer/discoverer.c @@ -484,7 +484,6 @@ static int discover_service(zbx_dservice_type_t type, char *ip, int port) sigaction(SIGALRM, &phan, NULL); alarm(10); - zabbix_log(LOG_LEVEL_WARNING, "Beforfe process(%s)", key); if(process(key, 0, &value) == SUCCEED) { if(GET_UI64_RESULT(&value)) @@ -494,7 +493,6 @@ static int discover_service(zbx_dservice_type_t type, char *ip, int port) else ret = FAIL; } else ret = FAIL; - zabbix_log(LOG_LEVEL_WARNING, "After process(%s)", key); alarm(0); } @@ -536,7 +534,6 @@ static void process_check(DB_DRULE *rule, DB_DCHECK *check, char *ip) s=(char *)strtok(tmp,","); while(s!=NULL) { - zabbix_log(LOG_LEVEL_WARNING, "s [%s]", s); c=strchr(s,'-'); if(c == NULL) { @@ -599,7 +596,6 @@ static void process_rule(DB_DRULE *rule) s=(char *)strtok(tmp,","); while(s!=NULL) { - zabbix_log(LOG_LEVEL_WARNING,"IP [%s]", s); if(sscanf(s,"%d.%d.%d.%d-%d",&i1,&i2,&i3,&i4,&i5) == 5) { zbx_snprintf(ip1,sizeof(ip)-1,"%d.%d.%d",i1,i2,i3); @@ -621,7 +617,7 @@ static void process_rule(DB_DRULE *rule) for(i=first;i<=last;i++) { - zabbix_log(LOG_LEVEL_WARNING, "I [%d]", i); + zabbix_log(LOG_LEVEL_WARNING, "IP [%d]", i); zbx_snprintf(ip,sizeof(ip)-1,"%s.%d", ip1, i); |