NagiosãCentOS 5.5ã«ã¤ã³ã¹ãã¼ã«ãMySQLã®ããã»ã¹ç£è¦ãã¡ã¼ã«éç¥è¨å®ã¾ã§
ãµã¼ãã¼ç£è¦ã«ã¤ãã¦ãããã調æ»ãã¦ãã¾ãã
ã¾ãã¯ä¸çªæåã©ããã®Nagiosããããã¦ã¿ã¾ããã
Nagiosã¯ãã¤ããªã¯ãmixiã§ã使ããã¦ãããå®ç¸¾ã¯ååã§ãã
è¨å®ã¯ããã¹ãã§ããããã³ãã¬ã¼ããç¨æããã¦ããã®ã§ããã»ã©é£ããã¯ããã¾ããã
Nagios以å¤ã§ã¯ãZABBIXãæ°ã«ãªãã®ã§ãã¾ãã®æ©ä¼ã«èª¿ã¹ã¦ã¿ããã¨æã£ã¦ãã¾ãã
ã§ã¯ãæ©éCentOS 5.5ã«Nagiosãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãã
å
¬å¼?ã®ã¤ã³ã¹ãã¼ã«ã¬ã¤ãã¯ãã¡ã:
http://nagios.sourceforge.net/docs/3_0/quickstart.html
ä»åã¯yumã使ç¨ãã¦ã¤ã³ã¹ãã¼ã«ãã¾ãããã»ã¼ä»¥ä¸ã®ãµã¤ããåèã«ãã¦ãã¾ã:
http://docs.cslabs.clarkson.edu/wiki/Install_Nagios_on_CentOS_5
åææ¡ä»¶
Fedoraのインストールガイドãè¦ãã¨åææ¡ä»¶ã¨ãã¦ã½ããã¦ã§ã¢ããªã¹ãããã¦ãã¾ãã
yumã§ã¤ã³ã¹ãã¼ã«
# yum install httpd php gcc glibc glibc-common gd gd-devel
Apacheã¯èªåèµ·åãã»ããããã¤ã³ãã¦ã³ãã®80çªãã¼ããéãã¾ã
# chkconfig --levels 345 httpd on # iptables -I INPUT -p tcp --dport 80 -j ACCEPT # /etc/init.d/iptables save # /etc/init.d/iptables restart
ãªãã¸ããªã®è¿½å
å
¬å¼ã¬ã¤ãã§ã¯ãmake installãã¦ãã¾ããyumã§ã¤ã³ã¹ãã¼ã«ãã¦ã¿ã¾ããã
Nagiosã¯ããã©ã«ãã®ãªãã¸ããªã«ã¯å«ã¾ãã¦ã¾ãããrpmforgeããªãã¸ããªè¿½å
32bitç
# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
64bitç
# rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
Nagiosããã³Nagiosãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«
yumã§ã¤ã³ã¹ãã¼ã«
# yum install nagios nagios-plugins nagios-plugins-setuid
Nagios Web管çç»é¢ã«ã¢ã¯ã»ã¹ããã¦ã¼ã¶IDã¨ãã¹ã¯ã¼ããä½æãã¾ãã
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
Nagiosãèµ·åãã¾ãã
# /etc/init.d/nagios start nagios is stopped Configuration validation failed [FAILED]
失æãã¾ããã以ä¸ã®ãµã¤ããè¦ãã¨SELinuxãæå¹ã«ãªã£ã¦ããã¨èµ·åããªãããã§ãã
http://www.harukari.net/index.php/Nagios%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB
SELinusãç¡å¹ã«ãã¦ãããä¸åº¦
# /etc/init.d/nagios start nagios is stopped Starting nagios: [ OK ]
ç¡äºèµ·å
次ã«ãApacheãåèµ·åãã¦ããã¾ãã
# /etc/init.d/httpd restart
ã¤ã³ã¹ãã¼ã«ã®ç¢ºèª
http://
ãã¼ã¸ã§ã³ã¯3.2.3ãã¤ã³ã¹ãã¼ã«ããã¾ããã
Nagiosã®è¨å®æ¹æ³
Nagiosã®è¨å®ã®åºæ¬ã¯ä»¥ä¸ã®ãµã¤ããåèã«ãªãã¾ãã
http://www.marsandares.jp/tools/nagios-config.html
MySQLãç£è¦ãã
MySQLç£è¦ç¨ã®ãã©ã°ã¤ã³
ã¤ã³ã¹ãã¼ã«ãããNagiosãã©ã°ã¤ã³ã¯ä»¥ä¸ã®ãã£ã¬ã¯ããªã«ããã¾ãã
ls /usr/lib/nagios/plugins/ check_apt check_ide_smart check_ntp check_ssmtp check_breeze check_ifoperstatus check_ntp_peer check_swap check_by_ssh check_ifstatus check_ntp_time check_tcp check_clamd check_imap check_nwstat check_time check_cluster check_ircd check_oracle check_udp check_dhcp check_jabber check_overcr check_ups check_dig check_ldap check_pgsql check_users check_disk check_ldaps check_ping check_wave check_disk_smb check_load check_pop contrib check_dns check_log check_procs eventhandlers check_dummy check_mailq check_radius negate check_file_age check_mrtg check_real plugins.pm check_flexlm check_mrtgtraf check_rpc urlize check_fping check_mysql check_sensors utils.pm check_ftp check_mysql_query check_simap utils.py check_game check_nagios check_smtp utils.pyc check_hpjd check_nntp check_snmp utils.sh check_http check_nntps check_spop check_icmp check_nt check_ssh
Nagiosãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«å¾ã«ããã©ã«ãã§å«ã¾ããMySQLç¨ã®ãã©ã°ã¤ã³ã¯check_mysqlã¨check_mysql_queryã§ãã
check_mysql
ããã»ã¹ç£è¦
http://nagiosplugins.org/man/check_mysql
check_mysql_query
SQLãå®è¡ãã¦ç¢ºèª
http://nagiosplugins.org/man/check_mysql_query
check_mysqlãè¨å®ãã¦ã¿ã
MySQLã®è¨å®ã¯ãã¡ãã®ããã°ãåèã«ããã¦ããã ãã¾ããã
http://d.hatena.ne.jp/kaorumori/20080607/1212863599
MySQLã«ç£è¦ç¨ã¦ã¼ã¶ã追å
mysql>create database nagios; mysql>GRANT SELECT ON nagios.* TO nagios@localhost IDENTIFIED BY 'password';
commands.cfg
# vi /etc/nagios/objects/commands.cfg
commands.cfgã®æå¾ã«check_mysqlã³ãã³ãã追å
# 'check_mysql' command definition define command{ command_name check_mysql command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ }
localhost.cfg
# vi /etc/nagios/objects/localhost.cfg
define service{ use local-service ; Name of service template to use host_name localhost service_description MySQL check_command check_mysql!nagios!password }
nagiosåèµ·å
è¨å®ããã§ãã¯ãã¦åé¡ç¡ããã°Nagiosãåèµ·å
# nagios -v /etc/nagios/nagios.cfg # /etc/init.d/nagios restart
ã¡ã¼ã«éç¥è¨å®
ã¡ã¼ã«éç¥ã¯contacts.cfgã«è¨å®ãã¾ãã
# vi /etc/nagios/objects/contacts.cfg
emailãå®éã«éç¥ããã¡ã¼ã«ã¢ãã¬ã¹ã«æ¸ãæãã¾ãã
define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }
è¨å®ããã§ãã¯ãã¦åé¡ç¡ããã°Nagiosãåèµ·å
# nagios -v /etc/nagios/nagios.cfg # /etc/init.d/nagios restart
ãã§ãã¯ééã¨è©¦è¡åæ°ã®è¨å®ã«ã¤ãã¦
localhost.cfgã«è¿½å ããMySQLã®serviceè¨å®ã¯templates.cfgã®local-serviceã®è¨å®ãåç §ãã¾ãã
define service{ name local-service ; The name of this service template use generic-service ; Inherit default values from the generic-service definition max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! }
normal_check_interval
ã³ãã³ãã®å®å¹ééãããã©ã«ã 5åãã¨
retry_check_interval
ã³ãã³ãã失æããå¾ã®å試è¡ééãããã©ã«ã 1å
max_check_attempts
ããã«æå®ããåæ°ã³ãã³ãã失æããå ´åéç¥ããããããã©ã«ã 4å
ã¡ã¼ã«éç¥ã®ç¢ºèª
éç¥ã¡ã¼ã«ãéä¿¡ãããªãå ´åã¯ä»¥ä¸ããã§ãã¯ãã¦ãã ããã
ããã©ã«ãã®éç¥æé帯ã¯workhours
templates.cfgã®linux-serverã®è¨å®ãè¦ãã¨
define host{ name linux-server ; The name of this host template ... notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day ... }
ã¨ããã¾ããæ¤è¨¼ã§ã¯24x7ã«å¤æ´ãã¦ç½®ããæ¹ãè¯ãããã§ãã
ãã©ããã³ã°æ¤ç¥ãæå¹ã ã¨ããã«ã¡ã¼ã«ã¯éä¿¡ãããªã
ããã©ã«ãã¯ãã©ããã³ã°ã®æ¤ç¥flap_detection_enabledãæå¹ã«ãªã£ã¦ãã¾ãã
define host{ name generic-host ; The name of this host template ... flap_detection_enabled 1 ; Flap detection is enabled ... }
flap_detection_enabledãã¡ã¼ã«ã®éä¿¡ãã¹ãã®éã¯0ã«ãã¦ç½®ããæ¹ãè¯ãããã§ãã
ãã©ããã³ã°ã¨ã¯æ£å¸¸ã¨ç°å¸¸ãé »ç¹ã«å
¥ãæ¿ãããã¨ã§ããããæ¤ç¥ãã¦å¤§éã®éç¥ãéä¿¡ãããªãããã«ããæ©è½ã®ããã§ãã
詳ããã¯ãã¡ãï¼
http://nagios.sourceforge.net/docs/3_0/flapping.html
æ£ããè¨å®ãããã¨ããã©ã«ãè¨å®ã§ã¯ãããªã¡ã¼ã«ãé£ã³ã¾ãã
åèã«ããã¦ããã ãããµã¤ã
- http://nagios.sourceforge.net/docs/3_0/quickstart.html
- http://docs.cslabs.clarkson.edu/wiki/Install_Nagios_on_CentOS_5
- http://www.marsandares.jp/tools/nagios-config.html
- http://d.hatena.ne.jp/kaorumori/20080607/1212863599
- http://www.fireproject.jp/feature/nms/nagios/intro.html
- http://network.station.ez-net.jp/server/system/monitoring/nagios/install/index.asp
- http://nagios.sourceforge.net/docs/3_0/flapping.html