91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

nagios監控安裝及設置案例

發布時間:2020-06-29 19:16:15 來源:網絡 閱讀:451 作者:sxlfxx 欄目:移動開發

[root@server1 nagios]# 1 安裝yum install gd-devel -y
[root@server1 nagios]# 2 部署lamp環境yum install httpd mysql mysql-server php php-mysql gcc gcc-c++ -y
[root@server1 nagios]# 3 安裝主程序nagios
[root@server1 nagios]# tar fvxz nagios.tar.gz
[root@server1 nagios]# ./configure --prefix=/usr/local/nagios
[root@server1 nagios]# useradd nagios
[root@server1 nagios]# make all
[root@server1 nagios]# make install
make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /et c/rc.d/init.d

   make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!


  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface

vim /etc/httpd/conf/httpd.conf
User nagios
Group nagios

重新啟動apache
service httpd restart
                                                                                                                                     service nagios start
生成用戶
[root@server1 nagios-3.2.0]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosm
New password: 
Re-type new password: 
Adding password for user nagios


給nagios用戶開權限,讓他能夠查看信息!
[root@server1 nagios-3.2.0]# vim /usr/local/nagios/etc/cgi.cfg 
在所有的nagiosadmin后面添加nagios

 

本機為什么是down的狀態???

監控分析控制臺   ---------------主程序
                插件
               --------------被監控主機
nagios報錯 無權查看任何主機的信息  解決方法

解決辦法:

vi /usr/local/nagios/etc/cgi.cfg

將use_authentication的值改為0.

use_authentication=0

然后重啟nagios服務

service nagios restart


[root@server1 libexec]# pwd
/usr/local/nagios/libexec
[root@server1 libexec]# ls
[root@server1 libexec]# 
插件目錄下什么沒有有阿!

安裝插件
[root@server1 nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios/ -
可選的選項--with-gnutls --with-openssl --enable-extra-opts --enable-perl-modules 

make

make install

 


怎樣監控的更多!

[root@server1 etc]# pwd
/usr/local/nagios/etc
[root@server1 etc]# vim nagios.cfg 
編輯主配置文件
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

通過上面的語句來調用那些配置文件
[root@server1 objects]# pwd
/usr/local/nagios/etc/objects

時間timeperiods.cfg
define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }


插件commands.cfg
define command{
        command_name    check-host-alive
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
        }

監控誰localhost.cfg
define host {
        host_name       fudong
        alias           test
        address         192.168.18.50
        check_command   check-host-alive
        notification_options    d,u,r
        check_interval  1
        max_check_attempts      2
        contact_groups  admins
        notification_interval   10
        notification_period     24x7
}

 

聯系人contacts.cfg

define contact {
        contact_name  kyo
        alias           kyo
        host_notification_period        24x7
        host_notification_options       d,u,r
        service_notification_period     24x7
        service_notification_options    w,u,c,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email   root@163.com
#通過飛信機器人發信報警!
}

 

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin,kyo
        }

 檢查錯誤
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 


定義服務
define service {
        host_name       fudong
        service_description     apache
        check_period    24x7
        normal_check_interval   2
        retry_check_interval    1
        max_check_attempts      5 
        notification_period     24x7
        notification_options    w,u,c,r
        check_command   check_http

}

 


關于插件的返回狀態
[root@server1 objects]# echo $?
2
[root@server1 objects]# /usr/local/nagios/libexec/check_http -I 192.168.18.50
HTTP OK HTTP/1.1 200 OK - 43306 bytes in 0.026 seconds |time=0.026288s;;;0.000000 size=43306B;;;0
[root@server1 objects]# echo $?
0
[root@server1 objects]# /usr/local/nagios/libexec/check_http -I 192.168.18.50 -u /a.html -s hello
HTTP WARNING: HTTP/1.1 404 Not Found
[root@server1 objects]# echo $?
1


0 成功  1 警告  2 嚴重錯誤  3 未知 
自己編寫插件!!!!!!!!!!!!!!!!
#!/bin/bash

curl -I http://192.168.18.155 &> /dev/null

