上犹电脑信息网我们一直在努力
您的位置:上犹电脑信息网 > 设置问题 > 监控软件 Nagios-3.2.3配置总结,一步一步详细设置-监视器设置

监控软件 Nagios-3.2.3配置总结,一步一步详细设置-监视器设置

作者:上犹日期:

返回目录:设置问题

监控软件 Nagios-3.2.3配置总结,一步一步详细设置

Nagios监控配置总结

一、安装apache

1.下载httpd-2.2.19.tar.bz2,并解压

tar -jxvf httpd-2.2.19.tar.bz2

进入解压目录

cd httpd-2.2.19

2.安装apache到/usr/local/apache

./configure --prefix=/usr/local/apache

可带参数:--enable-so 设置apache服务可以动态加载模块功能

--enable-rewrite 设置apache服务器具有rewrite功能

3.安装

make && make install

二、安装PHP

1.下载php-5.3.6.tar.bz2,并解压

tar -jxvf php-5.3.6.tar.bz2

进入解压目录

cd php-5.3.6

2.安装PHP到/usr/local/php5

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs(apache目录)

3.安装

make && make test && make install

4.配置apache,使其支持PHP

修改apache配置文件httpd.conf

vim /usr/local/apache/conf/httpd.conf

找到LoadModule php5_module modules/libphp5.so所在行,在该行下增加AddType application/x-httpd-php .php

找到DirectoryIndex index.html一行,在其后添加index.php ,index.html和index.php之间有空格

5.关闭SELINUX,并设置防火墙放行80端口及服务

vim /etc/SELINUX/config

修改SELINUX=enabled为SELINUX=disabled

重启系统

此时测试PHP是否正确安装并配置无误

编写测试页面

vim /usr/local/apache/htdocs/index.php

写入如下内容

<HTML>

<HEAD></HEAD>

<BODY>

<?php

phpinfo();

?>

</BODY>

</HTML>

保存退出!

启动apache

/usr/local/apache/bin/apachectl start

在浏览器中输入http://IP/index.php

显示php的信息,配置无误!

三、安装nagios

1.下载nagios-3.2.3.tar.gz,并解压

tar -zxvf nagios-3.2.3.tar.gz

进入解压目录

cd nagios-3.2.3

2.建立用户和用户组nagios

groupadd nagios

useradd nagios

usermod -G nagios nagios

3.安装nagios到/usr/local/nagios

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios

make

make install

make install-init

make install-commandmode

make install-config

确保以上步骤没有错误!则nagios安装完毕

四、安装nagios插件nagios-plugin(插件版本并不重要)

1.下载nagios-plugin,并解压

tar -zxvf nagios-plugin

进入解压目录

cd nagios-plugin

2.安装nagios-plugin到/usr/local/nagios

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios

make

make install

五、配置nagios

1.修改apache配置文件,在配置文件末尾追加如下内容

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER

# Last Modified: 11-26-2005

# This file contains examples of entries that need

# to be incorporated into your Apache web server

# configuration file. Customize the paths, etc. as

# needed to fit your system.

criptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">

# SSLRequireSSL

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

# Order deny,allow

# Deny from all

# Allow from 127.0.0.1

AuthName "Nagios Access"

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">

# SSLRequireSSL

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

# Order deny,allow

# Deny from all

# Allow from 127.0.0.1

AuthName "Nagios Access"

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

</Directory>

通过命令生成的登录nagios管理界面的用户名密码配置文件:

/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios

输入两次密码

在浏览器中输入http://IP/nagios,输入用户名、密码即可进入nagios欢迎界面

2.为了监控主机服务器,需要编辑配置文件cgi.cfg

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

编辑use_authentication=1为use_authencation=0.

3.nagios作为监控软件,实现监控其它主机服务器,主要实现目的就是创建配置文件,每一个主机一个配置文件。

编辑nagios主配置文件/usr/local/nagios/etc/nagios.cfg

vim /usr/local/nagios/etc/nagios.cfg

#cfg_dir=/usr/local/nagios/etc/servers 启用,去掉前面的#

4.监控linux.在目录/usr/local/nagios/etc/servers下创建配置文件,监控linux主机20.20.20.20,配置文件名字随意,

必须以 .cfg结尾。

vim /usr/local/nagios/etc/servers/20.20.20.20.cfg

输入如下内容:

define host {

use linux-server

host_name 20.20.20.20

alias 20.20.20.20

address 20.20.20.20

}

define service {

use generic-service

host_name 20.20.20.20

service_description check_ping

check_command check_ping!100.0,20%!200.0,50%

max_check_attempts 5

normal_check_interval 1

}

