亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

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

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

yum搭建nagios監控linux&&window及郵件報警

發布時間:2020-07-09 21:43:54 來源:網絡 閱讀:2997 作者:rooney0987 欄目:移動開發

本文是小弟整合幾位大神的文章,見笑@@

Linux利用sendmail和fetion發送報警通知

 nagios監控windows主機 && linux主機

 CentOS 5/6.X 使用 EPEL YUM源:


實驗環境:

兩臺64位的centos-6.6

一臺window-server-2003


安裝網絡yum源:

centos5.x--32位
[root@centos-server ~]# wget http://mirrors.yun-idc.com/epel/5/i386/epel-release-5-4.noarch.rpm
centos5.x--64位
[root@centos-server ~]# wget http://mirrors.hust.edu.cn/epel//5/x86_64/epel-release-5-4.noarch.rpm
centos6.x--32位
[root@centos-server ~]# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
centos6.x--64位
[root@centos-server ~]# wget http://mirrors.hust.edu.cn/epel//6/x86_64/epel-release-6-8.noarch.rpm
[root@centos-server ~]# rpm -ivh epel-release-6-8.noarch.rpm


搭建nagios監控服務器

yum install httpd php* openssl openssl-devel nagios nagios-plugins*
setenforce 0
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
增加httpd的訪問驗證
[root@centos-server ~]# htpasswd -c /etc/nagios/htpasswd nagiosadmin
New password: 
Re-type new password: 
Adding password for user nagiosadmin

注意nagios的默認用戶就是nagiosadmin,如果你使用的不是此用戶,需要修改以下項目
[root@centos-server objects]# cat /etc/nagios/cgi.cfg |grep nagiosadmin
authorized_for_system_information=nagiosadmin
authorized_for_configuration_information=nagiosadmin
authorized_for_system_commands=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin
快速修改命令

[root@centos-server ~]# sed -i 's/nagiosadmin/dragon/g' /etc/nagios/cgi.cfg 
通過httpd訪問nagios的web文件

[root@centos-server objects]# cat >> /etc/httpd/conf/httpd.conf <<END
scriptAlias /nagios/cgi-bin "/usr/lib64/nagios/cgi-bin/"
<Directory "/usr/lib64/nagios/cgi-bin/">
AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
AuthUserFile /etc/nagios/htpasswd 
</Directory>
Alias /nagios /usr/share/nagios/html/
<Directory "/usr/share/nagios/html/">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthUserFile /etc/nagios/htpasswd
</Directory>
END


定義監控LINUX文件:

[root@centos-server objects]# mkdir /etc/nagios/objects/server
[root@centos-server objects]# vim /etc/nagios/nagios.cfg
cfg_dir=/usr/local/nagios/etc/servers
[root@centos-server objects]# vim /etc/nagios/objects/server/192.168.150.143.cfg 
define host{
        use                     linux-server
        host_name               192.168.150.143
        alias                   linux
        address                 192.168.150.143
        }
 
 
define service{
        use                             generic-service
        host_name                       192.168.150.143
        service_description             Check Swap
        check_command                   check_nrpe!check_swap
        }
 
define service{
        use                             generic-service
        host_name                       192.168.150.143
        service_description             total
        check_command                   check_nrpe!check_total_procs
        }
 
define service{
        use                             generic-service
        host_name                       192.168.150.143
        service_description             check_load
        check_command                   check_nrpe!check_load
        }
 
define service{
        use                             generic-service
        host_name                       192.168.150.143
        service_description             check_tcp_3306
        check_command                   check_tcp!3306
        }
 
define service{
        use                             generic-service
        host_name                       192.168.150.143
        service_description             check_users
        check_command                   check_nrpe!check_users
        }
 
 
define service{
        use                             generic-service
        host_name                       192.168.150.143
        service_description             check_mysql
        check_command                   check_nrpe!check_mysql
        }
define service{
        use                             generic-service
        host_name                        192.168.150.143
        service_description             check_http  192.168.150.143/index.html
        check_command                   check_http!'-u /index.html' 
}
define service{
        use                             generic-service
        host_name                       192.168.150.143
        service_description             check_disk
        check_command                   check_nrpe!check_sda1
        }
在commonds.cfg中添加check_nrpe的命令
[root@centos-server objects]# vim /etc/nagios/objects/commands.cfg 
define command{
      command_name  check_nrpe
      command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}


配置linux客戶端:

[root@centos-server ~]# yum install nagios-plugins* openssl-devel openssl mysql-server
[root@centos-server ~]# cat /etc/nrpe.d/nrpe 
only_from=127.0.0.1 192.168.150.139
[root@centos-server objects]# vim /etc/nagios/nrpe.cfg 
添加nagios監控端的ip
allowed_hosts=127.0.0.1,192.168.150.139
添加以下內容
command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_sda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200 
command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql -H 127.0.0.1 -ubbq -pqwe123  #此用戶需要在mysql中添加
command[check_swap]=/usr/lib64/nagios/plugins/check_swap -w 20% -c 10%

