Skip to content

Instantly share code, notes, and snippets.

@nekoya
Created September 17, 2012 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nekoya/3736324 to your computer and use it in GitHub Desktop.
Save nekoya/3736324 to your computer and use it in GitHub Desktop.
wiki/nagios

#Nagios

##setup

  • EPELからyumでインストール
sudo yum install nagios nagios-plugins
  • 必要なプラグインもnagios-plugins-XXXXから入れる
  • デフォルトの設定で必要な物を入れるなら
sudo yum install nagios-plugins-disk nagios-plugins-load nagios-plugins-ping nagios-plugins-procs  nagios-plugins-users
  • 面倒になったらnagios-plugins-all入れてしまっていい

###basic

  • /var/spool/nagios/cmdのgroupをhttpdと合わせる
  • sudo htpasswd -c /etc/nagios/passwd username
  • /etc/httpd/conf.d/nagios.cfgの設定を適当に

###/etc/nagios/cgi.cfg

  • authorized_for_XXXXにusernameを設定して回る

###/etc/nagios/nagios.cfg

  • check_external_commands=1に変更

##configuration

  • localhost.cfgにまとまってるのは好きじゃない
  • 用途別にファイルを分ける方がいい
  • /etc/nagios/に置くファイルにテンプレを
  • contacts.cfg
  • hosts.cfg
  • services.cfg
  • timeperiods.cfg
  • /etc/nagios/サービス名/にサービス毎の設定を書く
  • contacts.cfg
  • hosts.cfg
  • services.cfg
  • contactgroup, hostgroupの設定もcontacts.cfg, hosts.cfgに統合した方が分かりやすい気がするがどうか

##plugin development

  • pluginを自作する場合は以下のように戻り値を設定する
code description
0 OK
1 Warning
2 Critical
3 Unknown

#other resources

##snmp plugins

###check_snmp_load

  • PerlのNet::SNMPが必要
sudo yum install perl-Net-SNMP
cd /usr/lib64/nagios/plugins
sudo wget http://nagios.manubulon.com/check_snmp_load.pl
sudo chmod +x check_snmp_load.pl

in nagios config

# 'check_snmp_load' command definition
define command{
    command_name    check_snmp_load
    command_line    $USER1$/check_snmp_load -H $HOSTADDRESS$ -C public -T netsl -w $ARG1$ -c $ARG2$
}

define service{
    use                             local-service
    hostgroup_name                  all
    service_description             load
    check_command                   check_snmp_load!3,3,3!5,5,5
}

###check_snmp_storage

  • nagios-plugins-perlが必要
  • use libのディレクトリが古い仕様なのでsedで置換する
sudo yum install nagios-plugins-perl
cd /usr/lib64/nagios/plugins
sudo wget http://nagios.manubulon.com/check_snmp_storage.pl
sudo sed -i "s|usr/local/nagios/libexec|usr/lib64/nagios/plugins|" check_snmp_storage.pl
sudo chmod +x check_snmp_storage.pl

in nagios config

# 'check_snmp_storage' command definition
define command{
    command_name    check_snmp_storage
    command_line    $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C public -m $ARG1$ -w $ARG2$ -c $ARG3$
}

define service{
    use                             local-service
    hostgroup_name                  all
    service_description             hdd
    check_command                   check_snmp_storage!/ -r!80!90
}
define service{
    use                             local-service
    hostgroup_name                  all
    service_description             swap
    check_command                   check_snmp_storage!Swap!1!1
}

###check_snmp_mem

  • メモリ使用量とSWAPをまとめて見てくれる
  • PerlのNet::SNMPが必要
  • nagios-plugins-perlが必要
  • use libのディレクトリが古い仕様なのでsedで置換する
cd /usr/lib64/nagios/plugins
sudo wget http://nagios.manubulon.com/check_snmp_mem.pl
sudo sed -i "s|usr/local/nagios/libexec|usr/lib64/nagios/plugins|" check_snmp_mem.pl
sudo chmod +x check_snmp_mem.pl

in nagios config

# 'check_snmp_mem' command definition
define command{
    command_name    check_snmp_mem
    command_line    $USER1$/check_snmp_mem.pl -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$
}

define service{
    use                             local-service
    hostgroup_name                  all
    service_description             memory_swap
    check_command                   check_snmp_mem!public!70,1!80,2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment