Nagios installation Configuration

Source: Internet
Author: User

http://www.codeweblog.com/nagios%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/

On-line servers can sometimes be attacked, resulting in service unavailability, today the installation of Nagios to monitor the online server, simple record

#安装必要的软件包yum install-y gcc glibc glibc-common gd gd-devel xinetd openssl-devel#创建nagios用户及授予目录权限useradd-s/sbin/nologin nagiosmkdir/usr/Local/nagioschown-r nagios.nagios/usr/Local/nagios#安装nagiostar XF nagios-4.0.7.tar.gzCD nagios-4.0.7./configure--prefix=/usr/Local/nagiosmake allmake Install && make install-init && make Install-commandmode && make install -configchkconfig--add nagios && chkconfig--levelNagios on && chkconfig--list Nagios#安装nagios-pluginstar XF nagios-plugins-2.0.2.tar.gzCD nagios-plugins-2.0.2./configure--prefix=/usr/Local/nagiosmake && make Install#安装apachetar XF httpd-2.2.23.tar.gz cd httpd-23./configure--prefix=/usr/local/apache2make && make Install #安装phptar XF Php-5.5. 13.tar.gz cd php-13./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxsmake && make install             

Next Configure Apache

#生成nagios密码文件/usr/Local/apache2/bin/htpasswd-c/usr/LOCAL/NAGIOS/ETC/HTPASSWD adminvim/usr/Local/apache2/conf/httpd.conf ... User nagiosgroup nagios...<ifmodule dir_module> directoryindex index.html index.php</ifmodule> .... AddType application/x-httpd-php. php ...#setting for Nagiosscriptalias/nagios/cgi-bin"/usr/local/nagios/sbin" <directory"/usr/local/nagios/sbin" > AuthType Basic Options execcgi allowoverride None Order allow,deny allow from all AuthName"Nagios Access" authuserfile/usr/LOCAL/NAGIOS/ETC/HTPASSWD//file used for this directory access authentication Require valid-user</directory> Alias/nagios"/usr/local/nagios/share" <directory"/usr/local/nagios/share" > AuthType Basic Options none allowoverride none Order Allow,deny allow from all AuthName"Nagios Access" authuserfile/usr/LOCAL/NAGIOS/ETC/HTPASSWD Require valid-user</directory>#启动apachevim/etc/init.d/httpd#!/bin/sh## Startup script for the Apache Web Server## chkconfig:345 85 15# Description:apache is a world Wide Web server. It's used to serve# HTML files and CGI.# PROCESSNAME:HTTPD# Pidfile:/usr/local/apache2/logs/httpd.pid# config:/usr/local/apache2/conf/httpd.conf# Source Function Library: /etc/rc.d/init.d/Functions# See how we were called.Case"$ "Instart)Echo-n"Starting httpd:" daemon/usr/Local/apache2/bin/httpd-dsslECHOTOUCH/VAR/LOCK/SUBSYS/HTTPD;; StopEcho-n"Shutting down http:" Killproc httpdEchorm-f/var/lock/subsys/httpdrm-f/usr/Local/apache2/logs/httpd.pid;; status) status httpd;; Restart$0 stopecho-n echo;; *) echo $0 {start|stop|restart|reload|status} "exit 1 Esacexit       

Next Configure Nagios

#确保admin用户登录后有权限查看信息vim/usr/Local/nagios/etc/cgi.cfg...default_user_name=adminauthorized_For_system_information=nagiosadmin,adminauthorized_For_configuration_information=nagiosadmin,adminauthorized_For_system_commands=adminauthorized_For_all_services=nagiosadmin,adminauthorized_For_all_hosts=nagiosadmin,adminauthorized_For_all_service_commands=nagiosadmin,adminauthorized_For_all_host_commands=nagiosadmin,admin ...#修改nagios主配置文件, place the definition of the host in the/usr/local/nagios/etc/hosts directory mkdir/usr/local/nagios/etc/hostsvim/usr/local/nagios/etc/nagios.cfg...cfg_dir=/usr/Local/nagios/etc/hosts ...#添加一个自定义命令vim/usr/Local/nagios/etc/objects/command.cfg ...# ' check_custom_http ' command definitiondefinecommand{Command_name check_custom_httpCommand_line$USER 1$/check_http-4-n-H$ARG 1$-U$ARG 2$}# ' Check_dns ' command definitiondefinecommand{Command_name Check_dnsCommand_line$USER 1$/check_dns-v-H$ARG 1$-A$ARG 2$-W$ARG 3$-C$ARG 4$} ...#定义主机组vim/usr/Local/nagios/etc/hosts/group.cfgdefine hostgroup{Hostgroup_name groupname1Alias Groupname1 members Server1There is a mapping in the #server1必须在/etc/hosts}#定义主机server1vim/usr/Local/nagios/etc/hosts/server1.cfgdefine host{use Linux-server host_name Server1Alias Server1 address xx.xx.xx.xx Notification_period24x7}define service{UseLocal-service; Name of service template to use host_name server1 service_description PING check_Command check_ping!100.0,20%!500.0,60%; Delay100MS packet loss rate is greater than20%, a warning notice is issued; Delay500MS packet loss rate is greater than60%, a critical Error notification is issued}; you need to do a native DNS setting to define define service{use in the/etc/resolv.conf fileLocal-service; Name of service template to use host_name server1 service_description DNS check_Command check_dns!xxx.test.com!xx.xx.xx.xx!4!10. Continuous parsing of domain name occurrences4 errors, a warning notification is issued, and consecutive parsing of the domain name occurs10 errors, serious error notification is issued;}define service{useLocal-service; Name of service template to use host_name server1 service_description HTTP check_command check_custom_http!xxx.abc.com!/somepath/path1; Notice the parameters here! Separate}define service{useLocal-service; Name of service template to use host_name server1 service_description SSH check_Command Check_ssh}#配置监控出现问题时要通知的联系人vim/usr/local/nagios/etc/objects/contacts.cfgdefine contact{Contact _name user1; Short name of the user use generic-contact; Inherit default values from Generic-contact template (defined above) alias user1; Full name of user email [email protected]; <<***** change this to YOUR EMAIL ADDRESS ******}define contact{contact_name user2; Short name of the user use generic-contact; Inherit default values from Generic-contact template (defined above) alias user2; Full name of user email [email protected]; <<***** change this to YOUR EMAIL ADDRESS ******} define contactgroup{contactgroup_name admins alias Nagios Administrators members User1,user2} Restart Nagios/etc/init.d/nagios restart    

Just found Nagios monitoring to the server exception also did not send an email notification, checked, but also need to configure the Mail command to send mail

Install mailvim/etc/mail.rc ...  [email protected]set smtp=smtp.abc.comset smtp-auth-[email protected]set smtp-auth-  Password=somepwdset Smtp-auth=login       ...

Nagios installation Configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.