summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--frontends/php/include/config.inc2
-rw-r--r--include/expression.c36
-rw-r--r--include/functions.c3
-rw-r--r--src/zabbix_trapper/zabbix_trapperd.c22
5 files changed, 52 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index ef01a1dd..b490c7cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
Changes for 1.0alpha12:
- - more changes in timeout handling (Alexei)
+ - added support for opertor '=' (Alexei)
+ - changes in timeout handling for zabbix_trapperd (Alexei)
+
- changes in doc/manual.lyx (Alexei)
- doc/manual.lyx created (Alexei)
- no SA_RESTART flag for sigaction() (Alexei)
diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc
index 74abdf93..5278dea9 100644
--- a/frontends/php/include/config.inc
+++ b/frontends/php/include/config.inc
@@ -128,7 +128,7 @@
// Replace all float sign float with 0
// echo "Expression:$expression<br>";
$arr="";
- if (eregi('^((.)*)([0-9\.]+)([\&\|\>\<]{1})([0-9\.]+)((.)*)$', $expression, &$arr))
+ if (eregi('^((.)*)([0-9\.]+)([\&\|\>\<\=]{1})([0-9\.]+)((.)*)$', $expression, &$arr))
{
// echo "OK<br>";
// for($i=0;$i<50;$i++)
diff --git a/include/expression.c b/include/expression.c
index 18ff854e..5ce29735 100644
--- a/include/expression.c
+++ b/include/expression.c
@@ -129,6 +129,7 @@ int evaluate_simple (float *result,char *exp)
j++;
}
second[j]=0;
+ syslog(LOG_DEBUG, "[%s] [%s]",first,second );
if( evaluate_simple(&value1,first) == FAIL )
{
syslog(LOG_WARNING, "Cannot evaluate expression [%s]", first );
@@ -195,6 +196,7 @@ int evaluate_simple (float *result,char *exp)
j++;
}
second[j]=0;
+ syslog(LOG_DEBUG, "[%s] [%s]",first,second );
if( evaluate_simple(&value1,first) == FAIL )
{
syslog(LOG_WARNING, "Cannot evaluate expression [%s]", first );
@@ -213,6 +215,40 @@ int evaluate_simple (float *result,char *exp)
{
*result=0;
}
+ syslog(LOG_DEBUG, "Result [%f]",*result );
+ return SUCCEED;
+ }
+ else if( find_char(exp,'=') != FAIL )
+ {
+ syslog(LOG_DEBUG, "= is found" );
+ l=find_char(exp,'=');
+ strcpy(first, exp);
+ first[l]=0;
+ j=0;
+ for(i=l+1;i<strlen(exp);i++)
+ {
+ second[j]=exp[i];
+ j++;
+ }
+ second[j]=0;
+ if( evaluate_simple(&value1,first) == FAIL )
+ {
+ syslog(LOG_WARNING, "Cannot evaluate expression [%s]", first );
+ return FAIL;
+ }
+ if( evaluate_simple(&value2,second) == FAIL )
+ {
+ syslog(LOG_WARNING, "Cannot evaluate expression [%s]", second );
+ return FAIL;
+ }
+ if( cmp_double(value1,value2) ==0 )
+ {
+ *result=1;
+ }
+ else
+ {
+ *result=0;
+ }
return SUCCEED;
}
else
diff --git a/include/functions.c b/include/functions.c
index 28689154..a001a8a9 100644
--- a/include/functions.c
+++ b/include/functions.c
@@ -309,7 +309,8 @@ void update_functions( DB_ITEM *item )
syslog( LOG_DEBUG, "Result:%f\n",value);
if (ret == SUCCEED)
{
- if((function.lastvalue_null == 1)||(cmp_double(function.lastvalue,value)==1))
+// Commented. Otherwise, if we have more than 1 function to update, only one function being updated. Wrong !
+ // if((function.lastvalue_null == 1)||(cmp_double(function.lastvalue,value)==1))
{
sprintf(c,"update functions set lastvalue=%f where itemid=%d and function='%s' and parameter=%d", value, function.itemid, function.function, function.parameter );
DBexecute(c);
diff --git a/src/zabbix_trapper/zabbix_trapperd.c b/src/zabbix_trapper/zabbix_trapperd.c
index 01d38cef..d4036767 100644
--- a/src/zabbix_trapper/zabbix_trapperd.c
+++ b/src/zabbix_trapper/zabbix_trapperd.c
@@ -118,28 +118,26 @@ void process_child(int sockfd)
char result[1024];
static struct sigaction phan;
- daemon_init();
-
phan.sa_handler = &signal_handler;
sigemptyset(&phan.sa_mask);
phan.sa_flags = 0;
- sigaction(SIGINT, &phan, NULL);
- sigaction(SIGQUIT, &phan, NULL);
- sigaction(SIGTERM, &phan, NULL);
-
- signal( SIGINT, signal_handler );
- signal( SIGQUIT, signal_handler );
- signal( SIGTERM, signal_handler );
-// signal( SIGALRM, signal_handler );
+ sigaction(SIGALRM, &phan, NULL);
// for(;;)
// {
// sigfunc = signal( SIGALRM, signal_handler );
- alarm(AGENT_TIMEOUT);
+ alarm(TRAPPER_TIMEOUT);
if( (nread = read(sockfd, line, 1024)) < 0)
{
- syslog( LOG_DEBUG, "Sending back:%s", result);
+ if(errno == EINTR)
+ {
+ syslog( LOG_DEBUG, "Timeout while waiting for parameter");
+ }
+ else
+ {
+ syslog( LOG_DEBUG, "read() error");
+ }
return;
}