define service {

use generic-service

host_name 20.20.20.20

service_description check_ssh

check_command check_ssh

max_check_attempts 5

normal_check_interval 1

}

define service {

use generic-service

host_name 20.20.20.20

service_description check_http

check_command check_http

max_check_attempts 5

normal_check_interval 1

}

define service {

use generic-service

host_name 20.20.20.20

service_description check_ftp

check_command check_ftp!21

max_check_attempts 5

normal_check_interval 1

}

保存退出!

5.启动nagios

service nagios start

此时在浏览器输入http://IP/nagios

即可也监控主机20.20.20.20的状态

6.监控windows.监控windows需要借助一款客户端软件NSClient++-0.3.8-Win32.msi,在windows服务器安装

NSClient++-0.3.8-Win32.msi。并启动服务...

7.在目录/usr/local/nagios/etc/servers下创建配置文件,监控windows主机30.30.30.30,配置文件名字随意,

必须以 .cfg结尾。

vim /usr/local/nagios/etc/servers/30.30.30.30.cfg

输入如下内容:

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

# WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE

#

# Last Modified: 06-13-2007

#

# NOTES: This config file assumes that you are using the sample configuration

# files that get installed with the Nagios quickstart guide.

#

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

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

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

#

# HOST DEFINITIONS

#

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

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

# Define a host for the Windows machine we'll be monitoring

# Change the host_name, alias, and address to fit your situation

define host{

usewindows-server; Inherit default values from a template

host_name30.30.30.30; The name we're giving to this host

aliasMy Windows Server; A longer name associated with the host

address30.30.30.30; IP address of the host

}

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

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

#

# HOST GROUP DEFINITIONS

#

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

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

# Define a hostgroup for Windows machines

# All hosts that use the windows-server template will automatically be a member of this group

define hostgroup{

#hostgroup_namewindows-servers; The name of the hostgroup

#aliasWindows Servers; Long name of the group

}

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

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

#

# SERVICE DEFINITIONS

#

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

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

# Create a service for monitoring the version of NSCLient++ that is installed

# Change the host_name to match the name of the host you defined above

define service{

usegeneric-service

host_name30.30.30.30

service_descriptionNSClient++ Version

check_commandcheck_nt!CLIENTVERSION

}

# Create a service for monitoring the uptime of the server

# Change the host_name to match the name of the host you defined above

define service{

usegeneric-service

host_name30.30.30.30

service_descriptionUptime

check_commandcheck_nt!UPTIME

}

# Create a service for monitoring CPU load

# Change the host_name to match the name of the host you defined above

define service{

usegeneric-service

host_name30.30.30.30

service_descriptionCPU Load

check_commandcheck_nt!CPULOAD!-l 5,80,90

}

# Create a service for monitoring memory usage

# Change the host_name to match the name of the host you defined above

define service{

usegeneric-service

host_name30.30.30.30

service_descriptionMemory Usage

check_commandcheck_nt!MEMUSE!-w 80 -c 90

}

# Create a service for monitoring C:\ disk usage

# Change the host_name to match the name of the host you defined above

define service{

usegeneric-service

host_name30.30.30.30

service_descriptionC:\ Drive Space

check_commandcheck_nt!USEDDISKSPACE!-l c -w 90 -c 95

}

# Create a service for monitoring the W3SVC service

# Change the host_name to match the name of the host you defined above

#define service{

#usegeneric-service

#host_name30.30.30.30

#service_descriptionW3SVC

#check_commandcheck_nt!SERVICESTATE!-d SHOWALL -l W3SVC

#}

# Create a service for monitoring the Explorer.exe process

# Change the host_name to match the name of the host you defined above

define service{

usegeneric-service

host_name30.30.30.30

service_descriptionExplorer

check_commandcheck_nt!PROCSTATE!-d SHOWALL -l Explorer.exe

}

8.重启nagios

service nagios restart

此时在浏览器输入http://IP/nagios

即可也监控主机30.30.30.30的状态

六、nagios 配置完成,此时通过浏览器可以随时监控主机状态!

相关阅读

  • Windows7如何添加超级终端-超级终端设置

  • 上犹设置问题
  • 超级终端设置,超级终端是一款通用的串行交互软件,可以通过超级终端与许多嵌入式应用的系统进行连接显示设置。更新到Windows 7,似乎就找不到相应的超级终端软件了。这时我们可以
关键词不能为空
极力推荐

电脑蓝屏_电脑怎么了_win7问题_win10问题_设置问题_文件问题_上犹电脑信息网

关于我们