nagios安装和配置

2016-09-02 10:58:04来源:oschina作者:党程V人点击


###### 下载nagios core
```
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz#_ga=1.235594305.1549406567.1472694403
```
```
su root
yum install httpd php
yum install gcc glibc glibc-common
yum install gd gd-devel
```
必须是root用户 创建用户
```
useradd -m nagios
passwd nagios
``````
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
```
下载nagios 和相关插件```
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz
wget http://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
```
安装
```
tar -xzvf nagios-4.0.8.tar.
./configure --with-command-group=nagcmd
```
```
make all
```
有可能会报错
```
make[1]: Entering directory `/home/nagios/nagios-4.0.2/base'
make[1]: *** No rule to make target `../include/locations.h', needed by `nagios.o'.Stop.
make[1]: Leaving directory `/home/nagios/nagios-4.0.2/base'
make: *** [all] Error 2
```
需要安装perl
```
yum -y install perl perl-devel
```
重新编译安装
```
./configure --with-command-group=nagcmd
make all
```
成功后安装二进制命令,初始化、配置等设置。。。
```
make install
make install-init
make install-config
make install-commandmode
```
修改配置文件,如报警邮件
```
vi /usr/local/nagios/etc/objects/contacts.cfg
```
安装web配置到apahce
```
make install-webconf
```
创建nagio web 登录界面账号,输入密码即可
```
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
``````
service httpd restart
```
这时候就可以通过浏览器打开nagios的首页进行查看了
http://192.168.84.42/nagios/
#### 安装插件
```
tar xzvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
```
编译安装
```
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
```
添加到服务列表,并且开机自动启动```
chkconfig --add nagios
chkconfig nagios on
```
验证安装结果
```
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
```
```
Nagios Core 4.0.8
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2014
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
```
启动nagios
```
service nagios start
```
设置SELinux模式
```
getenforce
setenforce 0
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
```###### ====Done====!
http://192.168.84.42/nagios/
## 测试环境:centos 7
==其他版本可参考:https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart.html==

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台