Nagios安装笔记

运维 系统运维
我们知道Nagios是Linux/Unix上的监控系统,在用Nagios监控时你们会发现他非常好用,能帮大家不少忙,本文就给大家介绍下Nagios安装的具体流程。

我用了Nagios有一年多,在日常的监控工作中他都能胜任,那大家安装一个Nagios系统是必要的,让我们来看看Nagios安装具体过程!

 

Nagios 

图-Nagios

  修改yum升级服务器[root@localhost ~]# cd /etc/yum.repos.d[root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak[root@localhost yum.repos.d]# wget http://centos.ustc.edu.cn/CentOS-Base.repo

  ---更新软件[root@localhost yum.repos.d]# yum update

  ---安装以下必备软件[root@localhost yum.repos.d]# yum install httpd[root@localhost yum.repos.d]# yum install gcc[root@localhost yum.repos.d]# yum install glibc glibc-common[root@localhost yum.repos.d]# yum install gd gd-devel

  ---添加nagios用户、nagcmd组等

 

  1.   [root@localhost yum.repos.d]# cd [root@localhost ~]# useradd -m nagios[root@localhost ~]# passwd nagios ---nagios[root@localhost ~]# groupadd nagcmd[root@localhost ~]# usermod -a -G nagcmd nagios[root@localhost ~]# usermod -a -G nagcmd apache  
  2.  

 

  ---安装nagios

 

  1.   [root@localhost ~]# mkdir -p ~/downloads[root@localhost ~]# cd ~/downloads[root@localhost downloads]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.3/nagios-3.2.3.tar.gz[root@localhost downloads]# wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz[root@localhost downloads]# tar xzf nagios-3.2.3.tar.gz[root@localhost downloads]# cd nagios-3.2.3[root@localhost nagios-3.2.3]# ./configure --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include [root@localhost nagios-3.2.3]# make all[root@localhost nagios-3.2.3]# make install[root@localhost nagios-3.2.3]# make install-init[root@localhost nagios-3.2.3]# make install-config[root@localhost nagios-3.2.3]# make install-commandmode  
  2.  
  3.   [root@localhost nagios-3.2.3]# cp /usr/local/nagios/etc/objects/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg.bak[root@localhost nagios-3.2.3]# vi /usr/local/nagios/etc/objects/contacts.cfg ---修改nagiosadmin:email  
  4.  
  5.   [root@localhost nagios-3.2.3]# make install-webconf[root@localhost nagios-3.2.3]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin ---nagios  
  6.  
  7.   [root@localhost nagios-3.2.3]# service httpd restart  
  8.  

 

  ---安装nagios-plugins

 

  1.   [root@localhost nagios-3.2.3]# cd ~/downloads[root@localhost downloads]# tar xzf nagios-plugins-1.4.15.tar.gz[root@localhost downloads]# cd nagios-plugins-1.4.15[root@localhost nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios[root@localhost nagios-plugins-1.4.15]# make[root@localhost nagios-plugins-1.4.15]# make install  
  2.  

 

  ---安装nagios-snmp-plugins

  

  1. [root@localhost nagios-plugins-1.4.15]# cd ~/downloads[root@localhost downloads]# wget http://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz[root@localhost downloads]# tar xzf nagios-snmp-plugins.1.1.1.tgz[root@localhost downloads]# cd nagios_plugins[root@localhost nagios_plugins]# perl -MCPAN -e shell  
  2.  
  3.   cpan> install Net::SNMP  
  4.  
  5.   [root@localhost nagios_plugins]# ./install.sh  
  6.  

 

