nagiosでpostgresqlを監視したかったが、nagios-pluginsをコンパイルしても、check_pgsqlが作成されませんでした。調査したところ、展開したフォルダに「REQUIREMENTS」というファイルがあり、それにコンパイルに必要なものがあるものは記載されていました。
色々ありますが、私は postgresql だけを監視すれば良いので、
$yum install postgresql-devel
でpostgresqlのインストールが必要でした。下記ページに詳しい説明があります。
http://umiushi.dip.jp/wordpress/linuxconfig/nagios-menu/nagios30_02/
2009年9月9日水曜日
nagios 設定、インストール 4
6.services.cfg(チェックする各監視対象ホストのサービス)を設定します。
設定ファイル上にある # Generic host definition template部はtemplateなので、そのままして下さい。その下に監視したいホストとサービスを追加します。
以下は、DB-WEBサーバのPING、HTTP。DB-PGサーバのPING、PGSQLを監視する例です。 # Service1 definitiondefine
service{
use generic-service ; Name of service template to use
host_name DB-WEB
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_ping
}
# Service2 definitiondefine
service{
use generic-service ; Name of service template to use
host_name DB-WEB
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_http
}
# Service3 definitiondefine service
{use generic-service ; Name of service template to use
host_name DB-PG
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_ping
}
# Service definitiondefine
service{use generic-service ; Name of service template to use
host_name DB-PG
service_description PGSQL
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_pgsql!dbname!dbuser!password
}
7.contactgroups.cfg(アラート通知先のグループ)の設定。
私は、以下のように設定しました。membersが contacts.cfgの contact_nameと一致しなければなりません。そこが注意点です。
# 'db-admins' contact group
definitiondefine contactgroup{
contactgroup_name DB-admins
alias Novell Administrators
members nagios
}
8.contacts.cfg(アラート通知先)の設定。
define contact{
contact_name nagios
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email,notify-by-epager
host_notification_commands host-notify-by-email,host-notify-by-epager
email nagios@xxx.xx.xx
pager nagios@xxx.xxx.xx
}
設定ファイル上にある # Generic host definition template部はtemplateなので、そのままして下さい。その下に監視したいホストとサービスを追加します。
以下は、DB-WEBサーバのPING、HTTP。DB-PGサーバのPING、PGSQLを監視する例です。 # Service1 definitiondefine
service{
use generic-service ; Name of service template to use
host_name DB-WEB
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_ping
}
# Service2 definitiondefine
service{
use generic-service ; Name of service template to use
host_name DB-WEB
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_http
}
# Service3 definitiondefine service
{use generic-service ; Name of service template to use
host_name DB-PG
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_ping
}
# Service definitiondefine
service{use generic-service ; Name of service template to use
host_name DB-PG
service_description PGSQL
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_pgsql!dbname!dbuser!password
}
7.contactgroups.cfg(アラート通知先のグループ)の設定。
私は、以下のように設定しました。membersが contacts.cfgの contact_nameと一致しなければなりません。そこが注意点です。
# 'db-admins' contact group
definitiondefine contactgroup{
contactgroup_name DB-admins
alias Novell Administrators
members nagios
}
8.contacts.cfg(アラート通知先)の設定。
define contact{
contact_name nagios
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email,notify-by-epager
host_notification_commands host-notify-by-email,host-notify-by-epager
email nagios@xxx.xx.xx
pager nagios@xxx.xxx.xx
}
2009年8月18日火曜日
nagios設定 check_http URL指定
CentOSなどでApacheをデフォルトで起動すると、/var/www/html に index.html がなく、/var/www/error/noindex.html が表示されるようである。
nagios で Apache(httpd)の死活監視を行うとデフォルトでは、 check_http が /var/www/html/index.html を見るようになっているようです。そこで check_http で参照できるURLを指定し、それを参照できるようにしないと下記の警告が出力されます。
「HTTP WARNING: HTTP/1.1 403 Forbidden」
以前、ここにも書きましたが、 check_http にはオプションがあります。URLを指定するには「-u」が必要です。
/usr/local/nagios/etc/checkcommand.cfg に以下を追加します
define command{
command_name check_http_url
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}
/usr/local/nagios/etc/services.cfg で check_command で
check_command check_http_url!URL
これで /etc/rc.d/init.d/nagios restart で反映するだけでOKです。
nagios で Apache(httpd)の死活監視を行うとデフォルトでは、 check_http が /var/www/html/index.html を見るようになっているようです。そこで check_http で参照できるURLを指定し、それを参照できるようにしないと下記の警告が出力されます。
「HTTP WARNING: HTTP/1.1 403 Forbidden」
以前、ここにも書きましたが、 check_http にはオプションがあります。URLを指定するには「-u」が必要です。
/usr/local/nagios/etc/checkcommand.cfg に以下を追加します
define command{
command_name check_http_url
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}
/usr/local/nagios/etc/services.cfg で check_command で
check_command check_http_url!URL
これで /etc/rc.d/init.d/nagios restart で反映するだけでOKです。
2009年8月8日土曜日
nagios 設定 check_pgsql の設定
check_pgsqlでもはまった箇所があったので、記録しておきます。
デフォルト通りに check_pgsql で監視をすると、以下のエラーが出力されました。
PGSQL: CRITICAL - no connection to 'template1' (FATAL: role "nagios" does not exist
どうやら、nagiosという roleでtemplate1というDBへアクセスしにいっているようです。
もちろん、nagiosというroleはないため、上記に示すエラーが出力されています。
そのため、以下のような設定をしました。
/usr/local/nagios/libexec/check_pgsql -h とヘルプを表示したところエラーに関係ありそうなところがありました。
-d, --database=STRING Database to check (default: template1)
-l, --logname = STRING Login name of user
-p, --password = STRING Password (BIG SECURITY ISSUE)
そこで、/usr/local/nagios/etc/checkcommands.cfg に以下を追加しました。
# 'check_pgsql' command definition
define command{
command_name check_pgsql
command_line $USER1$/check_pgsql -H $HOSTADDRESS$ -d $ARG1$ -l $ARG2$ -p $ARG3$
# command_line $USER1$/check_http -I $HOSTADDRESS$
}
その次に、/usr/local/nagios/etc/services.cfg に以下を追加しました。以下の例ではデータベースを「postgres」ユーザーID「userid」パスワードを「password」とした例です。
define service{
use generic-service ; Name of service template to use
host_name DB-PG
service_description PGSQL
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_pgsql!postgres!userid!password
}
これで /etc/rc.d/inint.d/nagios restart で再起動し
PGSQL: ok - database postgres (0 sec.)
とか出力されれば「OK]です。
デフォルト通りに check_pgsql で監視をすると、以下のエラーが出力されました。
PGSQL: CRITICAL - no connection to 'template1' (FATAL: role "nagios" does not exist
どうやら、nagiosという roleでtemplate1というDBへアクセスしにいっているようです。
もちろん、nagiosというroleはないため、上記に示すエラーが出力されています。
そのため、以下のような設定をしました。
/usr/local/nagios/libexec/check_pgsql -h とヘルプを表示したところエラーに関係ありそうなところがありました。
-d, --database=STRING Database to check (default: template1)
-l, --logname = STRING Login name of user
-p, --password = STRING Password (BIG SECURITY ISSUE)
そこで、/usr/local/nagios/etc/checkcommands.cfg に以下を追加しました。
# 'check_pgsql' command definition
define command{
command_name check_pgsql
command_line $USER1$/check_pgsql -H $HOSTADDRESS$ -d $ARG1$ -l $ARG2$ -p $ARG3$
# command_line $USER1$/check_http -I $HOSTADDRESS$
}
その次に、/usr/local/nagios/etc/services.cfg に以下を追加しました。以下の例ではデータベースを「postgres」ユーザーID「userid」パスワードを「password」とした例です。
define service{
use generic-service ; Name of service template to use
host_name DB-PG
service_description PGSQL
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_pgsql!postgres!userid!password
}
これで /etc/rc.d/inint.d/nagios restart で再起動し
PGSQL: ok - database postgres (0 sec.)
とか出力されれば「OK]です。
nagios 設定 Basic認証WEB での check_http
nagiosの設定、インストールは問題なく終了。ホスト、サービスの監視を設定したのですが、はまった箇所があったので、記録を残しておきます。
Basic認証を行っている WEBのサービス監視ですが、通常の「check_http」で設定すると、「HTTP WARNING: HTTP/1.1 401 Authorization Required」と出力されて、正常に監視できません。
/usr/local/nagios/libexec/check_http -h とヘルプを表示したところ認証に関係ありそうなところがありました。
-a, --authorization=AUTH_PAIR Username:password on sites with basic authentication
そこで、/usr/local/nagios/etc/checkcommands.cfg に以下を追加しました。
# 'check_http_auth' command definition
define command{
command_name check_http_auth
command_line $USER1$/check_http -H $HOSTADDRESS$ -a $ARG1$
}
ちなみに通常の check_http は下記のようになっています。オプション「-a 」を付けました。
# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -H $HOSTADDRESS$
}
その次に、/usr/local/nagios/etc/services.cfg に以下を追加しました。以下の例ではユーザーID「userid」パスワードを「password」とした例です。
define service{
use generic-service ; Name of service template to use
host_name DB-WEB
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_http_auth!userid:password
}
これで /etc/rc.d/inint.d/nagios restart で再起動し
HTTP ok: HTTP/1.1 200 OK - 0.004 second response time
とか出力されれば「OK]です。
Basic認証を行っている WEBのサービス監視ですが、通常の「check_http」で設定すると、「HTTP WARNING: HTTP/1.1 401 Authorization Required」と出力されて、正常に監視できません。
/usr/local/nagios/libexec/check_http -h とヘルプを表示したところ認証に関係ありそうなところがありました。
-a, --authorization=AUTH_PAIR Username:password on sites with basic authentication
そこで、/usr/local/nagios/etc/checkcommands.cfg に以下を追加しました。
# 'check_http_auth' command definition
define command{
command_name check_http_auth
command_line $USER1$/check_http -H $HOSTADDRESS$ -a $ARG1$
}
ちなみに通常の check_http は下記のようになっています。オプション「-a 」を付けました。
# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -H $HOSTADDRESS$
}
その次に、/usr/local/nagios/etc/services.cfg に以下を追加しました。以下の例ではユーザーID「userid」パスワードを「password」とした例です。
define service{
use generic-service ; Name of service template to use
host_name DB-WEB
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups DB-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_http_auth!userid:password
}
これで /etc/rc.d/inint.d/nagios restart で再起動し
HTTP ok: HTTP/1.1 200 OK - 0.004 second response time
とか出力されれば「OK]です。
2009年8月3日月曜日
nagios 設定、インストール 2
NagiosをWEB画面で確認するため、CGIの設定が必要になります。Apacheの設定ファイルである httpd.conf(私の場合は /etc/httpd/conf/httpd.conf)に以下を追記します。
ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
<Directory "/usr/local/nagios/sbin/">
AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
</Directory>
Alias /nagios/ /usr/local/nagios/share/
<Directory "/usr/local/nagios/share">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
</Directory>
Basic認証の設定ファイルを作成します。
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
最後に
/etc/rc.d/init.d/httpd restart で Apacheを再起動します。
ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
<Directory "/usr/local/nagios/sbin/">
AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
</Directory>
Alias /nagios/ /usr/local/nagios/share/
<Directory "/usr/local/nagios/share">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
</Directory>
Basic認証の設定ファイルを作成します。
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
最後に
/etc/rc.d/init.d/httpd restart で Apacheを再起動します。
nagios インストール、設定 1
Nagiosはネットワーク上にあるサーバやNW機器のサービスを監視するオープンソースです。グラフなどは無く、トラフィックや負荷などを時系列に見るには向いていませんが、システムのアップ、ダウン監視は問題なく、メール通知も行え、設定も簡単なので重宝しています。
実は約5年前から利用していますが、今回サーバ障害が発生し、再構築したので以下にインストールと設定内容を書きます。
1.ダウンロード
ここからダウンロードできます。http://www.nagios.org/download
nagio本体である Nagios core とプラグインである Nagios plugins から最新のものをダウンロードしてください。
2.ダウンロードしてきたファイルを /usr/local/src などに配置し、解凍、コンパイルを行います。
・解凍
$tar zxvf nagios-X.X.tar.gz
・Makefileの作成
$ cd nagios-X.X
$ ./configure
コンパイル
$make all
エラーが出なければ、コンパイル成功です。
3.インストールです。以下は root ユーザで行って下さい。
モジュールをインストールします。
make install
起動ファイルをインストールします。
make install-init
コマンドファイルをインストールします。
make install-commandmode
サンプルの設定ファイルをインストールします。make install-config
以上でNagios coreのインストールは終了です。
4.nagios-pluguinsのインストール
・解凍 $tar zxvf nagios-plugins-X.X.X.tar.gz
・Makefileの作成 $ cd nagios-plugins.X.X.X $ ./configure
・ コンパイル $make all
・インストール ここは root ユーザで
#make install
nagios-pluginsのインストールも終了です。
つぎは httpd(Apach)との連携部の設定です。
実は約5年前から利用していますが、今回サーバ障害が発生し、再構築したので以下にインストールと設定内容を書きます。
1.ダウンロード
ここからダウンロードできます。http://www.nagios.org/download
nagio本体である Nagios core とプラグインである Nagios plugins から最新のものをダウンロードしてください。
2.ダウンロードしてきたファイルを /usr/local/src などに配置し、解凍、コンパイルを行います。
・解凍
$tar zxvf nagios-X.X.tar.gz
・Makefileの作成
$ cd nagios-X.X
$ ./configure
コンパイル
$make all
エラーが出なければ、コンパイル成功です。
3.インストールです。以下は root ユーザで行って下さい。
モジュールをインストールします。
make install
起動ファイルをインストールします。
make install-init
コマンドファイルをインストールします。
make install-commandmode
サンプルの設定ファイルをインストールします。make install-config
以上でNagios coreのインストールは終了です。
4.nagios-pluguinsのインストール
・解凍 $tar zxvf nagios-plugins-X.X.X.tar.gz
・Makefileの作成 $ cd nagios-plugins.X.X.X $ ./configure
・ コンパイル $make all
・インストール ここは root ユーザで
#make install
nagios-pluginsのインストールも終了です。
つぎは httpd(Apach)との連携部の設定です。
登録:
投稿 (Atom)
What A Wonderful World - ルイ・アームストロング 名曲です。
きょうは、ルイ・アームストロングの「What A Wonderful World 」です。 コロナ禍時こそ、この歌を聞きたくなりました。 なんて、素晴らしい世界なんだー! 素晴らしい世界は身近なことにあることを教えてくれる曲です。 この曲を知ったきっかけは、予備校時...
-
以前、Windows、IISで構築していたシステムでURLに日本語(SJIS)があるシステムがあった。それをLinux、Apacheで再構築したときに、Apachedで日本語URLを利用できるようにしなければならなくなりました。そのときの作業メモを残しておきます。ここでのApac...
-
nagiosの設定、インストールは問題なく終了。ホスト、サービスの監視を設定したのですが、はまった箇所があったので、記録を残しておきます。 Basic認証を行っている WEBのサービス監視ですが、通常の「check_http」で設定すると、「HTTP WARNING: HTTP/...
-
HTTPSを一度設定したのち、無効にしたい場合がありました。 その設定方法を記録しておきます。 ちなみに、CentOS5で yum でインストールした環境です。 /etc/httpd/conf.d/ssl.conf の中にある 「SSLEngine on」を「SSLEngine ...