實驗平臺:LInux-5.8,yum源已配置好,SeLinux處于關(guān)閉狀態(tài)
我們提供的服務(wù)有:成都做網(wǎng)站、成都網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、電白ssl等。為千余家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的電白網(wǎng)站制作公司
- # yum -y install httpd gcc glibc glibc-common gd gd-devel \
- php php-MySQL mysql mysql-devel mysql-server
- # groupadd nagcmd
- # useradd -G nagcmd nagios
- # passwd nagios
- # usermod -a -G nagcmd apache
- # tar zxf nagios-3.3.1.tar.gz
- # cd nagios
- # ./configure --with-command-group=nagcmd --enable-event-broker
- ##--sysconfdir=/etc/nagios 自己可以指定nagios的配置文件路徑
- ##--with-command-group=nagcmd 使用前面創(chuàng)建的組
- ##--enable-event-broker 為使用NDOutils做準(zhǔn)備的
- # make all
- # make install ##安裝nagios
- # make install-init ##安裝nagios的init腳本,即/etc/rc.d/init.d/nagios
- # make install-commandmode ##安裝命令模式
- # make install-config ##安裝生成配置文件
- # make install-webconf ##安裝web接口的,識別nagios程序位置/usr/local/nagios/share
- ##然后進(jìn)入/etc/httpd/conf.d,會發(fā)現(xiàn)多了nagios.conf文件,為訪問
- ##nagios的web頁面定義了一個別名,當(dāng)訪問172.16.14.15/nagios時就可
- ##以訪問/usr/local/nagios/share的文件了
- # htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
- # service httpd restart
- # tar zxf 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
- (1)把nagios添加為系統(tǒng)服務(wù)并將之加入到自動啟動服務(wù)隊列:
- # chkconfig --add nagios
- # chkconfig nagios on
- (2)檢查其主配置文件的語法是否正確:
- # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- (3)如果上面的語法檢查沒有問題,接下來就可以正式啟動nagios服務(wù)了:
- # service nagios start
- current Load:CPU的負(fù)載情況,當(dāng)前顯示是Ok的
- Current Users:用戶數(shù)
- HTTP:顯示HTTP服務(wù)事物信息的,當(dāng)前顯示W(wǎng)ARNING是因為沒有提供web頁面
- PING:用來ping主機(jī)的
- Root Partition:顯示根分區(qū)信息的
- SSH:顯示SSH的狀態(tài)的
- Swap Usage:顯示交換分區(qū)使用情況的
- Total Processes:總進(jìn)程數(shù)狀態(tài)
- 在右上角還有一個各項狀態(tài)匯總圖
- 安裝開發(fā)包組:
- yum -y groupinstall "Development Libraries" "Development Tools"
- # useradd -s /sbin/nologin nagios
- # tar zxf nagios-plugins-1.4.15.tar.gz
- # cd nagios-plugins-1.4.15
- # ./configure --with-nagios-user=nagios --with-nagios-
- group=nagios
- # make all
- # make install
- # tar -zxvf nrpe-2.13.tar.gz
- # cd nrpe-2.13.tar.gz
- # ./configure --with-nrpe-user=nagios \ ##添加nrpe用戶
- --with-nrpe-group=nagios \ ##nrpe組
- --with-nagios-user=nagios \ ##nagios用戶名
- --with-nagios-group=nagios \ ##nagios組名
- --enable-command-args \ ##向命令傳遞參數(shù)的
- --enable-ssl ##默認(rèn)選項,監(jiān)控端和被監(jiān)控端傳遞信息需要ssl加密
- # make all
- # make install-plugin ##安裝插件
- # make install-daemon ##將nrpe安裝成守護(hù)進(jìn)程
- # make install-daemon-config ##安裝守護(hù)進(jìn)程的配置文件
- # vim /usr/local/nagios/etc/nrpe.conf
- log_facility=daemon ##日志文件的設(shè)施
- pid_file=/var/run/nrpe.pid ##pid文件路徑,自己可以定義
- server_address=172.16.14.14 ##監(jiān)聽的地址
- server_port=5666 ##端口號
- nrpe_user=nagios ##nrpe用戶
- nrpe_group=nagios ##nrpe組名
- allowed_hosts=172.16.14.15 ##定義本機(jī)所允許的監(jiān)控端的IP地址。
- command_timeout=60 ##定義命令的超時時間
- connection_timeout=300 ##鏈接的超時時間
- debug=0 ##調(diào)試功能沒打開
- # /usr/local/nagios/bin/nrpe -c
- /usr/local/nagios/etc/nrpe.cfg –d
- #!/bin/bash
- # chkconfig: 2345 88 12
- # description: NRPE DAEMON
- NRPE=/usr/local/nagios/bin/nrpe
- NRPECONF=/usr/local/nagios/etc/nrpe.cfg
- case "$1" in
- start)
- echo -n "Starting NRPE daemon..."
- $NRPE -c $NRPECONF -d
- echo " done."
- ;;
- stop)
- echo -n "Stopping NRPE daemon..."
- pkill -u nagios nrpe
- echo " done."
- ;;
- restart)
- $0 stop
- sleep 2
- $0 start
- ;;
- *)
- echo "Usage: $0 start|stop|restart"
- ;;
- esac
- exit 0
- # chmod +x /etc/init.d/nrped
- # chkconfig --add nrped
- # chkconfig --list nrped
- # service nrped start
- # netstat -tnlp | grep 5666
- tcp 0 0 172.16.14.14:5666 0.0.0.0:* LISTEN \
- 24909/nrpe
- 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_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
- command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda2
- command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda3
- 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
- # tar -zxvf nrpe-2.13.tar.gz
- # cd nrpe-2.13.tar.gz
- # ./configure --with-nrpe-user=nagios \
- --with-nrpe-group=nagios \
- --with-nagios-user=nagios \
- --with-nagios-group=nagios \
- --enable-command-args \
- --enable-ssl
- # make all
- # make install-plugin
- # cd /usr/local/nagios/libexec/
- # ./check_nrpe -H 172.16.14.14
- NRPE v2.13 ##說明監(jiān)控端與被監(jiān)控端可以通信了
- 在commands.cfg 定義check_nrpe命令:
- define command
- {
- command_name check_nrpe
- command_line $USER1$/check_nrpe –H $HOSTADDRESS$ -c $ARG1$
- }
- # vim linhost.cfg
- define host{
- use linux-server
- host_name linhost
- alias My Linux Host
- address 172.16.14.14
- }
- define service{
- use generic-service
- host_name linhost
- service_description CHECK USERS
- check_command check_nrpe!check_users
- }
- define service{
- use generic-service
- host_name linhost
- service_description Load
- check_command check_nrpe!check_load
- }
- define service{
- use generic-service
- host_name linhost
- service_description SDA1
- check_command check_nrpe!check_sda1
- }
- define service{
- use generic-service
- host_name linhost
- service_description SDA2
- check_command check_nrpe!check_sda2
- }
- define service{
- use generic-service
- host_name linhost
- service_description SDA3
- check_command check_nrpe!check_sda3
- }
- define service{
- use generic-service
- host_name linhost
- service_description Zombie
- check_command check_nrpe!check_zombie_procs
- }
- define service{
- use generic-service
- host_name linhost
- service_description Total procs
- check_command check_nrpe!check_total_procs
- # vim /usr/local/nagios/etc/nagios.cfg
- cfg_file=/usr/local/nagios/etc/objects/linhost.cfg
- # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- Total Warnings: 0
- Total Errors: 0
- Things look okay - No serious problems were detected during the pre-flight check
當(dāng)前題目:Nagios安裝配置和基于NRPE監(jiān)控遠(yuǎn)程Linux主機(jī)
本文地址:http://www.chinadenli.net/article12/joiidc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計公司、電子商務(wù)、網(wǎng)站制作、網(wǎng)站改版、建站公司、虛擬主機(jī)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)