summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-01-23 13:08:27 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-01-23 13:08:27 +0000
commit29e58eff62e7df4e9d25f2c217bc2a5e9ffc1f6e (patch)
tree7692207839c52a3f5ac3abc4952980d1865c55c1 /include
parent82eae21f70bade28aacd15473cc5b2c2faa36456 (diff)
downloadzabbix-29e58eff62e7df4e9d25f2c217bc2a5e9ffc1f6e.tar.gz
zabbix-29e58eff62e7df4e9d25f2c217bc2a5e9ffc1f6e.tar.xz
zabbix-29e58eff62e7df4e9d25f2c217bc2a5e9ffc1f6e.zip
- added support of functiona dayofweek() for triggers (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1620 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include')
-rw-r--r--include/functions.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/functions.c b/include/functions.c
index bb53319c..541eec5e 100644
--- a/include/functions.c
+++ b/include/functions.c
@@ -544,6 +544,8 @@ int evaluate_FUNCTION_thread(MYSQL *database, char *value,DB_ITEM *item,char *fu
float value_float_abs;
char suffix[MAX_STRING_LEN];
+ int day;
+
zabbix_log( LOG_LEVEL_DEBUG, "Function [%s]",function);
if(strcmp(function,"last")==0)
@@ -623,6 +625,15 @@ int evaluate_FUNCTION_thread(MYSQL *database, char *value,DB_ITEM *item,char *fu
tm=localtime(&now);
snprintf(value,MAX_STRING_LEN-1,"%.4d%.2d%.2d",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday);
}
+ else if(strcmp(function,"dayofweek")==0)
+ {
+ now=time(NULL);
+ tm=localtime(&now);
+ /* The number of days since Sunday, in the range 0 to 6. */
+ day=tm->tm_wday;
+ if(0 == day) day=7;
+ snprintf(value,MAX_STRING_LEN-1,"%d", day);
+ }
else if(strcmp(function,"time")==0)
{
now=time(NULL);
@@ -805,6 +816,8 @@ int evaluate_FUNCTION(char *value,DB_ITEM *item,char *function,char *parameter,
float value_float_abs;
char suffix[MAX_STRING_LEN];
+ int day;
+
zabbix_log( LOG_LEVEL_DEBUG, "In evaluate_FUNCTION() Function [%s] flag [%d]",function,flag);
if(strcmp(function,"last")==0)
@@ -884,6 +897,15 @@ int evaluate_FUNCTION(char *value,DB_ITEM *item,char *function,char *parameter,
tm=localtime(&now);
snprintf(value,MAX_STRING_LEN-1,"%.4d%.2d%.2d",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday);
}
+ else if(strcmp(function,"dayofweek")==0)
+ {
+ now=time(NULL);
+ tm=localtime(&now);
+ /* The number of days since Sunday, in the range 0 to 6. */
+ day=tm->tm_wday;
+ if(0 == day) day=7;
+ snprintf(value,MAX_STRING_LEN-1,"%d", day);
+ }
else if(strcmp(function,"time")==0)
{
now=time(NULL);