監控nagios

第一章 簡介

 

1.nagios監控原理
1.Nagios 執行安裝在它裏面的 check_nrpe 插件,並告訴 check_nrpe 去檢測哪些服務。
2.通過 SSL,check_nrpe 連接遠端機子上的 NRPE daemon
3.NRPE 運行本地的各種插件去檢測本地的服務和狀態(check_disk,..etc)
4.最後,NRPE 把檢測的結果傳給主機端的 check_nrpe,check_nrpe 再把結果送到 Nagios狀態隊列中

 

第二章 Nagios安裝

 

安裝需要準備的軟件包
nagios-3.4.3.gz
nagios-plugins-1.4.13.tar.gz
nrpe-2.8.1.tar.gz
gd-devel-2.1.0-7.5.1.x86_64.rpm

2.安裝nagios

2.1 安裝PHP環境

配置本地yum環境
cd /etc/yum.repos.d/
mkdir repo.bak
cp CentOS-* repo.bak/
rm -rf CentOS-*
vi aa.repo
[aa]
name=aa
baseurl=file:///mnt
gpgcheck=1

:wq 保存退出

掛載
mount /dev/dvd /mnt

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-*

rpm -ivh gd-devel-2.1.0-7.5.1.x86_64.rpm --force --nodeps

yum install make gcc glibc glibc-common php gd gd-devel libpng libmng libjpeg zlib expect openssl openssl-devel -y

service httpd start


檢測php安裝是否成功
cd /var/www/html
建立php頁面
vi index.php
<?php
phpinfo()
?>

:wq 保存退出

http://192.168.1.242

 

2.2 添加nagios軟件用戶和用戶組

useradd nagios
groupadd nagcmd
usermod -G nagcmd apache
usermod -G nagcmd nagios


 

2.3安裝和編譯nagios

tar zxvf nagios-3.4.3.gz
cd nagios
# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd

編譯Nagios程序包源碼
# make all


安裝二進制運行程序、初始化腳本、配置文件樣本並設置運行目錄權限
# make install

安裝生成/usr/local/nagios/share的目錄(即nagiosWEB訪問界面的站點目錄)
# make install-init

安裝生成/etc/rc.d/init.d/nagios 啓動腳本
# make install-config

安裝生成/usr/local/nagios/etc下的nagios相關配置文件
# make install-commandmode

設定相應nagios工作目錄的權限
# make install-webconf

安裝Nagios的WEB配置文件到Apache的conf.d目錄下
 

2.4 配置web接口

我們應該創建一個的用戶用於Nagios的WEB接口登錄。記住設置好的登錄口令,一會兒你會用到它。
用戶名:nagiosadmin
密碼:herendh
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
輸入密碼 herendh進行密碼設置。


重啓Apache服務以使設置生效。
service httpd reload
輸入地址訪問,此時nagios 什麼也沒有,需要安裝下面的插件

將 Nagios和httpd設置爲開機啓動
chkconfig --add nagios
chkconfig nagios on
chkconfig --add httpd
chkconfig httpd on


 

3.安裝nagios插件(服務器)nagios-plugins


tar zxvf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make all
make install
service nagios reload
service httpd reload

 

 

 

4.安裝nagios插件(服務器)nrpe

tar zxvf nrpe-2.8.1.tar.gz
cd nrpe-2.8.1
./configure
make all
make install-plugin

 

 

 

 

 

 

5.手動監控本機的監控對象

 

 

 

5.1 nagios文件的具體含義

nagios文件的具體含義:(/usr/local/nagios/etc/objects)
command.cfg 定義nagios能調用的命令;
contacts.cfg 定義聯繫人;
localhost.cfg 定義監控本機的對象;
printer.cfg 定義對打印機的監控;
switch.cfg 定義對交換機的監控;
templates.cfg 定義模板;
timeperiods.cfg 定義時間對象;
windows.cfg 定義監控的windows主機
 

