成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

nagios整合cact實(shí)現(xiàn)網(wǎng)絡(luò)監(jiān)控報(bào)警的方法

創(chuàng)新互聯(lián)長(zhǎng)期為近1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為吉縣企業(yè)提供專業(yè)的成都做網(wǎng)站、網(wǎng)站建設(shè),吉縣網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。

這篇文章主要介紹了nagios整合cact實(shí)現(xiàn)網(wǎng)絡(luò)監(jiān)控報(bào)警的方法,具有一定借鑒價(jià)值,需要的朋友可以參考下。如下資料是關(guān)于實(shí)現(xiàn)網(wǎng)絡(luò)監(jiān)控報(bào)警的詳細(xì)步驟內(nèi)容。

系統(tǒng)環(huán)境:rhel6.3

        selinux   and  iptables  disabled  

    整合cacti和nagios是利用了cacti的一個(gè)插件nagios for cacti,它的原理是將nagios的數(shù)據(jù)通過(guò)ndo2db導(dǎo)入到MySQL數(shù)據(jù)庫(kù)(cacti的庫(kù)中),然后cacti讀取數(shù)據(jù)庫(kù)信息將nagios的結(jié)果展示出來(lái)。

一、nagios監(jiān)控本地主機(jī)

localhost.cfg中主機(jī)與服務(wù)是在一塊的,為了便于管理,將主機(jī)與服務(wù)的配置信息分隔開。注釋掉localhost.cfg,新增加hosts.cfg,services.cfg文件:

[root@server34 etc]#vim  /usr/local/nagios/etc/nagios.cfg

# You can specify individual object config files as shown below:

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/timeperiods.cfg

cfg_file=/usr/local/nagios/etc/objects/templates.cfg

cfg_file=/usr/local/nagios/etc/objects/hosts.cfg

cfg_file=/usr/local/nagios/etc/objects/services.cfg

# Definitions for monitoring the local (Linux) host

#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

更改主機(jī):

[root@server34 objects]# cp localhost.cfg hosts.cfg

[root@server34 objects]# vim hosts.cfg

define host{

       use                     linux-server

       host_name              server34.example.com

       alias                   Manager

       address                 192.168.0.34

       icon_p_w_picpath              server.gif

       statusmap_p_w_picpath         server.gd2

2d_coords500,200

3d_coords500,200,100

       }

###############################################################################

###############################################################################

#

# HOST GROUP DEFINITION

#

###############################################################################

###############################################################################

# Define an optional hostgroup for Linux machines

define hostgroup{

       hostgroup_name  linux-servers ; The name of the hostgroup

       alias           Linux Servers ; Long name of the group

       members         *     ; Comma separated list of hosts that belong to this group

       }

[root@server34 objects]# cp localhost.cfg services.cfg

[root@server34 objects]# vim hosts.cfg

define host{

       use                     linux-server

       host_name              server34.example.com

       alias                   Manager

       address                 192.168.0.34

       icon_p_w_picpath              server.gif

       statusmap_p_w_picpath         server.gd2

2d_coords500,200

3d_coords500,200,100

       }

###############################################################################

###############################################################################

#

# HOST GROUP DEFINITION

#

###############################################################################

###############################################################################

# Define an optional hostgroup for Linux machines

define hostgroup{

       hostgroup_name  linux-servers ; The name of the hostgroup

       alias           Linux Servers ; Long name of the group

       members         *     ; Comma separated list of hosts that belong to this group

       }

[root@server34 objects]# vim services.cfg

define servicegroup{

servicegroup_name 系統(tǒng)負(fù)荷檢查

alias 負(fù)荷檢查

members server34.example.com,進(jìn)程總數(shù),server34.example.com,登錄用戶數(shù),server34.example.com,根分區(qū),server34.example.com,交換空間利用率

}

define servicegroup{

servicegroup_name 全部聯(lián)通性檢查

alias 聯(lián)通性檢查

members server34.example.com,PING

}

###############################################################################

###############################################################################

#

# SERVICE DEFINITIONS

#

###############################################################################

###############################################################################

# Define a service to "ping" the local machine

define service{

       use                             local-service         ; Name of service template to use

       host_name                       *

       service_description             PING

check_commandcheck_ping!100.0,20%!500.0,60%

       }

# Define a service to check the disk space of the root partition

# on the local machine.  Warning if < 20% free, critical if

# < 10% free space on partition.

define service{

       use                             local-service         ; Name of service template to use

       host_name                       server34.example.com

       service_description             根分區(qū)

check_commandcheck_local_disk!20%!10%!/

       }

# Define a service to check the number of currently logged in

# users on the local machine.  Warning if > 20 users, critical

# if > 50 users.

define service{

       use                             local-service         ; Name of service template to use

       host_name                       server34.example.com

       service_description             登錄用戶數(shù)

check_commandcheck_local_users!20!50

       }

# Define a service to check the number of currently running procs

# on the local machine.  Warning if > 250 processes, critical if

# > 400 users.

define service{

       use                             local-service         ; Name of service template to use

       host_name                       server34.example.com

       service_description             進(jìn)程總數(shù)

check_commandcheck_local_procs!250!400!RSZDT

       }

# Define a service to check the load on the local machine.

define service{

       use                             local-service         ; Name of service template to use

       host_name                       server34.example.com

       service_description             系統(tǒng)負(fù)荷

check_commandcheck_local_load!5.0,4.0,3.0!10.0,6.0,4.0

       }

# Define a service to check the swap usage the local machine.

# Critical if less than 10% of swap is free, warning if less than 20% is free

define service{

       use                             local-service         ; Name of service template to use

       host_name                       server34.example.com

       service_description             交換空間利用率

check_commandcheck_local_swap!20!10

       }

# Define a service to check SSH on the local machine.

# Disable notifications for this service by default, as not all users may have SSH enabled.

define service{

       use                             local-service         ; Name of service template to use

       host_name                       server34.example.com

       service_description             SSH

check_commandcheck_tcp!22!1.0!10.0

notifications_enabled0

       }

# Define a service to check HTTP on the local machine.

# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{

       use                             local-service         ; Name of service template to use

       host_name                       server34.example.com

       service_description             HTTP

check_commandcheck_http

notifications_enabled0

       }

檢測(cè)nagios的配置文件

[root@server34 objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

[root@server34 objects]# /etc/init.d/nagios reload

http://192.168.0.34/nagios

點(diǎn)擊服務(wù),看到以上配置的服務(wù)則證明配置成功

二、nagios監(jiān)控遠(yuǎn)程主機(jī)

1、監(jiān)控遠(yuǎn)程主機(jī)的網(wǎng)絡(luò)服務(wù)

監(jiān)控遠(yuǎn)程主機(jī)的網(wǎng)絡(luò)服務(wù)(如監(jiān)控mysql服務(wù)等)

監(jiān)控主機(jī):192.168.0.34

遠(yuǎn)程主機(jī)(被監(jiān)控主機(jī)):192.168.0.17

rhel6.4 selinux disabled and iptables

此處以監(jiān)控遠(yuǎn)程主機(jī)的mysql服務(wù)為例來(lái)說(shuō)明nagios是如何監(jiān)控遠(yuǎn)程主機(jī)的網(wǎng)絡(luò)服務(wù)

安裝mysql

[root@server17 ~]# yum install mysql -y

啟動(dòng)mysql

創(chuàng)建nagios數(shù)據(jù)庫(kù),并給nagios用戶授予在監(jiān)控主機(jī)上登錄nagios庫(kù)的權(quán)限。

mysql> create database nagios;

mysql> grant select on nagios.* to nagios@'192.168.0.34' identified by 'westos';

檢測(cè)能否采集到信息:

[root@server34 libexec]# ./check_mysql -H 192.168.0.17 -u nagios -p westos -d nagios

Uptime: 1648  Threads: 1  Questions: 15  Slow queries: 0  Opens: 15  Flush tables: 1  Open tables: 8  Queries per second avg: 0.9|Connections=8c;;; Open_files=16;;; Open_tables=8;;; Qcache_free_memory=0;;; Qcache_hits=0c;;; Qcache_inserts=0c;;; Qcache_lowmem_prunes=0c;;; Qcache_not_cached=0c;;; Qcache_queries_in_cache=0;;; Queries=15c;;; Questions=15c;;; Table_locks_waited=0c;;; Threads_connected=1;;; Threads_running=1;;; Uptime=1648c;;;

[root@server34 libexec]# pwd

/usr/local/nagios/libexec

添加檢測(cè)命令:

[root@server34 objects]# vim commands.cfg

# 'check_mysql' command definition

define command{

       command_name    check_mysql

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

       }

添加主機(jī):

[root@server34 objects]# vim hosts.cfg

define host{

       use                     linux-server

       host_name               server17.example.com

       alias                   mysql

       address                 192.168.0.17

       icon_p_w_picpath              server.gif

       statusmap_p_w_picpath         server.gd2

       2d_coords               600,300

       3d_coords               600,300,100

       }

添加服務(wù):

[root@server34 objects]# vim services.cfg   ###添加服務(wù)組

define servicegroup{

       servicegroup_name 全部聯(lián)通性檢查

       alias 聯(lián)通性檢查

       members server34.example.com,PING,server17.example.com,PING

       }

################################check_mysql#################################

define service{                             ###添加服務(wù)

       use                             local-service         ; Name of service template to use

       host_name                       server17.example.com

       service_description             check_mysql

       check_command                   check_mysql!nagios!westos!nagios

       }

驗(yàn)證配置文件更改是否正確:

[root@server34 objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

重新加載nagios:

[root@server34 objects]# /etc/init.d/nagios reload

檢測(cè):http://192.168.0.34/nagios

點(diǎn)擊主機(jī)->出現(xiàn)server17.example.com

點(diǎn)擊服務(wù)->出現(xiàn)check_mysql服務(wù)

2、通過(guò)nrpe監(jiān)控遠(yuǎn)程主機(jī)的基本信息(如磁盤的使用情況等)

在被監(jiān)控主機(jī)上操作

下載nagios插件包、nrpe包

nagios-plugins-1.5.tar.gz, nrpe-2.15.tar.gz  

[root@server17 ~]# tar zxf nagios-plugins-1.5.tar.gz

創(chuàng)建nagios用戶

[root@server17 ~]# useradd nagios

編譯安裝nagios-plugin

[root@server17 ~]# cd nagios-plugins-1.5

[root@server17 nagios-plugins-1.5]# ./configure --with-nagios-user=nagios --with-nagios-user=nagios

[root@server17 nagios-plugins-1.5]# make && make install

編譯安裝nrpe,nrpe是守護(hù)進(jìn)程,需安裝更改xinetd

[root@server17 nrpe-2.15]# yum install xinetd -y

[root@server17 nrpe-2.15]# vim /etc/xinetd.d/nrpe

only_from       = 192.168.0.34

[root@server17 nrpe-2.15]# vim /etc/services

nrpe            5666/tcp

[root@server17 nrpe-2.15]# ./configure

[root@server17 nrpe-2.15]# make all

[root@server17 nrpe-2.15]# make install-plugin

[root@server17 nrpe-2.15]# make install-daemon

[root@server17 nrpe-2.15]# make install-daemon-config

[root@server17 nrpe-2.15]# make install-xinetd

[root@server17 nrpe-2.15]# /etc/init.d/xinetd start

配置nrpe

[root@server34 etc]# vim 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

[root@server17 ~]# /etc/init.d/xinetd start

##########################################

在監(jiān)控主機(jī)上

下載nrpe包:

nrpe-2.15.tar.gz

[root@server17 nrpe-2.15]# ./configure

[root@server17 nrpe-2.15]# make all

[root@server17 nrpe-2.15]# make install-plugin

[root@server17 nrpe-2.15]# make install-daemon

[root@server17 nrpe-2.15]# make install-daemon-config

安裝檢測(cè):

[root@server34 libexec]# ./check_nrpe -H 192.168.0.17

NRPE v2.15

檢測(cè)磁盤使用情況:

[root@server34 libexec]# ./check_nrpe -H 192.168.0.17 -c check_disk

DISK OK - free space: / 14459 MB (85% inode=91%);| /=2540MB;14327;16118;0;17909

添加check_nrpe檢測(cè)命令

[root@server34 objects]# vim commands.cfg

# 'check_nrpe' command definition

define command{

       command_name    check_nrpe

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

       }

[root@server34 objects]# vim services.cfg

define servicegroup{

       servicegroup_name 系統(tǒng)負(fù)荷檢查

       alias 負(fù)荷檢查

       members server34.example.com,進(jìn)程總數(shù),server34.example.com,登錄用戶數(shù),server34.example.com,根分區(qū),server34.example.com,交換空間利用率

       }

define servicegroup{

       servicegroup_name 全部聯(lián)通性檢查

       alias 聯(lián)通性檢查

       members server34.example.com,PING,server17.example.com,PING

       }

配置檢測(cè):

[root@server34 objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

檢測(cè):

http ://192.168.0.34/nagios

點(diǎn)擊服務(wù),查看結(jié)果


三、整合nagios與微信、飛信

    nagios與微信、飛信整合,使得nagios的監(jiān)控報(bào)警具有了錦上添花的效果。這樣,管理員不用經(jīng)常性的查看系統(tǒng)運(yùn)行是否正常,磁盤使用情況等等,有什么異常情況,微信、飛信會(huì)第一時(shí)間的通知你,可以達(dá)到7*24小時(shí)的監(jiān)控。你要做的就是手機(jī)保持暢通就ok了。既然這么好,那大家就跟隨我一塊愉快的感受下吧!

首先打開相關(guān)服務(wù):

[root@server34 objects]# /etc/init.d/nagios start

[root@server34 objects]# /etc/init.d/httpd start

[root@server34 objects]# /etc/init.d/mysqld start

檢測(cè)nagios@server34.example.com是否能收發(fā)郵件

[root@server34 objects]# mail nagios@server34.example.com

切換到nagios用戶,查看到以下郵件時(shí)則成功

[root@server34 objects]# su - nagios

-bash-4.1$ mail

Heirloom Mail version 12.4 7/29/08.  Type ? for help.

"/var/spool/mail/nagios": 1 message

>   1 root                  Sun Apr 27 09:54  20/642   "dsdssds"

&

一般自定義域名會(huì)被QQ郵箱當(dāng)作垃圾郵件處理,在QQ郵箱中設(shè)置白名單

-bash-4.1$ ping mail.qq.com  //檢測(cè)網(wǎng)絡(luò)是否暢通

PING mail.qq.com (14.17.32.178) 56(84) bytes of data.

64 bytes from 14.17.32.178: icmp_seq=1 ttl=53 time=54.4 ms

64 bytes from 14.17.32.178: icmp_seq=2 ttl=53 time=1088 ms

添加郵箱:

[root@server34 objects]# vim contacts.cfg

 email                           281588847@qq.com

[root@server34 objects]# /etc/init.d/nagios reload

下載fetion,和飛信的庫(kù)文件linuxso_20101113.tar.gz

[root@server34 ~]# tar zxf linuxso_20101113.tar.gz -C /lib^C

[root@server34 ~]# cp fetion /usr/local/nagios/libexec/

給以下文件加可執(zhí)行權(quán)限

[root@server34 libexec]# chmod +x libACE*^C

[root@server34 libexec]# chmod +x libcrypto.so.4 libssl.so.4

[root@server34 libexec]# chmod nagios.nagios fetion

[root@server34 libexec]# su - nagios

根據(jù)提示的錯(cuò)誤依次安裝以下軟件包:

-bash-4.1$ /usr/local/nagios/libexec/fetion

-bash: /usr/local/nagios/libexec/fetion: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

[root@server34 ~]# yum install /lib/ld-linux.so.2  libstdc++.so.6  libgssapi_krb5.so.2  libz.so.1  -y

-bash-4.1$ /usr/local/nagios/libexec/fetion --mobile=1870924**** --pwd=****** --to=187********,187******** --msg-utf8="hahahahhhhhhhhhhhaaaa"//第一次發(fā)送時(shí)會(huì)要求輸入校驗(yàn)碼,以后發(fā)送時(shí)則不需要

為了查看校驗(yàn)碼的內(nèi)容,將校驗(yàn)碼拷貝到物理主機(jī)的桌面上

[root@server34 libexec]# scp 18709242146.jpg 192.168.0.39:/root/Desktop

整合飛信與nagios

因發(fā)送的對(duì)象與內(nèi)容可能發(fā)生改變,故用腳本實(shí)現(xiàn)則更為方便,以下是實(shí)現(xiàn)該功能的腳本:

-bash-4.1$ vim fetion.sh

/usr/local/nagios/libexec/fetion --mobile=187******** --pwd=****** --to="$1" --msg-utf8="$2" &>/dev/null

給fetion.sh加可執(zhí)行權(quán)限

-bash-4.1$ chmod +x fetion.sh 

測(cè)試:

-bash-4.1$ /usr/local/nagios/libexec/fetion.sh 1870924**** "westos linux"

-bash-4.1$ vim 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

       email                           281588847@qq.com        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

       pager                           1870924****

       }

-bash-4.1$ vim commands.cfg

# 'notify-host-by-fetion' command definition

define command{

       command_name    notify-host-by-fetion

       command_line    $USER1$/fetion.sh $CONTACTPAGER$ " $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$"    

       }

# 'notify-service-by-FETION' command definition

define command{

       command_name    notify-service-by-fetion

       command_line     $USER1$/fetion.sh $CONTACTPAGER$ " $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"    

       }

-bash-4.1$ vim templates.cfg

   service_notification_commands   notify-service-by-email,notify-service-by-fetion        ; send service notifications via email

       host_notification_commands      notify-host-by-email,notify-host-by-fetion      ; send host notifications via email

檢測(cè)配置文件

[root@server34 objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

測(cè)試:

[root@server17 ~]# /etc/init.d/mysqld stop

Stopping mysqld:                                           [  OK  ]

當(dāng)收到飛信報(bào)警信息時(shí)配置成功

看完這篇文章,你們學(xué)會(huì)nagios整合cact實(shí)現(xiàn)網(wǎng)絡(luò)監(jiān)控報(bào)警的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀。

分享標(biāo)題:nagios整合cact實(shí)現(xiàn)網(wǎng)絡(luò)監(jiān)控報(bào)警的方法
文章來(lái)源:http://jinyejixie.com/article16/jpdgdg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、軟件開發(fā)移動(dòng)網(wǎng)站建設(shè)、面包屑導(dǎo)航、品牌網(wǎng)站設(shè)計(jì)、搜索引擎優(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)

網(wǎng)站托管運(yùn)營(yíng)
衢州市| 铜鼓县| 大埔县| 紫金县| 白水县| 隆尧县| 澎湖县| 古交市| 洮南市| 利辛县| 南安市| 抚宁县| 弥勒县| 获嘉县| 天祝| 楚雄市| 江都市| 三台县| 宁海县| 巨鹿县| 柘城县| 定结县| 德化县| 武胜县| 清原| 宝山区| 上虞市| 邓州市| 宜君县| 轮台县| 文成县| 杭锦旗| 巴马| 彰化县| 三原县| 平山县| 高尔夫| 八宿县| 从化市| 清徐县| 四川省|