Warning: Undefined array key "cperpage" in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 230

Warning: Undefined variable $output in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 300

Warning: Undefined variable $fixed_tags in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 301

Warning: Undefined variable $isshowdots in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 302

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 305

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 308

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 311

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $more_text_link in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320
Centos6.3安装Cacti+Nagios+NDOUtils – 理想社会

Centos6.3安装Cacti+Nagios+NDOUtils

C

准备环境:

  1. 系统为Centos6.3-64bit,所下的软件都在/root/src下
  2. iptables和selinux都关闭,
  3. 安装必要组件 yum -y install httpd php php-gd freetype php-mysql php-snmp php-devel mysql mysql-server perl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-devel ruby ruby-devel gcc glibc glibc-common gd gd-devel ntp openssl openssl-devel

提供src文件如下:

 

一、安装Nagios:

  • 创建nagios用户及组。
useradd -m -s /bin/bash nagios
passwd nagios
  • 创建一个nagcmd的用户组,用于从web接口执行外部命令,将nagios和apache用户加入组中。
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www
  • 编译安装Nagios
tar zxvf nagios-3.4.3.tar
cd nagios-3.2.3
./configure --with-command-group=nagcmd
make
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cd ..

注:make install 用于安装主要的程序、CGI及HTML文件
make install-init 用于生成init启动脚本
make install-config 用于安装示例配置文件
make install-commandmode 用于设置相应的目录权限
make install-webconf 用于安装Apache配置文件

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

切换目录到安装路径,这里是/usr/local/nagios,看是否存在etc、bin、 sbin、 share、 var这五个目录,如果存在则可以表明程序被正确的安装到系统了。

ls /usr/local/nagios/
bin/ etc/ sbin/ share/ var/

注;bin–Nagios执行程序所在目录,其中的nagios文件即为主程序。
etc–Nagios配置文件位置
sbin–Nagios cgi文件所在目录,也就是执行外部命令所需文件所在的目录
Share–Nagios网页文件所在的目录
var–Nagios日志文件、spid 等文件所在的目录
var/archives–日志归档目录
var/rw–用来存放外部命令文件

  • 配置Nagios Web界面登陆帐号及密码
htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin

修改Nagios配置文件,给新增的用户增加访问权限

  • 编译并安装Nagios插件

由于Nagios主程序只是提供一个运行框架,其具体监控是靠运行在其下的插件完成的,所以Nagios插件是必须安装的。

tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

验证Nagios插件是否正确安装

ls /usr/local//nagios/libexec

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

  • 启动服务

启动前先检查下配置文件是否正确

/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

查看Nagios运行状态

/usr/local/nagios/bin/nagiostats
  • 安装NRPE

由于Nagios只能监测自己所在的主机的一些本地情况,例如,cpu负载、内存使用、硬盘使用等等。如果想要监测被监控的服务器上的这些本地情 况,就要用到NRPE。NRPE(Nagios Remote Plugin Executor)是Nagios的一个扩展,它被用于被监控的服务器上,向Nagios监控平台提供该服务器的一些本地的情况。NRPE可以称为 Nagios的Linux客户端。

tar zxvf nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config

注:监控主机上只需要make install-plugin这一步就可以了。监控机上只要有一个check_nrpe插件用于连接被监控端nrpe的daemon就行了。
启动NRPE

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

验证NRPE是否正确安装

/usr/local/nagios/libexec/check_nrpe -H localhost

注:如果成功,会返回NRPE的版本号。
二、Nagios被控端安装配置

  • 创建Nagios用户及组

建立Nagios账号

/usr/sbin/useradd -m -s /sbin/nologin nagios
  • 编译并安装Nagios插件
tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
cd ..

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

ls /usr/local/nagios/libexec

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

  • 安装NRPE
tar zxvf nrpe-2.13.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
cd ..
  • 启动NRPE
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

验证NRPE是否正确安装

/usr/local/nagios/libexec/check_nrpe -H localhost

注:如果成功,会返回NRPE的版本号。

  • 修改NRPE配置文件,让监控主机可以访问被监控主机的NRPE。

缺省NRPE配置文件中只允许本机访问NRPE的Daemon。

About the author

Add comment

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

By now163

Your sidebar area is currently empty. Hurry up and add some widgets.