Nagios监控系统部署
Nagios介绍
Nagios是一套監視服務的軟體。它可以透過網路監視各種服務,像是TCP port, SMTP, POP3, HTTP,NNTP, PING等等。它提供一套介面,任何人都可以利用這個介面,為任何特殊的服務開發監視用插件,然後交給Nagios運行。
當所監視的對象(主機或服務)發生問題時,或是問題解決時,它可已經由email,呼叫器,或是任何設定好的方法,對於相關人士發出通知。
它可以定義一些事件的處理方法。當問題或是事件發生時,針對問題或是事件的種類進行問題對應或是事件反應。
它有一個美麗的Web畫面和很多便利的功能。你可以觀看現在各種服務運行的狀況,發出了那些通知,問題發生的履歷,以及運行期間的記錄檔。
它具有C語言的所有優點,設計也非常的平易近人。Nagios正是用這語言所寫的,讓Nagios很容易可以被客制化,作一些修改來更附合每個人的特殊需要。
它的設計可以讓插件的開發者很有發揮的空間。Nagios的核心裡包含了所有的功能,是以c語言寫成的。但是監視的插件是獨立於核心之外,這些插件可以用任何語言寫成,只要是輸入與輸出的結果能夠照者核心所能認識的格式,插件本身是如何被開發是完全自由的。
Nagios部署
1.准备工作
yum install gcc glibc glibc-common gd gd-devel httpd php
2.优化服务
chkconfig NetworkManager off
chkconfig acpid off
chkconfig apmd off
chkconfig anacron off
chkconfig atd off
chkconfig auditd off
chkconfig autofs off
chkconfig avahi-daemon off
chkconfig avahi-dnsconfd off
chkconfig bluetooth off
chkconfig capi off
chkconfig conman off
chkconfig cpuspeed off
chkconfig crond on
chkconfig cups off
chkconfig dnsmasq off
chkconfig dund off
chkconfig firstboot off
chkconfig gpm off
chkconfig haldaemon off
chkconfig hidd off
chkconfig ip6tables off
chkconfig iptables off
chkconfig irda off
chkconfig irqbalance off
chkconfig isdn off
chkconfig kudzu off
chkconfig lvm2-monitor off
chkconfig mcstrans off
chkconfig mdmonitor off
chkconfig mdmpd off
chkconfig messagebus off
chkconfig microcode_ctl off
chkconfig multipathd off
chkconfig netconsole off
chkconfig netfs off
chkconfig netplugd off
chkconfig network on
chkconfig nfs off
chkconfig nfslock off
chkconfig nscd off
chkconfig ntpd off
chkconfig oddjobd off
chkconfig pand off
chkconfig pcscd off
chkconfig portmap off
chkconfig psacct off
chkconfig rawdevices off
chkconfig rdisc off
chkconfig readahead_early off
chkconfig readahead_later off
chkconfig restorecond off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig rpcsvcgssd off
chkconfig saslauthd off
chkconfig sendmail off
chkconfig smartd off
chkconfig sshd on
chkconfig syslog on
chkconfig tcsd off
chkconfig vncserver off
chkconfig wdaemon off
chkconfig wpa_supplicant off
chkconfig xfs off
chkconfig ypbind off
chkconfig yum-updatesd off3.用户设置
/usr/sbin/useradd nagios /usr/sbin/usermod -s /sbin/nologin nagios /usr/sbin/groupadd nagcmd /usr/sbin/usermod -G nagcmd nagios /usr/sbin/usermod -G nagcmd apache
4.编译程序
./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode make install-webconf
5.配置邮件通知
vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email admin@g868.com ;
}
6.配置访问权限
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin service httpd restart
7.插件部署
./configure --with-nagios-user=nagios --with-nagios-group=nagios make && make install
8.安装NRPE
./configure make all make install-plugin make install-daemon make install-daemon-config
9.配置NRPE通讯地址
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,服务器地址
10.启动NRPE
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
11.设置启动
chkconfig --add nagios
chkconfig nagios on检查配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg service nagios start
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
Linux监控部署
1.用户设置
/usr/sbin/useradd nagios /usr/sbin/usermod -s /sbin/nologin nagios
2.安装NRPE
./configure make all make install-plugin make install-daemon make install-daemon-config
3.配置NRPE权限
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,服务器地址
4.启动NRPE
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
5.对象配置文件[Nagios监控服务器配置]
vi /usr/local/nagios/etc/objects/Hostname.cfg
define host{
use linux-server
host_name Hostname
alias Hostname
address IP address
}
define service{
use generic-service
host_name Hostname
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
6.主配置文件
echo "cfg_file=/usr/local/nagios/etc/objects/Hostname.cfg" >> /usr/local/nagios/etc/nagios.cfg
Windows监控部署
该部分配置比较简单,基本属于傻瓜方式安装。对象配置文件系统已经有了,修改一下就可以了!









