Chia Sẽ Kinh Nghiệm Về IT



Tìm Kiếm Với Google
-


Linux Applications Tập hợp các bài viếc hướng dẫn cài đặt các ứng dụng phổ biến trên Linux (CentOS)

Gởi Ðề Tài Mới  Gửi trả lời
 
Công Cụ Xếp Bài
Tuổi 08-11-2009, 04:18 PM   #1
hoctinhoc
Guest
 
Trả Lời: n/a
Cài đặt và giám xác các dịch vụ trên Centos bằng Negios

Cài đặt và giám sát các dịch vụ trên Centos bằng Negios



1. Install Nagios on Centos 5



By Fabio Milano


Installing Nagios server and network monitoring on Centos 5 server
The official documentation can be found at http://support.nagios.com/knowledge-...-documentation
Install necessary packages

Mã:
yum install httpd gcc glibc glibc-common gd gd-devel php
Create Nagios User account and group

Mã:
useradd -m nagios
Create nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user


Mã:
 groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
Create Directory to store Nagios installation files

Mã:
mkdir /opt/Nagios
Download Nagios and Plugins

Save file to directory /opt/Nagios
http://www.nagios.org/download/download.php
As of this writing Nagios 3.0.6 (Stable) and Nagios Plugins 1.4.13 (Stable)
Extract Files:


Mã:
 cd /opt/Nagios

tar xzf nagios-3.0.6.tar.gz

cd nagios-3.0.6



Compile and Configure Nagios


Mã:
./configure --with-command-group=nagcmd
Compile Nagios:

Mã:
 make all
Compile binaries, init script, sample config files:

Mã:
 make install

make install-init

make install-config

make install-commandmode


** Do Not Start Nagios **


Nagios has now been installed to the directory /usr/local/nagios/
Install Nagios Web Interface:


Mã:
 make install-webconf
Nagios Web Interface installed to /usr/local/nagios/share ( http conf file added to /etc/httpd/conf.d/nagios.conf )
Create Web Interface Login User:
** This is not the most secure method **
We will create user “nagiosadmin” ( remember the password you assign !)


Mã:
 htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 

Restart Apache:

 service httpd restart

Install Nagios Plugins


Extract Files:


Mã:
 cd /opt/Nagios

tar xzf nagios-plugins-1.4.13.tar.gz

cd nagios-plugins1.4.13
Compile and Configure Nagios Plugins


Mã:
./configure --with-nagios-user=nagios --with-nagios-group=nagios

make

make install


Configure nagiosadmin email address for alerts



Mã:
vi /usr/local/nagios/etc/objects/contacts.cfg

email     nagios@localhost   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
Verify the sample Nagios configuration files

Mã:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Total Warnings: 0
Total Errors: 0
Start Nagios


Mã:
Enable Nagios to start at system startup / boot
 chkconfig --add nagios

chkconfig nagios on

chkconfig httpd on Start Nagios
 service nagios start
Log into Web Interface


Mã:
http://ip-address/nagios/


2. Nagios NRPE add Services to Monitor



Scenario / Question:

I followed the Tutorial on installing and configuring NRPE, but now I want to monitor more services on the remote server.

Solution / Answer:

You can add services by configuring nrpe.cfg on the remote host and adding a new service definition on the Nagios monitoring server.
Download Service Plugin on Remote Host Server

1. Download the plugin to folder /usr/local/nagios/libexec/
2. Change permissions on plugin to nagios


Mã:
 # cd /usr/local/nagios/libexec/
# chown nagios.nagios check_something
# chmod 775 check_something 3. Test the plugin works
 # /usr/local/nagios/libexec/check_something
Edit nrpe.cfg File on Remote Host Server

Add a new command definition to the nrpe.cfg file on the remote host


Mã:
 # vi /usr/local/nagios/etc/nrpe.cfg
Add a new check_something command definition. (replace “check_something” with the actual plugin file name). Also you must define any arguments. Do a “check_something -h” for a plugins arguments.
Mã:
command[check_something]=/usr/local/nagios/libexec/check_something -t 20 -c 30
Because we are running xinetd we do not need to restart the NRPE daemon. Otherwise you would have to restart the NRPE daemon for the changes to take effect.
Add Service Definition to Nagios Monitoring Server


On the monitoring host, you need to define a new service for check_something on the remote host. Add
the following entry to one of your object configuration files (linux-server-remote.cfg)
define service{
use generic-service
host_name remotehost
service_description Check Something
check_command check_nrpe!check_something
}


Next, verify your Nagios configuration files and restart Nagios.


Mã:
 # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

# service nagios restart


Bonus 1:
Tôi muốn cài đặt 1 server Nagios để giám xác các dịch vụ (HTTP, SSH, SMTP, POP3,IMAP...Server Windows or Linux từ xa) thì tôi làm như sau:

1. Trên Server cần giám xác(Do nothing)

2. Trên Server Nagios tôi cài đặt Nagios, Nagios_Pluins, NRPE (3 thành phần này phải được cài trên server Nagios)

3. Và làm theo hướng dẫn theo tài liệu của Nagios

Trích dẫn:

http://nagios.sourceforge.net/docs/3...cservices.html
Bonus 2: Tôi muốn cài đặt 1 server Nagios để giám xác (RAM, CPU load, HDD trên ....Server Windows or Linux từ xa) thì tôi làm như sau:

Trích dẫn:

http://www.kernelhardware.org/nagios...-linux-server/
Bài viết được tổng hợp từ nhiều nguồn: nagios, kernalhardware.


Các links liên quan:

http://www.kernelhardware.org/nagios...es-to-monitor/


Chúc các bạn thành công



  Trả lời ngay kèm theo trích dẫn này
Gửi trả lời



Quyền Hạn Của Bạn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Hình Cảm xúc đang Mở
[IMG] đang Mở
Mã HTML đang Tắt




Bây giờ là 08:33 AM. Giờ GMT +7



Diễn đàn tin học QuantriNet
quantrinet.com | quantrimang.co.cc
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.