if [ $? -eq 0 ]; then
        ( curl -I http://192.168.18.155 | grep 'HTTP/1.1 200' ) &> /dev/null
        if [ $? -eq 0 ];then
                echo "OK!"
                exit 0
        else
                echo "warning!"
                exit 1
        fi
else
        echo "down!"
        exit 2
fi


自定義命令
define command {
        command_name    check_url
        command_line    $USER1$/check_http -I $HOSTADDRESS$ -u $ARG1$ -s $ARG2$
}


使用新定義的命令

define service {
        host_name       fudong
        service_description     apache
        check_period    24x7
        normal_check_interval   2
        retry_check_interval    1
        max_check_attempts      5
        notification_period     24x7
        notification_options    w,u,c,r
#       check_command   check_http
        check_command   check_url!/index.html!hello

}

########################################################################
check_mysql
vim /usr/local/nagios/libexec/check_mysql
#!/bin/bash
#check_mysql status
IP=$1

mysql -u test -h $IP -p123 -e 'show databases;' &> /dev/null

if [ $? -eq 0 ]; then
        echo "mysql OK!"
        exit 0;
else
        echo "mysql err!"                                                                                                                                          
        exit 2;
fi

vim /usr/local/nagios/etc/objects/commands.cfg
define command{
        command_name check_mysql
        command_line $USER1$/check_mysql $ARG1$
}

vim /usr/local/nagios/etc/objects/localhost.cfg
define service {
        host_name       mail.vfast.com
        service_description     mysql
        check_period    24x7
        normal_check_interval   2
        retry_check_interval    1
        max_check_attempts      2
        notification_period     24x7
        notification_options    w,u,c,r
        check_command   check_mysql!192.168.18.69
}

service nagios restart

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

yum install expect -y


define command{
        command_name    notify-host-by-sms
        command_line    /usr/local/nagios/libexec/nagios-mail "$(/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n")"  smtp.163.com  Y29vbHdhbmdjaG9uZ0AxNjMuY29t  UVE4MTBXQU5HODIwMCFA  coolwangchong@163.com $CONTACTEMAIL$  "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
        }

 

 

 


如果遇到host條目一會有,一會消失的問題,可以killall nagios 再重新啟動nagios!

 

監控遠程主機的系統信息
被監控主機
安裝nrpe的server端
tar fvxz nrpe*.tar.gz
./configure --prefix=/usr/local/nagios
useradd nagios
make 

make install-daemon

make install-daemon-config

make install-xinetd


安裝插件2
make install (這步不是必須的!)
把插件拷貝給監控主機nagios
scp /usr/local/nagios/libexec/check_nrpe   root@監控主機的ip:/usr/local/nagios/libexec


在被監控主機開啟nrpe服務
vim /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe

{
        flags           = REUSE
        socket_type     = stream    
        port            = 5666    
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = 192.168.18.254  #監控主機的ip,保證他可以連接進來!
}


vim /etc/services 
nrpe 5666/tcp

service xinetd restart

[root@server1 objects]# /usr/local/nagios/libexec/check_nrpe -H 192.168.18.188
NRPE v2.12

#注意關閉防火墻!

 

在被監控主機安裝插件

vim nrpe.cfg
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_u]=/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 

通過以上字段來定義命令,以及接收命令后執行的插件


如果想不明白


定義服務,來檢測一下
define host {
        host_name       zcg
        alias           nrpe-server
        address         192.168.18.188
        check_command   check-host-alive
        notification_options    d,u,r
        check_interval  1
        max_check_attempts      2
        contact_groups  admins
        notification_interval   10
        notification_period     24x7
}

define service {
        host_name       zcg
        service_description     nrpe
        check_period    24x7
        normal_check_interval   2
        retry_check_interval    1
        max_check_attempts      5
        notification_period     24x7
        notification_options    w,u,c,r
        check_command   check_nrpe!check_users
#這里定義的check_nrpe需要在command.cfg里面定義
}
別忘了,先定義好zcg這臺主機!!


定義命令
define command {
        command_name    check_nrpe
        command_line    /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

重啟nagios服務!

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

阿瓦提县| 盐边县| 宁津县| 绥阳县| 济阳县| 静安区| 西藏| 和平县| 桓仁| 宜城市| 华蓥市| 太湖县| 东源县| 来宾市| 新和县| 阜新市| 东莞市| 遵义市| 梧州市| 随州市| 永州市| 封丘县| 宁阳县| 扶绥县| 九江市| 吕梁市| 哈密市| 平定县| 海晏县| 清新县| 西盟| 重庆市| 开阳县| 来宾市| 怀仁县| 富宁县| 六安市| 吴旗县| 扎鲁特旗| 黔西县| 高尔夫|