Nagios安裝筆記
我用了Nagios有一年多,在日常的監(jiān)控工作中他都能勝任,那大家安裝一個Nagios系統(tǒng)是必要的,讓我們來看看Nagios安裝具體過程!
圖-Nagios
修改yum升級服務(wù)器[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組等
- [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
---安裝nagios
- [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
- [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
- [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
- [root@localhost nagios-3.2.3]# service httpd restart
---安裝nagios-plugins
- [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
---安裝nagios-snmp-plugins
- [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
- cpan> install Net::SNMP
- [root@localhost nagios_plugins]# ./install.sh
#p#
---其它設(shè)置
[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
---檢測配置
- [root@localhost ~]# service nagios start
- @localhost ~]# cp /etc/sysconfig/selinux /etc/sysconfig/selinux.bak[root@localhost ~]# vi /etc/sysconfig/selinux ---SELINUX=permissive
---安裝mysql
- [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
- [root@localhost ~]# chkconfig --levels 345 mysqld on[root@localhost ~]# service mysqld start
- [root@localhost ~]# mysqlSET PASSWORD FOR 'root'@'localhost' = PASSWORD('mysql');
- [root@localhost yum.repos.d]# yum install php
---安裝cacti
- [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
- [root@localhost ~]# yum install cacti ---php-mysql,php-pdo,php-snmp
- [root@localhost conf.d]# vi cacti.conf
- 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
- [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;
---apache設(shè)置
- [root@localhost ~]# vi /var/www/cacti/include/config.php
- $database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cacti";$database_password = "cacti";$database_port = "3306";
---安裝ndoutils,實(shí)現(xiàn)nagios采集數(shù)據(jù)寫入mysql
- [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
通過文章,我們對Nagios的安裝都有了自己的心得,希望你們趕快去裝一個Nagios,真的非常好用。
【編輯推薦】
- Suse 9 安裝Nagios過程
- Nagios擴(kuò)展的主機(jī)和服務(wù)監(jiān)測
- Nagios編譯安裝之配置Apache服務(wù)
- Nagios的配置文件
- Nagios插件plugins配置和安裝