5.2 業務監控

cd /usr/local/nagios/etc/objects/
定義主機和服務
vi heren.cfg
define host{
use heren-server
host_name 192.168.1.241
alias 192.168.1.241
address 192.168.1.241
}
define service{
use heren-service
host_name 192.168.1.241
service_description master8051
check_command check_url_port!'192.168.1.241'!'http://192.168.1.241:8051/heren/security/login-new.html'!'class'!8051
}

define service{
use heren-service
host_name 192.168.1.241
service_description message9999
check_command check_url_port!'192.168.1.241'!'http://192.168.1.241:9999/heren-message/personal/index.html'!'class'!9999
}

define service{
use heren-service
host_name 192.168.1.241
service_description schedule8061
check_command check_url_port!'192.168.1.241'!'http://192.168.1.241:8061/schedule/schedule/schedule.html'!'class'!8061
}

define service{
use heren-service
host_name 192.168.1.241
service_description report8081
check_command check_url_port!'192.168.1.241'!'http://192.168.1.241:8081/heren-report/api/jasper-prints/fill'!'class'!8081
}

define service{
use heren-service
host_name 192.168.1.241
service_description Disk
check_command check_nrpe_disk!check_sda
}

define service{
use heren-service
host_name 192.168.1.241
service_description Load
check_command check_nrpe_load!check_load
}
define service{
use heren-service
host_name 192.168.1.241
service_description mem
check_command check_nrpe_mem!check_mem
}

定義模板
vi templates.cfg
define host{
name heren-server
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 4
check_command check-host-alive
notification_period 24x7
process_perf_data 1
notification_interval 2
notification_options d,u,r
contact_groups mail_admins
register 0
}
define service{
name heren-services
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups mail_admins
notification_options w,u,c,r
notification_interval 5
notification_period 24x7
register 0
}
define service{
name heren-service
use heren-services
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
register 0
}
定義命令
Vi command
##############################################################################
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
define command{
command_name check_nrpe_mem
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 20 -c $ARG1$
}
define command{
command_name check_url_port
command_line $USER1$/check_http -I $ARG1$ -u $ARG2$ -s $ARG3$ -p $ARG4$ -t 60
}
define command{
command_name check_nrpe_disk
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -t 20 -c $ARG1$
}

define command{
command_name check_nrpe_disk_port
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -t 20 -c $ARG1$ -p $ARG2$
}

define command{
command_name check_nrpe_load
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -t 20 -c $ARG1$
}

define command{
command_name check_nrpe_ping
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -t 200 -c $ARG1$
}
###############################################################################
 

5.3應用服務器監控

cd /usr/local/nagios/etc/objects/
定義主機和服務
vi yingyong.cfg
define host{
use heren-server
host_name 192.168.1.244
alias 192.168.1.244
address 192.168.1.244
}
define host{
use heren-server
host_name 192.168.1.245
alias 192.168.1.245
address 192.168.1.245
}
define host{
use heren-server
host_name 192.168.1.248
alias 192.168.1.248
address 192.168.1.248
}
define host{
use heren-server
host_name 192.168.1.249
alias 192.168.1.249
address 192.168.1.249
}

define service{
use heren-service
host_name 192.168.1.248
service_description vip1_url
check_command check_url_port!'192.168.1.248'!'http://192.168.1.248:80'!'nginx'!80
}
define service{
use heren-service
host_name 192.168.1.249
service_description vip2_url
check_command check_url_port!'192.168.1.249'!'http://192.168.1.249:80'!'nginx'!80
}


define service{
use heren-service
host_name 192.168.1.244,192.168.1.245
service_description Disk
check_command check_nrpe_disk!check_sda
}
define service{
use heren-service
host_name 192.168.1.244,192.168.1.245
service_description Load
check_command check_nrpe_load!check_load
}

