参考文献:
http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html
http://my.oschina.net/duangr/blog/183160
设定文件权限
chown -R nagios.nagios envision_*
chown -R nagios.nagios envision_*
1.创建用户并设定密码
# useradd -s /sbin/nologin nagios
修改nagios密码
sudo passwd nagios
密码设置为nagios
2.创建目录并设定权限
# mkdir /usr/local/nagios
ls -al --查看目录权限
# chown -R nagios.nagios /usr/local/nagios
ls -al --再次查看目录权限
# mkdir /usr/local/nagios
ls -al --查看目录权限
# chown -R nagios.nagios /usr/local/nagios
ls -al --再次查看目录权限
mkdir /home/nagios
chown -R nagios.nagios /home/nagios
su nagios
测试mutt发送邮件,
echo "test" |mutt -s "my_first_test" aaa@126.com,会自动穿件/home/nagios/sent文件
./configure --prefix 作用
不指定prefix,则可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其它的资源文件放在/usr/local/share。你要卸载这个程序,要么在原来的make目录下用一次make uninstall(前提是make文件指定过uninstall),要么去上述目录里面把相关的文件一个个手工删掉。
指定prefix,直接删掉一个文件夹就够了。
3.下载安装
解压缩
tar -zxf nagios-4.0.4.tar.gz
进入根目录
cd nagios-4.0.4/
配置
enadmin@cgnmon:~/software/nagios-4.0.4$ ./configure --prefix=/usr/local/nagios
配置
./configure --prefix=/usr/local/nagios
编译
make all
make install && make install-init && make install-commandmode && make install-config
./configure --prefix 作用
不指定prefix,则可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其它的资源文件放在/usr/local/share。你要卸载这个程序,要么在原来的make目录下用一次make uninstall(前提是make文件指定过uninstall),要么去上述目录里面把相关的文件一个个手工删掉。
指定prefix,直接删掉一个文件夹就够了。
3.下载安装
解压缩
tar -zxf nagios-4.0.4.tar.gz
进入根目录
cd nagios-4.0.4/
配置
enadmin@cgnmon:~/software/nagios-4.0.4$ ./configure --prefix=/usr/local/nagios
配置
./configure --prefix=/usr/local/nagios
编译
make all
make install && make install-init && make install-commandmode && make install-config
4. 安装Nagios 插件
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
# tar zxvf nagios-plugins-1.4.16.tar.gz
# cd nagios-plugins-1.4.16
# ./configure --prefix=/usr/local/nagios
# make && make install
6.使用chkconfig管理服务
ubuntu中使用chkconfig可能有bug,解决方法参考:http://blog.db89.org/ubuntu-error-in-the-chkconfig-command-prompt-sbin-insserv-no-such-file-or-directory/
sudo ln -s /usr/lib/insserv/insserv /sbin/insserv
root@ubuntu-server:/sbin# ll /sbin/insserv
lrwxrwxrwx 1 root root 24 Mar 28 09:21 /sbin/insserv -> /usr/lib/insserv/insserv*
lrwxrwxrwx 1 root root 24 Mar 28 09:21 /sbin/insserv -> /usr/lib/insserv/insserv*
7.Nagios 启动的时候有下面的警告:
Starting nagios:No directory, logging in with HOME=/
done.
修改/etc/passwd
nagios:x:1001:1001::/home/nagios:/bin/sh 改为:
nagios:x:1001:1001::/usr/local/nagios:/bin/sh
Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd‘ for update!
The permissions on the external command file and/or directory may be incorrect. Read the FAQs on how to setup proper permissions.
An error occurred while attempting to commit your command for processing.
Return from whence you came
Return from whence you came
问题
enadmin@ubuntu-server:~$ sudo service apache2 restart
* Restarting web server apache2
apache2: Could not reliably determine the server‘s fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server‘s fully qualified domain name, using 127.0.1.1 for ServerName
...done.
* Restarting web server apache2
apache2: Could not reliably determine the server‘s fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server‘s fully qualified domain name, using 127.0.1.1 for ServerName
...done.
解决方法
修改 httpd.conf 文件
打开终端,输入以下命令:
sudo vim /etc/apache2/httpd.conf
默认情况下,这个是一个空文件,在文件中加入以下内容:
ServerName localhost
保存文件退出,再次重启apache,错误提示没有了。