From a8f1a4240dceea50b0907f5ca98f958c7c3d859c Mon Sep 17 00:00:00 2001 From: hugetoad Date: Thu, 28 Apr 2005 11:28:03 +0000 Subject: More support for active checks. git-svn-id: svn://svn.zabbix.com/trunk@1728 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- include/functions.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ include/functions.h | 1 + src/zabbix_server/trapper.c | 36 +++++++++++++++++++++------------- 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/include/functions.c b/include/functions.c index f5652122..459c2ace 100644 --- a/include/functions.c +++ b/include/functions.c @@ -2202,6 +2202,54 @@ int get_lastvalue(char *value,char *host,char *key,char *function,char *paramete return res; } +/* For zabbix_trapper(d) */ +int send_list_of_active_checks(int sockfd) +{ + char sql[MAX_STRING_LEN]; + char s[MAX_STRING_LEN]; + + zabbix_log( LOG_LEVEL_DEBUG, "In send_list_of_active_checks()"); + + snprintf(sql,sizeof(sql)-1,"select i.key_,i.delay from items i,hosts h where i.hostid=h.hostid and h.status=%d and i.status=%d and i.type=%d", HOST_STATUS_MONITORED, ITEM_STATUS_ACTIVE, ITEM_TYPE_ACTIVE_CHECK); + + result = DBselect(sql); + + for(i=0;is && ( *p=='\r' || *p =='\n' || *p == ' ' ); --p ); p[1]=0; - server=(char *)strtok(s,":"); - if(NULL == server) +/* Request for list of active checks */ + if(strcmp(s,"ZBX_GET_ACTIVE_CHECKS") == 0) { - return FAIL; + ret=send_list_of_active_check(sockfd); } - - key=(char *)strtok(NULL,":"); - if(NULL == key) +/* Process information sent by zabbix_sender */ + else { - return FAIL; - } + server=(char *)strtok(s,":"); + if(NULL == server) + { + return FAIL; + } - value_string=(char *)strtok(NULL,":"); - if(NULL == value_string) - { - return FAIL; - } + key=(char *)strtok(NULL,":"); + if(NULL == key) + { + return FAIL; + } - ret=process_data(sockfd,server,key,value_string); + value_string=(char *)strtok(NULL,":"); + if(NULL == value_string) + { + return FAIL; + } + ret=process_data(sockfd,server,key,value_string); + } return ret; } -- cgit