define service{
use heren-service
host_name 192.168.1.244,192.168.1.245
service_description mem
check_command check_nrpe_mem!check_mem
}
define service{
use heren-service
host_name 192.168.1.244,192.168.1.245
service_description keepalived
check_command check_nrpe_keepalived!check_keepalived
}

定義命令
define command{
command_name check_nrpe_keepalived
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 20 -c $ARG1$
}

5.4 oracle監控

cd /usr/local/nagios/nagios/etc/objects/
定義主機和服務
vi oracle.cfg
define host{
use heren-server
host_name 192.168.1.238
alias oracle 11g
address 192.168.1.238
}
define service{
use heren-service
host_name 192.168.1.238
service_description Disk
check_command check_nrpe_disk!check_sda
}

define service{
use heren-service
host_name 192.168.1.238
service_description Load
check_command check_nrpe_load!check_load
}

define service{
use heren-service
host_name 192.168.1.238
service_description Mem
check_command check_nrpe_mem!check_mem
}




define service {
use heren-service
host_name 192.168.1.238
service_description Oracle TNS
check_command check_nrpe_oracle!check_oracle_tns
}
define service {
use heren-service
host_name 192.168.1.238
service_description Oracle DB
check_command check_nrpe_oracle!check_oracle_db
}
define service {
use heren-service
host_name 192.168.1.238
service_description Oracle Login
check_command check_nrpe_oracle!check_oracle_login
}
define service {
use heren-service
host_name 192.168.1.238
service_description Oracle Cache
check_command check_nrpe_oracle!check_oracle_cache
}
define service {
use heren-service
host_name 192.168.1.238
service_description Oracle Tablespace
check_command check_nrpe_oracle!check_oracle_tablespace
}
定義命令
define command {
command_name check_nrpe_oracle
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 20 -c $ARG1$
}

5.5windows監控

vi windows

define host{
use windows-server
host_name 192.168.1.235
alias My Windows Server
address 192.168.1.235
}

define hostgroup{
hostgroup_name windows-servers
alias Windows Servers
}

define service{
use generic-service
host_name 192.168.1.235
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}

define service{
use generic-service
host_name 192.168.1.235
service_description Uptime
check_command check_nt!UPTIME
}

define service{
use generic-service
host_name 192.168.1.235
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
define service{
use generic-service
host_name 192.168.1.235
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}

define service{
use generic-service
host_name 192.168.1.235
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
 

6.啓動nagios

6.1 檢測配置文件是否正確

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果沒有報錯,可以啓動Nagios服務

service nagios start
 

6.2 打開nagios監控web頁面

在web裏面輸入http://192.168.1.242/nagios










 

第三章 nagios添加郵件報警功能

 

1.解壓並配置sendEmail插件

tar -zxvf sendEmail-v1.56.tar.gz
cp /sendEmail-v1.56/sendEmail /usr/local/bin/

 

 

 

2.測試sendEmail軟件能否發送成功

/usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.163.com -u "nimei" -m "test1" -xu liudian456 -xp 789
顯示發送ok就表明sendEmail能共正常發送郵件


3.定義發送sendEmail 的 command 命令
vi command.cfg
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.163.com -u "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu liudian456 -xp 789
}
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.163.com -u "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu liudian456-xp 789
}

4.定義郵件聯繫人
vim /usr/local/nagios/etc/objects/contacts.cfg

define contactgroup{
contactgroup_name mail_admins
alias Nagios Administrators
members mail_lilin,nagiosadmin
}
define contact{
contact_name mail_lilin
use mail-contact
alias mail_lilin
email [email protected]
}

5.定義郵件聯繫模板
define contact{
name mail-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
register 0 }

6.啓動nagios 郵件服務功能
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果沒有報錯,可以啓動Nagios服務
service nagios reload 現在有報警就會自動發送到[email protected]這個聯繫的定義的郵箱了。可以加入多個郵箱,中間用”,”隔開。

 

 

 

 

 

 

 

 