#p#

  ---其它设置

  [root@localhost nagios_plugins]# cd [root@localhost ~]# chkconfig --add nagios[root@localhost ~]# chkconfig nagios on[root@localhost ~]# chkconfig httpd on[root@localhost ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

       ---检测配置

  1. [root@localhost ~]# service nagios start  
  2.  
  3. @localhost ~]# cp /etc/sysconfig/selinux /etc/sysconfig/selinux.bak[root@localhost ~]# vi /etc/sysconfig/selinux ---SELINUX=permissive  

 

  ---安装mysql

 

  1.   [root@localhost ~]# yum -y install mysql[root@localhost ~]# yum -y install mysql-server[root@localhost ~]# yum -y install mysql-devel[root@localhost ~]# yum -y install php-mysql  
  2.  
  3.   [root@localhost ~]# chkconfig --levels 345 mysqld on[root@localhost ~]# service mysqld start  
  4.  
  5.   [root@localhost ~]# mysqlSET PASSWORD FOR 'root'@'localhost' = PASSWORD('mysql');  
  6.  
  7.   [root@localhost yum.repos.d]# yum install php  
  8.  

 

  ---安装cacti

 

  1.   [root@localhost ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm[root@localhost ~]# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm[root@localhost ~]# yum install rrdtool[root@localhost ~]# yum install net-snmp net-snmp-utils net-snmp-devel  
  2.  
  3.   [root@localhost ~]# yum install cacti ---php-mysql,php-pdo,php-snmp  
  4.  
  5.   [root@localhost conf.d]# vi cacti.conf  
  6.  
  7.   Alias /cacti/ /usr/local/wwwroot/cacti/ DirectoryIndex index.php Options -Indexes AllowOverride all order deny,allow allow from all AddType application/x-httpd-php .php php_flag magic_quotes_gpc on php_flag track_vars on  
  8.  
  9.   [root@localhost ~]# mysql -u root -pMysql>create database cacti;Mysql>use cacti;Mysql>source /usr/local/wwwroot/cacti/cacti.sqlMysql>grant all privileges on cacti.* to cacti@localhost identified by 'cacti';Mysql>flush privileges;  
  10.  

 

  ---apache设置

 

  1.   [root@localhost ~]# vi /var/www/cacti/include/config.php  
  2.  
  3.   $database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cacti";$database_password = "cacti";$database_port = "3306";  
  4.  

 

  ---安装ndoutils,实现nagios采集数据写入mysql

 

  1.   [root@localhost ~]# wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz[root@localhost ~]# tar zxf ndoutils-1.4b9.tar.gz[root@localhost ~]# cd ndoutils-1.4b9[root@localhost ndoutils-1.4b9]# ./configure --enable-mysql --disable-pgsql --with-mysql-lib=/usr/lib/mysql[root@localhost ndoutils-1.4b9]# make[root@localhost ndoutils-1.4b9]# cp config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg  
  2.  

 

通过文章,我们对Nagios的安装都有了自己的心得,希望你们赶快去装一个Nagios,真的非常好用。

【编辑推荐】

  1. Suse 9 安装Nagios过程
  2. Nagios扩展的主机和服务监测
  3. Nagios编译安装之配置Apache服务
  4. Nagios的配置文件
  5. Nagios插件plugins配置和安装

 

责任编辑:赵鹏 来源: 网络转载
相关推荐

2010-05-31 12:22:13

Nagios pnp

2011-11-08 21:58:01

Nagios 配置 流

2010-05-31 10:22:31

Nagios pnp

2011-03-28 15:22:00

nagios

2011-03-21 15:35:01

Nagiosnagios-plug安装

2011-03-31 16:05:18

Redhat配置nagios

2011-08-22 12:25:02

nagios

2011-03-28 13:27:36

RHELnagios

2011-03-23 09:07:38

Nagios安装

2010-05-31 11:10:37

Nagios pnp

2011-03-22 13:28:00

Nagios安装

2011-03-28 09:21:08

RedhatNagios

2011-03-22 10:54:01

2011-03-28 12:42:26

nagios

2011-03-31 16:05:18

Redhat配置nagios

2011-03-23 13:32:14

配置Nagios系统

2011-03-25 17:35:12

SuseNagios

2011-03-21 13:01:56

LinuxNagios安装

2013-12-13 17:04:37

运维监控Nagios

2011-04-01 15:42:13

CactiNagios
点赞
收藏

51CTO技术栈公众号