1.确定Centos系统中是否安装如下软件包:
Apache
GCC compiler
GD development libraries
2.如果没有安装,则按如下方式进行安装:
GCC compiler
GD development libraries
2.如果没有安装,则按如下方式进行安装:
yum -y install PHP(nagios3.2.0将页面从之前的html换成了php,首次安装需要先决条件php,如果不安装php,则有可能在输入完成nagios的登陆用户后,出现permission 的问题)
yum -y install httpd
yum -y install gcc
yum -y install glibc glibc-common
yum -y install gd gd-devel
3.创建一个nagios user并为其设置password
useradd nagios
passwd nagios
4.创建用户组并将nagios user和apache user加入到用户组中
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
5.下载nagios软件包及nagios插件
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
yum -y install gcc
yum -y install glibc glibc-common
yum -y install gd gd-devel
3.创建一个nagios user并为其设置password
useradd nagios
passwd nagios
4.创建用户组并将nagios user和apache user加入到用户组中
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
5.下载nagios软件包及nagios插件
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
如果下载不了,推荐去chinaunix网站下载
http://download.chinaunix.net/search/?key=&q=nagios&frmid=48
http://download.chinaunix.net/search/?key=&q=nagios&frmid=48
编译安装nagios
tar xzf nagios-3.0.6.tar.gz
cd nagios-3.0.6
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
7.配置web接口
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
最好输入nagiosadmin
重启apache服务器,让刚才的配置生效。
8.安装nagios插件
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure --with-nagios-user=nagios --with-nagios group=nagios
make
make install
9.把nagios服务增加到服务清单中并设置开机自启动
chkconfig –add nagios
chkconfig nagios on
10.检查nagios服务器是否存在配置错误。
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
若没有错误信息就启动nagios服务器
service nagios start
11.在ie中输入http://“nagios server ipaddress”/nagios/,测试nagios服务器是否已经能正确安装。
安装到此完成,之后做troubleshooting.
tar xzf nagios-3.0.6.tar.gz
cd nagios-3.0.6
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
7.配置web接口
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
最好输入nagiosadmin
重启apache服务器,让刚才的配置生效。
8.安装nagios插件
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure --with-nagios-user=nagios --with-nagios group=nagios
make
make install
9.把nagios服务增加到服务清单中并设置开机自启动
chkconfig –add nagios
chkconfig nagios on
10.检查nagios服务器是否存在配置错误。
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
若没有错误信息就启动nagios服务器
service nagios start
11.在ie中输入http://“nagios server ipaddress”/nagios/,测试nagios服务器是否已经能正确安装。
安装到此完成,之后做troubleshooting.
备注:templates.cfg里面
define host{
name linux-server
use generic-host
check_period 24x7 ;检查的周期(在时间配置文件定义timeperiods.cfg
check_command check-host-alive ;检测主机存活
notification_period 24x7 ;通知周期
notification_options d,u,r ;通知的选项,d=down(宕机),u=unreacheable(无法连接),r=recover(恢复)
contact_groups admins ;报警到admin组(在contacts.cfg)
register 0
check_interval 5
retry_interval 1
max_check_attempts 3 ;故障后,最大尝试检测次数
normal_check_interval 2 ;正常检查间隔,默认单位为分钟
notification_interval 30 ;故障后,两次报警通知的间隔,默认单位为分钟
retry_check_interval 2 ;故障后重试的检查间隔,默认单位为分钟
name linux-server
use generic-host
check_period 24x7 ;检查的周期(在时间配置文件定义timeperiods.cfg
check_command check-host-alive ;检测主机存活
notification_period 24x7 ;通知周期
notification_options d,u,r ;通知的选项,d=down(宕机),u=unreacheable(无法连接),r=recover(恢复)
contact_groups admins ;报警到admin组(在contacts.cfg)
register 0
check_interval 5
retry_interval 1
max_check_attempts 3 ;故障后,最大尝试检测次数
normal_check_interval 2 ;正常检查间隔,默认单位为分钟
notification_interval 30 ;故障后,两次报警通知的间隔,默认单位为分钟
retry_check_interval 2 ;故障后重试的检查间隔,默认单位为分钟