nagios最新详细安装

nagios最新详细安装


第一部分:
一、开发库等安装
首先安装相关应用包。如gcc、 glibc、glibc-common、gd、gd-devel
[root@lnx13 ~]# yum install gcc* glibc glibc-common gd gd-devel
[root@lnx13 ~]# yum install libtool-ltdl 

二、httpd安装
[root@lnx13 ~]# wget http://sunsite.bilkent.edu.tr/pub/apache/httpd/httpd-2.2.9.tar.gz
[root@lnx13 ~]# tar -zxvf httpd-2.2.9.tar.gz
[root@lnx13 ~]# cd httpd-2.2.9
[root@lnx13 ~]# ./configure --enable-so --prefix=/usr/local/apache
[root@lnx13 ~]# make ; make install


三、安装PHP
[root@lnx13 ~]#wget http://download.huihoo.com/php/php-5.2.6.tar.gz
[root@lnx13 ~]#tar -zxvf php-5.2.6.tar.gz
[root@lnx13 ~]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql
[root@lnx13 ~]#make; make install

四、安装mysql
[root@lnx13 ~]#wget http://acelnmp.googlecode.com/files/mysql-5.1.52.tar.gz
[root@lnx13 ~]#groupadd mysql;
[root@lnx13 ~]#useradd mysql -g mysql -s /sbin/nologin -d /dev/null -M -c "just for mysql";
[root@lnx13 ~]#cd /usr/local/src/
[root@lnx13 ~]#tar -zxvf mysql-5.1.52.tar.gz;
[root@lnx13 ~]#cd mysql-5.1.52;
[root@lnx13 ~]#./configure --prefix=/usr/local/mysql     \
                    --without-debug                   \
                    --with-pthread                    \
          --with-plugins=partition,blackhole,heap,innobase,myisam,ndbcluster            \
                    --with-big-tables                 \
                    --with-extra-charsets=all         \
                    --with-mysqld-ldflags=-rdynamic  \
                    --with-client-ldflags=-all-static \
                    --enable-assembler                \
                    --enable-local-infile             \
                    --enable-thread-safe-client      \
           
make ; make install;
/usr/local/mysql/bin/mysql_install_db  --user=mysql; chown -R root /usr/local/mysql;
chown -R mysql /usr/local/mysql/var;
chgrp -R mysql /usr/local/mysql;
cp /usr/local/src/mysql-5.1.52/support-files/mysql.server /etc/init.d/mysqld;
chmod 755 /etc/init.d/mysqld;
chkconfig --add mysqld;
service mysqld restart;
/usr/local/mysql/bin/mysqladmin -u root password 'tomcat2008';
cp /usr/local/src/mysql-5.1.52/support-files/my-medium.cnf /etc/my.cnf;
(以上步骤可以直接copy.你懂的)

五、修改httpd的配置文件:

[root@lnx13 ~]# more /usr/local/apache/conf/httpd.conf
修改的地方: ServerName :80
增加:AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
增加:LoadModule php5_module        modules/libphp5.so
增加:
LoadModule jk_module      modules/mod_jk.so
增加DirectoryIndex index.html index.php
测试内容test.php
<?php phpinfo(); ?>
如果以上内容没有增加,打开test.php会一直提示需要下载,同时需要重启。
[root@lnx13 ~]# /usr/local/apache/bin/apachectl stop
[root@lnx13 ~]# /usr/local/apache/bin/apachectl start


第二部分:
一、安装nagios及相关组件
下载nagios组件
[root@lnx13 ~]# wget http://nchc.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.1/nagios-3.4.1.tar.gz


[root@lnx13 ~]# useradd -s /sbin/nologin  nagios
[root@lnx13 ~]# groupadd nagioscmd
[root@lnx13 ~]# usermod -G nagioscmd nagios
[root@lnx13 ~]# tar -zxvf nagios-3.4.1.tar.gz
[root@lnx13 ~]# cd  nagios-3.4.1
[root@lnx13 nagios]# ./configure --with‐command‐group=nagioscmd --prefix=/usr/local/nagios
[root@lnx13 nagios]# make all
[root@lnx13 nagios]# make install
[root@lnx13 nagios]# make install-init
[root@lnx13 nagios]# make install-config
[root@lnx13 nagios]# make install-commandmode

