您好,登錄后才能下訂單哦!
實驗平臺:LInux-5.8,yum源已配置好,SeLinux處于關閉狀態
- # 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 使用前面創建的組
- ##--enable-event-broker 為使用NDOutils做準備的
- # 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
- ##然后進入/etc/httpd/conf.d,會發現多了nagios.conf文件,為訪問
- ##nagios的web頁面定義了一個別名,當訪問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添加為系統服務并將之加入到自動啟動服務隊列:
- # chkconfig --add nagios
- # chkconfig nagios on
- (2)檢查其主配置文件的語法是否正確:
- # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- (3)如果上面的語法檢查沒有問題,接下來就可以正式啟動nagios服務了:
- # service nagios start
- current Load:CPU的負載情況,當前顯示是Ok的
- Current Users:用戶數
- HTTP:顯示HTTP服務事物信息的,當前顯示WARNING是因為沒有提供web頁面
- PING:用來ping主機的
- Root Partition:顯示根分區信息的
- SSH:顯示SSH的狀態的
- Swap Usage:顯示交換分區使用情況的
- Total Processes:總進程數狀態
- 在右上角還有一個各項狀態匯總圖
- 安裝開發包組:
- 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 \ ##向命令傳遞參數的
- --enable-ssl ##默認選項,監控端和被監控端傳遞信息需要ssl加密
- # make all
- # make install-plugin ##安裝插件
- # make install-daemon ##將nrpe安裝成守護進程
- # make install-daemon-config ##安裝守護進程的配置文件
- # vim /usr/local/nagios/etc/nrpe.conf
- log_facility=daemon ##日志文件的設施
- pid_file=/var/run/nrpe.pid ##pid文件路徑,自己可以定義
- server_address=172.16.14.14 ##監聽的地址
- server_port=5666 ##端口號
- nrpe_user=nagios ##nrpe用戶
- nrpe_group=nagios ##nrpe組名
- allowed_hosts=172.16.14.15 ##定義本機所允許的監控端的IP地址。
- command_timeout=60 ##定義命令的超時時間
- connection_timeout=300 ##鏈接的超時時間
- debug=0 ##調試功能沒打開
- # /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 ##說明監控端與被監控端可以通信了
- 在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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。