一 ,需下载的安装包 2017-11-22
1,nagios-4.3.4.tar.gz, 2, nagios-plugins-2.2.1.tar.gz 3,nrpe-2.15.tar.gz ,4,pnp4nagios-head.tar.gz
我的安装目录为/nagios /magios/pnp4nagios /nagios/nrpe
二,安装环境
yum install -y wget httpd php php-devel php-gd gcc glibc glibc-common gd gd-devel make net-snmp
三,添加 用户 创建 nagios安装目录
useradd nagios
mkdir /nagios
chown -R nagios.nagios /nagios
四,安装nagios4.3.4
./configure --prefix=/nagios --with-command-group=nagios --with-nagios-group=nagios
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
2,把文件复制到安装目录
cp -R contrib/eventhandlers/ /nagios/libexec/
chown -R nagios.nagios /nagios/
3,检测配置文件是否正常
/nagios/bin/nagios -v /nagios/etc/nagios.cfg
Total Warnings: 0 #警告0个
Total Errors: 0 #错误0个 没有问题
五,配置httpd
htpasswd -c /nagios/etc/htpasswd.users nagiosadmin #添加登录用户名 和回车后输入两次密码 #这里一定要用nagiosadmin(超级)用户 可以使用其他用户 以后再说
修改/etc/httpd/conf/httpd.conf 如下:
User =nagios Group=nagios
#ServerName www.example.com:80 #解释掉#号 修改端口号 使其大于1024 使普通用户nagios可以启动
Listen 8080 #这个也要修改 和上面使用一样的端口
六,安装 nagios-plugins
./configure --prefix=/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
七,设置开机自启并启动服务
chkconfig nagios on
service nagios start
chkconfig httpd on
service httpd start
service nagios start #启动nagios 或者 /nagios/bin/nagios -d /nagios/etc/nagios.cfg 启动 #ps -ef|grep nagios 可以过滤出nagios进程
访问: nagios http://IP:port/nagios
默认有一个localhost.cfg 监控本地 我的httpd_prot:8080 所以爆错
二、为nagios安装图标pnp4nagios
1,安装组件
yum install perl-Time-HiRes rrdtool rrdtool-perl
2,安装pnp4nagios
mkdir /nagios/pnp4nagios #创建pnp4nagios 目录
./configure --prefix=/nagios/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios
下方为输出信息
make all #编译
make install
make install-webconf
make install-config
make install-init
3、启用配置文件
cp /nagios/pnp4nagios/contrib/ssi /nagios/pnp4nagios/share/ -R #将ssi目录复制到share下面,不然后面图片显示会报错
cd /nagios/pnp4nagios/etc/
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
cd pages/
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands/
mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
mv check_nrpe.cfg-sample check_nrpe.cfg
mv check_nwstat.cfg-sample check_nwstat.cfg
4,启动npcd
service npcd start # 或者 /nagios/pnp4nagios/bin/npcd -d -f /nagios/pnp4nagios/etc/npcd.cfg 启动
chconfig npcd on #开机自启
三,nagios配置修改文档 其中npn4nagios是图片绘图显示可以查看历史数据
1,vi /nagios/etc/nagios.cfg #需要时请备份源文件
将process_performance_data=0 修改为 process_performance_data=1
将以下两项的#去掉
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
2,vi /nagios/etc/objects/commands.cfg #命令文件 可以自己添加命令
注释掉末尾两个配置项 新添加两个
# 'process-host-perfdata' command definition
#define command{
# command_name process-host-perfdata
# command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /nagios/var/host-perfdata.out
# }
# 'process-service-perfdata' command definition
#define command{
# command_name process-service-perfdata
# command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /nagios/var/service-perfdata.out
# }
define command{
command_name process-service-perfdata-file
command_line /bin/mv /nagios/pnp4nagios/var/service-perfdata /nagios/pnp4nagios/var/spool/service-perfdata.$TIMET$
}
define command{
command_name process-host-perfdata-file
command_line /bin/mv /nagios/pnp4nagios/var/host-perfdata /nagios/pnp4nagios/var/spool/host-perfdata.$TIMET$
}
3,编辑vi /nagios/etc/objects/templates.cfg 添加两个url
define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
check_interval 5 ; Check the service every 10 minutes under normal conditions
retry_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ #添加内容
}
# Local service definition template - This is NOT a real service, just a template!
define service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state
check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_interval 1 ; Re-check the service every minute until a hard state can be determined
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ #添加内容
}
4,编辑vi /nagios/etc/nagios.cfg
# Values: 1 = process performance data, 0 = do not process performance data
process_performance_data=1
host_perfdata_file=/nagios/pnp4nagios/var/host-perfdata #指定路径
service_perfdata_file=/nagios/pnp4nagios/var/service-perfdata #指定路径
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$ #解释
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
#解释
host_perfdata_file_mode=a #解释
service_perfdata_file_mode=a #解释
host_perfdata_file_processing_interval=15 #修改
service_perfdata_file_processing_interval=15 #修改
host_perfdata_file_processing_command=process-host-perfdata-file #解释
service_perfdata_file_processing_command=process-service-perfdata-file #解释
5,检测配置文件是否有误
/nagios/bin/nagios -v /nagios/etc/nagios.cfg
6,由于我是自定义目录安装所以要配置vi /etc/httpd/conf.d/pnp4nagios.conf
指定它的目录Alias /pnp4nagios "/nagios/pnp4nagios/share" 以及 AuthUserFile /nagios/etc/htpasswd.users 密码文件,建议指定到nagios的密码文件不然你每一次都要重新输入pnp4nagios密码
7, 重启 nagios httpd
会有下图 1 图形 点击后是 pnp4nagios 2图 有提示删除install.pnp 删除后就会有下图3 可能会报错 有可能正在生成图片 也有可能是权限问题
图1
图2
图3
四,客户端插件nrpe 被监控客户机设置
1,安装nrpe依赖包
yum install openssl openssl-devel gcc gcc-c++ -y
2,安装nrpe
./configure --enable-ssl --with-nagios-user=nagios --with-nagios-group=nagios --with-nrpe-user=nagios --with-nrpe-group=nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
3、编辑nrpe配置文件,增加监控机地址Nagios-ip和本机IP:
vi /etc/xinetd.d/nrpe
only_from = 192.168.8.10,127.0.0.1
4、编辑vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=192.168.8.10,127.0.0.1
5、修改services文件,增加端口
vi /etc/services
nrpe 5666/tcp #NRPE
6、启动 nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
设置开机启动 #如果你发现主机是存活的服务全部不在 那就是服务器重启了
vi /etc/rc.d/rc.local
最后一行加入 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
7,nagios监控端主机监控文件设置
1、vi /nagios/etc/nagios.cfg
加入cfg_file=vi /nagios/etc/objects/192.168.8.11.cfg
2、创建并编辑192.168.8.11.cfg 此配置文件可能会有误 修改请参考 下面 八,自定义监控脚本1.2.添加到nrpe.cfg中
vi /nagios/etc/objects/192.168.8.11.cfg
define host{
use linux-server
host_name 192.168.8.11
alias my
address 192.168.8.11
}
define service{
use generic-service
host_name 192.168.8.11
service_description Swap Usage
check_command check_local_swap!20!10
}
define service{
use generic-service
host_name 192.168.8.11
service_description check-load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
define service{
use generic-service
host_name 192.168.8.11
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
define service{
use generic-service
host_name 192.168.8.11
service_description Swap Usage
check_command check_local_swap!20!10
}
define service{
use generic-service
host_name 192.168.8.11
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}
define service{
use generic-service ; Name of service template to use
host_name 192.168.8.11
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service ; Name of service template to use
host_name 192.168.8.11
service_description HTTP_11
check_command check_http
notifications_enabled 0
}
3,编辑命令文件
vi /nagios/etc/objects/commands.cfg
在最后面增加如下内容
#############################################
# 'check_nrpe ' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
3、service nagios restart
五、邮件报警设置
1,安装邮件组件
yum install mailx senmail* -y
2,编辑邮箱并发送测试
vi /etc/mail.rc
set bsdcompat
set from=jie_linux@163.com
set smtp=smtp.163.com
set smtp-auth-user=jie_linux@163.com
set smtp-auth-password="XXXXXXXXXXX"
set smtp-auth=login
进行测试:
echo "测试邮件"|nail -s "测试" 717122108@qq.com
3、编辑contacts.cfg(联系人) command.cfg----下列邮件定义信息无需修改(nagios 4.3.4)
vi contacts.cfg #只需要修改email就行
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 717122108@qq.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
下方是邮件内容 一分钟就刷出服务器DOWN了但邮件好慢 服务器起来时邮件是秒发 还需要调监控频率 和 发送邮件的设置
核心文件 nagios.cfg文件
Nagios.cfg默认的路径为/usr/local/nagios/etc/nagios.cfg,是nagios的核心配置文件,所有的对象配置文件都必须在这个文件中进行定义才能发挥其作用,这里只需将对象配置文件在Nagios.cfg文件中进行引用即可。
log_file=/usr/local/nagios/var/nagios.log
“log_file”变量用来定义nagios日志文件的路径。
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/templates.cfg
cfg_file=/nagios/etc/objects/192.168.8.11.cfg
cfg_file=/nagios/etc/objects/jinzhong.cfg #我对不同的业务写入了不同的文件
“cfg_file”变量用来引用对象配置文件,如果有更多的对象配置文件,在这里依次添加即可。
object_cache_file=/usr/local/nagios/var/objects.cache
该变量用于指定一个“所有对象配置文件”的副本文件,或者叫对象缓冲文件
resource_file=/usr/local/nagios/etc/resource.cfg
该变量用于指定nagios资源文件的路径,可以在Nagios.cfg中定义多个资源文件。
status_file=/usr/local/nagios/var/status.dat
该变量用于定义一个状态文件,此文件用于保存nagios的当前状态、注释和宕机信息等。
status_update_interval=10
该变量用于定义状态文件(即status.dat)的更新时间间隔,单位是秒,最小更新间隔是1秒。
nagios_user=nagios
该变量指定了Nagios进程使用哪个用户运行。
nagios_group=nagios
该变量用于指定Nagios使用哪个用户组运行。
check_external_commands=1
该变量用于设置是否允许nagios在web监控界面运行cgi命令,也就是是否允许nagios在web界面下执行重启nagios、停止主机/服务检查等操作。“1”为运行,“0”为不允许。
command_check_interval=2
该变量用于设置nagios对外部命令检测的时间间隔,如果指定了一个数字加一个"s"(如10s),那么外部检测命令的间隔是这个数值以秒为单位的时间间隔。如果没有用"s",那么外部检测命令的间隔是以这个数值的“时间单位”的时间间隔。
interval_length=60
该变量指定了nagios的时间单位,默认值是60秒,也就是1分钟,即在nagios配置中所有的时间单位都是分钟。
nagios.cfg 文件里 interval_length=60设置为60 那么 objects/templates.cfg 文件里和其他文件的时间都是分钟了
define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
check_interval 1 ; Check the service every 10 minutes under normal conditions # 每分钟检测一次
retry_interval 1 ; Re-check the service every two minutes until a hard state can be determined#每分钟重试一次
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour #每60分钟重新发送一次报告给admins组中定义的的用户(文件为contacts.cfg)发送邮件 飞信 。。。。
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
}
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 717122108@qq.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
六,自定义用户:
不同的用户登录http://192.168.8.10:8080/nagios/ 看到的监控是不一样的,nagios会根据配置文件把对应警告发送给对应的运维。
涉及到的文件有contacts.cfg templates.cfg htpasswd.users 然后就是监控文件我的是jinzhong.cfg
contacts.cfg 文件复制原有的修改名称就行:
define contact{
contact_name jinzhong #设置名称 ; Short name of user
use use_jz #使用名 templates.cfg 中使用 ; Inherit default values from generic-contact template (defined above)
alias Nagios jinzhong ; Full name of user
email lixj3@yusys.com.cn ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
define contactgroup{
contactgroup_name G_jz #设置一个组名 templates.cfg 中使用
alias Nagios jz #别名
members jinzhong #组中的成员
}
templates.cfg文件复制原有的修改名称就行:
define contact{
name use_jz #修改名 ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
host_notification_period 24x7 ; host notifications can be sent anytime
service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
service_notification_commands notify-service-by-email ; send service notifications via email
host_notification_commands notify-host-by-email ; send host notifications via email
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}
define host{
name host-jz #修改名 ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 1 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 1 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups G_jz #修改组名 contacts.cfg 中定义的组#也可以修改这里面的时间达到业务的需求 ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
define service{
name service-jz #修改名 ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
check_interval 1 ; Check the service every 10 minutes under normal conditions
retry_interval 1 ; Re-check the service every two minutes until a hard state can be determined
contact_groups G_jz #修改组名 contacts.cfg 中定义的组 ; Notifications get sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
}
jinzhong.cfg监控文件 这个文件里定义了组 主机 服务 是对一个组监控的配置
define hostgroup{
hostgroup_name use_jz #对应templates.cfg 文件里的名字 ; The name of the hostgroup
alias JZ_APP ; Long name of the group
members 192.168.8.12 #组成员 对个成员用逗号隔开 ; Comma separated list of hosts that belong to this group
}
define host{
use host-jz #对应templates.cfg 文件里的名字
host_name 192.168.8.12
alias my_jz
address 192.168.8.12
check_interval 1
retry_interval 1
icon_image linux40.png
}
define service{
use service-jz #对应templates.cfg 文件里的名字
host_name 192.168.8.12
service_description Swap Usage
check_command check_local_swap!20!10
}
添加登录nagios用户jinzhong
htpasswd /nagios/etc/htpasswd.users jinzhong 回车输入密码
检测 配置文件是否正确 /nagios/bin/nagios -v /nagios/etc/nagios.cfg
重启 nagios
jinzhong登录http://192.168.8.10:8080/nagios/
nagiosadmin登录http://192.168.8.10:8080/nagios/ nagiosadmin拥有加入了管理员组 他拥有一切权限
七,音频报警(cgi.cfg)
vi /nagios/etc/cgi.cfg
# under the HTML path (i.e. /usr/local/nagios/share/media/). 默认安装音频文件路径 本文为 /nagios/share/media/ 需要自己找音频放上去
host_unreachable_sound=hostdown.wav
host_down_sound=hostdown.wav
service_critical_sound=critical.wav
service_warning_sound=warning.wav
service_unknown_sound=warning.wav
#normal_sound=noproblem.wav
下方为配置nagios页面自动刷新频率 10秒
# REFRESH RATE
# This option allows you to specify the refresh rate in seconds
# of various CGIs (status, statusmap, extinfo, and outages).
refresh_rate=10
八,自定义监控内容(脚本)
自定义监控脚本分为两步:
1,客户端配置:
1.1写脚本:vi 1.sh
#! /bin/sh
D1=`cat /tmp/D1.txt`
if [ $D1=0 ];then
echo "D1 is $D1"
exit 0
elif [ $D1=1 ];then
echo "D1 is $D1"
return 0
检测文件 OK echo 0 > /tmp/D1.txt
检测文件 Wraing echo 1 > /tmp/D1.txt
1.2.添加到nrpe.cfg中
vi /usr/local/nagios/etc/nrpe.cfg
command[check_test]=/usr/local/nagios/libexec/1.sh
1.3 重启nrpe
2:配置服务端:
2.1 :编辑 192.168.8.11.cfg
define service{
use generic-service ; Name of service template to use
host_name my-linux
service_description 1.sh
check_command check_nrpe!check_test
}
2.2重启nagios
注:本文参考 1,Jim的ChinaUnix博客 http://blog.chinaunix.net/uid-25896650-id-5069857.html
2,http://blog.csdn.net/Cooling88/article/details/51759087
3, http://blog.sina.com.cn/s/blog_8d75b4400100tbsc.html