通過yum安裝的nagios監控插件還有很多,有需要用到的可以研究下:

yum搭建nagios監控linux&&window及郵件報警


兩端重啟服務:

service nagios restart
service httpd restart
service nrpe restart
service xinetd restart
[root@centos-server ~]# netstat -anl|grep 5666
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      
tcp        0      0 :::5666                     :::*                        LISTEN  
在nagios監控端測試被監控端nrpe聯通:
[root@centos-server ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.150.143
NRPE v2.15



監控window-server:

[root@centos-server objects]# vim /etc/nagios/objects/server/192.168.150.146.cfg
define host{
usewindows-server 
        host_name               192.168.150.146
        alias                   my computer
        address                 192.168.150.146
        }
 
 
define service{
        use                             generic-service
        host_name                       192.168.150.146
        service_description             NSClient++ Version
        check_command                   check_win!CLIENTVERSION
         }
 
define service{
        use                             generic-service
        host_name                       192.168.150.146
        service_description             Uptime
        check_command                   check_win!UPTIME
        }
 
define service{
        use                             generic-service
        host_name                       192.168.150.146
        service_description             CPU Load
        check_command                   check_win!CPULOAD!-l 5,80,90
}
 
define service{
       use                     generic-service
       host_name               192.168.150.146
       service_description     Memory Usage
       check_command           check_win!MEMUSE!-w 80 -c 90
       }
 
define service{
       use                     generic-service
       host_name               192.168.150.146
       service_description     C:\ Drive Space
       check_command           check_win!USEDDISKSPACE!-l c -w 80 -c 90
       }
 
define service{
       use                     generic-service
       host_name               192.168.150.146
       service_description     D:\ Drive Space
       check_command           check_win!USEDDISKSPACE!-l d -w 80 -c 90
       }
 
define service{
       use                     generic-service
       host_name               192.168.150.146
       service_description     E:\ Drive Space
       check_command           check_win!USEDDISKSPACE!-l e -w 80 -c 90
       }
define service{
       use                     generic-service
       host_name               192.168.150.146
       service_description     Explorer
       check_command           check_win!PROCSTATE!-d SHOWALL -l Explorer.exe
       }
[root@centos-server objects]# vim /etc/nagios/objects/commands.cfg 
define command{
        command_name    check_win
        command_line    $USER1$/check_nt -H "$HOSTADDRESS$" -p 12489 -s dianyi123 -v $ARG1$ $ARG2$
}


測試配置文件:

[root@centos-server objects]# /usr/sbin/nagios -v /etc/nagios/nagios.cfg 
Error: Could not find any hostgroup matching 'windows-servers' (config file '/etc/nagios/objects/server/192.168.150.146.cfg', starting on line 1)
#這里我遇到這個錯誤了,把/etc/nagios/objects/templates.cfg 里window-server模版主機中以下這項注釋就可以了
 #hostgroups             windows-servers ; 
重啟以下服務
[root@centos-server objects]# service nagios restart


配置window安裝NSClient++:

1.

yum搭建nagios監控linux&&window及郵件報警

2.

yum搭建nagios監控linux&&window及郵件報警

3.

yum搭建nagios監控linux&&window及郵件報警


看到監控結果:

yum搭建nagios監控linux&&window及郵件報警


郵件報警設置:

引用鄭彥生的原文
1、停止系統自帶的sendmail服務
# /etc/init.d/postfix stop
 
2、安裝sendmail和mailx
# yum -y install sendmail mailx
 
3、修改sendmail配置文件
# cp /etc/mail.rc /etc/mail.rc.bak
# cat >> /etc/mail.rc << EOF
set from=13260071987@139.com smtp=smtp.139.com 
set smtp-auth-user=13260071987@139.com smtp-auth-password=yi15093547036 smtp-auth=login
EOF
 
4、重新啟動sendmail服務
# service sendmail restart
5.修改聯系人
[root@centos-server objects]# vim /etc/nagios/objects/contacts.cfg 
define contact{
        contact_name                    nagiosadmin             
        use                             generic-contact         
        alias                           Nagios Admin          
        email                           18507656225@139.com     
        }


查看郵件:

yum搭建nagios監控linux&&window及郵件報警

yum搭建nagios監控linux&&window及郵件報警


向AI問一下細節

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

AI

濉溪县| 玛多县| 石林| 镇江市| 九台市| 蒙城县| 顺昌县| 建阳市| 姜堰市| 道孚县| 贵南县| 遂平县| 鄂托克前旗| 福清市| 通河县| 鹤壁市| 鄂伦春自治旗| 台安县| 进贤县| 渝北区| 浦北县| 简阳市| 北京市| 山东省| 广水市| 万宁市| 都安| 营口市| 云霄县| 宜黄县| 平和县| 海城市| 忻州市| 安泽县| 茂名市| 土默特左旗| 安阳县| 松阳县| 青田县| 吉隆县| 牙克石市|