summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-12 12:38:10 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-12 12:38:10 +0000
commit136972cd16e5afe6078313d5b67d85e16e3d0e06 (patch)
tree8c5ac07ccb1a20eef92f1d4774f042eea7879122 /src
parent928871adddbb7f7db0aa1fd0b6809fc1070cadb2 (diff)
downloadzabbix-136972cd16e5afe6078313d5b67d85e16e3d0e06.tar.gz
zabbix-136972cd16e5afe6078313d5b67d85e16e3d0e06.tar.xz
zabbix-136972cd16e5afe6078313d5b67d85e16e3d0e06.zip
Added support for required string in WEB monitoring
git-svn-id: svn://svn.zabbix.com/trunk@3697 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/zabbix_server/httppoller/httptest.c32
-rw-r--r--src/zabbix_server/httppoller/httptest.h8
2 files changed, 38 insertions, 2 deletions
diff --git a/src/zabbix_server/httppoller/httptest.c b/src/zabbix_server/httppoller/httptest.c
index db7e999f..7b42269a 100644
--- a/src/zabbix_server/httppoller/httptest.c
+++ b/src/zabbix_server/httppoller/httptest.c
@@ -30,6 +30,8 @@
#include "httpmacro.h"
#include "httptest.h"
+S_ZBX_HTTPPAGE page;
+
/******************************************************************************
* *
* Function: process_value *
@@ -87,6 +89,16 @@ static size_t WRITEFUNCTION2( void *ptr, size_t size, size_t nmemb, void *stream
zabbix_log(LOG_LEVEL_WARNING, "In WRITEFUNCTION");
*/
+ /* First piece of data */
+ if(page.data == NULL)
+ {
+ page.allocated=8096;
+ page.offset=0;
+ page.data=malloc(page.allocated);
+ }
+
+ zbx_snprintf_alloc(&page.data, &page.allocated, &page.offset, 8096, ptr);
+
return size*nmemb;
}
@@ -234,7 +246,7 @@ static int process_httptest(DB_HTTPTEST *httptest)
return FAIL;
}
- result = DBselect("select httpstepid,httptestid,no,name,url,timeout,posts from httpstep where httptestid=" ZBX_FS_UI64 " order by no",
+ result = DBselect("select httpstepid,httptestid,no,name,url,timeout,posts,required from httpstep where httptestid=" ZBX_FS_UI64 " order by no",
httptest->httptestid);
while((row=DBfetch(result)))
{
@@ -245,6 +257,8 @@ static int process_httptest(DB_HTTPTEST *httptest)
strscpy(httpstep.url,row[4]);
httpstep.timeout=atoi(row[5]);
strscpy(httpstep.posts,row[6]);
+ strscpy(httpstep.required,row[7]);
+
memset(&stat,0,sizeof(stat));
/* Substitute macros */
@@ -272,12 +286,28 @@ static int process_httptest(DB_HTTPTEST *httptest)
ret = FAIL;
break;
}*/
+
+ memset(&page, 0, sizeof(page));
if(CURLE_OK != (err = curl_easy_perform(easyhandle)))
{
zabbix_log(LOG_LEVEL_ERR, "Error doing curl_easy_perform [%s]", curl_easy_strerror(err));
ret = FAIL;
break;
}
+zabbix_log(LOG_LEVEL_ERR, "Got %d bytes", strlen(page.data));
+
+ if(zbx_regexp_match(page.data,httpstep.required,NULL) != NULL)
+ {
+zabbix_log(LOG_LEVEL_ERR, "Page matched [%s]", httpstep.required);
+ }
+ else
+ {
+zabbix_log(LOG_LEVEL_ERR, "Page didn't match [%s]", httpstep.required);
+ }
+
+ free(page.data);
+
+
if(CURLE_OK != (err = curl_easy_getinfo(easyhandle,CURLINFO_RESPONSE_CODE ,&stat.rspcode)))
{
zabbix_log(LOG_LEVEL_ERR, "Error doing curl_easy_perform [%s]", curl_easy_strerror(err));
diff --git a/src/zabbix_server/httppoller/httptest.h b/src/zabbix_server/httppoller/httptest.h
index faef2097..dc167f3b 100644
--- a/src/zabbix_server/httppoller/httptest.h
+++ b/src/zabbix_server/httppoller/httptest.h
@@ -20,9 +20,15 @@
#ifndef ZABBIX_HTTPTEST_H
#define ZABBIX_HTTPTEST_H
+#define S_ZBX_HTTPPAGE struct s_zbx_httppage_t
+S_ZBX_HTTPPAGE
+{
+ char *data;
+ int allocated;
+ int offset;
+};
#define S_ZBX_HTTPSTAT struct s_zbx_httpstat_t
-
S_ZBX_HTTPSTAT
{
long rspcode;