Linux下Nagios的安装与配置V1.0
nagios安装中文显示,PMBOK,企业安全设计

nagios安装过程操作系统:gentoo一、nagios主程序安装# groupadd -g 9000 nagios# groupadd -g 9001 nagcmd# useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c "Nagios Admin" nagios查找apache的运行用户名# grep "^User" /etc/apache2/conf/httpd.confUser www-data# usermod -G nagcmd www-data# mkdir /usr/local/nagios /etc/nagios /var/nagios# chown nagios.nagios /usr/local/nagios /etc/nagios /var/nagios# cd /usr/local/src/nagios-3.0.6# CFLAGS="-O3 -pipe" CXXFLAGS="-O3 -pipe" ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --with-command-group=nagcmd# make all# make install# make install-init# make install-commandmode# make install-config# rc-update -a nagios default二、plugin安装# CFLAGS="-O3 -pipe" CXXFLAGS="-O3 -pipe" ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios# make# make install# chown nagios.nagios -R /usr/local/nagios# mkdir /var/nagios# chown nagios.nagios /var/nagios三、修改apache的配置文件httpd.conf,添加ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin">AllowOverride AuthConfigOptions ExecCGIOrder allow,denyAllow from allAuthName "No Unauthorized Access Allowed"AuthType BasicAuthUserFile /etc/nagios/ersRequire valid-user</Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share">Options NoneAllowOverride AuthConfigOrder allow,denyAllow from allAuthName "No Unauthorized Access Allowed"AuthType BasicAuthUserFile /etc/nagios/ersRequire valid-user</Directory>四、NRPE的安装(可以不用安装,使用自己定制的CGI接口即可)4.1 客户端安装(假设IP为10.60.0.233)4.1.1 首先安装plugins,同二,略4.1.2 按章nrpe# ./configure --sysconfdir=/etc/nagios --enable-ssl #(--enable-command-args,可以向nrpe服务器传递参数,但是由于安全和稳定性,避免编译)# make all# make install-plugin# make install-daemon# make install-daemon-config#make install-xinetd# vi /etc/xinet.d/nrpeonly_from = 110.60.4.138 127.0.0.1# vi /etc/servicenrpe 5666/tcp4.1.3 根据需要修改配置文件# vi /etc/nagios/nrpe.cfg4.1.4 本地测试# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs4.2 服务端安装(在nagios服务器上):# ./configure --sysconfdir=/etc/nagios --enable-ssl# make all# make install-plugin连接客户端测试:/usr/local/nagios/libexec/check_nrpe -H 10.60.0.233五、nagios的升级# cd /usr/local/src/nagios-3.1.0# CFLAGS="-O3 -pipe" CXXFLAGS="-O3 -pipe" ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --with-command-group=nagcmd# make all# make install六、支持UTF-8的方法如果使用nagios-plugin check_http检测url,页面utf-8中文,一旦报警,在nagios的页面出现的关键字将会是乱码,需要修改nagios的cgi程序路径在源代码/cgi在所有c源代码中查找着两行,如果有就在这两行下面增加:printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");printf("<html>\n");printf("<head>\n");。
Nagios安装配置手册

12.配置和启动 nagios cd /usr/local/nagios/etc 里面如果有 cfg-sample,就把目录里的.cfg-sample 文件全部拷贝成.cfg 例如: cp nagios.cfg-sample nagios.cfg 没有的话就直接修改:
修改 vi cgi.cfg, use_authentication=1 改成 use_authentication=0, 即不用验证.不然有一些页面不会显示。
情况二: 如果还不行,从这个网站: 下载一下 Mudule 包,tar.gz 格式的! - Crypt::DES - Digest::MD5 - Digest::SHA1 - Digest::HMACcd - Net::SNMP 按以下操作顺序安装这些 Module: tar zxf <module>.tar.gz cd <module> perl Makefile.PL make test make install 完了以后 cd nagios_plugins ./install.sh (路径选默认,y/n 选 Y!)
6.安装 nagios nagios 之前的准备,特别需要安装 gd-devel, 另外安装 nagios 时需要加--with-gd-lib=/usr/lib --with-gd-inc=/usr/include 不然不能生成 statusmap.cgi 也就不能看状态图了!
groupadd nagios useradd -g nagios nagios passwd nagios mkdir /usr/local/nagios chown -R nagios:nagios /usr/local/nagios chmod 755 /usr/local/nagios/ usermod -G nagios apache usermod -G nagios nagios grep ^User /etc/httpd/conf/httpd.conf User apache 查看运行 apache 的用户
nagios监控端安装配置手册

