Nagios4.X快速安装笔记
一、平台
OS:CENTOS 6.4 X64
APP:NAGIOS4.0,nagios-plugins-master.tar.gz(nagios-plugins-1.5-1-gf657)
二、安装步骤
1.安装相关软件
需要安装Apache,php,GCC compiler,GD development libraries
具体安装:
#yum install httpd php
#yum install gcc glibc glibc-common
#yum install gd gd-devel
2.配置用户帐号
增加nagios用户
#useradd –m nagios
#passwd nagios ------china1949
3.创建一个新组nagcmd,通过WEB接口提交外部命令,并把nagios和apache用户加入该组内
#groupadd nagcmd
#usermod –a –G nagcmd nagios
#usermod –a –G nagcmd apache
4.下载nagios和plugins
/usr/local/src/nagios-4.0.0.tar.gz
/usr/local/src/nagios-plugins-1.5.tar.gz
5.编译和安装
#tar xzvf nagios-4.0.0.tar.gz
#./configure –with-command-group=nagcmd
#make all
#make install
#make install-init
#make install-commandmode
#make install-config
6.定制配置
作为上手阶段,只需修改/usr/local/nagios/etc/objects/contacts.cfg中nagiosadmin的联系方式即可。修改为jiangchong@zucc.edu.cn ,用来接受报警信息。
7.配置WEB接口
在apache的conf.d目录下安装nagios的WEB配置文件
#make install-webconf
-回到NAGIOS源文件安装目录
配置nagios管理员的WEB访问密码
#htpasswd –c /usr/local/nagios/etc/htpasswd.users jiangchong
8.编译安装Nagios Plugins
#tar xzvf nagios-plugins-1.5.tar.gz
#cd nagios-plugins-1.5
#./configure –with-nagios-user=nagios –with-nagios-group=nagios
#make
#make install
9.启动nagios
#chkconfig –add nagios
#chkconfig nagios on
验证示例的nagios配置文件
#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
#service nagios start
10.修改SElinux设置
#genenforce
#setenforce 0
11.关闭主机防火墙,登录WEB接口
http://HOSTNAME/nagios
主机IP地址:10.61.3.125,目录/nagios,帐号:jiangchong/china1949
启动命令:/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
诊断命令:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
nagios配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 ############################################################################### # CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS # # # NOTES: This config file provides you with some example contact and contact # group definitions that you can reference in host and service # definitions. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # Just one contact defined by default - the Nagios admin (that's you) # This contact definition inherits a lot of default values from the 'generic-contact' # template which is defined elsewhere. define contact{ contact_name nagiosadmin use generic-contact alias Nagios Admin host_notification_commands notify-host-by-email service_notification_commands notify-service-by-email host_notification_options d,u,r service_notification_options w,u,c,r host_notification_period 24x7 service_notification_period 24x7 email 18768105624@139.com } ############################################################################### ############################################################################### # # CONTACT GROUPS # ############################################################################### ############################################################################### # We only have one contact in this simple configuration file, so there is # no need to create more than one contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin } define contactgroup{ contactgroup_name network-basic-group alias network-basic-group members nagiosadmin }
hosts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 define host { host_name windows alias windows address 192.168.1.251 contact_groups network-basic-group check_command check-host-alive max_check_attempts 5 notification_interval 10 notification_period 24x7 notification_options d,u,r } define host { host_name nagios alias nagios address 192.168.100.131 contact_groups network-basic-group check_command check-host-alive max_check_attempts 5 notification_interval 10 notification_period 24x7 notification_options d,u,r }
service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 define service { host_name windows service_description check-host-alive check_period 24x7 max_check_attempts 4 normal_check_interval 3 retry_check_interval 2 contact_groups network-basic-group notification_interval 10 notification_period 24x7 notification_options w,u,c,r check_command check-host-alive } define service { host_name nagios service_description check-host-alive check_period 24x7 max_check_attempts 4 normal_check_interval 3 retry_check_interval 2 contact_groups network-basic-group notification_interval 10 notification_period 24x7 notification_options w,u,c,r check_command check-host-alive } define service { host_name nagios service_description check_ftp check_period 24x7 max_check_attempts 4 normal_check_interval 3 retry_check_interval 2 contact_groups network-basic-group notification_interval 10 notification_period 24x7 notification_options w,u,c,r check_command check_ftp }