summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-19 12:19:59 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-19 12:19:59 +0000
commit7434fa236e1a6d52f9d98d79f01cd69fcfdffc24 (patch)
tree4f734e19e598f54c19144fb654b604395bc61328 /src
parent8f48d61bd34c7420e7967874f60ead4f1e36fc66 (diff)
Minor code beautification.
git-svn-id: svn://svn.zabbix.com/trunk@3898 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/zabbix_server/actions.c107
-rw-r--r--src/zabbix_server/evalfunc.c128
-rw-r--r--src/zabbix_server/expression.c140
3 files changed, 267 insertions, 108 deletions
diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c
index bb583d2f..1664500a 100644
--- a/src/zabbix_server/actions.c
+++ b/src/zabbix_server/actions.c
@@ -73,9 +73,12 @@ static void send_to_user_medias(DB_EVENT *event,DB_ACTION *action, zbx_uint64_t
DB_RESULT result;
DB_ROW row;
- zabbix_log( LOG_LEVEL_DEBUG, "In send_to_user_medias(objectid:" ZBX_FS_UI64 ")", event->objectid);
+ zabbix_log( LOG_LEVEL_DEBUG, "In send_to_user_medias(objectid:" ZBX_FS_UI64 ")",
+ event->objectid);
- result = DBselect("select mediatypeid,sendto,active,severity,period from media where active=%d and userid=" ZBX_FS_UI64,MEDIA_STATUS_ACTIVE,userid);
+ result = DBselect("select mediatypeid,sendto,active,severity,period from media where active=%d and userid=" ZBX_FS_UI64,
+ MEDIA_STATUS_ACTIVE,
+ userid);
while((row=DBfetch(result)))
{
@@ -86,7 +89,10 @@ static void send_to_user_medias(DB_EVENT *event,DB_ACTION *action, zbx_uint64_t
media.severity = atoi(row[3]);
media.period = row[4];
- zabbix_log( LOG_LEVEL_DEBUG, "Trigger severity [%d] Media severity [%d] Period [%s]",event->trigger_priority, media.severity, media.period);
+ zabbix_log( LOG_LEVEL_DEBUG, "Trigger severity [%d] Media severity [%d] Period [%s]",
+ event->trigger_priority,
+ media.severity,
+ media.period);
if(((1<<event->trigger_priority)&media.severity)==0)
{
zabbix_log( LOG_LEVEL_DEBUG, "Won't send message (severity)");
@@ -147,9 +153,11 @@ static void send_to_user(DB_EVENT *event, DB_ACTION *action)
else
{
zabbix_log( LOG_LEVEL_WARNING, "Unknown recipient type [%d] for actionid [" ZBX_FS_UI64 "]",
- action->recipient,action->actionid);
+ action->recipient,
+ action->actionid);
zabbix_syslog("Unknown recipient type [%d] for actionid [" ZBX_FS_UI64 "]",
- action->recipient,action->actionid);
+ action->recipient,
+ action->actionid);
}
zabbix_log(LOG_LEVEL_DEBUG, "End send_to_user()");
}
@@ -184,10 +192,13 @@ static void run_remote_command(char* host_name, char* command)
assert(host_name);
assert(command);
- zabbix_log(LOG_LEVEL_DEBUG, "In run_remote_command(hostname:%s,command:%s)", host_name, command);
+ zabbix_log(LOG_LEVEL_DEBUG, "In run_remote_command(hostname:%s,command:%s)",
+ host_name,
+ command);
result = DBselect("select distinct host,ip,useip,port,dns from hosts where host='%s' and " ZBX_COND_NODEID,
- host_name, LOCAL_NODE("hostid"));
+ host_name,
+ LOCAL_NODE("hostid"));
row = DBfetch(result);
if(row)
{
@@ -207,7 +218,8 @@ static void run_remote_command(char* host_name, char* command)
}
DBfree_result(result);
- zabbix_log(LOG_LEVEL_DEBUG, "End run_remote_command(result:%d)", ret);
+ zabbix_log(LOG_LEVEL_DEBUG, "End run_remote_command(result:%d)",
+ ret);
}
/******************************************************************************
@@ -244,7 +256,8 @@ static int get_next_command(char** command_list, char** alias, int* is_group, ch
assert(is_group);
assert(command);
- zabbix_log(LOG_LEVEL_DEBUG, "In get_next_command(command_list:%s)", *command_list);
+ zabbix_log(LOG_LEVEL_DEBUG, "In get_next_command(command_list:%s)",
+ *command_list);
*alias = NULL;
*is_group = 0;
@@ -292,7 +305,10 @@ static int get_next_command(char** command_list, char** alias, int* is_group, ch
}
}
- zabbix_log(LOG_LEVEL_DEBUG, "End get_next_command [alias:%s,is_group:%i,command:%s]", *alias, *is_group, *command);
+ zabbix_log(LOG_LEVEL_DEBUG, "End get_next_command(alias:%s,is_group:%i,command:%s)",
+ *alias,
+ *is_group,
+ *command);
return 0;
}
@@ -335,7 +351,9 @@ static void run_commands(DB_EVENT *event, DB_ACTION *action)
if(alias == '\0' || command == '\0') continue;
if(is_group)
{
- result = DBselect("select distinct h.host from hosts_groups hg,hosts h, groups g where hg.hostid=h.hostid and hg.groupid=g.groupid and g.name='%s' and" ZBX_COND_NODEID, alias, LOCAL_NODE("h.hostid"));
+ result = DBselect("select distinct h.host from hosts_groups hg,hosts h, groups g where hg.hostid=h.hostid and hg.groupid=g.groupid and g.name='%s' and" ZBX_COND_NODEID,
+ alias,
+ LOCAL_NODE("h.hostid"));
while((row=DBfetch(result)))
{
run_remote_command(row[0], command);
@@ -380,7 +398,10 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
int ret = FAIL;
- zabbix_log( LOG_LEVEL_DEBUG, "In check_action_condition [actionid:" ZBX_FS_UI64 ",conditionid:" ZBX_FS_UI64 ",cond.value:%s]", condition->actionid, condition->conditionid, condition->value);
+ zabbix_log( LOG_LEVEL_DEBUG, "In check_action_condition [actionid:" ZBX_FS_UI64 ",conditionid:" ZBX_FS_UI64 ",cond.value:%s]",
+ condition->actionid,
+ condition->conditionid,
+ condition->value);
if(condition->conditiontype == CONDITION_TYPE_HOST_GROUP)
{
@@ -414,14 +435,17 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
}
else
{
- zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]", condition->operator, condition->conditionid);
+ zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
+ condition->operator,
+ condition->conditionid);
}
DBfree_result(result);
}
else if(condition->conditiontype == CONDITION_TYPE_HOST)
{
ZBX_STR2UINT64(condition_value, condition->value);
- result = DBselect("select distinct h.hostid from hosts h, items i, functions f, triggers t where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid=" ZBX_FS_UI64, event->objectid);
+ result = DBselect("select distinct h.hostid from hosts h, items i, functions f, triggers t where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid=" ZBX_FS_UI64,
+ event->objectid);
if(condition->operator == CONDITION_OPERATOR_EQUAL)
{
while((row=DBfetch(result)))
@@ -449,14 +473,18 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
}
else
{
- zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]", condition->operator, condition->conditionid);
+ zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
+ condition->operator,
+ condition->conditionid);
}
DBfree_result(result);
}
else if(condition->conditiontype == CONDITION_TYPE_TRIGGER)
{
ZBX_STR2UINT64(condition_value, condition->value);
- zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_TRIGGER [" ZBX_FS_UI64 ":%s]", condition_value, condition->value);
+ zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_TRIGGER [" ZBX_FS_UI64 ":%s]",
+ condition_value,
+ condition->value);
if(condition->operator == CONDITION_OPERATOR_EQUAL)
{
if(event->objectid == condition_value)
@@ -473,7 +501,9 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
}
else
{
- zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [%d]", condition->operator, condition->conditionid);
+ zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [%d]",
+ condition->operator,
+ condition->conditionid);
}
}
else if(condition->conditiontype == CONDITION_TYPE_TRIGGER_NAME)
@@ -499,7 +529,8 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
else
{
zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
- condition->operator, condition->conditionid);
+ condition->operator,
+ condition->conditionid);
}
zbx_free(tmp_str);
}
@@ -536,12 +567,15 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
else
{
zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
- condition->operator, condition->conditionid);
+ condition->operator,
+ condition->conditionid);
}
}
else if(condition->conditiontype == CONDITION_TYPE_TRIGGER_VALUE)
{
- zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_TRIGGER_VALUE [%d:%s]", event->value, condition->value);
+ zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_TRIGGER_VALUE [%d:%s]",
+ event->value,
+ condition->value);
if(condition->operator == CONDITION_OPERATOR_EQUAL)
{
if(event->value == atoi(condition->value))
@@ -552,12 +586,15 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
else
{
zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
- condition->operator, condition->conditionid);
+ condition->operator,
+ condition->conditionid);
}
}
else if(condition->conditiontype == CONDITION_TYPE_TIME_PERIOD)
{
- zabbix_log( LOG_LEVEL_ERR, "Condition type [CONDITION_TYPE_TRIGGER_VALUE] is supported");
+ zabbix_log( LOG_LEVEL_DEBUG, "CONDITION_TYPE_TRIGGER_VALUE [%d:%s]",
+ event->value,
+ condition->value);
if(condition->operator == CONDITION_OPERATOR_IN)
{
if(check_time_period(condition->value, (time_t)NULL)==1)
@@ -568,13 +605,15 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition)
else
{
zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]",
- condition->operator, condition->conditionid);
+ condition->operator,
+ condition->conditionid);
}
}
else
{
zabbix_log( LOG_LEVEL_ERR, "Condition type [%d] is unknown for condition id [" ZBX_FS_UI64 "]",
- condition->conditiontype, condition->conditionid);
+ condition->conditiontype,
+ condition->conditionid);
}
if(FAIL==ret)
@@ -624,7 +663,8 @@ static int check_action_conditions(DB_EVENT *event, DB_ACTION *action)
zabbix_log( LOG_LEVEL_DEBUG, "In check_action_conditions (actionid:" ZBX_FS_UI64 ")",
action->actionid);
- result = DBselect("select conditionid,actionid,conditiontype,operator,value from conditions where actionid=" ZBX_FS_UI64 " order by conditiontype", action->actionid);
+ result = DBselect("select conditionid,actionid,conditiontype,operator,value from conditions where actionid=" ZBX_FS_UI64 " order by conditiontype",
+ action->actionid);
while((row=DBfetch(result)))
{
@@ -685,7 +725,8 @@ static int check_action_conditions(DB_EVENT *event, DB_ACTION *action)
}
break;
default:
- zabbix_log( LOG_LEVEL_DEBUG, "End check_action_conditions (result:%d)", (FAIL==ret)?"FALSE":"TRUE");
+ zabbix_log( LOG_LEVEL_DEBUG, "End check_action_conditions (result:%d)",
+ (FAIL==ret)?"FALSE":"TRUE");
ret = FAIL;
break;
@@ -697,7 +738,8 @@ static int check_action_conditions(DB_EVENT *event, DB_ACTION *action)
/* Ifnot conditions defined, return SUCCEED*/
if(num == 0) ret = SUCCEED;
- zabbix_log( LOG_LEVEL_DEBUG, "End check_action_conditions (result:%d)", (FAIL==ret)?"FALSE":"TRUE");
+ zabbix_log( LOG_LEVEL_DEBUG, "End check_action_conditions (result:%d)",
+ (FAIL==ret)?"FALSE":"TRUE");
return ret;
}
@@ -724,13 +766,16 @@ void apply_actions(DB_EVENT *event)
DB_ACTION action;
- zabbix_log( LOG_LEVEL_DEBUG, "In apply_actions(eventid:" ZBX_FS_UI64 ")",event->eventid);
+ zabbix_log( LOG_LEVEL_DEBUG, "In apply_actions(eventid:" ZBX_FS_UI64 ")",
+ event->eventid);
if(TRIGGER_VALUE_TRUE == event->value)
{
zabbix_log( LOG_LEVEL_DEBUG, "Check dependencies");
- result = DBselect("select count(*) from trigger_depends d,triggers t where d.triggerid_down=" ZBX_FS_UI64 " and d.triggerid_up=t.triggerid and t.value=%d",event->objectid, TRIGGER_VALUE_TRUE);
+ result = DBselect("select count(*) from trigger_depends d,triggers t where d.triggerid_down=" ZBX_FS_UI64 " and d.triggerid_up=t.triggerid and t.value=%d",
+ event->objectid,
+ TRIGGER_VALUE_TRUE);
row=DBfetch(result);
if(row && DBis_null(row[0]) != SUCCEED)
{
@@ -746,7 +791,9 @@ void apply_actions(DB_EVENT *event)
zabbix_log( LOG_LEVEL_DEBUG, "Applying actions");
- result = DBselect("select actionid,userid,subject,message,recipient,scripts,actiontype,evaltype from actions where status=%d and" ZBX_COND_NODEID, ACTION_STATUS_ACTIVE, LOCAL_NODE("actionid"));
+ result = DBselect("select actionid,userid,subject,message,recipient,scripts,actiontype,evaltype from actions where status=%d and" ZBX_COND_NODEID,
+ ACTION_STATUS_ACTIVE,
+ LOCAL_NODE("actionid"));
while((row=DBfetch(result)))
{
diff --git a/src/zabbix_server/evalfunc.c b/src/zabbix_server/evalfunc.c
index 542f6338..8b8e59d3 100644
--- a/src/zabbix_server/evalfunc.c
+++ b/src/zabbix_server/evalfunc.c
@@ -179,7 +179,9 @@ static int evaluate_COUNT(char *value, DB_ITEM *item, int parameter)
strscpy(table,"history");
}
result = DBselect("select count(value) from %s where clock>%d and itemid=" ZBX_FS_UI64,
- table,now-parameter,item->itemid);
+ table,
+ now-parameter,
+ item->itemid);
row = DBfetch(result);
@@ -246,7 +248,9 @@ static int evaluate_SUM(char *value, DB_ITEM *item, int parameter, int flag)
strscpy(table,"history");
}
result = DBselect("select sum(value) from %s where clock>%d and itemid=" ZBX_FS_UI64,
- table, now-parameter,item->itemid);
+ table,
+ now-parameter,
+ item->itemid);
row = DBfetch(result);
if(!row || DBis_null(row[0])==SUCCEED)
@@ -270,7 +274,8 @@ static int evaluate_SUM(char *value, DB_ITEM *item, int parameter, int flag)
strscpy(table,"history");
}
zbx_snprintf(sql,sizeof(sql),"select value from %s where itemid=" ZBX_FS_UI64 " order by clock desc",
- table,item->itemid);
+ table,
+ item->itemid);
result = DBselectN(sql, parameter);
if(item->value_type == ITEM_VALUE_TYPE_UINT64)
{
@@ -299,7 +304,10 @@ static int evaluate_SUM(char *value, DB_ITEM *item, int parameter, int flag)
}
else
{
- zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]", flag, ZBX_FLAG_SEC, ZBX_FLAG_VALUES);
+ zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]",
+ flag,
+ ZBX_FLAG_SEC,
+ ZBX_FLAG_VALUES);
return FAIL;
}
@@ -398,7 +406,10 @@ static int evaluate_AVG(char *value,DB_ITEM *item,int parameter,int flag)
}
else
{
- zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]", flag, ZBX_FLAG_SEC, ZBX_FLAG_VALUES);
+ zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]",
+ flag,
+ ZBX_FLAG_SEC,
+ ZBX_FLAG_VALUES);
return FAIL;
}
@@ -460,7 +471,9 @@ static int evaluate_MIN(char *value,DB_ITEM *item,int parameter, int flag)
if(flag == ZBX_FLAG_SEC)
{
result = DBselect("select min(value) from %s where clock>%d and itemid=" ZBX_FS_UI64,
- table, now-parameter,item->itemid);
+ table,
+ now-parameter,
+ item->itemid);
row = DBfetch(result);
if(!row || DBis_null(row[0])==SUCCEED)
{
@@ -476,7 +489,8 @@ static int evaluate_MIN(char *value,DB_ITEM *item,int parameter, int flag)
else if(flag == ZBX_FLAG_VALUES)
{
zbx_snprintf(sql,sizeof(sql),"select value from %s where itemid=" ZBX_FS_UI64 " order by clock desc",
- table,item->itemid);
+ table,
+ item->itemid);
result = DBselectN(sql,parameter);
rows=0;
@@ -517,7 +531,10 @@ static int evaluate_MIN(char *value,DB_ITEM *item,int parameter, int flag)
}
else
{
- zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]", flag, ZBX_FLAG_SEC, ZBX_FLAG_VALUES);
+ zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]",
+ flag,
+ ZBX_FLAG_SEC,
+ ZBX_FLAG_VALUES);
return FAIL;
}
@@ -579,7 +596,9 @@ static int evaluate_MAX(char *value,DB_ITEM *item,int parameter,int flag)
strscpy(table,"history");
}
result = DBselect("select max(value) from %s where clock>%d and itemid=" ZBX_FS_UI64,
- table,now-parameter,item->itemid);
+ table,
+ now-parameter,
+ item->itemid);
row = DBfetch(result);
@@ -605,7 +624,8 @@ static int evaluate_MAX(char *value,DB_ITEM *item,int parameter,int flag)
strscpy(table,"history");
}
zbx_snprintf(sql,sizeof(sql),"select value from %s where itemid=" ZBX_FS_UI64 " order by clock desc",
- table,item->itemid);
+ table,
+ item->itemid);
result = DBselectN(sql,parameter);
rows=0;
while((row=DBfetch(result)))
@@ -644,7 +664,10 @@ static int evaluate_MAX(char *value,DB_ITEM *item,int parameter,int flag)
}
else
{
- zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]", flag, ZBX_FLAG_SEC, ZBX_FLAG_VALUES);
+ zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]",
+ flag,
+ ZBX_FLAG_SEC,
+ ZBX_FLAG_VALUES);
return FAIL;
}
@@ -696,7 +719,8 @@ static int evaluate_DELTA(char *value,DB_ITEM *item,int parameter, int flag)
if(flag == ZBX_FLAG_SEC)
{
result = DBselect("select max(value)-min(value) from history where clock>%d and itemid=" ZBX_FS_UI64,
- now-parameter,item->itemid);
+ now-parameter,
+ item->itemid);
row = DBfetch(result);
if(!row || DBis_null(row[0])==SUCCEED)
@@ -743,7 +767,10 @@ static int evaluate_DELTA(char *value,DB_ITEM *item,int parameter, int flag)
}
else
{
- zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]", flag, ZBX_FLAG_SEC, ZBX_FLAG_VALUES);
+ zabbix_log(LOG_LEVEL_WARNING, "Unknown flag [%d] Expected [%d] or [%d]",
+ flag,
+ ZBX_FLAG_SEC,
+ ZBX_FLAG_VALUES);
return FAIL;
}
@@ -821,7 +848,8 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
int day;
int len;
- zabbix_log( LOG_LEVEL_DEBUG, "In evaluate_function(%s)",function);
+ zabbix_log( LOG_LEVEL_DEBUG, "In evaluate_function(%s)",
+ function);
if(strcmp(function,"last")==0)
{
@@ -914,7 +942,10 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
{
now=time(NULL);
tm=localtime(&now);
- zbx_snprintf(value,MAX_STRING_LEN,"%.4d%.2d%.2d",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday);
+ zbx_snprintf(value,MAX_STRING_LEN,"%.4d%.2d%.2d",
+ tm->tm_year+1900,
+ tm->tm_mon+1,
+ tm->tm_mday);
}
else if(strcmp(function,"dayofweek")==0)
{
@@ -923,13 +954,17 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
/* The number of days since Sunday, in the range 0 to 6. */
day=tm->tm_wday;
if(0 == day) day=7;
- zbx_snprintf(value,MAX_STRING_LEN,"%d", day);
+ zbx_snprintf(value,MAX_STRING_LEN,"%d",
+ day);
}
else if(strcmp(function,"time")==0)
{
now=time(NULL);
tm=localtime(&now);
- zbx_snprintf(value,MAX_STRING_LEN,"%.2d%.2d%.2d",tm->tm_hour,tm->tm_min,tm->tm_sec);
+ zbx_snprintf(value,MAX_STRING_LEN,"%.2d%.2d%.2d",
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
}
else if(strcmp(function,"abschange")==0)
{
@@ -946,7 +981,8 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
del_zeroes(value);
break;
case ITEM_VALUE_TYPE_UINT64:
- zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_UI64, labs(item->lastvalue_uint64-item->prevvalue_uint64));
+ zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_UI64,
+ labs(item->lastvalue_uint64-item->prevvalue_uint64));
break;
default:
if(strcmp(item->lastvalue_str, item->prevvalue_str) == 0)
@@ -976,7 +1012,8 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
del_zeroes(value);
break;
case ITEM_VALUE_TYPE_UINT64:
- zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_UI64, item->lastvalue_uint64-item->prevvalue_uint64);
+ zbx_snprintf(value,MAX_STRING_LEN,ZBX_FS_UI64,
+ item->lastvalue_uint64-item->prevvalue_uint64);
break;
default:
if(strcmp(item->lastvalue_str, item->prevvalue_str) == 0)
@@ -1146,12 +1183,15 @@ int evaluate_function(char *value,DB_ITEM *item,char *function,char *parameter)
}
else
{
- zabbix_log( LOG_LEVEL_WARNING, "Unsupported function:%s",function);
- zabbix_syslog("Unsupported function:%s",function);
+ zabbix_log( LOG_LEVEL_WARNING, "Unsupported function:%s",
+ function);
+ zabbix_syslog("Unsupported function:%s",
+ function);
ret = FAIL;
}
- zabbix_log( LOG_LEVEL_DEBUG, "End of evaluate_function(result:%s)",value);
+ zabbix_log( LOG_LEVEL_DEBUG, "End of evaluate_function(result:%s)",
+ value);
return ret;
}
@@ -1179,7 +1219,8 @@ int add_value_suffix(char *value, DB_ITEM *item)
char suffix[MAX_STRING_LEN];
- zabbix_log( LOG_LEVEL_DEBUG, "In add_value_suffix() Value [%s]",value);
+ zabbix_log( LOG_LEVEL_DEBUG, "In add_value_suffix() Value [%s]",
+ value);
/* Add suffix: 1000000 -> 1 MB */
if(!(
@@ -1219,14 +1260,24 @@ int add_value_suffix(char *value, DB_ITEM *item)
/* if(cmp_double((double)round(value_double), value_double) == 0) */
if(cmp_double((int)(value_double+0.5), value_double) == 0)
{
- zbx_snprintf(value, MAX_STRING_LEN, ZBX_FS_DBL_EXT(0) " %s%s", value_double, suffix, item->units);
+ zbx_snprintf(value, MAX_STRING_LEN, ZBX_FS_DBL_EXT(0) " %s%s",
+ value_double,
+ suffix,
+ item->units);
}
else
{
- zbx_snprintf(value, MAX_STRING_LEN, ZBX_FS_DBL_EXT(2) " %s%s", value_double, suffix, item->units);
+ zbx_snprintf(value, MAX_STRING_LEN, ZBX_FS_DBL_EXT(2) " %s%s",
+ value_double,
+ suffix,
+ item->units);
}
- zabbix_log(LOG_LEVEL_DEBUG, "Value [%s] [" ZBX_FS_DBL "] Suffix [%s] Units [%s]",value,value_double,suffix,item->units);
+ zabbix_log(LOG_LEVEL_DEBUG, "Value [%s] [" ZBX_FS_DBL "] Suffix [%s] Units [%s]",
+ value,
+ value_double,
+ suffix,
+ item->units);
return SUCCEED;
}
@@ -1261,7 +1312,8 @@ int replace_value_by_map(char *value, zbx_uint64_t valuemapid)
if(valuemapid == 0) return FAIL;
result = DBselect("select newvalue from mappings where valuemapid=" ZBX_FS_UI64 " and value='%s'",
- valuemapid, value);
+ valuemapid,
+ value);
row = DBfetch(result);
if(!row || DBis_null(row[0])==SUCCEED) return FAIL;
@@ -1273,9 +1325,12 @@ int replace_value_by_map(char *value, zbx_uint64_t valuemapid)
or_value = sql; /* sql variarbvle used as tmp - original value */
zbx_strlcpy(sql,value,MAX_STRING_LEN);
- zbx_snprintf(value, MAX_STRING_LEN, "%s (%s)", new_value, or_value);
+ zbx_snprintf(value, MAX_STRING_LEN, "%s (%s)",
+ new_value,
+ or_value);
- zabbix_log(LOG_LEVEL_DEBUG, "Value: %s", value);
+ zabbix_log(LOG_LEVEL_DEBUG, "End replace_value_by_map(result:%s)",
+ value);
return SUCCEED;
}
@@ -1306,9 +1361,17 @@ int evaluate_function2(char *value,char *host,char *key,char *function,char *par
int res;
- zabbix_log(LOG_LEVEL_DEBUG, "In evaluate_function2(%s,%s,%s,%s)",host,key,function,parameter);
+ zabbix_log(LOG_LEVEL_DEBUG, "In evaluate_function2(%s,%s,%s,%s)",
+ host,
+ key,
+ function,
+ parameter);
- result = DBselect("select %s where h.host='%s' and h.hostid=i.hostid and i.key_='%s' and" ZBX_COND_NODEID, ZBX_SQL_ITEM_SELECT, host, key, LOCAL_NODE("h.hostid"));
+ result = DBselect("select %s where h.host='%s' and h.hostid=i.hostid and i.key_='%s' and" ZBX_COND_NODEID,
+ ZBX_SQL_ITEM_SELECT,
+ host,
+ key,
+ LOCAL_NODE("h.hostid"));
row = DBfetch(result);
@@ -1332,6 +1395,7 @@ int evaluate_function2(char *value,char *host,char *key,char *function,char *par
/* Cannot call DBfree_result until evaluate_FUNC */
DBfree_result(result);
- zabbix_log(LOG_LEVEL_DEBUG, "End evaluate_function2(result:%s)",value);
+ zabbix_log(LOG_LEVEL_DEBUG, "End evaluate_function2(result:%s)",
+ value);
return res;
}
diff --git a/src/zabbix_server/expression.c b/src/zabbix_server/expression.c
index b0563598..3f04b00d 100644
--- a/src/zabbix_server/expression.c
+++ b/src/zabbix_server/expression.c
@@ -124,7 +124,8 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
char first[MAX_STRING_LEN],second[MAX_STRING_LEN];
char *p;
- zabbix_log( LOG_LEVEL_DEBUG, "In evaluate_simple(%s)", exp);
+ zabbix_log( LOG_LEVEL_DEBUG, "In evaluate_simple(%s)",
+ exp);
/* Remove left and right spaces */
lrtrim_spaces(exp);
@@ -237,14 +238,18 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
strscpy( second, p);
if( evaluate_simple(&value1,first,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( evaluate_simple(&value2,second,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( value1 < value2 )
@@ -267,14 +272,18 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
strscpy( second, p);
if( evaluate_simple(&value1,first,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( evaluate_simple(&value2,second,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
*result=value1*value2;
@@ -289,21 +298,29 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
strscpy( second, p);
if( evaluate_simple(&value1,first,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( evaluate_simple(&value2,second,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if(cmp_double(value2,0) == 0)
{
- zbx_snprintf(error,maxerrlen,"Division by zero. Cannot evaluate expression [%s/%s]", first,second);
- zabbix_log(LOG_LEVEL_WARNING, "%s", error);
- zabbix_syslog("%s", error);
+ zbx_snprintf(error,maxerrlen,"Division by zero. Cannot evaluate expression [%s/%s]",
+ first,
+ second);
+ zabbix_log(LOG_LEVEL_WARNING, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
else
@@ -321,14 +338,18 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
strscpy( second, p);
if( evaluate_simple(&value1,first,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( evaluate_simple(&value2,second,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
*result=value1+value2;
@@ -343,14 +364,18 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
strscpy( second, p);
if( evaluate_simple(&value1,first,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( evaluate_simple(&value2,second,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
*result=value1-value2;
@@ -365,14 +390,18 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
strscpy( second, p);
if( evaluate_simple(&value1,first,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( evaluate_simple(&value2,second,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( cmp_double(value1,value2) ==0 )
@@ -394,14 +423,18 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
strscpy( second, p);
if( evaluate_simple(&value1,first,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( evaluate_simple(&value2,second,error,maxerrlen) == FAIL )
{
- zabbix_log(LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
if( cmp_double(value1,value2) != 0 )
@@ -416,9 +449,12 @@ int evaluate_simple(double *result,char *exp,char *error,int maxerrlen)
}
else
{
- zbx_snprintf(error,maxerrlen,"Format error or unsupported operator. Exp: [%s]", exp);
- zabbix_log(LOG_LEVEL_WARNING, "%s", error);
- zabbix_syslog("%s", error);
+ zbx_snprintf(error,maxerrlen,"Format error or unsupported operator. Exp: [%s]",
+ exp);
+ zabbix_log(LOG_LEVEL_WARNING, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
@@ -452,7 +488,8 @@ int evaluate(int *result, char *exp, char *error, int maxerrlen)
char c;
int t;
- zabbix_log(LOG_LEVEL_DEBUG, "In evaluate(%s)",exp);
+ zabbix_log(LOG_LEVEL_DEBUG, "In evaluate(%s)",
+ exp);
res = NULL;
@@ -472,9 +509,12 @@ int evaluate(int *result, char *exp, char *error, int maxerrlen)
}
if( l == -1 )
{
- zbx_snprintf(error, maxerrlen, "Cannot find left bracket [(]. Expression:[%s]", tmp);
- zabbix_log(LOG_LEVEL_WARNING, "%s", error);
- zabbix_syslog("%s", error);
+ zbx_snprintf(error, maxerrlen, "Cannot find left bracket [(]. Expression:[%s]",
+ tmp);
+ zabbix_log(LOG_LEVEL_WARNING, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
for(i=l+1;i<r;i++)
@@ -486,8 +526,10 @@ int evaluate(int *result, char *exp, char *error, int maxerrlen)
if( evaluate_simple( &value, simple, error, maxerrlen ) != SUCCEED )
{
/* Changed to LOG_LEVEL_DEBUG */
- zabbix_log( LOG_LEVEL_DEBUG, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log( LOG_LEVEL_DEBUG, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
@@ -496,7 +538,8 @@ int evaluate(int *result, char *exp, char *error, int maxerrlen)
res = zbx_strdcat(res, tmp);
tmp[l]=c;
- zbx_snprintf(value_str,MAX_STRING_LEN-1,"%lf",value);
+ zbx_snprintf(value_str,MAX_STRING_LEN-1,"%lf",
+ value);
res = zbx_strdcat(res, value_str);
res = zbx_strdcat(res, tmp+r+1);
@@ -507,13 +550,17 @@ int evaluate(int *result, char *exp, char *error, int maxerrlen)
}
if( evaluate_simple( &value, tmp, error, maxerrlen ) != SUCCEED )
{
- zabbix_log(LOG_LEVEL_WARNING, "%s", error);
- zabbix_syslog("%s", error);
+ zabbix_log(LOG_LEVEL_WARNING, "%s",
+ error);
+ zabbix_syslog("%s",
+ error);
return FAIL;
}
- zabbix_log(LOG_LEVEL_DEBUG, "End evaluate(result:%lf)",value);
*result=value;
+ zabbix_log(LOG_LEVEL_DEBUG, "End evaluate(result:%lf)",
+ value);
+
return SUCCEED;
}
@@ -584,7 +631,8 @@ void substitute_simple_macros(DB_EVENT *event, DB_ACTION *action, char **data, i
if(!data || !*data) return;
- zabbix_log(LOG_LEVEL_DEBUG, "In substitute_simple_macros (data:%s)",*data);
+ zabbix_log(LOG_LEVEL_DEBUG, "In substitute_simple_macros (data:%s)",
+ *data);
if('\0' == *data[0]) return;