CentOS 6.3_Nagios安装配置

简介:

实验环境

包含3台主机,详细信息如下

主机名

操作系统

IP地址

作用

nagios

CentOS 6.3_x64

10.10.10.254

监控机

web

CentOS 6.3_x64

10.10.10.253

被监控机

winserver

Windows sever 2003

10.10.10.252

被监控机

 

Nagios定义的监控状态

nagios定义了4中监控状态,代表不同的严重级别,除了OK代表正常不用关心外,其余3种都要引起重视.如下表

状态

代码

颜色

正常

OK

绿色

警告

WARNING

黄色

严重

CRITICAL

红色

未知错误

UNKOWN

深黄色

 

1、安装前准备

Nagios安装前,首先安装相关软件包,对于RHEL / CentOS系统: (依赖包的安装:wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp openssl openssl-devel)

检看一下是否安装相关软件包:

[root@nagios ~]# rpm -qa |grep *****(略)

[root@nagios ~]# yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp openssl openssl-devel

 

Nagios源代码程序和插件

监控主机下载:

[root@nagios ~]# wget http://nchc.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz

[root@nagios ~]# wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

[root@nagios ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

 

被监控Linux 主机下载:

[root@nagios ~]# wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

[root@nagios ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

 

被监控Windows 主机下载:

http://nsclient.org/nscp/downloads

http://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-Win32.zip

http://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-x64.zip

 

2、添加Nagios用户和组  

[root@nagios ~]# useradd nagios

[root@nagios ~]# passwd nagios

[root@nagios ~]# groupadd nagcmd

[root@nagios ~]# usermod -a -G nagcmd nagios

3、编译与安装Nagios

[root@nagios ~]# tar -zxvf nagios-3.4.4.tar.gz

[root@nagios ~]# cd nagios

[root@nagios nagios]#./configure --with-command-group=nagcmd //编译Nagios 配置脚本并使用先前开设的用户及用户组

[root@nagios nagios]#make all     //编译Nagios 程序包源码

*** Compile finished ***

If the main program and CGIs compiled without any errors, you

can continue with installing Nagios as follows (type 'make'

without any arguments for a list of all possible options):

  make install   //使用make install来安装主程序,CGIHTML文件

     - This installs the main program, CGIs, and HTML files

  make install-init  //使用make install-init/etc/rc.d/init.d安装启动脚本

     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode  //使用make install-commandmode来配置目录权限

     - This installs and configures permissions on the

       directory for holding the external command file

  make install-config  //把配置文件的例子复制到nagios的安装目录: /usr/local/nagios/etc

     - This installs *SAMPLE* config files in /usr/local/nagios/etc

       You'll have to modify these sample files before you can

       use Nagios.  Read the HTML documentation for more info

       on doing this.  Pay particular attention to the docs on

       object configuration files, as they determine what/how

       things get monitored!

  make install-webconf   //安装Nagios WEB 配置文件到Apache conf.d 目录下

     - This installs the Apache config file for the Nagios

       web interface

  make install-exfoliation

     - This installs the Exfoliation theme for the Nagios

       web interface

  make install-classicui

     - This installs the classic theme for the Nagios

       web interface

*** Support Notes *******************************************

安装二进制运行程序、初始化脚本、配置文件样本并设置运行目录权限

[root@nagios nagios]#make install  

[root@nagios nagios]#make install-init

[root@nagios nagios]#make install-config

[root@nagios nagios]#make install-commandmode

[root@nagios nagios]#make install-webconf

 

复制nagios/contrib/eventhandlers目录下所有文件到/usr/local/nagios/libexec下:

[root@nagios nagios]#cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

 

修改用户和主权限

[root@nagios nagios]#chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

[root@nagios nagios]# ll /usr/local/nagios/libexec/eventhandlers/

总用量 28

-rwxr-xr-x. 1 nagios nagios  828 9  27 11:33 disable_active_service_checks

-rwxr-xr-x. 1 nagios nagios  759 9  27 11:33 disable_notifications

drwxr-xr-x. 2 nagios nagios 4096 9  27 11:33 distributed-monitoring

-rwxr-xr-x. 1 nagios nagios  827 9  27 11:33 enable_active_service_checks

-rwxr-xr-x. 1 nagios nagios  760 9  27 11:33 enable_notifications

drwxr-xr-x. 2 nagios nagios 4096 9  27 11:33 redundancy-scenario1

-rwxr-xr-x. 1 nagios nagios 1184 9  27 11:33 submit_check_result

验证Nagios配置文件,验证配置是否有误

[root@nagios nagios]#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

重启httpd

[root@nagios ~]# /etc/init.d/httpd start

[root@nagios ~]# chkconfig httpd on

 

修改配置文件

[root@nagios ~]# vim /usr/local/nagios/etc/objects/contacts.cfg

修改nagiosadmin(这里修改为你自己创建的帐号) 注:nagiosadmin是配置文件默认,可以不用修改。

创建一个默认用户登录Web界面访问创建HTTP认证用户登录Nagios,用户名nagiosadmin,密码123456

[root@nagios ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

New password: 123456

Re-type new password: 123456

 

验证程序是否被正确安装:

切换目录到安装路径(这里是/usr/local/nagios,看是否存在 bin  etc  libexec  sbin  share  var这六个目录,如果存在则可以表明程序被正确的安装到系统了。后表是六个目录功能的简要说明:

bin

Nagios执行程序所在目录,nagios文件即为主程序

etc

Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件

libexec

Nagios 系统库文件

sbin

Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录

Share

Nagios网页文件所在的目录

Var

Nagios日志文件、spid 等文件所在的目录

var/archives

Empty directory for the archived logs

var/rw

Empty directory for the external command file

 

4、编译并安装Nagios 插件

[root@nagios ~]# tar zxvf nagios-plugins-1.4.16.tar.gz

[root@nagios ~]# cd nagios-plugins-1.4.16

[root@nagios nagios-plugins-1.4.16]#./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@nagios nagios-plugins-1.4.16]# make;make install

 

会显示安装的插件文件,即所有的插件都安装在libexec这个目录下

[root@nagios ~]# ls /usr/local/nagios/libexec/

 

验证Nagios 配置文件

[root@nagios ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

5、启动Nagios

Nagios 加入到服务列表中以使之在系统启动时自动启动

[root@nagios ~]#/etc/init.d/nagios start

[root@nagios ~]# chkconfig nagios on

 

6、登录到WEB界面

输入用户名密码:nagiosadmin  123456

http://localhost/nagios

Services

7、防火墙配置

如果WEB无法访问,检查一下IPtables是否关闭。

[root@nagios ~]# service iptables status

添加httpd 80端口:

[root@nagios ~]# vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

 

Nagios 安装完成!




本文转自 yhw85 51CTO博客,原文链接:http://blog.51cto.com/yanghuawu/1008162,如需转载请自行联系原作者

相关文章
|
4月前
|
应用服务中间件 Linux 网络安全
Centos 8.0中Nginx配置文件和https正书添加配置
这是一份Nginx配置文件,包含HTTP与HTTPS服务设置。主要功能如下:1) 将HTTP(80端口)请求重定向至HTTPS(443端口),增强安全性;2) 配置SSL证书,支持TLSv1.1至TLSv1.3协议;3) 使用uWSGI与后端应用通信(如Django);4) 静态文件托管路径设为`/root/code/static/`;5) 定制错误页面(404、50x)。适用于Web应用部署场景。
600 87
|
2月前
|
存储 Linux Apache
在CentOS上配置SVN至Web目录的自动同步
通过上述配置,每次当SVN仓库中提交新的更改时,`post-commit`钩子将被触发,SVN仓库的内容会自动同步到指定的Web目录,从而实现代码的连续部署。
124 16
|
2月前
|
NoSQL 安全 Linux
设置Redis在CentOS7上的自启动配置
这些步骤总结了在CentOS 7系统上设置Redis服务自启动的过程。这些命令提供了一个直接且明了的方式,确保Redis作为关键组件在系统启动时能自动运行,保障了依赖于Redis服务的应用的稳定性和可用性。
336 9
|
4月前
|
Linux
Centos6配置阿里云yum源报错
在CentOS 6配置阿里云Yum源时,可能出现EPEL仓库访问报错(404 Not Found)。解决方法:编辑`/etc/yum.repos.d/epel.repo`文件,将`enabled`和`gpgcheck`参数设为0 ``` 此设置可解决仓库无法访问的问题。
1235 29
|
4月前
|
Ubuntu 安全 Linux
CentOS与Ubuntu中防火墙配置命令集汇
有了这些,你就能遨游在 CentOS 和 Ubuntu 的海洋中,频繁地改变你的防火墙设置,快速地应对各种安全威胁,同时也能保证你的系统可以正常工作。出发吧,勇敢的编程者,随着这些命令集的涌动,扬帆起航,走向安全的网络世界!
149 5
|
5月前
|
关系型数据库 MySQL Linux
CentOS 7系统下详细安装MySQL 5.7的步骤:包括密码配置、字符集配置、远程连接配置
以上就是在CentOS 7系统下安装MySQL 5.7的详细步骤。希望这个指南能帮助你顺利完成安装。
1395 26
|
3月前
|
XML Java 应用服务中间件
在centos7.x上安装配置tomcat
本指南介绍了在Linux系统中部署Tomcat服务器的完整流程,包括关闭防火墙与SELinux、安装JDK、下载及解压Tomcat、启动和关闭Tomcat服务,以及配置Tomcat管理功能。同时,详细描述了如何导入项目到Tomcat的webapps目录、修改配置文件,并测试项目访问。通过这些步骤,您可以成功搭建并运行一个基于Tomcat的Web应用环境。
|
5月前
|
安全 Linux 网络安全
在Linux(CentOS和AWS)上安装更新的git2的方法并配置github-ssh
经过以上这些步骤,你现在就能在GitHub上顺利往返,如同海洋中的航海者自由驰骋。欢迎你加入码农的世界,享受这编程的乐趣吧!
201 10
|
11月前
|
Linux 网络安全 Apache
CentOS 7.2配置Apache服务httpd(上)
CentOS 7.2配置Apache服务httpd(上)
682 1