第一步执行make install安装主要的程序、CGI及HTML文件
第二步执行 make install-commandmode 给外部命令访问nagios配置文件的权限
第三步执行 make install-config 把配置文件的例子复制到nagios的安装目录
第三步执行make install-init 它的作用是把nagios做成一个运行脚本,使nagios随系统开机启动,

二、编译并安装nagios插件 nagios‐plugins
[root@lnx13 ~]# wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
[root@lnx13 ~]#tar -zxvf nagios-plugins-1.4.16.tar.gz
[root@lnx13 ~]#cd  nagios-plugins-1.4.16
[root@lnx13 nagios-plugins-1.4.16]#./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios/
[root@lnx13 nagios-plugins-1.4.16]#make ; make install

[root@lnx13 nagios]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
在httpd.conf最后添加如下内容:
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">
   Options ExecCGI
   AllowOverride None
   AddHandler cgi-script cgi pl
   Order allow,deny
   Allow from all
   AuthName "Monitor System"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd
   Require valid-user henry
</Directory>

# Where the HTML pages live
Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Monitor System"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd
   Require valid-user
</Directory>


[root@lnx13 nagios]# /usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin
注:htpasswd –c表示追加,否者是覆盖写入。

[root@lnx13 etc]# pwd
/usr/local/nagios/etc
[root@lnx13 etc]# vi cgi.cfg
authorized_for_system_information=nagiosadmin,hanling
authorized_for_configuration_information=nagiosadmin,hanling
authorized_for_system_commands=nagiosadmin,hanling
authorized_for_all_services=nagiosadmin,hanling
authorized_for_all_hosts=nagiosadmin,hanling
authorized_for_all_service_commands=nagiosadmin,hanling
authorized_for_all_host_commands=nagiosadmin,hanling
cgi.cfg修改内容如上(多用户,请用逗号格开 )
验证Nagios的样例配置文件
[root@lnx13 etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
启动Nagios
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

[root@lnx13 etc]# /usr/local/apache/bin/apachectl stop
[root@lnx13 etc]# /usr/local/apache/bin/apachectl start
可以进入http://192.168.1.113/nagios/


第三部分配置文件修改:
1、修改nagios.cfg
[root@lnx13 libexec]# more /usr/local/nagios/etc/nagios.cfg
增加或修改:
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
修改:
command_check_interval=1s

2、commands.cfg 在最后增加
define command {     
       command_name check_nrpe    
       command_line $USER1$/check_nrpe -n -H $HOSTADDRESS$ -c $ARG1$ -t 45
}

define command {
       command_name check_nagios
       command_line $USER1$/check_nagios -e 5 -F /usr/local/nagios/var/status.dat -C /usr/local/nagios/bin/nagios
}

define command {
       command_name check_apache
       command_line $USER1$/check_apachestatus -H 192.168.1.113 -p 80
}

define command {
       command_name check_ntp
       command_line $USER1$/check_ntp -H $HOSTADDRESS$ -w 0.5 -c 1
}

define command {
       command_name check_memcached
       command_line $USER1$/check_memcached -H 192.168.1.113
}

define command {
       command_name check_mysql_slave
       command_line $USER1$/check_mysql_slave
}

3、hosts.cfg 修改如下
define host{
       host_name                  Nagios-server
       alias                      Nagios-server
       address                    192.168.1.113
       contact_groups             admins
       hostgroups                 realserver
       check_command              check-host-alive
       notification_interval      10
       notification_period        24x7
       notification_options       d,u,r
       max_check_attempts         4
       process_perf_data          1
}
define host{
       host_name                  Real_112
       alias                      Real_112
       address                    192.168.1.112
       contact_groups             admins
       hostgroups                 realserver
       check_command              check-host-alive
       notification_interval      10
       notification_period        24x7
       notification_options       d,u,r
       max_check_attempts         4
       process_perf_data          1
}

define host{
       host_name                  DB115
       alias                      DB115
       address                    192.168.1.115
       contact_groups             admins
       hostgroups                 DBservers
       check_command              check-host-alive
       notification_interval      10
       notification_period        24x7
       notification_options       d,u,r
       max_check_attempts         4
       process_perf_data          1
}
define hostgroup{
       hostgroup_name            realserver
       alias                     All Linux/BSD servers
       members                   Nagios-server,Real_112
}
define hostgroup{
       hostgroup_name            DBservers
       alias                     All DB servers
       members                   DB115
}
define hostgroup{
       hostgroup_name            Allserver
       alias                     All Servers
       members                   Nagios-server,Real_112,DB115
}

4、 services.cfg修改如下
# -----------------------------------------------
# Enable ssh monitor for all server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-SSH
        check_period             24x7
        max_check_attempts       4
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        normal_check_interval    3
        retry_check_interval     2
        notification_interval    10
        notifications_enabled    1
        check_command            check_nrpe!check_ssh
}

