




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
linux_nagios服务端:yum install httpdphp1.添加账户和组:useradd nagiosgroupadd nagcmdusermod -G nagcmd nagiosusermod -G nagcmd apache2.安装nagios:tar zxvf nagios-3.2.0.tar.gz -C /usr/local/src/cd /usr/local/src/nagios-3.2.0/./configure -with-nagios-group=nagcmd-prefix=/usr/local/nagios #有的写-with-command-group=nagcmd 我做实验时没这么写make allmake installmake install-initmake install-configmake install-commandmodemake install-webconf3.安装插件nagios-plugins-1.4.14.tartar zxvf nagios-plugins-1.4.14.tarcd /nagios-plugins-1.4.14./configure -with-nagios-user=nagios -with-nagios-group=nagiosmakemake install4.安装httpd,如果安装nagios之前用yum 安装了httpd,则不用改httpd的配置文件。如果在安装nagios之后才用yum安装的httpd 或编译安装的httpd:则在 /etc/httpd/conf/httpd.conf 后面加入以下内容:vim /httpd.conf#setting for nagiosScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin AuthType Basic Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName Nagios Access AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user Alias /nagios /usr/local/nagios/share AuthType Basic Options None AllowOverride None Order allow,deny Allow from all AuthName nagios Access AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user :wq/usr/local/apache/bin/apachctl t #检查APACHE的配置文件有无语法错误5.htpasswd -c/usr/local/nagios/etc/htpasswd.users nagiosadmin #给nagios访问网页加用户6.设置邮件联系人yum install sendmail m4 mailxvim /usr/local/nagios/etc/objects/contacts.cfg define contact contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email ; * CHANGE THIS TO YOUR EMAIL ADDRESS * service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r,f,s host_notification_options d,u,r,f,s service_notification_commands notify-service-by-email host_notification_commands notify-host-by-email host_notifications_enabled 1 service_notifications_enabled 1 7.在/usr/local/nagios/etc/nagios.cfg 里配置监控主机和服务的配置文件路径cfg_file=/usr/local/nagios/etc/hosts.cfg /主机配置文件路径cfg_file=/usr/local/nagios/etc/services.cfg /服务配置文件路径8.在cgi.cfg文件里配置authorized_for_system_information=nagiosadmin,seryauthorized_for_configuration_information=nagiosadmin,seryauthorized_for_system_commands=sery /多个用户之间用逗号隔开authorized_for_all_services=nagiosadmin,seryauthorized_for_all_hosts=nagiosadmin,seryauthorized_for_all_service_commands=nagiosadmin,seryauthorized_for_all_host_commands=nagiosadmin,sery9.7./usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg #检测nagios的配置文件是否正常后启动nagios/etc/init.d/nagios restart10. 若要监测远程,则服务器端和被监控端都要安装openssl openssl-devel,nrpeubuntu安装opensslapt-get 无法安装 openssl-devel请执行:sudo apt-get install openssl xinetdsudo apt-get install libssl-dev#dpkg -L libssl-dev #找到libssl.so文件做个链接rootnode2:/usr/lib# ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.soaptitude search mysql | grep develapt-get installlibmysqld-devliblua5.1-sql-mysql-dev liblua5.1-sql-mysql-dev:i38611.服务器端安装openssl openssl-develyum install openssl openssl-devel服务器端安装nrpetar zxvf nrpecd nrpe./configure & make all & make install #例如:只有安装了mysql-devel,执行这一命令才能生成check_mysql文件make install-plugin之后要在 /usr/local/nagios/etc/object/commands.cfg 文件里 加入以下内容define commandcommand_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c$ARG1$12.在被监控端安装openssl openssl-devel nagios-plugins nrpe xinetduseradd nagios 添加用户以及组groupadd nagcmdusermod -G nagcmd nagiosyum inistall openssl openssl-devel xinetdtar nagios-pluginscd nagios-plugins./configure & make all & make installtar zxvf nrpecd nrpe./configure & make all & make installmake install-pluginmake install-daemonmake install-daemon-configmake install-xinetd 产生xinetd的配置文件nrpe13.vim /etc/xinetd.d/nrpeonly_from = 后添加 (服务端ip)14.添加nrpe对应的端口(必须做)vi /etc/services (该文件记录系统中所有服务的端口)nrpe 5666/tcp # NRPE-完成。以下是要用到的配置文件。被监控端的nrpe.cfgcommandcheck_users=/usr/local/nagios/libexec/check_users -w 5 -c 10commandcheck_load=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20commandcheck_sda3=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda3commandcheck_zombie_procs=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Zcommandcheck_total_procs=/usr/local/nagios/libexec/check_procs -w 150 -c 200commandcheck_ping=/usr/local/nagios/libexec/check_ping -H -w 100.0,20% -c 500.0,60% -p 5commandcheck_local_swap=/usr/local/nagios/libexec/check_swap -w 20% -c 10%commandcheck_ssh=/usr/local/nagios/libexec/check_ssh commandcheck_tomcat=/usr/local/nagios/libexec/check_http -I -p 8066 -u /aaa/index.html -e 200 #监控会议后台用commandcheck_httpd=/usr/local/nagios/libexec/check_http -I -p 8167 -u /aaa/index.html -e 200 #监控文档转换用commandcheck_mem=/usr/local/nagios/libexec/check_mem -w 10 -c 5 #监控内存commandcheck_mysql=/usr/local/nagios/libexec/check_mysql -H -unagios -d nagdb9.vim /usr/local/nagios/etc/object/hosts.cfgdefine host use linux-server host_name linux-19 alias linux-19 address 9 define host use linux-server host_name liusai-virtual-10 alias liusai-virtual-10 address 0 define hostgroup hostgroup_name meetingManager-servers alias meetingManager-servers # members linux-19,liusai-virtual-10 10.vim /usr/local/nagios/etc/object/services.cfgdefine service use local-service ; Name of service template to use host_name linux-19 service_description HTTP check_command check_tcp!8066 ;check_nrpe!check_http #notifications_enabled 0 define service use local-service ; Name of service template to use host_name linux-19 service_description tomcat check_command check_nrpe!check_http ;check_nrpe!check_http #notifications_enabled 0 define service use local-service ; Name of service template to use host_name liusai-virtual-10 service_description PING check_command check_nrpe!check_ping ;!100.0,20%!500.0,60% define service use local-service ; Name of service template to use host_name liusai-virtual-10 service_description disk_free_space check_command check_nrpe!check_sda3监控内存的脚本:vim /usr/local/nagios/libexec/check_mem#!/bin/bash USAGE=basename $0 -w|-warning -c|-criticalTHRESHOLD_USAGE=WARNING threshold must be greater than CRITICAL: basename $0 $*calc=/tmp/memcalcpercent_free=/tmp/mempercentcritical=warning=STATE_OK=0STATE_WARNING=1STATE_CRITICAL=2STATE_UNKNOWN=3# print usage if $# -lt 4 then echo echo Wrong Syntax: basename $0 $* echo echo Usage: $USAGE echo exit 0fi# read input while $# -gt 0 do case $1 in -w|-warning) shift warning=$1 ; -c|-critical) shift critical=$1 ; esac shift done# verify input if $warning -eq $critical | $warning -lt $critical then echo echo $THRESHOLD_USAGE echo echo Usage: $USAGE echo exit 0fi# Total memory available total=free -m | head -2 |tail -1 |gawk print $2# Total memory used echo exit 0fi# Total memory available total=free -m | head -2 |tail -1 |gawk print $2# Total memory used used=free -m | head -2 |tail -1 |gawk print $3# Calc total minus used free=free -m | head -2 |tail -1 |gawk print $2-$3# normal values #echo $totalMB total #echo $usedMB used #echo $freeMB free # make it into % percent free = (free mem / total mem) * 100) echo 5 $calc # decimal accuracy echo k $calc # commit echo 100 $calc # multiply echo $free $calc # division integer echo $total $calc # division integer echo / $calc # division sign echo * $calc # multiplication sign echo p $calc # print percent=/usr/bin/dc $calc|/bin/sed s/./0./|/usr/bin/tr . |/usr/bin/gawk print $1#percent1=/usr/bin/dc $calc #echo $percent1 if $percent -le $critical then echo CRITICAL - $free MB ($percent%) Free Memory exit 2fiif $percent -le $warning then echo WARNING - $free MB ($percent%) Free Memory exit 1fiif $percent -gt $warning then echo OK - $free MB ($percent%) Free Memory exit 0fi:wqwindows下安装NSClient+从http:/./nscp/downloads 下载NSClient+CmdCd c:nsclient+Nsclient+ /install #安装nsclient+服务Nsclient+ SysTray #将nsclient+ 作为启动进程(系统托盘)在运行里打开 Services.msc然后找到NSClientpp(nagios).属性点 登录允许服务与桌面交互. 确定编辑c:NSClient+ 目录下的 NSC.inimodules;# NSCLIENT+ MODULES;# A list with DLLs to load at startup.; Youwill need to enable some of these for NSClient+ to work.; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !; *; * N O T I C E ! ! ! - Y O U H A V ET O E D I T T H I S *; *; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !FileLogger.dllCheckSystem.dllCheckDisk.dllNSClientListener.dllNRPEListener.dllSysTray.dllCheckEventLog.dllCheckHelpers.dll;CheckWMI.dllCheckNSCP.dll; Script to check external scripts and/orinternal aliases.CheckExternalScripts.dll; NSCA Agent if you enable this NSClient+will talk to NSCA hosts repeatedly (so dont enable unless you want to use NSCA)NSCAAgent.dll; LUA script module used to write your owncheck deamon.LUAScript.dll; RemoteConfiguration IS AN EXTREM EARLY IDEASO
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工程爆破考试试题及答案
- 劳动力市场学试卷及答案
- 幕墙施工组织设计专家论证的
- 深远海养殖智能化水下养殖平台建设方案
- 大宗固废资源化利用技术方案
- 环境影响评价技术服务与生态建设规划合同
- 高难度离婚协议:财产分割、子女抚养及赡养费协议
- 医疗机构消毒清洁与卫生监督服务协议
- 教育培训机构股份简单转让与师资培训合同
- 房屋建筑施工技术方案及创新设计
- 动物药理课件
- 2022城市轨道交通列车驾驶员技能及素质要求第1部分:地铁、轻轨和单轨
- 蓝桥杯c语言历届试题及答案
- 金融风险管理习题第1-13章金融风险概述思考题-经济资本与风险调整绩效
- 2024-2025学年高一下学期时间管理主题班会课件
- 2024国家安全教育大学生读本题库
- 教师的校本研修课件
- 《万以内的加减法》课件
- 《国际贸易学(第四版)》第七章-关税措施
- DB11-T 1891-2021 建(构)筑物与应急设施地震安全韧性建设指南
- 学生作文稿纸(A4打印)
评论
0/150
提交评论