第四章 配置nagios 監控客戶機

 

 

 

 

 

 

 

1.安裝編譯環境和ssl(客戶機)

 

 

1.1、安裝基礎環境

yum install make gcc* xinetd openssl openssl-devel –y

1.2、添加用戶名和用戶組

/usr/sbin/useradd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios

2.安裝nagios插件(客戶機)

tar zxvf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure --prefix=/usr/local/nagios
make
make install
 

3.安裝nrpe插件(客戶機)

tar zxvf nrpe-2.8.1.tar.gz
cd nrpe-2.8.1
./configure --prefix=/usr/local/nagios
make all
make install
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

4.將heren.cfg、oracle.cfg、yingyong.cfg、windows.cfg加入nagios主配置文件中(服務器)

# pwd
/usr/local/nagios/etc
[root@localhost etc]# vi nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/heren.cfg
cfg_file=/usr/local/nagios/etc/objects/oracle.cfg
cfg_file=/usr/local/nagios/etc/objects/yingyong.cfg
cfg_file=/usr/local/nagios/etc/objects/windows.cfg

 

5.將服務端ip加入客戶端

vi /etc/xinetd.d/nrpe
only_from = 127.0.0.1,192.168.1.242
 

6.客戶機上添加監控私有服務的command

6.1應用服務器監控

cd /usr/local/nagios/etc/
Vi nrpe
allowed_hosts=127.0.0.1,192.168.1.242
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
#command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_sda]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -c /dev/sde
command[check_mem]=/usr/local/nagios/libexec/check_mem -w 20 -c 10
command[check_keepalived]=/usr/local/nagios/libexec/check_procs -w 2: -c:4 -C keepalived
上傳腳本check_mem
cd /usr/local/nagios/libexec
修改權限
chmod +x check_mem
chown nagios:nagios check_mem

6.2監控oracle

cd /usr/local/nagios/etc/
Vi nrpe
allowed_hosts=127.0.0.1,192.168.1.242
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
#command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_sda]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -c /dev/sde
command[check_mem]=/usr/local/nagios/libexec/check_mem -w 20 -c 10
command[check_oracle_tns]=/usr/local/nagios/libexec/check_oracle --tns orcl
command[check_oracle_db]=/usr/local/nagios/libexec/check_oracle --db orcl
command[check_oracle_login]=/usr/local/nagios/libexec/check_oracle --login orcl
command[check_oracle_cache]=/usr/local/nagios/libexec/check_oracle --cache orcl herendh herendh 80 90
command[check_oracle_tablespace]=/usr/local/nagios/libexec/check_oracle --tablespace orcl herendh herendh herendh 90 80
修改腳本
cd /usr/local/nagios/libexec
vi check_oracle
在開頭加入
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
PATH=$PATH:/u01/app/oracle/product/11.2.0/db_1/bin
 

6.3 windows客戶端

安裝NSCP-0.4.1.73-x64
填上nagios主機的地址,192.168.1.242,不需要填寫密碼

7.配置nrpe (客戶機)

7.1添加nrpe對應端口

vi /etc/services
nrpe 5666/tcp # NRPE
 

7.2啓動nrpe

service xinetd restart
netstat -anptl | grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 21403/xinetd
啓動nrpe 命令
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
加入開機自動啓動
echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.d/rc.local

7.3測試nrpe

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v2.12
 

7.4服務器端測試nrpe

/usr/local/nagios/libexec/check_nrpe -H 192.168.1.241(客戶機ip)
NRPE v2.12

7.5檢查配置

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

7.6重啓服務

service nagios reload

對客戶機的監控部署完畢,如需添加新的監控對象可照此添加。




 

第五章 nagios 圖形化

 

 

 

 

Pnp4nagios圖形化繪製nagios 數據

