nagios系统监控部署

安装前的准备工作

(1)解决安装Nagios的依赖关系:
Nagios基本组件的运行依赖于httpd、gcc和gd。可以通过以下命令来检查nagios所依赖的rpm包是否已经完全安装:
# yum -y install httpd gcc glibc glibc-common *gd* php php-mysql mysql mysql-server
(2)所需要安装组件:
服务端所用的安装包为 nagios nagios-plugins ndoutils(非必须)
linux客户端 nrpe
windows客户端 NSClient++
(3)
进行selinux设置,或者关闭selinux
开始搭建:
(1)添加nagios运行所需要的用户和组:
# groupadd nagcmd
# useradd -m nagios
# usermod -a -G nagcmd nagios

把apache加入到nagcmd组,以便于在通过web Interface操作nagios时能够具有足够的权限:

# usermod -a -G nagcmd apache


2、编译安装nagios:
# tar zxf nagios-3.1.2.tar.gz 
# cd nagios-3.1.2
# ./configure --with-command-group=nagcmd --enable-event-broker 
# make all
# make install
# make install-init
# make install-config
# make install-commandmode

为email指定您想用来接收nagios警告信息的邮件地址,默认是本机的nagios用户:
# vi /usr/local/nagios/etc/objects/contacts.cfg 
email        nagios@localhost       #这个是默认设置

在httpd的配置文件目录(conf.d)中创建Nagios的Web程序配置文件:
# make install-webconf

创建一个登录nagios web程序的用户,这个用户帐号在以后通过web登录nagios认证时所用:
# htpasswd -c /var/www/nagios/etc/htpasswd.users nagiosadmin

以上过程配置结束以后需要重新启动httpd:
# service httpd restart

3、编译、安装nagios-plugins

nagios的所有监控工作都是通过插件完成的,因此,在启动nagios之前还需要为其安装官方提供的插件。

# tar zxf nagios-plugins-1.4.13.tar.gz 
# cd nagios-plugins-1.4.13
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/var/www/nagios --with-mysql


确定mysql的库文件位置没有错,但是编译时候跳过找不到采用以下方法解决:
1、如果在编译过程中找不到mysql,cp /usr/lib/mysql到/usr/lib/pkgconfig 即可
2、可以去网上找check_mysql的脚本 或者安装开发库组 在指定mysql的库目录
# make
# make install

4、配置并启动Nagios

(1)把nagios添加为系统服务并将之加入到自动启动服务队列:
# chkconfig --add nagios
# chkconfig nagios on

(2)检查其主配置文件的语法是否正确:
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

(3)如果上面的语法检查没有问题,接下来就可以正式启动nagios服务了:
# service nagios start


(4)配置selinux

如果您的系统开启了selinux服务,则默认为拒绝nagios web cgi程序的运行。您可以通过下面的命令来检查您的系统是否开启了selinux:
#getenforce

如果上面命令的结果显示开启了selinux服务,您可以通过下面的命令暂时性的将其关闭:
#setenforce 0


如果您想在以后完全关闭selinux,可以通过编辑/etc/sysconfig/selinux文件,将其中的selinux后面的值“force”修改为“disable”即可。

当然,您也可以通过以下方式将nagios的CGI程序运行于SELinux/targeted模式而不用关闭selinux:
# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin
# chcon -R -t httpd_sys_content_t /usr/local/nagios/share

(5)通过web界面查看nagios:
http://your_nagios_IP/nagios

登录时需要指定前面设定的web认证帐号和密码。


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

windos端
1.被监控端安装NSClient++-0.3.8-Win32.msi
2.安装完成后修改配置文件NSC.ini把需要的库都打开




3.在监控服务器上修改nagios配置文件nagios.cfg
去掉注释cfg_file=/usr/local/nagios/etc/objects/windows.cfg
定义windows.cfg
define host{
        use             windows-server  ; Inherit default values from a template
        host_name       winserver       ; The name we're giving to this host
        alias           My Windows Server       ; A longer name associated with the host
        address         192.168.0.191   ; 你主机的IP
        }


#################################################################
linux端


被监控端
先添加nagios用户
useradd nagios
为了安装nrpe,先安装nagios-plugins-1.4.15.tar.gz 插件
# tar zxf nagios-plugins-1.4.15.tar.gz 
# cd nagios-plugins-1.4.15
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install


