nagios安装和配置


###### 下载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==

 

转载于:https://my.oschina.net/youa/blog/740929

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值