一、系统环境与软件版本情况本文档使用被监控机的操作系统为rhel6.3 _64位。
监控主机操作系统为rhel6.0 _64位及windows 2003,nagios主服务版本Nagios® Core™ 3.2.3,linu被监控机与主监控通信插件NRPE版本为nrpe-2.8.1。
window被监控机与主监控服务软件为NSClient++-0.2.7所使用的软件如下nrpe-2.8.1.tar.gzNSClient++-0.2.7.zip二、安装配置过程。
因为系统安装大家都非常熟悉了此次略过操作系统安装过程,首先是linux环境下被监控机的安装配置过程。
在安装之前先写个nagios监控非本地信息的原理图主监控机被监控机NRPE总共由两部分组成:–check_nrpe 插件,位于在监控主机上–NRPE daemon,运行在远程的linux主机上(通常就是被监控机)按照上图,整个的监控过程如下:当nagios需要监控某个远程linux主机的服务或者资源情况时1.nagios会运行check_nrpe这个插件,告诉它要检查什么.2.check_nrpe插件会连接到远程的NRPE daemon,所用的方式是SSL3.NRPE daemon会运行相应的nagios插件来执行检查4.NRPE daemon将检查的结果返回给check_nrpe插件,插件将其递交给nagios做处理.注意:NRPE daemon需要nagios插件安装在远程的linux主机上,否则,daemon不能做任何的监控.因为使用rehl线上的yum源安装需要授权,所以先使用iso搭个本地的yum源。
mount /dev/cdrom /mnt/cdrom/ 挂载光驱mkdir /home/rehliso 创建yum源目录。
cp -Rf /mnt/cdrom/* /home/rehliso/ 拷贝安装文件到源目录cd /etc/yum.repos.d/ 切换至yum配置文件目录cp rhel-source.repo rhel-source.repo.bak 备份配置文件vi rhel-source.repo 编辑配置文件,删除之前内容加入[rhel_6_iso]name=local isobaseurl=file:///home/rehlisogpgcheck=1gpgkey=file:///home/rehliso/RPM-GPG-KEY-redhat-release保存退出Yum clean all清除YUM缓存因为是用二进制安装包进行安装所以要先安装gcc编译器yum -y install gcc 安装gcc编译器安装完成后用sftp上传安装文件nrpe-2.8.1.tar.gz, nagios-plugins-1.4.13.tar.gz至/usr/local/src/目录下创建nagios用户Userad nagiosPasswd nagiosCd /usr/local/src 切换至/usr/local/src/目录解压安装包tar zxvf nagios-plugins-1.4.13.tar.gzcd nagios-plugins-1.4.13编译安装./configuremakemake install这一步完成后会在/usr/local/nagios/下生成两个目录libexec和share修改目录权限把权限所属chown nagios.nagios /usr/local/nagios/chown -R nagios.nagios /usr/local/nagios/libexec/至此被监控机nagios插件已经安装完成,接下来就是安装nrpe服务了切换至软件包目录Cd /usr/local/src解压安装文件tar zxvf nrpe-2.8.1.tar.gzcd nrpe-2.8.1编译安装./configurechecking for SSL... configure: error: Cannot find ssl libraries 出现了该错误主要是因为监控主机插件check_nrpe与被监控nrpe服务的通信是通过ssl方式连接的所以必须安装sslyum -y install openssl-devel 所以这个可以在gcc安装时顺便也安装了ssl安装完成后重新./configure*** Configuration summary for nrpe 2.8.1 05-10-2007 ***:General Options:-------------------------NRPE port: 5666NRPE user: nagiosNRPE group: nagiosNagios user: nagiosNagios group: nagiosReview the options above for accuracy. If they look okay,type 'make all' to compile the NRPE daemon and client.成功后会出现以上安装的基本信息接下来编译安装make allmake install-daemonmake install-daemon-configmake install-plugin 安装check_nrpe这个插件之前说过监控机需要安装check_nrpe这个插件,被监控机并不需要,我们在这里安装它是为了测试的目的安装xinetd脚本make install-xinetd这里还要补充一下因为官网的安装文档是将NRPE deamon作为xinetd下的一个服务运行的.在这样的情况下xinetd就必须要先安装好,所以还得确定系统是否已经安装了xinetd的服务[root@localhost nrpe-2.8.1]# service xinetd restartxinetd: unrecognized service服务并未安装yum -y install xinetd 安装xinetd服务安装完成后修改配置文件vi /etc/xinetd.d/nrpeservice nrpe{flags = REUSEsocket_type = streamport = 5666 端口wait = nouser = nagios 用户group = nagios 用户组server = /usr/local/nagios/bin/nrpeserver_args = -c /usr/local/nagios/etc/nrpe.cfg --inetdlog_on_failure += USERIDdisable = noonly_from = 127.0.0.1,192.168.1.243}only_from = 127.0.0.1,192.168.1.243在后面增加监控主机的地址192.168.1.243以空格间隔编辑/etc/services文件,增加NRPE服务端口添加如下信息nrpe 5666/tcp #nrpe查看防火墙是否启动chkconfig iptables –list如果启动需要添加5666端口的开放规则vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT添加该条目service iptables restart 重启iptables服务重启xinetd服务service xinetd restart检查服务端口状态[root@localhost ~]# netstat -natp |grep 5666tcp 0 0 :::5666 :::* LISTEN 1959/xinetd 服务端口已经启动测试NRPE是否则正常工作之前我们在安装了check_nrpe这个插件用于测试,现在就是用的时候.执行[root@localhost ~]# /usr/local/nagios/libexec/check_nrpe -H localhostNRPE v2.8.1返回了版本信息说明nrpe已经正常的工作了。
Nagios Network Analyzer 安装手册说明书

This document is intended to outline the steps required to manually install Nagios NetworkAnalyzer, along with its prerequisites and sub-components.Target AudienceThis document is written for administrators who are looking to perform a new installation of Nagios Network Analyzer from source, rather than using a pre-configured virtual machine image.Platform SupportNagios Enterprises provide support for installing Nagios Network Analyzer on the following Linux Distributions (Only 64-bit supported):•Red Hat Enterprise Linux (RHEL)◦7.x / 8.x◦RHEL requires the Optional software channel to be enabled, further details are located here:◦Enabling RHEL Optional Software Channel•CentOS◦7.x / 8.x•CentOS Stream•Debian◦9.x / 10.x•Ubuntu◦All active Long Term Support (LTS), these are all the even numbered versions (16, 18, 20)If you discover bugs or have fixes for installing Nagios Network Analyzer on other platforms, please let us know. We will do our best to incorporate your improvements to expand support for additional platforms in future releases, which will make future installation processes smoother for you and your clients.1295 Bandana Blvd N, St. Paul, MN 55108 US: 1-888-624-4671 INTL: 1-651-204-9102Installation PrerequisitesImportant: Nagios Enterprises highly recommends and will only support installing Nagios Network Analyzer on a newly installed, "clean" system (a bare minimal install with nothing else installed or configured).Attempting to install Nagios Network Analyzer on a pre-existing system with other applications already installed can cause the Nagios Network Analyzer installation process to fail, critical system components and settings (e.g. database servers) to be modified in a way that negatively affects other applications, and previously installed applications to be automatically upgraded or removed. While installing Network Analyzer on a system with other applications is possible, it is not recommended due to the possible interactions and complexity of multiple components that are required for Nagios Network Analyzer to function. If you choose to ignore these warnings, you do so at your own risk.Internet access is required for installation and upgrades!Terminal AccessThese instructions require you to establish a terminal session to the server you plan to install Nagios Network Analyzer on. You will need to login to your server as the root user to perform the installation.Install Nagios Network AnalyzerThere are two methods for installing Nagios Network Analyzer, they both perform a full installation, quick and manual.1295 Bandana Blvd N, St. Paul, MN 55108 **************** US: 1-888-624-4671 INTL: 1-651-204-9102QuickExecute the following command in your terminal session:curl https:///downloads/nagios-network-analyzer/install.sh | shThat one command will download and install Nagios Network Analyzer. Please proceed to the Finalize Installation section.Manual DownloadAlternatively, you can install Nagios Network Analyzer by issuing the following commands in your terminal session:cd /tmpwget https:///downloads/nagios-network-analyzer/nagiosna-latest.tar.gz tar xzf nagiosna-latest.tar.gzcd nagiosna./fullinstallNote: If you need to install a specific version of Nagios Network Analyzer, please visit the following page of Nagios Network Analyzer versions to obtain the URL, use that in the wget command above:https:///downloads/nagios-network-analyzer/versions.phpPlease proceed to the Finalize Installation section.1295 Bandana Blvd N, St. Paul, MN 55108 **************** US: 1-888-624-4671 INTL: 1-651-204-9102Finalize InstallationThe installation will be complete when you see this message:Nagios Network Analyzer Installation Success!You can finish the final setup steps for Nagios Network Analyzer by visiting: http://<server_ip_address>/nagiosna/Navigate to the user interface by using the URL provided in your terminal session.When you open the URL provided on the consolein your web browser, you will be shown theInstallation page.Here you will set your Administrator accountUsername, Password and email address. You alsoare able to add your license key if you alreadypurchased your license.Click Finish Installation to save these settings.1295 Bandana Blvd N, St. Paul, MN 55108 **************** US: 1-888-624-4671 INTL: 1-651-204-9102The Log In screen screen will be shown, it will have thestatus of Installation Complete. Type the username andpassword required to login to Nagios Network Analyzer.Click the Log In button to begin.You will be logged into Nagios Network Analyzerand be placed at the home screen.Setting Up SSL/TLSIf you desire to implement SSL/TLS on your Nagios Network Analyzer Server, see Configuring SSL with NNA.1295 Bandana Blvd N, St. Paul, MN 55108 **************** US: 1-888-624-4671 INTL: 1-651-204-9102Finishing UpThis completes the documentation on how to manually install Nagios Network Analyzer.Please refer to the Nagios Network Analyzer Administrator Guide to help you start using Nagios Network Analyzer.Schedule a Quickstart:https:///services/quickstart/nagios-network-analyzer/Contact Sales:****************Nagios Support Forums:https:///forumThe Nagios Support Knowledgebase:https:///kb1295 Bandana Blvd N, St. Paul, MN 55108 **************** US: 1-888-624-4671 INTL: 1-651-204-9102。
Linux命令行中的系统安装和配置技巧

Linux命令行中的系统安装和配置技巧在Linux命令行中,系统安装和配置是非常重要的技巧。
通过正确的安装和配置,我们可以提高系统的性能,增强系统的稳定性,并满足个性化需求。
本文将介绍一些Linux命令行中的系统安装和配置技巧,帮助您更好地管理和运维您的系统。
1. 系统安装在Linux命令行中,系统安装是第一步。
通常情况下,我们会从官方网站下载适合自己需求的Linux发行版镜像文件,然后通过命令行进行安装。
首先,将镜像文件写入到USB设备上,可以使用dd命令(例如:dd if=镜像文件 of=/dev/sdX bs=4M),注意将X替换为您的USB设备代号。
然后,将USB设备连接到需要安装系统的计算机,并重启计算机。
在启动过程中,按下相应的按键(通常是F2、F9、F12或Del键),进入计算机的启动菜单,选择从USB设备启动。
最后,根据安装界面的提示,进行具体的操作(选择安装目标、分区、设置密码等)。
完成安装后,重新启动计算机,您的Linux系统就成功安装了。
2. 系统更新与软件安装安装完成后,第一步就是进行系统更新和软件安装。
这可以确保系统拥有最新的补丁和功能,并且配备您所需的软件。
在命令行中,可以使用以下命令更新系统软件包:```sudo apt update # 更新软件包列表sudo apt upgrade # 升级已安装的软件包```要安装特定的软件包,可以使用以下命令:```sudo apt install 软件包名称 # 安装指定软件包sudo apt remove 软件包名称 # 卸载指定软件包```3. 系统配置与优化在安装和更新完系统后,我们需要进行一些系统配置和优化,以满足我们的需求和提高系统的性能。
首先,我们可以编辑配置文件来修改系统行为和参数。
通过vi或nano等文本编辑器打开配置文件:```sudo vi /etc/配置文件路径 # 编辑指定的配置文件```然后,根据需要修改文件中的参数,并保存文件。
Nagios安装与配置详解

Nagios学习笔记之(一)最初搭建2012-07-17 13:05:08标签:linux监控nagios cacti声明:原创作品,如需,请与作者联系。
否则将追究法律责任。
Nagios学习笔记之一最初搭建一、简介:Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。
在系统或服务状态异常时发出或短信报警第一时间通知运维人员,在状态恢复后发出正常的或短信通知。
二、搭建过程:OS:CentOS 5.5 x86_64(最小化即可)Nagios主程序:nagios-cn-3.4.1Nagios插件:nagios-plugins-1.4.15.tar.gz2.1安装前:2.1.1安装依赖包,下载源程序包1.#cd/etc/yum.repos.d/2.#rm-fr./*3.#wget wget mirrors.163./.help/CentOS-Base-163.repo4.#yum makecache#删除系统自带的yum源,下载网易的网络源并更新缓存1.#yum-y install gcc glibc glibc-common gd gd-devel httpd#安装必须的依赖包1.#wget /sourceforge/nagios/nagios-3.4.1.tar.gz2.#wget /sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz#下载nagios主程序以及插件程序2.1.2正式安装:1.#groupadd nagcmd2.#useradd-G nagcmd nagios3.#usermod-G nagcmd apache#创建一个用户组名为nagcmd用于从Web接口执行外部命令。
将nagios用户和apache用户都加到这个组中。
1.#tar zxf nagios-3.4.1.tar.gz2.#cd nagios3.#./configure--prefix=/usr/local/nagios --with-command-group=nagcmd4.#解压程序包,并进行预编译前的配置(默认用户就是nagios,所以只需指定组)5.#make all#编译Nagios程序包源码6.#make install#安装二进制运行程序7.#make install-init#初始化脚本8.#make install-config#配置文件样本9.#make install-commandmode#设置运行目录权限10.#make install-webconf#安装Nagios的WEB配置文件到Apache的conf.d目录下#htpasswd -c /usr/local/nagios/etc/ers nagiosadmin#创建一个nagiosadmin的用户用于登录Nagios的web界面。
nagios安装配置笔记

# tar zxvf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins
# ./configure --prefix=/usr/local/nagios nagios-plugins是安装到nagios的主目录下的
# make
make install 安装主要的程序、CGI、HTML文件等等。
make install-commandmode 赋予外部命令访问nagios配置文件的权限
make install-config 将nagios的配置文件的例子复制到nagios的安装目录下
make install-init 将nagios做成一个运行脚本,放入init.d中,使nagios可以随系统的开机而启动
分析nagios的配置文件
# vi /usr/local/nagios/etc/localhost.cfg
把下面的几行注释去掉
cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg //联系组配置文件路径
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg //联系人配置文件路径
PS: 好吧, 弄了一整天终于把nagios全部配置完成了,先应用到内部的服务器,观察一段时间。
决定记录下过程和心得。顺便说一句
这东西确实麻烦,配置好了都不大能看得懂web界面信息,相当痛苦,慢慢来吧。
【nagios概述】
Nagios是一个非常强大且柔性化的软件,但可能需要不少心血来学习如何配置使之
# SSLRequireSSL
Nagios监控Linux主机(NRPE安装与应用)

Nagios监控Linux主机(NRPE安装与应用)一、NRPE简介及工作原理NRPE是nagios的一个扩展,它被用于被监控的服务器上,向nagios监控平台提供该服务器的一些本地的情况。
例如,cpu负载、内存使用、硬盘使用等等。
NRPE可以称为nagios 的for linux 客户端。
NRPE 由两个部分组成:工作在监控机一侧的check_nrpe 插件、工作在被监控机一侧的NRPE 守护进程。
Nagios 服务器执行check_nrpe 插件并告诉他检查哪个服务,check_nrpe 插件通过SSL 连接方式联系远程服务器上的NRPE 守护进程,NRPE 守护进程执行相应的插件完成指定的检查,并返回结果。
工作原理是:插件nrpe在被监控机上开启一个daemon,通过这个daemon来和监控主机建立一条ssl加密通道,通过这条通道来传送被监控机的本地信息,达到监控的目的。
装在被监控机上的daemon就相当于一个nagios的传递员,命令行从nagios监控主机发出,然后daemon接受到信息,就会执行这条命令行,执行的方式,其实是和nagios主机是一样的,所以被监控机上也需要装一套nagios-plugins插件。
例如:nagios主机需要监控被监控机的硬盘信息,就会对被监控机发出一条命令说:“我要看你的硬盘信息。
”被监控机nrpe的daemon接到这个命令之后,就会运行一个插件,来检查被监控机本地硬盘的信息,然后插件把信息反馈到nrpe,nrpe通过ssl通道再把这些信息反馈到nagios主机。
如下图所示二、NRPE安装1、所需安装包nrpe、nagios-plugins,这两个包都可以从上得到,本例为nrpe-2.12.tar.gz2、安装openssl、openssl-devel;yum install -y opensslyum install -y openssl-devel3、安装nrpe和nagios-plugins插件1)安装nagios-plugins,在安装时首先在被监控机上新建nagios用户及组。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Linux下Nagios的安装与配置一、Nagios简介Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows、Linux和Unix 的主机状态,交换机路由器等网络设置,打印机等。
在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
Nagios原名为NetSaint,由Ethan Galstad开发并维护至今。
NAGIOS是一个缩写形式: "Nagios Ain't Gonna Insist On Sainthood" Sainthood 翻译为圣徒,而"Agios"是"saint"的希腊表示方法。
Nagios被开发在Linux下使用,但在Unix下也工作得非常好。
主要功能∙网络服务监控(SMTP、POP3、HTTP、NNTP、ICMP、SNMP、FTP、SSH)∙主机资源监控(CPU load、disk usage、system logs),也包括Windows主机(使用NSClient++ plugin)∙可以指定自己编写的Plugin通过网络收集数据来监控任何情况(温度、警告……)∙可以通过配置Nagios远程执行插件远程执行脚本∙远程监控支持SSH或SSL加通道方式进行监控∙简单的plugin设计允许用户很容易的开发自己需要的检查服务,支持很多开发语言(shell scripts、C++、Perl、ruby、Python、PHP、C#等)∙包含很多图形化数据Plugins(Nagiosgraph、Nagiosgrapher、PNP4Nagios等)∙可并行服务检查∙能够定义网络主机的层次,允许逐级检查,就是从父主机开始向下检查∙当服务或主机出现问题时发出通告,可通过email, pager, sms 或任意用户自定义的plugin进行通知∙能够自定义事件处理机制重新激活出问题的服务或主机∙自动日志循环∙支持冗余监控∙包括Web界面可以查看当前网络状态,通知,问题历史,日志文件等二、Nagios工作原理Nagios的功能是监控服务和主机,但是他自身并不包括这部分功能,所有的监控、检测功能都是通过各种插件来完成的。
启动Nagios后,它会周期性的自动调用插件去检测服务器状态,同时Nagios会维持一个队列,所有插件返回来的状态信息都进入队列,Nagios每次都从队首开始读取信息,并进行处理后,把状态结果通过web显示出来。
Nagios提供了许多插件,利用这些插件可以方便的监控很多服务状态。
安装完成后,在nagios主目录下的/libexec里放有nagios自带的可以使用的所有插件,如,check_disk是检查磁盘空间的插件,check_load是检查CPU负载的,等等。
每一个插件可以通过运行./check_xxx –h 来查看其使用方法和功能。
Nagios可以识别4种状态返回信息,即0(OK)表示状态正常/绿色、1(WARNING)表示出现警告/黄色、2(CRITICAL)表示出现非常严重的错误/红色、3(UNKNOWN)表示未知错误/深黄色。
Nagios根据插件返回来的值,来判断监控对象的状态,并通过web显示出来,以供管理员及时发现故障。
四种监控状态再说报警功能,如果监控系统发现问题不能报警那就没有意义了,所以报警也是nagios 很重要的功能之一。
但是,同样的,Nagios 自身也没有报警部分的代码,甚至没有插件,而是交给用户或者其他相关开源项目组去完成的。
Nagios 安装,是指基本平台,也就是Nagios软件包的安装。
它是监控体系的框架,也是所有监控的基础。
打开Nagios官方的文档,会发现Nagios基本上没有什么依赖包,只要求系统是Linux 或者其他Nagios支持的系统。
不过如果你没有安装apache(http服务),那么你就没有那么直观的界面来查看监控信息了,所以apache姑且算是一个前提条件。
关于apache 的安装,网上有很多,照着安装就是了。
安装之后要检查一下是否可以正常工作。
知道Nagios 是如何通过插件来管理服务器对象后,现在开始研究它是如何管理远端服务器对象的。
Nagios 系统提供了一个插件NRPE。
Nagios 通过周期性的运行它来获得远端服务器的各种状态信息。
它们之间的关系如下图所示:Nagios 通过NRPE 来远端管理服务1. Nagios 执行安装在它里面的check_nrpe 插件,并告诉check_nrpe 去检测哪些服务。
2. 通过SSL,check_nrpe 连接远端机子上的NRPE daemon3. NRPE 运行本地的各种插件去检测本地的服务和状态(check_disk,..etc)4. 最后,NRPE 把检测的结果传给主机端的check_nrpe,check_nrpe 再把结果送到Nagios状态队列中。
5. Nagios 依次读取队列中的信息,再把结果显示出来。
Server 安装了nagios软件,对监控的数据做处理,并且提供web界面查看和管理。
当然也可以对本机自身的信息进行监控。
Client 安装了NRPE等客户端,根据监控机的请求执行监控,然后将结果回传给监控机。
防火墙已关闭/iptables: Firewall is not running.SELINUX=disabled所用安装包:httpd-2.2.23.tar.gz nagios-3.4.3.tar.gz nagios-plugins-1.4.16.tar.gzphp-5.4.10.tar.gz四、实验目标五、Nagios服务端安装5.1 基础支持套件:gcc glibc glibc-common gd gd-devel xinetd openssl-devel # rpm -q gcc glibc glibc-common gd gd-devel xinetd openssl-devel如果系统中没有这些套件,使用yum 安装# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel 5.2 创建nagios用户和用户组# useradd -s /sbin/nologin nagios# mkdir /usr/local/nagios# chown -R nagios.nagios /usr/local/nagios查看nagios 目录的权限# ll -d /usr/local/nagios/5.3 编译安装Nagios#wget /sourceforge/nagios/nagios-3.4.3.tar .gz# tar zxvf nagios-3.4.3.tar.gz# cd nagios# ./configure --prefix=/usr/local/nagios# make all# make install# make install-init# make install-commandmode# make install-config# chkconfig --add nagios5.5 安装Nagios 插件#wget /sourceforge/nagiosplug/nagios-plug ins-1.4.16.tar.gz# tar zxvf nagios-plugins-1.4.16.tar.gz# cd nagios-plugins-1.4.16# ./configure --prefix=/usr/local/nagios# make && make install5.6 安装与配置Apache和PhpApache 和Php 不是安装nagios 所必须的,但是nagios提供了web监控界面,通过web监控界面可以清晰的看到被监控主机、资源的运行状态,因此,安装一个web服务是很必要的。
需要注意的是,nagios在nagios3.1.x版本以后,配置web监控界面时需要php的支持。
这里我们下载的nagios版本为nagios-3.4.3,因此在编译安装完成apache后,还需要编译php模块,这里选取的php版本为php5.4.10。
a. 安装Apache# wget /dist/httpd/httpd-2.2.23.tar.gz# tar zxvf httpd-2.2.23.tar.gz# cd httpd-2.2.23# ./configure --prefix=/usr/local/apache2# make && make install若出现错误:则在编译时入加--with-included-apr 即可解决。
b. 安装Php# wget /distributions/php-5.4.10.tar.gz # tar zxvf php-5.4.10.tar.gz# cd php-5.4.10# ./configure --prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs# make && make installc. 配置apache找到apache 的配置文件/usr/local/apache2/conf/httpd.conf 找到:User daemonGroup daemon修改为User nagiosGroup nagios然后找到<IfModule dir_module>DirectoryIndex index.html</IfModule>修改为<IfModule dir_module>DirectoryIndex index.html index.php</IfModule>接着增加如下内容:AddType application/x-httpd-php .php为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:#setting for nagiosScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin">AuthType BasicOptions ExecCGIAllowOverride NoneOrder allow,denyAllow from allAuthName "Nagios Access"AuthUserFile /usr/local/nagios/etc/htpasswd //用于此目录访问身份验证的文件Require valid-user</Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share">AuthType BasicOptions NoneAllowOverride NoneOrder allow,denyAllow from allAuthName "nagios Access"AuthUserFile /usr/local/nagios/etc/htpasswdRequire valid-user</Directory>d. 创建apache目录验证文件在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david这样就在/usr/local/nagios/etc 目录下创建了一个htpasswd 验证文件,当通过http://192.168.1.108/nagios/访问时就需要输入用户名和密码了。