# -----------------------------------------------
# Enable NTP monitor for all server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-NTP
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        notification_interval    10
        notifications_enabled    1
        check_command            check_nrpe!check_ntp
}

# -----------------------------------------------
# Check MySQL Slave status for all DB server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           realserver
        service_description      Check-MySQL-Slave
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_mysql_slave
}

# --------------------------------------------
# MySQL slave only for 115
# --------------------------------------------
define service{
        use                      local-service
        host_name                DB115
        service_description      Check-MySQL-Slave
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_mysql_slave
}

# -----------------------------------------------
# Enable MySQL monitor for all DB server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           DBservers
        service_description      Check-MySQL
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_mysql
}

# -----------------------------------------------
# Enable Apache status monitor for all server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           realserver
        service_description      Check-Apache
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_apache
}

# -----------------------------------------------
# Check how much memory left on each server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-Memory
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_mem
}

# -----------------------------------------------
# Check SNMP service on each server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-SNMP
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_snmp
}

# -----------------------------------------------
# Check how much disk space left on each server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-Disk
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_sda
}

# -----------------------------------------------
# Check how much disk space left on each server
# -----------------------------------------------
define service{
        use                      local-service
        host_name                DB115
        service_description      Check-/
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_/
}

# -----------------------------------------------
# Check how much disk space left on each server
# -----------------------------------------------
define service{
        use                      local-service
        host_name                DB115
        service_description      Check-/var
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_/var
}

# -----------------------------------------------
# Check how much disk space left on each server
# -----------------------------------------------
define service{
        use                      local-service
        host_name                DB115
        service_description      Check-/boot
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_/boot
}

# -----------------------------------------------
# Check how much disk space left on each server
# -----------------------------------------------
define service{
        use                      local-service
        host_name                DB115
        service_description      Check-/home
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_/home
}

# -----------------------------------------------
# Check how much disk space left on each server
# -----------------------------------------------
define service{
        use                      local-service
        host_name                DB115
        service_description      Check-/data
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_/data
}

# -----------------------------------------------
# Check how much disk space left on each server
# -----------------------------------------------
define service{
        use                      local-service
        host_name                DB115
        service_description      Check-/usr
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_/usr
}
# -----------------------------------------------
# Load average
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-load
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     u,c,r
        check_command            check_nrpe!check_load
}

# -----------------------------------------------
# Calculate total process for each server
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-total-process
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     w,u,c,r
        check_command            check_nrpe!check_total_procs
}

# -----------------------------------------------
# How much swap space left we have
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-Swap
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     w,u,c,r
        check_command            check_nrpe!check_swap
}

# -----------------------------------------------
# How many users logon to my system
# -----------------------------------------------
define service{
        use                      local-service
        hostgroup_name           Allserver
        service_description      Check-Users
        check_period             24x7
        max_check_attempts       4
        normal_check_interval    3
        retry_check_interval     2
        contact_groups           admins
        notification_interval    10
        notification_period      24x7
        notification_options     w,u,c,r
        check_command            check_nrpe!check_users
}


5、  hostgroups.cfg 修改如下
define hostgroup{
       hostgroup_name     System-Admin
       alias              Admin
       members            Nagios-Server,real-112,DB114
}

6、contactgroups.cfg修改如下
define contactgroup {
       contactgroup_name   sagroup
       alias system administrator  group
       members nagiosadmin
   }


7、contacts.cfg 修改如下
# --------------------------------------------------------------
define contact{
       contact_name                   SAadmin1
#      use                            generic-contact
       alias                          Test
       service_notification_period    24x7
       host_notification_period       24x7
       #service_notification_period    notworkhours
       #host_notification_period       notworkhours
       service_notification_options   w,u,c,r
       host_notification_options      d,u,r
       service_notification_commands  notify-service-by-fetion
       host_notification_commands     notify-host-by-fetion
#      email                          [email protected]
       pager                          13482397937
}


# --------------------------------------------------------------
# Define two contact groups
# --------------------------------------------------------------
define contactgroup{
       contactgroup_name              admins
       alias                          admins group
       members                        SAadmin1
}