pnp4nagios是一個基於php和perl語言的強大工具,它可以通過process_perfdata.pl腳本調用rrdtool對nagios的性能數據進行分析並繪製成相應的性能圖。所以在安裝pnp4nagios之前,我們必須先安裝php、perl、rrdtool。
rrdtool是Round Robin Database Tool的縮寫。從功能上說,rrdtool可用於數據存儲+數據展示。著名的網絡流量繪圖軟件cacti和集羣監控系統Ganglia使用的都是rrdtool。在數據存儲方面,rrdtool採用“Round Robin”模式存儲數據,即環狀數據庫。注意:rrdtool數據庫文件後綴名爲“.rrd”。

 

 

 

 

 

1.安裝rrdtool

基礎庫安裝
yum -y install gcc cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel php-gd
tar -xf rrdtool-1.5.4.tar.gz
cd rrdtool-1.5.4
./configure
make
make install

 

 

2.安裝pnp4nagios

yum -y install perl-Time-HiRes
tar -xf pnp4nagios-0.6.25.tar.gz
cd pnp4nagios-0.6.25
./configure --with-rrdtool=/opt/rrdtool-1.5.4/bin/rrdtool --with-perl_lib_path=/opt/rrdtool-1.5.4/lib/perl/5.10.1/x86_64-linux-thread-multi/
make all
make install
make install-webconf
make install-config
make install-init

 

 

 

3.配置pnp4nagios

cd /usr/local/pnp4nagios/etc/
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
mv pages/web_traffic.cfg-sample pages/web_traffic.cfg
[root@localhost etc]#mv check_commands/check_all_local_disks.cfg-sample
check_commands/check_all_local_disks.cfg
[root@localhost etc]# mv check_commands/check_nrpe.cfg-sample
check_commands/check_nrpe.cfg
[root@localhost etc]# mv check_commands/check_nwstat.cfg-sample
check_commands/check_nwstat.cfg

 

 

 

4.啓動pnp4nagios

/etc/init.d/npcd start
ps aux |grep npcd
chkconfig npcd on
chkconfig --list npcd

 

 

 

5.訪問pnp4nagios

http://192.168.1.242/pnp4nagios/
輸入nagios用戶名和密碼

最下方出現這句
Your environment passed all requirements. Remove or rename the
/usr/local/pnp4nagios/share/install.php file now.
執行
mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.bak

 

 

 

 

6.配置nagios

定義nagios配置文件
vi /usr/local/nagios/etc/nagios.cfg
process_performance_data=1
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file

定義命令

vi /usr/local/nagios/etc/objects/commands.cfg
define command{
    command_name    process-service-perfdata-file
    command_line    /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$
}
define command{
  command_name    process-host-perfdata-file
  command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
}

定義模板
vi /usr/local/nagios/etc/objects/templates.cfg
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_’ class=’tips’ rel=’/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$’ class=’tips’ rel=’/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
在heren.cfg、yingyong.cfg、oracle.cfg配置文件主機加入host-pnp ,服務加入srv-pnp
如下:
vi /usr/local/nagios/etc/objects/
define host{
use heren-server,host-pnp
host_name 192.168.1.240
alias 192.168.1.240
address 192.168.1.240
}

define service{
use heren-service,srv-pnp
host_name 192.168.1.240
service_description heren_url
check_command check_url_port!'192.168.1.240'!'http://192.168.1.240:80'!'nginx'!80
}




報錯一:

1.缺少openssl openssl-devel
2.客戶端配置文件,需要加入服務器IP
vi nrpe
allowed_hosts=127.0.0.1,192.168.1.242


報錯二:

1..客戶端配置文件需要加入服務端ip
vi /etc/xinetd.d/nrpe

報錯三:
監控頁面報錯
DISK CRITICAL - /root/.gvfs is not accessible
客戶端/root下執行
umount .gvfs
rm -rf .gvfs

 

 

發佈了35 篇原創文章 · 獲贊 5 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章