nagios:environment
                文書の過去の版を表示しています。
目次
nagios構築
サーバ)インストール
rpmforge リポジトリを追加
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm # rpm -Uhv rpmforge-release-*.rpm # yum --enablerepo=rpmforge install nagios nagios-plugins nagios-plugins-setuid # yum -y --enablerepo=rpmforge install nagios-plugins-nrpe
サーバ初期設定
# vi /etc/nagios/nagios.cfg
-) #cfg_dir=/etc/nagios/servers +) cfg_dir=/etc/nagios/servers
# mkdir /etc/nagios/servers # chown nagios. /etc/nagios/servers
apache設定ファイル
とりあえずつながる設定なので、本番運用禁止!!
# vi /etc/httpd/conf.d/nagios.conf
BASIC認証関連の4行をコメントアウトして、IP制限の3行を追加
# AuthName "Nagios Access" # AuthType Basic # AuthUserFile /etc/nagios/htpasswd.users # Require valid-user Order deny,allow Deny from all Allow from 192.168.0.0/24
BASIC認証の場合は、以下実行
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin New password:***** Re-type new password:***** Adding password for user nagiosadmin
設定導入(=Apache再起動)
# /etc/rc.d/init.d/httpd restart
iptalesを使用する場合は、/etc/sysconfig/iptablesに以下を追記する。
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT -A INPUT -m state --state NEW -m udp -p udp --dport 5666 -j ACCEPT
CentOS/SELINUX
動作確認
サーバ)監視ホスト追加
# vi /etc/nagios/servers/web01.cfg
define host{
      use                       linux-server
      host_name                 web01
      alias                     web01
      address                   192.168.0.223
}
define service{
      use                       generic-service
      host_name                 web01
      service_description       PING
      check_command             check_ping!100.0,20%!500.0,60%
}
サーバ)通知先追加
# vi contacts.cfg
# 'nagios-admin' contact definition
define contact{
      contact_name                  nagios-admin
      alias                         Nagios Admin
      service_notification_period   24x7
      host_notification_period      24x7
      service_notification_options  w,u,c,r       ; warning, unknown, critical, recover
      host_notification_options     d,u,r         ; down, unknown, recover
      service_notification_commands notify_by_irc
      host_notification_commands    host_notify_to_irc
      email                         error@example.com
}
define contact{
      contact_name                  user
      alias                         user
      service_notification_options  u,c,r         ; unknown, critical, recover
      host_notification_options     d,u,r         ; down, unknown, recover
      email                         error@example.com
}
# 'admins' contactgroup definition
define contactgroup{
      contactgroup_name admins
      alias             Nagios Administrators
      members           nagios-admin
}
define contactgroup{
      contactgroup_name users
      alias             Users
      members           nagios-admin,user
}
# commands.cfg
#
define command{
      command_name    notify_by_irc
      command_line    /toirc "$NOTIFICATIONTYPE$ - $HOSTALIAS$ is $SERVICEOUTPUT$"
}
#
define command{
      command_name    host_notify_to_irc
      command_line    /toirc "Host $HOSTSTATE$ - $HOSTNAME$!"
}
ホスト)インストール・監視設定
# yum -y install --enablerepo=remi,epel,rpmforge nagios-plugins-users.x86_64 # yum -y install --enablerepo=remi,epel,rpmforge nagios-plugins-load.x86_64 # yum -y install --enablerepo=remi,epel,rpmforge nagios-plugins-disk.x86_64 # yum -y install --enablerepo=remi,epel,rpmforge nagios-plugins-procs.x86_64
# vi /etc/nagios/objects/commands.cfg
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
# vi /etc/nagios/servers/web01.cfg
define service{
use generic-service
host_name web01
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name web01
service_description Current Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name web01
service_description Root Partition
check_command check_nrpe!check_disk
}
define service{
use generic-service
host_name web01
service_description Total Processes
check_command check_nrpe!check_procs
}
# vi /etc/nagios/nrpe.cfg
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p / command[check_procs]=/usr/lib64/nagios/plugins/check_procs -w 250 -c 400 -s RSZDT
参考
nagios/environment.1458019332.txt.gz · 最終更新: 2025/02/16 13:50 (外部編集)
                
                