tar -zxvf nrpe-2.12.tar.gz
cd nrpe-2.12.tar.gz
./configure  (会自动加载SSL)
#如果后面make报错,加如下参数
./configure --enable-ssl --with-ssl-lib=/usr/lib/(当然前提要有openssl)
make all
make install-plugin
make install-daemon
make install-daemon-config


4.配置nrpe信息
vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1  //允许监控的IP
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d



服务端
3.安装NRPE
cd nagios-nrpe_2.8.1
./configure   #默认自动添加了openssl
#因为传送过程要加密,如果后面make报错,加如下参数
rpm -qa| grep ssl
openssl-devel-0.9.7a-43.17.el4_6.1
rpm -ql openssl-devel-0.9.7a-43.17.el4_6.1 | more
./configure --enable-ssl --with-ssl-lib=/lib/(当然前提要有openssl)
make all
make install-plugin


4.commands.cfg定义外部构件nrpe
vi /usr/local/nagios/etc/objects/commands.cfg
#添加
#check nrpe
define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }
定义 mylinux.cfg
define host{
           use             linux-server
          host_name     mylinux
          alias            mylinux
          address        192.168.0.27(客户端IP既被监控的IP)
        }
define service{
        use                      generic-service
        host_name             mylinux
        service_description     check-swap
        check_command        check_nrpe!check_swap
               }
define service{
        use                      generic-service
        host_name             mylinux
        service_description     check-load
       check_command         check_nrpe!check_load
               }
define service{
        use                      generic-service
        host_name             mylinux
       service_description     check-disk
       check_command        check_nrpe!check_had1
       }
define service{
        use                      generic-service
        host_name             mylinux
       service_description     check-users
       check_command        check_nrpe!check_users
               }
define service{
        use                    generic-service
        host_name           mylinux
        service_description  otal_procs
        check_command     check_nrpe!check_total_procs



#################################################################################
define service{
        use                    generic-service
        host_name           mylinux
        service_description  httpd
        check_command     check_http! -H 192.168.0.27
}


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


nagios监控mysql服务器: 
 
1、建立专用数据库: 
[root@svr3 ~]# /usr/local/webserver/mysql/bin/mysql -u root -p 
Enter password:  
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 51910 
Server version: 5.5.3-m3-log Source distribution 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
 
mysql> create database nagios; 
Query OK, 1 row affected (0.00 sec) 
 
mysql> grant select on nagios.* to nagios@'%' identified by '123456'; 
grant select on nagios.* to nagios@'%' identified by '123456'; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> flush privileges; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> select User,Password,Host from user; 
+----------------+-------------------------------------------+------------------+ 
| User           | Password                                  | Host             | 
+----------------+-------------------------------------------+------------------+ 
| root           | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | localhost        | 
| nagios         | *A1F1CB851D62F002C09A0C9C4A76262473432F55 | %                | 
+----------------+-------------------------------------------+------------------+ 
14 rows in set (0.00 sec) 
12 rows in set (0.00 sec) 
 
[root@svr3 ~]# /var/www/nagios/libexec/check_mysql -H 10.1.1.30 -u nagios -d nagios -p 123qweasd 
Uptime: 970046  Threads: 1  Questions: 684583  Slow queries: 3  Opens: 672  Flush tables: 1  Open tables:  
 
369  Queries per second avg: 0.705 
 
[root@svr4 nrpe_install]# /var/www/nagios/libexec/check_mysql -H 10.1.1.30 -u nagios -d nagios -p 123qweasd 
Uptime: 970348  Threads: 1  Questions: 684584  Slow queries: 3  Opens: 672  Flush tables: 1  Open tables: 369  Queries per second avg: 0.705 
 
果断开始设置: 
#定义用户 
#定义组,及隶属用户 
#用户增加 
 
在command.cfg里增加插件命令: 
#check mysql 
define command{ 
command_name check_mysql 
command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u nagios -d nagios -p 123qweasd 

 
#定义服务: 
define service { 
        host_name mysql
      
        check_period 24x7 
        max_check_attempts 2 
        normal_check_interval 1 
        retry_check_interval 1 
        contact_groups admins
        notification_interval 5 
        notification_period 24x7 
        notification_options w,u,c,r 
        check_command check_mysql 
        }
        
        
飞信报警
1.修改模板文件
修改concont.cfg
2.
修改
 commands.cfg
define command{
        command_name notify-service-by-fetion
        command_line      /usr/bin/fetion --mobile 15003880800 --pwd 123qweQWE --to 15003880800 --msg-tpye=0  --msg-utf8 $HOSTNAME

}

最后呈现的的图:



深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括均方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值