本篇內(nèi)容主要講解“l(fā)inux 5.4 nagios監(jiān)控的搭建方法”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“l(fā)inux 5.4 nagios監(jiān)控的搭建方法”吧!
創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)、鎮(zhèn)康網(wǎng)絡(luò)推廣、重慶小程序開(kāi)發(fā)、鎮(zhèn)康網(wǎng)絡(luò)營(yíng)銷、鎮(zhèn)康企業(yè)策劃、鎮(zhèn)康品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供鎮(zhèn)康建站搭建服務(wù),24小時(shí)服務(wù)熱線:18980820575,官方網(wǎng)址:aaarwkj.com
nagios監(jiān)控服務(wù)器 10.1.7.110
linux客戶端服 10.1.7.120
windows客戶端 10.1.7.119
1創(chuàng)建nagios組和賬號(hào)
root@nagios ~]# useradd -m nagios
[root@nagios ~]# groupadd nagcmd
[root@nagios ~]# groupadd nagcmd
[root@nagios ~]# usermod -a -G nagcmd nagios
[root@nagios ~]# usermod -a -G nagcmd apache
2編譯安裝
[root@nagios ~]# tar xvf nagios-3.2.0.tar.gz
[root@nagios ~]# cd nagios-3.2.0
[root@nagios nagios-3.2.0]# less Makefile
[root@nagios nagios-3.2.0]# ./configure --with-command-group=nagcmd\ --with-nagios-user=nagios\ --with-nagios-group=nagios
[root@nagios nagios-3.2.0]# make all
[root@nagios nagios-3.2.0]# make install
[root@nagios nagios-3.2.0]# make install-init
[root@nagios nagios-3.2.0]# make install-config
[root@nagios nagios-3.2.0]# make install-commandmode
[root@nagios nagios-3.2.0]# make install-webconf
3為nagios設(shè)置web驗(yàn)證密碼
root@nagios nagios-3.2.0]# htpasswd -c usr/local/nagios/etc/htpasswd.users nagiosadmin
5設(shè)置nagios的開(kāi)機(jī)啟動(dòng)
root@nagios ~]# chkconfig --add nagios
[root@nagios ~]# chkconfig nagios on
6修改selinux
[root@nagios nagios-3.2.0]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= disable:
二 安裝nagios的插件 nagios-plugin
[root@nagios ~]# tar xvf nagios-plugins-1.4.14.tar.gz
[root@nagios ~]# cd nagios-plugins-1.4.14
[root@nagios nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios
[root@nagios nagios-plugins-1.4.14]# make && make install
檢查主機(jī)是佛存在
[root@nagios ~]# cd /usr/local/nagios/etc/
[root@nagios etc]# ls -l
總計(jì) 76
-rw-rw-r-- 1 nagios nagios 11408 05-18 16:46 cgi.cfg
-rw-r--r-- 1 root root 26 05-18 19:16 htpasswd.users
-rw-rw-r-- 1 nagios nagios 44020 05-18 18:53 nagios.cfg
-rw-r--r-- 1 nagios nagios 7207 05-18 19:33 nrpe.cfg
drwxrwxr-x 2 nagios nagios 4096 05-18 20:06 objects
-rw-rw---- 1 nagios nagios 1340 05-18 16:46 resource.cfg
[root@nagios etc]#
2主配置文件nagios。cfg配置
[root@nagios etc]# vim nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg //注釋掉此行
3主機(jī)定義文件配置
define host{
host_name Nagios-server
alias Nagios server
address 10.1.7.110
check_command check-host-alive
check_interval 5
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contact_groups sagroup
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
define host{
host_name client-server
alias client server
address 10.1.7.120
check_command check-host-alive
check_interval 5
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contact_groups sagroup
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
3主機(jī)組定義文件配置
[root@nagios etc]# vim objects/hostgroups.cfg
define hostgroup {
hostgroup_name Sysem-Admin
alias system Admin
members Nagios-server,client-server,windows-server
}
~
4服務(wù)定義文件配置
[root@nagios etc]# vim objects/services.cfg
define service{
host_name Nagios-server
service_description check-host-alive
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,c,u,r
check_command check-host-alive
}
define service{
host_name client-server
service_description check-host-alive
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,c,u,r
check_command check-host-alive
}
5聯(lián)系人定義文件配置
[root@nagios etc]# vim objects/contacts.cfg
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email 472730846@qq.com
6聯(lián)系組定義文件配置
[root@nagios etc]# vim objects/contactgroups.cfg
define contactgroup {
contactgroup_name sagroup
alias system administrator group
members nagiosadmin
}
7修改目錄所有者
~
[root@nagios etc]# chown -R nagios.nagios objects/
8檢查配置文件是否正卻
[root@nagios etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0
9啟動(dòng)nagios服務(wù)
[root@nagios etc]# etc/init.d/httpd restart
[root@nagios etc]# /etc/init.d/nagios start
10 測(cè)試功能
http://10.1.7.110/nagios/ 輸入 nagiosadmin 密碼 accp
三 使用nagios監(jiān)控linux客戶端
1 nagios監(jiān)控服務(wù)器的配置
[root@nagios ~]# tar zxvf nrpe-2.12.tar.gz
[root@nagios ~]# cd nrpe-2.12
[root@nagios nrpe-2.12]# ./configure && make all
[root@nagios nrpe-2.12]# make install-plugin
[root@nagios nrpe-2.12]# make install-daemon
[root@nagios nrpe-2.12]# make install-daemon-config
[root@nagios nrpe-2.12]# make install-xinetd
2 配置
[root@nagios nrpe-2.12]# vim /etc/xinetd.d/nrpe
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1,10.1.7.120,10.1.7.119
3 添加端口
[root@nagios nrpe-2.12]# vim /etc/services
nrpe 5666/tcp #nrpe
4 重新啟動(dòng) xinetd服務(wù)
[root@nagios nrpe-2.12]# /etc/init.d/xinetd restart
[root@nagios nrpe-2.12]# netstat -na | grep 5666
以上步驟要到客戶機(jī)上做 1--4
5修改配置文件commands.cfg加入對(duì)nrpe的支持
[root@nagios ~]# vim /usr/local/nagios/etc/objects/commands.cfg
#nrpe set
define command {
command_name check_nrpe
command_line /usr/local/nagios/libexec/check_nrpe -H $ HOSTADDRESS$ -c $ ARG1$
}
檢查nrpe命令那些可用
[root@nagios ~]# cat /usr/local/nagios/etc/nrpe.cfg
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
7 使用命令監(jiān)控客戶端
[root@nagios ~]# vim /usr/local/nagios/etc/objects/services.cfg
define service{
host_name Nagios-server
service_description check-users
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,c,u,r
check_command check-nrpe!check_users
}
define service{
host_name Nagios-server
service_description check-load
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,c,u,r
check_command check-nrpe!check_load
}
define service{
host_name Nagios-server
service_description check-total-procs
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,c,u,r
check_command check-total_procs
}
到此,相信大家對(duì)“l(fā)inux 5.4 nagios監(jiān)控的搭建方法”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
當(dāng)前名稱:linux5.4nagios監(jiān)控的搭建方法
文章地址:http://aaarwkj.com/article32/pjsdsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、品牌網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站營(yíng)銷、用戶體驗(yàn)、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)