summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-04-28 11:28:03 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-04-28 11:28:03 +0000
commita8f1a4240dceea50b0907f5ca98f958c7c3d859c (patch)
treed645f3f156f4475130e012a4620985c165685f74
parentd69fc9eff62bb96509f6cb4438776ed0880891a7 (diff)
downloadzabbix-a8f1a4240dceea50b0907f5ca98f958c7c3d859c.tar.gz
zabbix-a8f1a4240dceea50b0907f5ca98f958c7c3d859c.tar.xz
zabbix-a8f1a4240dceea50b0907f5ca98f958c7c3d859c.zip
More support for active checks.
git-svn-id: svn://svn.zabbix.com/trunk@1728 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--include/functions.c48
-rw-r--r--include/functions.h1
-rw-r--r--src/zabbix_server/trapper.c36
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
@@ -2203,6 +2203,54 @@ int get_lastvalue(char *value,char *host,char *key,char *function,char *paramete
}
/* 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;i<DBnum_rows(result);i++)
+ {
+ snprintf(s,sizeof(s)-1,"%s:%s\n",DBget_field(result,i,0),DBget_field(result,i,1));
+ if( write(s,c,strlen(c)) == -1 )
+ {
+ switch (errno)
+ {
+ case EINTR:
+ zabbix_log( LOG_LEVEL_WARNING, "Timeout while sending data to [%s]",server );
+ break;
+ default:
+ zabbix_log( LOG_LEVEL_WARNING, "Error while sending data to [%s] [%s]",server, strerror(errno));
+ }
+ close(s);
+ return FAIL;
+ }
+ }
+ DBfree_result(result);
+
+ snprintf(s,sizeof(s)-1,"%s\n","ZBX_EOF");
+ if( write(s,c,strlen(c)) == -1 )
+ {
+ switch (errno)
+ {
+ case EINTR:
+ zabbix_log( LOG_LEVEL_WARNING, "Timeout while sending data to [%s]",server );
+ break;
+ default:
+ zabbix_log( LOG_LEVEL_WARNING, "Error while sending data to [%s] [%s]",server, strerror(errno));
+ }
+ close(s);
+ return FAIL;
+ }
+ return SUCCEED;
+}
+
+/* For zabbix_trapper(d) */
/* int process_data(char *server,char *key, double value)*/
int process_data(int sockfd,char *server,char *key,char *value)
{
diff --git a/include/functions.h b/include/functions.h
index deb2afd5..0c7d3d37 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -31,6 +31,7 @@ void update_triggers (int itemid);
int get_lastvalue(char *value,char *host,char *key,char *function,char *parameter);
int process_data(int sockfd,char *server,char *key, char *value);
void process_new_value(DB_ITEM *item,char *value);
+int send_list_of_active_checks(int sockfd);
#ifdef ZABBIX_THREADS
void update_triggers_thread(MYSQL *database, int itemid);
diff --git a/src/zabbix_server/trapper.c b/src/zabbix_server/trapper.c
index 463ef4c3..d3b56bf7 100644
--- a/src/zabbix_server/trapper.c
+++ b/src/zabbix_server/trapper.c
@@ -65,26 +65,34 @@ int process_trap(int sockfd,char *s)
for( p=s+strlen(s)-1; p>s && ( *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;
}