jiay 发表于 2017-4-20 08:50:31

nagios最新详细安装

nagios最新详细安装


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

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


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

四、安装mysql
#wget http://acelnmp.googlecode.com/files/mysql-5.1.52.tar.gz
#groupadd mysql;
#useradd mysql -g mysql -s /sbin/nologin -d /dev/null -M -c "just for mysql";
#cd /usr/local/src/
#tar -zxvf mysql-5.1.52.tar.gz;
#cd mysql-5.1.52;
#./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的配置文件:

# 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会一直提示需要下载,同时需要重启。
# /usr/local/apache/bin/apachectl stop
# /usr/local/apache/bin/apachectl start


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


# useradd -s /sbin/nologinnagios
# groupadd nagioscmd
# usermod -G nagioscmd nagios
# tar -zxvf nagios-3.4.1.tar.gz
# cdnagios-3.4.1
# ./configure --with‐command‐group=nagioscmd --prefix=/usr/local/nagios
# make all
# make install
# make install-init
# make install-config
# make install-commandmode

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

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

# 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>


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

# pwd
/usr/local/nagios/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的样例配置文件
# /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

# /usr/local/apache/bin/apachectl stop
# /usr/local/apache/bin/apachectl start
可以进入http://192.168.1.113/nagios/


第三部分配置文件修改:
1、修改nagios.cfg
# 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 administratorgroup
       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_commandsnotify-service-by-fetion
       host_notification_commands   notify-host-by-fetion
#      email                        test@163.com
       pager                        13482397937
}


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



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

2、安装nrpe
# wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz
# tar -zxvf nrpe-2.13.tar.gz ;cd nrpe-2.13
#./configure --disable-ssl
#make all && make install-plugin && make install-daemon && make install-daemon-config
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
# /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=/usr/local/nagios/libexec/check_users -w 5 -c 10
command=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command=/usr/local/nagios/libexec/check_ssh -H localhost
command=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command=/usr/local/nagios/libexec/check_mysql -H localhost -uroot -ptomcat2008
(以上组件一般都会有,以下为添加的)
command=/usr/local/nagios/libexec/check_mysql_slave -w 5 -c 10
command=/usr/local/nagios/libexec/check_apachestatus -H localhost -p 80
command=/usr/local/nagios/libexec/check_ntp -H localhost -w 0.5 -c 1
command=/usr/local/nagios/libexec/check_snmp_service -H localhost -C monitor_energysh
command=/usr/local/nagios/libexec/check_mem -u M
command=/usr/local/nagios/libexec/check_memcached -H localhost
command=/usr/local/nagios/libexec/check_rsync -H localhost -p 873

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

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

1、check_mysql_slave报错(如下)
# /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相关的组件
# yum -y install perl-DBD-MySQL
# /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报错(如下)
# /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.
解决方法:
# perl -MCPAN -eshell
cpan> install Bundle::LWP
# /usr/local/nagios/libexec/check_apachestatus -H localhost -p 80
CRITICAL 404 Not Found

3、ntpd server
# /usr/local/nagios/libexec/check_ntp -H localhost -w 0.5 -c 1
NTP CRITICAL: No response from NTP server
(没有安装此服务)
4、snmp server
# /usr/local/nagios/libexec/check_snmp_service -H localhost -C monitor_energysh
Critical! SNMP is not accessible. Please check!
(没有安装此服务cacti需要用到的)
5、监控内存
#/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.
解决方法:
# cpan -iNagios::Plugin
如果这样安装不行,下载再安装
# wget http://mirrors.sohu.com/CPAN/authors/id/T/TO/TONVOON/Nagios-Plugin-0.36.tar.gz
# tar -zxvf Nagios-Plugin-0.36.tar.gz
# cdNagios-Plugin-0.36
# perl Makefile.PL
# make ; make install

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

# /usr/local/nagios/libexec/check_mem -u M                  
CHECK_MEMORY OK - 730M free | free=765685760b;;




5、监控memcached

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


# /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安装一下。)
# tar -jxvf Python-2.6.5.tar.bz2
# ./configure --prefix=/usr/local/python
# make; make install
# vi /etc/profile
# PATH=/usr/local/python/bin:$PATH
# source /etc/profile
# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c10.tar.gz#md5=30f822f19b02c3082cb1ba1d69be35dd
# tar zxvf setuptools-0.6c10.tar.gz
# cd setuptools-0.6c10
# python setup.py build
# python setup.py install

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

《nagios部署完毕----7少》
页: [1]
查看完整版本: nagios最新详细安装