大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
一、安装nagios前的准备工作
我们提供的服务有:成都网站制作、网站设计、微信公众号开发、网站优化、网站认证、华州ssl等。为千余家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的华州网站制作公司
1.解决安装Nagios的依赖关系:Nagios基本组件的运行依赖于httpd、gcc和gd
2. 所需要安装组件:
服务端所用的安装包为 nagios nagios-plugins
linux客户端 nrpe
windows客户端 NSClient++
二.下载需求软件
nagios主程序:wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
nagios插件程序:wget http://down1.chinaunix.net/distfiles/nagios-plugins-1.4.13.tar.gz
apache程序:wget http://autosetup1.googlecode.com/files/httpd-2.2.11.tar.gz
php程序:wget http://museum.php.net/php5/php-5.3.0.tar.gz
三.编译安装nagios
1.tar zxf nagios-3.1.2.tar.gz
[root@localhost nagios-3.1.2]# cd nagios-3.1.2
[root@localhost nagios-3.1.2]#./configure --enable-event-broker--prefix=/usr/local/nagios
[root@localhost nagios-3.1.2]#make all
[root@localhost nagios-3.1.2]#make install
[root@localhost nagios-3.1.2]#make install-init
[root@localhost nagios-3.1.2]#make install-config
[root@localhost nagios-3.1.2]#make install-commandmode
在httpd的配置文件目录(conf.d)中创建Nagios的Web程序配置文件:
[root@localhost nagios-3.1.2]#make install-webconf
创建一个登录nagiosweb程序的用户,这个用户帐号在以后通过web登录nagios认证时所用:
# htpasswd -c/var/www/nagios/etc/htpasswd.users nagiosadmin
2.编译安装nagios-plugins
nagios的所有监控工作都是通过插件完成的,因此,在启动nagios之前还需要为其安装官方提供的插件。
tar zxf nagios-plugins-1.4.13.tar.gz
[root@localhost nagios-plugins-1.4.13]#cd nagios-plugins-1.4.13
[root@localhost nagios-plugins-1.4.13]#./configure --with-nagios-user=nagios --with-[root@localhost nagios-plugins-1.4.13]#nagios-group=nagios -with-MySQL
[root@localhost nagios-plugins-1.4.13]#make
[root@localhost nagios-plugins-1.4.13]#make install
4.配置并启动Nagios
/etc/init.d/nagios start
注:如果启动时会报错
Error: Cannot open main configuration file '/root/nagios-plugins-1.4.13/start' for reading!
Nagios 3.1.2 starting... (PID=14327)
Local time is Fri Feb 28 02:52:22 CST 2014
Bailing out due to one or more errors encountered in the configuration files. Run Nagios from the command line with the -v option to verify your config before restarting. (PID=14327)
使用: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg检查配置文件没有发现错误
可使用:/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg 尝试启动
启动成功之后 可以使用top命令查看是否有nagios进程(有nagios进程说明启动成功)
注: service nagios restart 启动时再次失败
Running configuration check...done.
Stopping nagios: done.
Starting nagios:su: warning: cannot change directory to /home/nagios: No such file or directory
This account is currently not available.
done.
可以使用: mkdir /home/nagios 解决
service nagios restart 如果启动时仍然失败 但错误提示是:
Running configuration check...done.
Stopping nagios: done.
Starting nagios:This account is currently not available.
done.
可以在:vi /etc/passwd
找到此行:nagios:x:500:500::/home/nagios:/sbin/nologin(注意红色字体),把此行改成如下一行
nagios:x:500:500::/home/nagios:/bin/bash
修改后再次重启 ,启动成功
[root@localhost nagios-3.1.2]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.