前面呢,服務(wù)器搭建起來了,可是光搭個監(jiān)控報(bào)警服務(wù)器有什么用呢,難道只為了監(jiān)控本機(jī),可是如果本機(jī)宕機(jī)了,那還能收到報(bào)警信息嗎,呵呵!
創(chuàng)新互聯(lián)主要從事網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)雙河,十余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
現(xiàn)在我們來弄點(diǎn)被監(jiān)控機(jī)吧...額,我現(xiàn)在就先弄下Linux和Windows主機(jī)
被監(jiān)控機(jī)Linux
linux客戶端的所用到的工具
- #!/bin/bash
- #filename: nagios-clt.sh
- #Environment: Centos 5.6 32-bit
- #Author: maoxian
- #blog: maoxian.blog.51cto.com
- #定義變量
- tooldir=/usr/local/src
- #添加nagios用戶
- useradd nagios
- #安裝nagios-plugins-1.4.15,nrpe,
- cd $tooldir
- tar zxvf nagios-plugins-1.4.15.tar.gz
- cd nagios-plugins-1.4.15
- ./configure --with-nagios-user=nagios --with-nagios-group=nagios
- make && make install
- cd $tooldir
- tar zxvf nrpe-2.12.tar.gz
- cd nrpe-2.12
- ./configure
- make all
- make install-plugin
- make install-daemon
- make install-daemon-config
- #配置nrpe信息
- #vim /usr/local/nagios/etc/nrpe.cfg
- #allowed_hosts=127.0.0.1 //允許監(jiān)控的IP
- #
- /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
到服務(wù)器上修改配置文件nagios.cfg,注釋localhost.cfg那行 添加一樣mylinux.cfg
創(chuàng)建/usr/local/nagios/etc/objects/mylinux.cfg
- #定義主機(jī)部分
- define host{
- use linux-server
- host_name nagios-server
- alias naigos-server
- address 192.168.81.128
- icon_p_w_picpath web.gif
- statusmap_p_w_picpath web.gd2
- 2d_coords 100,300
- 3d_coords 100,300,100
- }
- define host{
- use linux-server
- host_name nagios-client
- alias nagios-client
- address 192.168.81.129
- icon_p_w_picpath server.gif
- statusmap_p_w_picpath server.gd2
- 2d_coords 200,300
- 3d_coords 200,300,100
- }
- #定義主機(jī)組部分
- define hostgroup{
- hostgroup_name linux-servers ; The name of the hostgroup
- alias Linux Servers ; Long name of the group
- members * ; Comma separated list of hosts that belong to this group
- }
- define hostgroup{
- hostgroup_name linux-server
- alias nagios-test
- members nagios-server,nagios-client
- }
- #定義服務(wù)組部分
- define servicegroup{
- servicegroup_name 系統(tǒng)負(fù)荷檢查
- alias 負(fù)荷檢查
- members nagios-client,進(jìn)程總數(shù),nagios-client,登錄用戶數(shù),nagios-client,根分區(qū),nagios-client,交換空間利用率,nagios-client,PING
- }
- #定義服務(wù)部分
- define service{
- use local-service ; Name of service template to use
- host_name *
- service_description PING
- check_command check_ping!100.0,20%!500.0,60%
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 根分區(qū)
- check_command check_local_disk!20%!10%!/
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 登錄用戶數(shù)
- check_command check_local_users!20!50
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 進(jìn)程總數(shù)
- check_command check_local_procs!250!400!RSZDT
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 系統(tǒng)負(fù)荷
- check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 交換空間利用率
- check_command check_local_swap!20!10
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description SSH
- check_command check_tcp!22!1.0!10.0
- notifications_enabled 0
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description HTTP
- check_command check_http
- notifications_enabled 0
- }
由于我這臺機(jī)器并沒有http 所以會出現(xiàn)異常,可以將以上文件的最后一段去掉.
Windows客戶端所用到的客戶端 NSClient++
這個很簡單,安裝完成后編輯安裝目錄下的NSC.ini這個文件,按需求配置.之后再運(yùn)行nsclient++.exe
將nagios-ser上的nagios.cfg的windows.cfg那行注釋去掉,再編輯windows.cfg 改下IP就行了. 然后重啟nagios服務(wù)!
配置文件中的配置可以到網(wǎng)上找找相關(guān)的資料,這里就不啰嗦了,呵呵!