温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Nagios 安装配置

发布时间:2020-08-04 08:54:05 来源:网络 阅读:811 作者:混蛋哥 栏目:移动开发
Nagios 介绍
Nagios 是一款Linux 上成熟的监视系统运行状态和网络信息的开源软件,可以对对主机或服务进行检测的自动化工具;Nagios 能监控所指定的本地或远程主机及服务,同时提供异常通知、事件处理等功能。与商业IT管理系统相比,Nagios 具有成本低廉、结构简单、可维护性强等诸多优点。
Nagios 安装配置:
*安装环境 centos 6.3
*新版本改进
5 3.4.4 - 01/12/2013
6 ------------------
7 * Reenabled check for newer versions of Nagios Core (Mike Guthrie)
8 * Fixed bug #408: service checks get duplicated on reload (Eric Stanley)
9 * Fixed bug #401: segmentation fault on Solaris when parsing unknown timeperiod directives. (Eric Stanley)
10 * Added NULL pointer checks to CGI code. (Eric Stanley)
11 * Fixed buffer overflow vulnerability in CGI code. Thanks to Neohapsis (http://archives.neohapsis.com/archives/fulldisclosure/2012-12/0108.html) for finding this. (Eric Stanley)
一、创建用户和组  
[root@localhost ~]# useradd -s /sbin/nologin nagios
[root@localhost ~]# mkdir /usr/local/nagios  
[root@localhost ~]# chown -R nagios:nagios /usr/local/nagios/ 
二、安装apache、php、sendmail、gd_devel   
[root@localhost ~]# yum install gd-devel httpd httpd-devel php sendmail -y
三、编译安装Nagios
[root@localhost ~]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz
[root@localhost ~]# tar zxvf nagios-3.4.4.tar.gz
[root@localhost ~]# cd nagios                   #跟老版本有点区别
[root@localhost nagios]# ./configure --prefix=/usr/local/nagios/  #指定安装目录
[root@localhost nagios]# make all
[root@localhost nagios]# make install           #安装Nagios主程序的CGI和HTML文件
[root@localhost nagios]# make install-init      #创建Nagios启动脚本
[root@localhost nagios]# make install-commandmode   #配置目录权限
[root@localhost nagios]# make install-config    #安装Nagios示例配置文件 
* nagios安装完成后,目录对应的功能说明如下:   
bin:可执行程序所在目录   
etc:配置文件所在目录   
sbincgi文件所在目录,也就是执行外部命令所需文件所在目录   
share:网页文件所在目录   
libexec:外部插件所在目录   
var:日志文件,lock等文件所在目录   
var/archives:日志自动归档目录   
var/rw:用来存放外部命令文件的目录 
四、编译安装nagios-plugins   

[root@localhost ~]# wget http://sourceforge.net/projects/nagiosplug/files/latest/download?source=directory

[root@localhost ~]# tar zxvf nagios-plugins-1.4.16.tar.gz
[root@localhost ~]# cd nagios-plugins-1.4.16
[root@localhost nagios-plugins-1.4.16]# ./configure --prefix=/usr/local/nagios/
[root@localhost nagios-plugins-1.4.16]# make && make install

 

五、配置Apache
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
#红色部分为修改添加部分
User nagios
Group nagios
DirectoryIndex index.html index.html.var index.php
AddType application/x-httpd-php .php
#在配置文件末尾添加如下信息:
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
         <Directory "/usr/local/nagios/sbin">
             AuthType Basic
             Options ExecCGI
             AllowOverride None
             Order allow,deny
             Allow from all
             AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
             Require valid-user
         </Directory>
Alias /nagios "/usr/local/nagios/share"
         <Directory "/usr/local/nagios/share">
             AuthType Basic
             Options None
             AllowOverride None
             Order allow,deny
             Allow from all
             AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
             Require valid-user
         </Directory>
#添加Apache认证用户:
[root@localhost ~]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd user
New password:
Re-type new password:
Adding password for user user
六、配置本机监控
1.新建monitor 文件,拷贝示例文件到该目录下
[root@localhost etc]# pwd
/usr/local/nagios/etc
[root@localhost etc]# mv objects/ monitor
2.修改联系人配置文件
[root@localhost monitor]# cat contacts.cfg |grep -v "#"|grep " "
define contact{
        contact_name                    user            ; Short name of user
        use                             generic-contact         ; 引用generic-contact属性信息
        alias                           Nagios Admin            ; Full name of user
        email                           user@163.com        ; 告警接收邮箱
        }
define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 user              ;添加上面定义的联系人,逗号分隔
        }
3.修改cgi.cfg
default_user_name=user ;将用户名修改为nagios界面登录的用户名
4.修改nagios.cfg 将所有cfg_file=都注释掉添加如下一行
cfg_dir=/usr/local/nagios/etc/monitor
#这样配置非常方便以后维护
5.使用命令:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg检查配置是否有误
6.重启apache、nagios 并加到开启启动项
[root@localhost ~]# service httpd restart
停止 httpd:[确定]
正在启动 httpd:[确定]
[root@localhost ~]# service nagios restart
Running configuration check...done.
Stopping nagios: .done.
Starting nagios: done.
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig nagios on
7.下图为了看的更直观,没有删除其他的配置,目前还没有这个版本的汉化包,3.2版本有汉化包,汉化过的软件比较别扭,英文版的多使用几次就熟悉了。
Nagios 安装配置

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI