真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

實戰(zhàn)Nagios網(wǎng)絡(luò)監(jiān)控(1)——監(jiān)控本機運行狀態(tài)和Mysq主機-創(chuàng)新互聯(lián)

Nagios是一個監(jiān)視系統(tǒng)運行狀態(tài)和網(wǎng)絡(luò)信息的監(jiān)視系統(tǒng)。Nagios能監(jiān)視所指定的本地或遠(yuǎn)程主機以及服務(wù),同時提供異常通知功能等。

創(chuàng)新互聯(lián)建站是一家專注于成都網(wǎng)站設(shè)計、成都做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)與策劃設(shè)計,晉源網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:晉源等地區(qū)。晉源做網(wǎng)站價格咨詢:13518219792

    Nagios可運行在Linux/Unix平臺之上,同時提供一個可選的基于瀏覽器的WEB界面以方便系統(tǒng)管理人員查看網(wǎng)絡(luò)狀態(tài),各種系統(tǒng)問題,以及日志等等

實驗環(huán)境:

物理主機 redhat7.0 內(nèi)核版本 3.10.0-123.el7.x86_64

虛擬機 redhat6.5 內(nèi)核版本 2.6.32-431.el6.x86_64

服務(wù)器端: server1.example.com 172.25.254.1

所需軟件包:

gd-devel-2.0.35-11.el6.x86_64.rpm

nagios-cn-3.2.3.tar.bz2

nagios-plugins-2.1.1.tar.gz

1.編譯nagios

  (1).準(zhǔn)備安裝

        [root@server1 mnt]# tar jxf nagios-cn-3.2.3.tar.bz2

        [root@server1 mnt]# mv nagios-cn-3.2.3  /root/

        [root@server1 mnt]# yum install gd-devel-2.0.35-11.el6.x86_64.rpm  gcc  -y                                            ##為./configure做準(zhǔn)備

    (2).編譯安裝

        [root@server1 mnt]# cd /root/nagios-cn-3.2.3/

        [root@server1 nagios-cn-3.2.3]# ./configure

        [root@server1 nagios-cn-3.2.3]# useradd -u 900 -M -d /usr/local/nagios nagios

        [root@server1 nagios-cn-3.2.3]# make all

       [root@server1 nagios-cn-3.2.3]# make

        [root@server1 nagios-cn-3.2.3]# make install-init

            *** Init script installed ***

        [root@server1 nagios-cn-3.2.3]# make install-commandmode

            *** External command directory configured ***

        [root@server1 nagios-cn-3.2.3]# make install-config

            *** Config files installed ***

        [root@server1 nagios-cn-3.2.3]# make install-webconf

            *** Nagios/Apache conf file installed ***

    (3).修改登陸用戶密碼

        [root@server1 nagios-cn-3.2.3]#  cat /usr/local/nagios/etc/htpasswd.users  ##查看密碼

        nagiosadmin:gCWSDnqEHR45c

        [root@server1 nagios-cn-3.2.3]# htpasswd /usr/local/nagios/etc/htpasswd.users nagiosadmin

        New password:                         ##更改密碼

        Re-type new password:

        Updating password for user nagiosadmin

    (4)啟動服務(wù)

         [root@server1 nagios-cn-3.2.3]# /etc/init.d/httpd start

        Starting httpd:                       [  OK  ]

        [root@server1 nagios-cn-3.2.3]# /etc/init.d/nagios start

        Starting nagios: done.

    (5)瀏覽器訪問:172.25.254.6/nagios,用戶為nagiosadmin,密碼為自己剛改的密碼。

實戰(zhàn)Nagios網(wǎng)絡(luò)監(jiān)控(1)——監(jiān)控本機運行狀態(tài)和Mysq主機

實戰(zhàn)Nagios網(wǎng)絡(luò)監(jiān)控(1)——監(jiān)控本機運行狀態(tài)和Mysq主機

實戰(zhàn)Nagios網(wǎng)絡(luò)監(jiān)控(1)——監(jiān)控本機運行狀態(tài)和Mysq主機

2.排除故障

    可以看到剛安裝的nagios不能監(jiān)控到主機的狀態(tài),需要安裝插件排除故障

    (1)[root@server1 0722-監(jiān)控-nagios]# cd /mnt/

        [root@server1 mnt]# tar -zxf nagios-plugins-2.1.1.tar.gz

        [root@server1 mnt]# mv nagios-plugins-2.1.1  /root/

        [root@server1 mnt]# cd /root/nagios-plugins-2.1.1/

    (2)編譯插件

        [root@server1 nagios-plugins-2.1.1]# yum install mysql-devel openssl-devel -y   #編譯所需軟件包

        [root@server1 nagios-plugins-2.1.1]# ./configure

*****************************************************************************************

config.status: creating po/Makefile

      --with-apt-get-command:

       --with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s

        --with-ping-command: /bin/ping -n -U -w %d -c %d %s

            --with-ipv6: yes

           --with-mysql: /usr/bin/mysql_config ##不能為no,如果為no,則 yum install mysql-devel -y

          --with-openssl: yes ##不能為no,如果為no,則 yum install openssh-devel -y

           --with-gnutls: no

        --enable-extra-opts: yes

            --with-perl: /usr/bin/perl

       --enable-perl-modules: no

           --with-cgiurl: /nagios/cgi-bin

        --with-trusted-path: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

          --enable-libtap: no

*****************************************************************************************

<2>make

<3>make install

(3)cd /usr/local/nagios/libexec/

<1>ll

<2>chown nagios.nagios * ##更改所有文件的所屬用戶和所屬組為nagios

<3>id apache

 usermod -G nagios apache

   id apache

*********************************************

[root@server6 libexec]# id apache

uid=48(apache) gid=48(apache) groups=48(apache),900(nagios)

*********************************************

    (3).編輯配置文件

    (3.1)

        [root@server1 nagios-plugins-2.1.1]# vim /usr/local/nagios/etc/nagios.cfg

         30 cfg_file=/usr/local/nagios/etc/objects/commands.cfg

         31 cfg_file=/usr/local/nagios/etc/objects/contacts.cfg

         32 cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg

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

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

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

         36

         37 # Definitions for monitoring the local (Linux) host

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

    (3.2)

        [root@server1 nagios-plugins-2.1.1]# cd /usr/local/nagios/etc/objects/

        [root@server1 objects]# cp -p localhost.cfg hosts.conf

        [root@server1 objects]# cp -p localhost.cfg services.cfg

        [root@server1 objects]# cp -p localhost.cfg hosts.cfg

    (3.3)

        [root@server1 objects]# vim hosts.cfg

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

# Define a host for the local machine

define host{

    use           linux-server       ; 給網(wǎng)絡(luò)設(shè)備用的

    host_name        監(jiān)控主機

    alias          MainSwitch

    address         127.0.0.1

    icon_p_w_picpath        switch.gif

    statusmap_p_w_picpath     switch.gd2

    2d_coords        100,200

    3d_coords        100,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

    }

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

    (3.4)[root@server1 objects]# vim services.cfg

define servicegroup{

    servicegroup_name 系統(tǒng)狀態(tài)檢查

    alias 系統(tǒng)概況

    }

define service{

    use               local-service     ; Name of service template to use

    host_name            *

    service_description       PING

    check_command          check_ping!100.0,20%!500.0,60%

    }

define service{

    use               local-service     ; Name of service template to use

    host_name            監(jiān)控主機

    service_description       根分區(qū)

    check_command          check_local_disk!20%!10%!/

    }

define service{

    use               local-service     ; Name of service template to use

    host_name            監(jiān)控主機

    service_description       登錄用戶數(shù)

    check_command          check_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            監(jiān)控主機

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

    check_command          check_local_procs!250!400!RSZDT

    }

