zabbix-serverのTimeoutについて
スクリプトによる外部チェックを行っています。
スクリプト内で30秒応答がなかったらタイムアウトメッセージを出力するようにしています。
zabbix_server.confのTimeoutは30秒に設定しています。
# Specifies how long we wait for agent response (in sec)
# Must be between 1 and 30
Timeout=30
監視をしていると「returned nothing.」というログが出て、監視値を取得できていません。
おそらく、スクリプトのタイムアウトよりzabbix-serverのタイムアウトの方が先に来てしまう為だと思います。
zabbix_server.confのTImeoutを30秒より長く設定したいのですが、それではzabbix_serverが起動できません。
この場合、どうしたらよいでしょうか?
KAZ - 投稿数: 1085
peyonさん
この値は30が上限ですのでそれ以上は設定できない様になってます。
※:設定できたとしてもプログラム中で30以上は30になるようになってます。
ちなみに、Zabbixのバージョンは何でしょうか?
peyon - 投稿数: 38
ありがとうございます。
Zabbixのバージョンは1.6.8です。
KAZ - 投稿数: 1085
peyonさん
zabbix_server.confのTimeoutは「接続タイムアウト」かと。
「実行待ちタイムアウト」ではないような…
下記のソースがスクリプトを実行している個所と思われます。
zabbix-1.6.8\src\zabbix_server\poller\checks_external.c
popen(でコマンド実行)の後、直ぐにfgetsして結果を取ってます。
zabbix_server.confのTimeoutを使って待っている様な処理はなさそうです。
<code>
/*
** ZABBIX
** Copyright (C) 2000-2005 SIA Zabbix
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#include "common.h"
#include "log.h"
#include "checks_external.h"
/******************************************************************************
* *
* Function: get_value_external *
* *
* Purpose: retrieve data from script executed on ZABBIX server *
* *
* Parameters: item - item we are interested in *
* *
* Return value: SUCCEED - data succesfully retrieved and stored in result *
* and result_str (as string) *
* NOTSUPPORTED - requested item is not supported *
* *
* Author: Mike Nestor *
* *
* Comments: *
* *
************************************************** ****************************/
int get_value_external(DB_ITEM *item, AGENT_RESULT *result)
{
FILE* fp;
char scriptname[MAX_STRING_LEN];
char key[MAX_STRING_LEN];
char params[MAX_STRING_LEN];
char cmd[MAX_STRING_LEN];
char msg[MAX_STRING_LEN];
char *p,*p2;
int i;
int ret = SUCCEED;
zabbix_log( LOG_LEVEL_DEBUG, "In get_value_external([%s])",item->key);
init_result(result);
strscpy(key, item->key);
if((p2=strchr(key,'[')) != NULL)
{
*p2=0;
strscpy(scriptname,key);
zabbix_log( LOG_LEVEL_DEBUG, "scriptname [%s]",scriptname);
*p2='[';
p2++;
}
else ret = NOTSUPPORTED;
if(ret == SUCCEED)
{
if((ret == SUCCEED) && (p=strchr(p2,']')) != NULL)
{
*p=0;
strscpy(params,p2);
zabbix_log( LOG_LEVEL_DEBUG, "params [%s]",params);
*p=']';
p++;
}
else ret = NOTSUPPORTED;
}
if (ret == NOTSUPPORTED)
{
SET_MSG_RESULT(result, strdup("External check is not supported"));
return NOTSUPPORTED;
}
zbx_snprintf(cmd, MAX_STRING_LEN-1, "%s/%s %s %s",
CONFIG_EXTERNALSCRIPTS,
scriptname,
/* item->host_name,*/
item->useip == 1 ? item->host_ip : item->host_dns,
params);
zabbix_log( LOG_LEVEL_DEBUG, "%s", cmd );
if (NULL == (fp = popen(cmd, "r")))
{
SET_MSG_RESULT(result, strdup("External check is not supported, failed execution"));
return NOTSUPPORTED;
}
/* we only care about the first line */
memset(msg,0,sizeof(msg));
if(NULL != fgets(msg, sizeof(msg)-1, fp))
{
for (i = 0; i < MAX_STRING_LEN && msg[i] != 0; ++i)
{
if (msg[i] == '\n')
{
msg[i] = 0;
break;
}
}
zabbix_log( LOG_LEVEL_DEBUG, "Result [%s]", msg);
if (SUCCEED != set_result_type(result, item->value_type, msg))
ret = NOTSUPPORTED;
}
else
{
SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Script %s/%s returned nothing.",
CONFIG_EXTERNALSCRIPTS,
scriptname));
ret = NOTSUPPORTED;
}
/* cleanup */
pclose(fp);
return ret;
}
</code>
peyon - 投稿数: 38
ありがとうございます。
「returned nothing.」を取得するアイテム、検知するトリガは考えられますでしょうか?
TrapperTimeoutは実行待ちタイムアウトとは関係ないですよね?
KAZ - 投稿数: 1085
peyonさん
上記が再現できなくて困ってます。A(^^;
私の場合、スクリプト中で30秒以上経過させると下記になります。
zabbix_server.confのTimeoutは30秒です。
<code>
11859:20100315:142728 Item [ホスト名:アイテム] error: Get value from agent failed: ZBX_TCP_READ() failed [Interrupted system call]
11859:20100315:142728 Host [ホスト名]: first network error, wait for 15 seconds
11859:20100315:142728 Parameter [ホスト名] will be checked after 120 seconds on host [ホスト名]
</code>
下記で監視して、「監視データ」−「最新データ」で「returned nothing」のキーワドが出力されれば監視可能です。
<code>
タイプ :ZABBIXインターナル
キー :zabbix[log]
データ型:文字
</code>
アイテムで検知できないZabbixのタイムアウト等は基本zabbix[log]監視でキーワド検知です。