Nagios監(jiān)控工具

Nagios監(jiān)控工具

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、成都微信小程序、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了遜克免費(fèi)建站歡迎大家使用!

不會(huì)顯示具體的值,僅顯示主機(jī)或服務(wù)的狀態(tài)

強(qiáng)大的報(bào)警功能

高度插件化

Nagios監(jiān)控主機(jī)/服務(wù)顯示的4種狀態(tài)

OK

WARNING

CRITICAL

UNKNOWN

Nagios對(duì)象:

主機(jī),主機(jī)組

服務(wù)/資源,服務(wù)組

聯(lián)系人,聯(lián)系人組

時(shí)間段

命令(模板--->應(yīng)用到某個(gè)被監(jiān)控對(duì)象,以實(shí)現(xiàn)監(jiān)控)

Nagios實(shí)現(xiàn)監(jiān)控的方式:

check_by_ssh

check_by_nrpe:專(zhuān)用于監(jiān)控Linux或Unix主機(jī)

check_by_nsclient++:用于監(jiān)控Windows主機(jī)

check_by_snmp

check_by_nsca:實(shí)現(xiàn)被動(dòng)方式的nagios,由被監(jiān)控對(duì)象主動(dòng)向nagios發(fā)送狀態(tài)信息

check_by_xyz:自定義監(jiān)控方式/腳本

安裝nagios

1、安裝依賴(lài)的軟件

# yum install -y httpd php php-MySQL mysql-devel mysql 

2、創(chuàng)建nagios運(yùn)行需要的用戶(hù)和組

# groupadd nagcmd

# useradd -G nagcmd nagios

將運(yùn)行apache進(jìn)程的用戶(hù)加入到nagcmd組中

# usermod -a -G nagcmd apache

3、安裝nagios

# tar zxf nagios-3.3.1.tar.gz 

# cd nagios

# ./configure --with-command-group=nagcmd --enable-event-broker --sysconfdir=/etc/nagios

# make all

# make install

# make install-init

# make install-commandmode

# make install-config

#  make install-webconf

創(chuàng)建一個(gè)登錄nagios web頁(yè)面的用戶(hù),這個(gè)用戶(hù)賬號(hào)在以后通過(guò)web登錄nagios時(shí)使用

# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin

New password: 

Re-type new password: 

Adding password for user nagiosadmin

啟動(dòng)httpd服務(wù)

# service httpd start

4、安裝nagios-plugins插件

# tar zxf nagios-plugins-1.5.tar.gz 

# cd nagios-plugins-1.5

# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

# make && make install

5、啟動(dòng)nagios服務(wù)

# chkconfig --add nagios

# service nagios start 

6、訪(fǎng)問(wèn)nagios

http://10.1.1.2/nagios

配置nagios

nagios配置文件保存在/etc/nagios目錄下

nagios插件目錄

/usr/local/nagios/libexec

nagios監(jiān)控windows主機(jī)

SNMP

NSClient++

nagios通過(guò)check_nt插件與windows NSClient++通信

NSClient++可提供check_nt,check_nrpe及NSCA的能力

NSClient++監(jiān)聽(tīng)在12489/tcp端口與check_nt插件通信

配置check_nt與NSClient++監(jiān)控windows主機(jī)

1、定義命令command

# vim /etc/nagios/objects/commands.cfg 

define command{

        command_name    check_nt

        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$

        }

2、定義主機(jī)host及服務(wù)service

# vim /etc/nagios/objects/windows.cfg 

define host{

        use             windows-server  ; Inherit default values from a template

        host_name       winhost; The name we're giving to this host

        alias           My Windows Server       ; A longer name associated with the host

        address         10.1.1.254      ; IP address of the host

        }

define service{

        use                     generic-service

        host_name               winhost

        service_description     Uptime

        check_command           check_nt!UPTIME

        }

   

3、啟用主機(jī)配置文件

# vim /etc/nagios/nagios.cfg 

cfg_file=/etc/nagios/objects/windows.cfg

4、檢測(cè)配置文件語(yǔ)法,并重啟nagios服務(wù)

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

# service nagios restart

瀏覽器訪(fǎng)問(wèn)http://10.1.1.2/nagios查看監(jiān)控狀態(tài)數(shù)據(jù)

配置check_nrpe監(jiān)控Linux及windows主機(jī)

監(jiān)控端通過(guò)check_nrpe與被監(jiān)控端nrpe進(jìn)程通信

nrpe監(jiān)聽(tīng)在5666/tcp端口 

監(jiān)控端、被監(jiān)控端都需要安裝nrpe addon,被監(jiān)控端需要啟動(dòng)nrpe服務(wù)

一、監(jiān)控Linux 主機(jī)10.1.1.1

1、在被監(jiān)控主機(jī)上安裝nrpe并配置

1)創(chuàng)建nagios用戶(hù)