第四部分:客户端安装相关组件(服务器端已安装过nagios-plugins.)
1、安装nagios-plugins
[root@lnx13 ~]#tar -zxvf nagios-plugins-1.4.16.tar.gz
[root@lnx13 ~]#cd nagios-plugins-1.4.16
[root@lnx13 ~]#./configure --prefix=/usr/local/nagios  make && make install
[root@lnx13 ~]#chown nagios.nagios /usr/local/nagios
[root@lnx13 ~]#chown -R nagios.nagios /usr/local/nagios/libexec

2、安装nrpe
[root@lnx13 ~]# wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz
[root@lnx13 ~]# tar -zxvf nrpe-2.13.tar.gz ;cd nrpe-2.13
[root@lnx13 nrpe-2.13]#./configure --disable-ssl
[root@lnx13 nrpe-2.13]#  make all && make install-plugin && make install-daemon && make install-daemon-config
[root@lnx13 nrpe-2.13]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@lnx13 nrpe-2.13]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1  
NRPE v2.13

添加nrpe服务器地址,允许服务器对其读取信息
more /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,203.212.5.19
增加command字段来添加要监控的服务
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_ssh]=/usr/local/nagios/libexec/check_ssh -H localhost
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_mysql]=/usr/local/nagios/libexec/check_mysql -H localhost -uroot -ptomcat2008
(以上组件一般都会有,以下为添加的)
command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql_slave -w 5 -c 10
command[check_apache]=/usr/local/nagios/libexec/check_apachestatus -H localhost -p 80
command[check_ntp]=/usr/local/nagios/libexec/check_ntp -H localhost -w 0.5 -c 1
command[check_snmp]=/usr/local/nagios/libexec/check_snmp_service -H localhost -C monitor_energysh
command[check_mem]=/usr/local/nagios/libexec/check_mem -u M
command[check_memcached]=/usr/local/nagios/libexec/check_memcached -H localhost
command[check_rsync]=/usr/local/nagios/libexec/check_rsync -H localhost -p 873

数据据的监控服务器
command[check_/]=/usr/local/nagios/libexec/check_disk -w 50% -c 55% -p  /
command[check_/data]=/usr/local/nagios/libexec/check_disk -w 10% -c 20% -p /data
command[check_/home]=/usr/local/nagios/libexec/check_disk -w 40% -c 45% -p /home
command[check_/var]=/usr/local/nagios/libexec/check_disk -w 70% -c 75% -p /var
command[check_/usr]=/usr/local/nagios/libexec/check_disk -w 70% -c 75% -p /usr
command[check_/boot]=/usr/local/nagios/libexec/check_disk -w 50% -c 55% -p /boot
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_sda]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 1000 -c 1200
command[check_ssh]=/usr/local/nagios/libexec/check_ssh -H localhost
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_mysql]=/usr/local/nagios/libexec/check_mysql -H localhost -uroot -ptomcat2008
command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql_slave -w 5 -c 10
command[check_apache]=/usr/local/nagios/libexec/check_apachestatus -H localhost -p 80
command[check_ntp]=/usr/local/nagios/libexec/check_ntp -H localhost -w 0.5 -c 1
command[check_tomcat]=/usr/local/nagios/libexec/check_tomcat -H localhost
command[check_snmp]=/usr/local/nagios/libexec/check_snmp_service -H localhost -C monitor_energysh
command[check_mem]=/usr/local/nagios/libexec/check_mem -u M

第五部分:监控服务报错处理

1、check_mysql_slave报错(如下)
[root@lnx13 libexec]# /usr/local/nagios/libexec/check_mysql_slave -w 5 -c 10
Can't locate DBI.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/nagios/libexec/check_mysql_slave line 4.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/check_mysql_slave line 4.
解决方法:
安装与mysql相关的组件
[root@lnx13 libexec]# yum -y install perl-DBD-MySQL
[root@lnx13 libexec]# /usr/local/nagios/libexec/check_mysql_slave -w 5 -c 10
CHECK MySQL SLAVE - process - CRITICAL -  Slave IO State not correct, slave stopped or replication broken!
(因为这台服务器没有做同步)

2、监控apache状态check_apachestatus报错(如下)
[root@lnx13 libexec]# /usr/local/nagios/libexec/check_apachestatus -H localhost -p 80
Can't locate LWP/UserAgent.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/nagios/libexec/check_apachestatus line 5.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/check_apachestatus line 5.
解决方法:
[root@lnx13 libexec]# perl -MCPAN -eshell
cpan> install Bundle::LWP
[root@lnx13 libexec]# /usr/local/nagios/libexec/check_apachestatus -H localhost -p 80
CRITICAL 404 Not Found