define service{

    use               local-service     ; Name of service template to use

    host_name            監(jiān)控主機

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

    check_command          check_local_load!5.0,4.0,3.0!10.0,6.0,4.0

    }

define service{

    use               local-service     ; Name of service template to use

    host_name            監(jiān)控主機

    service_description       交換空間利用率

    check_command          check_local_swap!20!10

    }

define service{

    use               local-service     ; Name of service template to use

    host_name            監(jiān)控主機

    service_description       SSH

    check_command          check_tcp!22!1.0!10.0

    notifications_enabled      0

    }

define service{

    use               local-service     ; Name of service template to use

    host_name            監(jiān)控主機

    service_description       HTTP

    check_command          check_http

    notifications_enabled      0

    }

    (3.5)[root@server1 objects]# /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

    (3.6)

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

            Running configuration check...done.

            Reloading nagios configuration...done

 瀏覽器刷新瀏覽:172.25.254.1/nagios

實戰(zhàn)Nagios網(wǎng)絡(luò)監(jiān)控(1)——監(jiān)控本機運行狀態(tài)和Mysq主機

3.加個mysql服務(wù)

    [root@server1 ~]# yum install mysql-server -y

  [root@server1 ~]# /etc/init.d/mysqld restart

  [root@server1 ~]# mysql

> show databases;

> grant select on test.* to nagios@localhost identified by 'redaht';

  [root@server1 ~]# cd /usr/local/nagios/libexec

    [root@server1 libexec]# ./check_mysql -H localhost  -u nagios -p westos

Uptime: 12566  Threads: 10  Questions: 207453  Slow queries: 0  Opens: 130  Flush tables: 1  Open tables: 42  Queries per second avg: 16.509|Connections=421c;;; Open_files=80;;; Open_tables=42;;; Qcache_free_memory=0;;; Qcache_hits=0c;;; Qcache_inserts=0c;;; Qcache_lowmem_prunes=0c;;; Qcache_not_cached=0c;;; Qcache_queries_in_cache=0;;; Queries=207453c;;; Questions=207453c;;; Table_locks_waited=5c;;; Threads_connected=10;;; Threads_running=1;;; Uptime=12566c;;;

*********************************************************************************

  [root@server1 libexec]cd /usr/local/nagios/etc/objects

  [root@server1 objects] vim command.cfg

*********************************************************************************

212 # 'check_mysql' command definition

213 define command{

214     command_name   check_mysql

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

216     }

*********************************************************************************

  [root@server1 objects] vim hosts.cfg

*********************************************************************************

14 # Define a host for the mysql on server4.example.com

  15 define host{

  16     use           linux-server

  17     host_name        server4.example.com

  18     alias          mysql

  19 #    parents         MainSwitch

  20     address        127.0.0.1

  21     icon_p_w_picpath        server.gif

  22     statusmap_p_w_picpath     server.gd2

  23     2d_coords        400,100 ##2D坐標(biāo)位置

  24     3d_coords        400,200,100 ##3D坐標(biāo)位置

  25     }

*********************************************************************************

  [root@server1 objects] vim services.cfg

*********************************************************************************

109 ################check_mysql##########################

110 define service{

111     use               local-service     ; Name of service template to use

112     host_name            server4.example.com

113     service_description       mysql

114     check_command          check_mysql!nagios!westos

115     notifications_enabled      0

116     }

*********************************************************************************

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

(4)瀏覽器刷新瀏覽:172.25.254.1/nagios

實戰(zhàn)Nagios網(wǎng)絡(luò)監(jiān)控(1)——監(jiān)控本機運行狀態(tài)和Mysq主機

    可以看到多了一個Mysql監(jiān)控

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


網(wǎng)站標(biāo)題:實戰(zhàn)Nagios網(wǎng)絡(luò)監(jiān)控(1)——監(jiān)控本機運行狀態(tài)和Mysq主機-創(chuàng)新互聯(lián)
文章來源:http://weahome.cn/article/jpicj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部