|NO.Z.00039|——————————|^^ 构建 ^^|——|Nagios构建.V5|——|3台server|

附录一:构建Nagios
一、实验环境
### --- 解决安装Nagios的依赖关系:                                                
### --- 需要注意*gb*必须按照视屏的方式进行后安装

yum install -y httpd gcc glibc glibc-common *gd*php php-mysql
二、创建运行身份
### --- 创建运行身份

groupadd nagcmd                                                             // 创建运行组
useradd -m nagios                                                           // 创建运行用户nagios
usermod -a -G nagcmd nagios                                                 // 将nagios用户添加到nagcmd组中
usermod -a -G nagcmd apache                                                 // 将Apache用户添加到nagcmd组中
三、编译安装nagios
### --- 编译安装nagios

tar -zxvf nagios-3.1.2.tar.gz                                               // 解压Nagios源码包
cd nagios-3.1.2
./configure --with-command-group=nagcmd --enable-event-broker               // Nagios Makefile文件
make all
make install
make install-init
make install-config
make install-commandmode
vim /usr/local/nagios/etc/objects/contacts.cfg
email nagios@loaclhost                                                      // 这个是默认设置
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart
四、编译安装nagios-plugins
### --- 编译安装nagios-plugins
tar zxf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql --enable-perl-modules
make 
make install
五、配置并启动Nagios
### --- 配置并启动Nagios

chkconfig -add nagios
chkconfig nagios on
/usr/local/naios/bin/nagios -v /usr//loacl/nagios/etc/nagios.cfg
service nagios start
//http://your_nagios_IP/nagios
六、添加监控主机
1、配置Windows端监控
### --- 配置Windows端监控
~~~     被监控端安装NSClient++-0.3.8-Win32.msi
~~~     安装完成后修改配置文件NSC.ini把需要的库都打开
~~~     在监控服务器修改nagios配置文件nagios.cfg

define host {
        use         windows-server ;Ingerit default 
    values from a template
        host_name   winserver       ;The name
    we're giving to this host
        alias       My Windows Server   ;A
    longer name associated with the host
        address         192.168.0.191   ;你主机的IP
}
2、配置Linux端监控
### --- 配置Linux端监控
### --- 创建用户
useradd nagios

### --- 为了安装nrpe,先安装nagios-plugins-1.4.15.tar.gz插件
tar -zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
### --- 安装nrpe

tar -zxvf nrpe-2.12.tar.gz
cd nrpe-2.12.tar.gz
./configure --enable-ssl --with-ssl-lib=/usr/lib64/
make all
make install-plugin
make install-daemon
make install-daemon-config
### --- 配置nrpe信息
vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=192.168.216.251,127.0.0.1
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

### --- 服务器端安装nrpe插件
cd nagios-nrpe_2.8.1
./configure --enable-ssl --with-ssl-lib=/usr/lib64
make all
make install-plugin
### --- commands.cfg定义外部构建nrpe

vi /usr/local/nagios/etc/objects/commands.cfg
    define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H 
$HOSTADDRESS$ -c $ARG1$
    }
### --- 定义mylinux.cgf

define host{
    use         linux-server 
    bost_name   mylinux/IP
    alias       mylinux
    address     192.168.0.27(客户端IP即被监控的IP)
}
define service{
    use                 generic-service
    host_name           mylinux
    service_description check-load
    check_command
check_nrpe!check_load
}
define service{
    use                 generic-service
    host_name           mylinux
    service_description check-users
    check_command   
    check_nrpe!check_users
}
define service{
    use                 generic-service
    host_name           mylinux
    service_description otal_procs
    check_command
check_nrpe!check_total_procs
}

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on 2022-03-22 16:00  yanqi_vip  阅读(30)  评论(0)    收藏  举报

导航