3、ntpd server
[root@lnx13 libexec]# /usr/local/nagios/libexec/check_ntp -H localhost -w 0.5 -c 1
NTP CRITICAL: No response from NTP server
(没有安装此服务)
4、snmp server
[root@lnx13 libexec]# /usr/local/nagios/libexec/check_snmp_service -H localhost -C monitor_energysh
Critical! SNMP is not accessible. Please check!
(没有安装此服务cacti需要用到的)
5、监控内存
[root@lnx13 libexec]#  /usr/local/nagios/libexec/check_mem -u M   
Can't locate Nagios/Plugin.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/nagios/libexec/check_mem line 26.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/check_mem line 26.
解决方法:
[root@lnx13 libexec]# cpan -i  Nagios::Plugin
如果这样安装不行,下载再安装
[root@lnx13 libexec]# wget http://mirrors.sohu.com/CPAN/authors/id/T/TO/TONVOON/Nagios-Plugin-0.36.tar.gz
[root@lnx13 ~]# tar -zxvf Nagios-Plugin-0.36.tar.gz
[root@lnx13 ~]# cd  Nagios-Plugin-0.36
[root@lnx13 Nagios-Plugin-0.36]# perl Makefile.PL
[root@lnx13 Nagios-Plugin-0.36]# make ; make install

[root@lnx13 Params-Validate-1.06]# cpan -i Module::Implementation
[root@lnx13 Params-Validate-1.06]# cpan -i Module::Build
[root@lnx13 Params-Validate-1.06]#  cpan -i Attribute::Handlers
[root@lnx13 Params-Validate-1.06]#  cpan -i Params::Validate
(以上安装,一定要注意一点就是看提示,看缺少哪个组件,就安装哪个组件,逐步安装)

[root@lnx13 Params-Validate-1.06]# /usr/local/nagios/libexec/check_mem -u M                   
CHECK_MEMORY OK - 730M free | free=765685760b;;




5、监控memcached

[root@lnx13 ~]# wget http://search.cpan.org/CPAN/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz
[root@lnx13 ~]# tar -zxvf Nagios-Plugins-Memcached-0.02.tar.gz
[root@lnx13 ~]# cd Nagios-Plugins-Memcached-0.02
[root@lnx13 Nagios-Plugins-Memcached-0.02]# perl Makefile.PL
[root@lnx13 Nagios-Plugins-Memcached-0.02]# make install


[root@lnx13 src]# /usr/local/nagios/libexec/check_memcached -H localhost
Traceback (most recent call last):
  File "/usr/local/nagios/libexec/check_memcached", line 15, in <module>
    import memcache
ImportError: No module named memcache

先把setuptools组先安装一下(在安装此setuptools也可以把python安装一下。)
[root@lnx13 src]# tar -jxvf Python-2.6.5.tar.bz2
[root@lnx13 src]# ./configure --prefix=/usr/local/python
[root@lnx13 src]# make; make install
[root@lnx13 src]# vi /etc/profile
[root@lnx13 src]# PATH=/usr/local/python/bin:$PATH
[root@lnx13 src]# source /etc/profile
[root@lnx13 src]# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c10.tar.gz#md5=30f822f19b02c3082cb1ba1d69be35dd
[root@lnx13 src]# tar zxvf setuptools-0.6c10.tar.gz
[root@lnx13 src]# cd setuptools-0.6c10
[root@lnx13 src]# python setup.py build
[root@lnx13 src]# python setup.py install

[root@lnx13 src]# wget http://lighttpd.googlecode.com/files/python-memcached-1.47.tar.gz
[root@lnx13 src]# tar -zxvf python-memcached-1.47.tar.gz
[root@lnx13 src]# cd python-memcached-1.47
[root@lnx13 python-memcached-1.47]# python setup.py install
[root@lnx13 python-memcached-1.47]# /usr/local/nagios/libexec/check_memcached -H localhost
CRITICAL - cannot set the value
6、监控rsync
[root@lnx13 libexec]#   /usr/local/nagios/libexec/check_rsync -H localhost -p 873
OK: Rsync is up

《nagios部署完毕----7少》


你可能感兴趣的:(nagios)