# useradd -s /sbin/nologin nagios

2)nrpe依賴(lài)于nagios-plugins,安裝nagios-plugins 

# tar zxf nagios-plugins-1.4.14.tar.gz 

# cd nagios-plugins-1.4.14

# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

# make all

# make install

3)安裝nrpe

# tar zxf nrpe-2.15.tar.gz  

# cd nrpe-2.15

# ./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

# make install-daemon

# make install-daemon-config

4)配置nrpe

# vim /usr/local/nagios/etc/nrpe.cfg 

log_facility=daemon

pid_file=/var/run/nrpe.pid

server_port=5666

server_address=10.1.1.1

nrpe_user=nagios

nrpe_group=nagios

allowed_hosts=10.1.1.2

command_timeout=60

定義監(jiān)控本地資源的命令

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 

5)編寫(xiě)啟動(dòng)nrpe服務(wù)腳本

# vim /etc/rc.d/init.d/nrpe

#!/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 damon...."

    $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/rc.d/init.d/nrpe

# chkconfig --add nrpe

# service nrpe start

# netstat -tnlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 10.1.1.1:5666               0.0.0.0:*                   LISTEN      6826/nrpe           

2、在監(jiān)控端安裝nrpe

1)安裝nrpe 

# tar zxf nrpe-2.15.tar.gz 

# cd nrpe-2.15

# ./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

安裝完成后,在/usr/local/nagios/libexec目錄下會(huì)產(chǎn)生check_nrpe插件

通過(guò)以下命令可測(cè)試插件是否工作正常

# ./check_nrpe -H 10.1.1.1

NRPE v2.15

3、配置監(jiān)控Linux主機(jī)

1)定義命令command

# vim /etc/nagios/objects/commands.cfg 

define command{

        command_name    check_nrpe

        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

}

2)定義主機(jī)host及服務(wù)service

# cp /etc/nagios/objects/windows.cfg /etc/nagios/objects/linux.cfg

# vim /etc/nagios/objects/linux.cfg

define host{

use linux-server; Inherit default values from a template

host_namelinuxhost; The name we're giving to this host

alias My Linux Server; A longer name associated with the host

address 10.1.1.1; IP address of the host

}

define service{

use generic-service

host_name linuxhost

service_descriptionUsers

check_command check_nrpe!check_users

}

define service{

use generic-service

host_name linuxhost

service_descriptionLoad

check_command check_nrpe!check_load

}

define service{

use generic-service

host_name linuxhost

service_descriptionSDA1

check_command check_nrpe!check_sda1

}

define service{

use generic-service

host_name linuxhost

service_descriptionSDA2

check_command check_nrpe!check_sda2

}

define service{

use generic-service

host_name linuxhost

service_descriptionSDA3

check_command check_nrpe!check_sda3

}

define service{

use generic-service

host_name linuxhost

service_descriptionZombie procs

check_command check_nrpe!check_zombie_procs

}

define service{

use generic-service

host_name linuxhost

service_descriptiontotal procs

check_command check_nrpe!check_total_procs

}

check_nrpe!check_total_procs

!后面為被監(jiān)控端定義好的命令名稱(chēng)

3)啟用主機(jī)配置文件

# vim /etc/nagios/nagios.cfg 

cfg_file=/etc/nagios/objects/linux.cfg

4)檢測(cè)配置文件語(yǔ)法,并重啟nagios服務(wù)

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

# service nagios restart

在10.1.1.1上分別安裝web及mysql服務(wù),配置監(jiān)控端10.1.1.2監(jiān)控這兩個(gè)服務(wù)

1、在10.1.1.1上安裝web及mysql

# yum install -y httpd mysql-server 

需要在mysql服務(wù)器上創(chuàng)建允許遠(yuǎn)程登錄的用戶(hù)

2、編輯command.cfg分別定義監(jiān)控web及mysql服務(wù)的命令

# vim /etc/nagios/objects/commands.cfg 

define command{

        command_name    check_http

        command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$

        }

define command{

        command_name    check_mysql

        command_line    $USER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$

        }

3、編輯linux.cfg配置文件,定義web及mysql服務(wù)

# vim /etc/nagios/objects/linux.cfg 

define service{

        use                     generic-service

        host_name               linuxhost

        service_description     Web Server

        check_command           check_http

        }

define service{

        use                     generic-service

        host_name               linuxhost

        service_description     Mysql Server

        check_command           check_mysql!admin!redhat

        }

4、檢測(cè)配置文件語(yǔ)法,并重啟nagios服務(wù)

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

# service nagios restart

標(biāo)題名稱(chēng):Nagios監(jiān)控工具
本文網(wǎng)址:http://muchs.cn/article30/ipgepo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、小程序開(kāi)發(fā)、網(wǎng)站制作、電子商務(wù)、定制開(kāi)發(fā)、外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司