summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-15 10:06:22 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-15 10:06:22 +0000
commit2bd2a0b597912994b44aaaba0d097549cbefd49c (patch)
treec557188a0ccff743418ed973b81becfa018770f6
parent4894534baa0876a46909fb4429093a2289a4d9ef (diff)
downloadzabbix-2bd2a0b597912994b44aaaba0d097549cbefd49c.tar.gz
zabbix-2bd2a0b597912994b44aaaba0d097549cbefd49c.tar.xz
zabbix-2bd2a0b597912994b44aaaba0d097549cbefd49c.zip
- finished WEB monitoring (Eugene)
- tested WEB monitoring (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@4137 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog1
-rw-r--r--frontends/php/chart3.php6
-rw-r--r--frontends/php/httpdetails.php30
-rw-r--r--frontends/php/httpmon.php16
-rw-r--r--frontends/php/include/classes/graph.inc.php8
-rw-r--r--frontends/php/include/defines.inc.php4
-rw-r--r--frontends/php/include/httptest.inc.php15
-rw-r--r--src/libs/zbxdbhigh/db.c8
-rw-r--r--src/zabbix_server/httppoller/httptest.c53
9 files changed, 94 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 9cb13aaa..279b9847 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Changes for 1.3.8:
+ - finished WEB monitoring (Eugene)
- changed type of httptest.lastfailedstep to integer (Alexei)
- added check for a list of status codes for WEB monitoring (Alexei)
- added acknowledge mangement for overview screen (Eugene)
diff --git a/frontends/php/chart3.php b/frontends/php/chart3.php
index 06261a5f..b5637aca 100644
--- a/frontends/php/chart3.php
+++ b/frontends/php/chart3.php
@@ -70,6 +70,8 @@ include_once "include/page_header.php";
$graph->SetHeader($host["host"].":".get_request("name",""));
+ unset($host, $denyed_hosts);
+
if(isset($_REQUEST["period"])) $graph->SetPeriod($_REQUEST["period"]);
if(isset($_REQUEST["from"])) $graph->SetFrom($_REQUEST["from"]);
if(isset($_REQUEST["stime"])) $graph->SetSTime($_REQUEST["stime"]);
@@ -84,7 +86,7 @@ include_once "include/page_header.php";
$graph->SetYAxisMin(get_request("yaxismin" ,0.00));
$graph->SetYAxisMax(get_request("yaxismax" ,100.00));
- foreach($items as $gitem)
+ foreach($items as $id => $gitem)
{
$graph->AddItem(
$gitem["itemid"],
@@ -95,6 +97,8 @@ include_once "include/page_header.php";
$gitem["type"],
$gitem["periods_cnt"]
);
+
+ unset($items[$id]);
}
$graph->Draw();
?>
diff --git a/frontends/php/httpdetails.php b/frontends/php/httpdetails.php
index 6be1fde3..3c1f1102 100644
--- a/frontends/php/httpdetails.php
+++ b/frontends/php/httpdetails.php
@@ -96,38 +96,45 @@ include_once "include/page_header.php";
$status['msg'] = S_OK_BIG;
$status['style'] = 'enabled';
- if($httptest_data['curstate'] > 0)
+ if( HTTPTEST_STATE_BUSY == $httptest_data['curstate'] )
{
- if($httptest_data['curstate'] == ($httpstep_data['no'] + 1))
+ if($httptest_data['curstep'] == ($httpstep_data['no']))
{
$status['msg'] = S_IN_PROGRESS;
$status['style'] = 'unknown';
$status['skip'] = true;
}
- elseif($httptest_data['curstate'] < ($httpstep_data['no'] + 1))
+ elseif($httptest_data['curstep'] < ($httpstep_data['no']))
{
$status['msg'] = S_UNKNOWN;
$status['style'] = 'unknown';
$status['skip'] = true;
}
}
- else
+ else if( HTTPTEST_STATE_IDLE == $httptest_data['curstate'] )
{
- if($httptest_data['lastfailedstep'] > 0)
+ if($httptest_data['lastfailedstep'] != 0)
{
- if($httptest_data['lastfailedstep'] == ($httpstep_data['no'] + 1))
+ if($httptest_data['lastfailedstep'] == ($httpstep_data['no']))
{
$status['msg'] = S_FAIL.' - '.S_ERROR.': '.$httptest_data['error'];
$status['style'] = 'disabled';
- $status['skip'] = true;
+ //$status['skip'] = true;
}
- else if($httptest_data['lastfailedstep'] < ($httpstep_data['no'] + 1))
+ else if($httptest_data['lastfailedstep'] < ($httpstep_data['no']))
{
$status['msg'] = S_UNKNOWN;
$status['style'] = 'unknown';
$status['skip'] = true;
}
}
+
+ }
+ else
+ {
+ $status['msg'] = S_UNKNOWN;
+ $status['style'] = 'unknown';
+ $status['skip'] = true;
}
$db_items = DBselect('select i.*, hi.type as httpitem_type from items i, httpstepitem hi '.
@@ -166,11 +173,16 @@ include_once "include/page_header.php";
$status['msg'] = S_OK_BIG;
$status['style'] = 'enabled';
- if($httptest_data['curstate'] > 0)
+ if( HTTPTEST_STATE_BUSY == $httptest_data['curstate'] )
{
$status['msg'] = S_IN_PROGRESS;
$status['style'] = 'unknown';
}
+ else if ( HTTPTEST_STATE_UNKNOWN == $httptest_data['curstate'] )
+ {
+ $status['msg'] = S_UNKNOWN;
+ $status['style'] = 'unknown';
+ }
else if($httptest_data['lastfailedstep'] > 0)
{
$status['msg'] = S_FAIL.' - '.S_ERROR.': '.$httptest_data['error'];
diff --git a/frontends/php/httpmon.php b/frontends/php/httpmon.php
index 35d87a01..d9c516a6 100644
--- a/frontends/php/httpmon.php
+++ b/frontends/php/httpmon.php
@@ -198,21 +198,21 @@ include_once "include/page_header.php";
else
$lastcheck = new CCol('-', 'center');
- if($httptest_data['curstate'] > 0)
+ if( HTTPTEST_STATE_BUSY == $httptest_data['curstate'] )
{
- $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['curstate'] - 1);
- $state = S_IN_CHECK.' "'.$step_data['name'].'" ['.$httptest_data['curstate'].' '.S_OF_SMALL.' '.$step_cout.']';
+ $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['curstep']);
+ $state = S_IN_CHECK.' "'.$step_data['name'].'" ['.$httptest_data['curstep'].' '.S_OF_SMALL.' '.$step_cout.']';
$status['msg'] = S_IN_PROGRESS;
$status['style'] = 'unknown';
}
- else
+ else if( HTTPTEST_STATE_IDLE == $httptest_data['curstate'] )
{
$state = S_IDLE_TILL." ".date(S_DATE_FORMAT_YMDHMS,$httptest_data['nextcheck']);
if($httptest_data['lastfailedstep'] > 0)
{
- $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['lastfailedstep'] - 1);
+ $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['lastfailedstep']);
$status['msg'] = S_FAILED_ON.' "'.$step_data['name'].'" '.
'['.$httptest_data['lastfailedstep'].' '.S_OF_SMALL.' '.$step_cout.'] '.
' '.S_ERROR.': '.$httptest_data['error'];
@@ -224,6 +224,12 @@ include_once "include/page_header.php";
$status['style'] = 'enabled';
}
}
+ else
+ {
+ $state = S_IDLE_TILL." ".date(S_DATE_FORMAT_YMDHMS,$httptest_data['nextcheck']);
+ $status['msg'] = S_UNKNOWN;
+ $status['style'] = 'unknown';
+ }
array_push($app_rows, new CRow(array(
$_REQUEST["hostid"] > 0 ? NULL : SPACE,
diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php
index 845be289..14d255fa 100644
--- a/frontends/php/include/classes/graph.inc.php
+++ b/frontends/php/include/classes/graph.inc.php
@@ -239,7 +239,7 @@
function ShowTriggers($value)
{
- $this->m_showTriggers = $value == 1 ? 1 : 0;;
+ $this->m_showTriggers = $value == 1 ? 1 : 0;
}
function AddItem($itemid, $axis=GRAPH_YAXIS_SIDE_RIGHT, $calc_fnc=CALC_FNC_AVG,
@@ -306,6 +306,7 @@
{
// Avoid sizeX==0, to prevent division by zero later
if($value <= 0) $value = NULL;
+ if($value > 1300) $value = 1300;
if(is_null($value)) $value = 900;
$this->sizeX = $value;
@@ -1218,7 +1219,7 @@
$this->fullSizeX = $this->sizeX+$this->shiftXleft+$this->shiftXright+1;
$this->fullSizeY = $this->sizeY+$this->shiftY+62+12*($this->num+ (($this->sizeY < 120) ? 0 : count($this->triggers)))+8;
-
+
if(function_exists("ImageColorExactAlpha")&&function_exists("ImageCreateTrueColor")&&@imagecreatetruecolor(1,1))
$this->im = ImageCreateTrueColor($this->fullSizeX,$this->fullSizeY);
else
@@ -1324,8 +1325,9 @@
$str=sprintf("%0.2f",($end_time-$start_time));
ImageString($this->im, 0,$this->fullSizeX-120,$this->fullSizeY-12,"Generated in $str sec", $this->GetColor("Gray"));
+ unset($this->items, $this->data);
+
ImageOut($this->im);
- ImageDestroy($this->im);
}
}
?>
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index 3ddd3850..87c02f65 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -334,6 +334,10 @@
define('HTTPTEST_STATUS_ACTIVE', 0);
define('HTTPTEST_STATUS_DISABLED', 1);
+ define('HTTPTEST_STATE_IDLE', 0);
+ define('HTTPTEST_STATE_BUSY', 1);
+ define('HTTPTEST_STATE_UNKNOWN',3);
+
define('HTTPSTEP_ITEM_TYPE_RSPCODE', 0);
define('HTTPSTEP_ITEM_TYPE_TIME', 1);
define('HTTPSTEP_ITEM_TYPE_IN', 2);
diff --git a/frontends/php/include/httptest.inc.php b/frontends/php/include/httptest.inc.php
index 409d992a..2c03a4cf 100644
--- a/frontends/php/include/httptest.inc.php
+++ b/frontends/php/include/httptest.inc.php
@@ -47,6 +47,12 @@
function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required, $status_codes, $delay, $history, $trends)
{
+ if( $no <= 0 )
+ {
+ error('Scenario step number can\'t be less then 1');
+ return false;
+ }
+
if (!eregi('^([0-9a-zA-Z\_\.[.-.]\$ ]+)$', $name))
{
error("Scenario step name should contain '0-9a-zA-Z_ .$'- characters only");
@@ -175,7 +181,8 @@
{
$result = DBexecute('update httptest set '.
' applicationid='.$applicationid.', name='.zbx_dbstr($name).', delay='.$delay.','.
- ' status='.$status.', agent='.zbx_dbstr($agent).', macros='.zbx_dbstr($macros).
+ ' status='.$status.', agent='.zbx_dbstr($agent).', macros='.zbx_dbstr($macros).','.
+ ' error='.zbx_dbstr('').', curstate='.HTTPTEST_STATE_UNKNOWN.
' where httptestid='.$httptestid);
}
else
@@ -190,9 +197,9 @@
}
$result = DBexecute('insert into httptest'.
- ' (httptestid, applicationid, name, delay, status, agent, macros) '.
+ ' (httptestid, applicationid, name, delay, status, agent, macros, curstate) '.
' values ('.$httptestid.','.$applicationid.','.zbx_dbstr($name).','.
- $delay.','.$status.','.zbx_dbstr($agent).','.zbx_dbstr($macros).')'
+ $delay.','.$status.','.zbx_dbstr($agent).','.zbx_dbstr($macros).','.HTTPTEST_STATE_UNKNOWN.')'
);
$test_added = true;
@@ -211,7 +218,7 @@
if(!isset($s['status_codes'])) $s['status_codes'] = '';
$result = db_save_step($hostid, $applicationid, $httptestid,
- $name, $s['name'], $sid, $s['timeout'], $s['url'], $s['posts'], $s['required'],$s['status_codes'],
+ $name, $s['name'], $sid+1, $s['timeout'], $s['url'], $s['posts'], $s['required'],$s['status_codes'],
$delay, $history, $trends);
if(!$result) break;
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 5cc1a6b9..26bcf90d 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -1422,13 +1422,10 @@ char* DBdyn_escape_string(const char *str)
char *str_esc = NULL;
int str_esc_len;
-
- assert(str);
-
- str_esc_len = strlen(str)+1;
- for(i=0; str[i]; i++)
+ for(i=0; str && str[i]; i++)
{
+ str_esc_len++;
if( ( str[i] == '\'' )
#ifndef HAVE_ORACLE
|| ( str[i] == '\\' )
@@ -1438,6 +1435,7 @@ char* DBdyn_escape_string(const char *str)
str_esc_len++;
}
}
+ str_esc_len++;
str_esc = zbx_malloc(str_esc_len);
diff --git a/src/zabbix_server/httppoller/httptest.c b/src/zabbix_server/httppoller/httptest.c
index cc786d55..c6d0b023 100644
--- a/src/zabbix_server/httppoller/httptest.c
+++ b/src/zabbix_server/httppoller/httptest.c
@@ -270,6 +270,7 @@ static void process_httptest(DB_HTTPTEST *httptest)
DB_ROW row;
DB_HTTPSTEP httpstep;
int err;
+ char *err_str = NULL, *esc_err_str = NULL;
int now;
int lastfailedstep;
@@ -366,6 +367,7 @@ static void process_httptest(DB_HTTPTEST *httptest)
{
zabbix_log(LOG_LEVEL_ERR, "Cannot set POST vars [%s]",
curl_easy_strerror(err));
+ err_str = strdup(curl_easy_strerror(err));
lastfailedstep = httpstep.no;
}
}
@@ -375,6 +377,7 @@ static void process_httptest(DB_HTTPTEST *httptest)
{
zabbix_log(LOG_LEVEL_ERR, "Cannot set URL [%s]",
curl_easy_strerror(err));
+ err_str = strdup(curl_easy_strerror(err));
lastfailedstep = httpstep.no;
}
}
@@ -392,6 +395,7 @@ static void process_httptest(DB_HTTPTEST *httptest)
{
zabbix_log(LOG_LEVEL_ERR, "Error doing curl_easy_perform [%s]",
curl_easy_strerror(err));
+ err_str = strdup(curl_easy_strerror(err));
lastfailedstep = httpstep.no;
}
else
@@ -399,60 +403,69 @@ static void process_httptest(DB_HTTPTEST *httptest)
if(zbx_regexp_match(page.data,httpstep.required,NULL) == NULL)
{
zabbix_log(LOG_LEVEL_DEBUG, "Page didn't match [%s]", httpstep.required);
+ err_str = strdup("Page didn't match");
lastfailedstep = httpstep.no;
}
}
free(page.data);
- }
- if(0 == lastfailedstep)
- {
- if(CURLE_OK != (err = curl_easy_getinfo(easyhandle,CURLINFO_RESPONSE_CODE ,&stat.rspcode)))
- {
- zabbix_log(LOG_LEVEL_ERR, "Error getting CURLINFO_RESPONSE_CODE [%s]",
- curl_easy_strerror(err));
- lastfailedstep = httpstep.no;
- }
- else if(httpstep.status_codes[0]!='\0' && (int_in_list(httpstep.status_codes,stat.rspcode) == FAIL))
+ if( !err_str )
{
- lastfailedstep = httpstep.no;
+ if(CURLE_OK != (err = curl_easy_getinfo(easyhandle,CURLINFO_RESPONSE_CODE ,&stat.rspcode)))
+ {
+ zabbix_log(LOG_LEVEL_ERR, "Error getting CURLINFO_RESPONSE_CODE [%s]",
+ curl_easy_strerror(err));
+ err_str = strdup(curl_easy_strerror(err));
+ lastfailedstep = httpstep.no;
+ }
+ else if(httpstep.status_codes[0]!='\0' && (int_in_list(httpstep.status_codes,stat.rspcode) == FAIL))
+ {
+ zabbix_log(LOG_LEVEL_DEBUG, "Status code didn't match [%s]", httpstep.status_codes);
+ err_str = strdup("Status code didn't match");
+ lastfailedstep = httpstep.no;
+ }
}
- }
- if(0 == lastfailedstep)
- {
- if(CURLE_OK != (err = curl_easy_getinfo(easyhandle,CURLINFO_TOTAL_TIME ,&stat.total_time)))
+ if( !err_str && CURLE_OK != (err = curl_easy_getinfo(easyhandle,CURLINFO_TOTAL_TIME ,&stat.total_time)))
{
zabbix_log(LOG_LEVEL_ERR, "Error getting CURLINFO_TOTAL_TIME [%s]",
curl_easy_strerror(err));
+ err_str = strdup(curl_easy_strerror(err));
lastfailedstep = httpstep.no;
}
- }
- if(0 == lastfailedstep)
- {
- if(CURLE_OK != (err = curl_easy_getinfo(easyhandle,CURLINFO_SPEED_DOWNLOAD ,&stat.speed_download)))
+ if( !err_str && CURLE_OK != (err = curl_easy_getinfo(easyhandle,CURLINFO_SPEED_DOWNLOAD ,&stat.speed_download)))
{
zabbix_log(LOG_LEVEL_ERR, "Error getting CURLINFO_SPEED_DOWNLOAD [%s]",
curl_easy_strerror(err));
+ err_str = strdup(curl_easy_strerror(err));
lastfailedstep = httpstep.no;
}
}
+
httptest->time+=stat.total_time;
process_step_data(httptest, &httpstep, &stat);
}
DBfree_result(result);
+ esc_err_str = DBdyn_escape_string(err_str);
+ zbx_free(err_str);
+
(void)curl_easy_cleanup(easyhandle);
- DBexecute("update httptest set curstep=0,curstate=%d,nextcheck=%d+delay,lastfailedstep=%d,time=" ZBX_FS_DBL " where httptestid=" ZBX_FS_UI64,
+ DBexecute("update httptest set curstep=0,curstate=%d,lastcheck=%d,nextcheck=%d+delay,lastfailedstep=%d,"
+ "time=" ZBX_FS_DBL ",error='%s' where httptestid=" ZBX_FS_UI64,
HTTPTEST_STATE_IDLE,
now,
+ now,
lastfailedstep,
httptest->time,
+ esc_err_str,
httptest->httptestid);
+ zbx_free(esc_err_str);
+
stat.test_total_time = httptest->time;
stat.test_last_step = lastfailedstep;