2022-10-23 392
编者按:作者楚霏由于需要关注sphinx的indexer是不是在要求的时间内更新,编写个简答插件。下面是Nagios监控Sphinx的indexer日志的具体方法。
以前写过一个监控sphinx的searchd的插件,参见http://www.chengyongxu.com/blog/nagios监控sphinx/
因为研发要求关注一下sphinx的indexer是不是在要求的时间内更新了,于是写一个简单插件吧
先把更新时间最早的文件和它的改动时间打出来,和规定的时间UPDATE_TIME比较,发现是规定时间之前更新的就报警。
使用方法:
#1.登上运行有sphinx的服务器上,下载脚本放到nagios的libexec目录下,例如: cd /usr/local/nagios/libexec/ wget http://down.chengyongxu.com/check_indexer_log # #2.改属主,加执行权限 chown nagios:nagios check_indexer_log chmod 755 check_indexer_log # #3.在nrpe.cfg文件中增加下边一行,参数根据你的需要修改 #----------------------------增加文字-开始---------------------------- command[check_indexer_log]=/usr/local/nagios/libexec/check_indexer_log #----------------------------增加文字-结束---------------------------- # #4.保存退出后重启nrpe service nrpe restart # #5.要主监控服务器上增加一个服务监控 #----------------------------增加文字-开始---------------------------- define service{ host_name 10.0.0.166 service_description check_indexer_log check_command check_nrpe!check_indexer_log max_check_attempts 3 check_interval 10 retry_interval 5 check_period 24x7 notification_interval 30 notification_period 24x7 notification_options w,u,c #contacts contacts(*) contact_groups sa_groups } #----------------------------增加文字-结束---------------------------- # #6.保存退出后重启nagios service nagios restart 插件贴出如下: #!/bin/bash LOG_DIR=/usr/local/sphinx/var/log UPDATE_TIME=40 # 上次改动时间最早的文件和其改动时间,格式为03-0317:25 FILE_A=`ls -t $LOG_DIR/*searchd.log | tail -n 1` TIME_A=`ls -tl $LOG_DIR/*searchd.log | tail -n 1 | awk '{print $6$7}'` # 要求的最近更新时间,格式为03-0317:25 TIME_B=`date +%m-%d%H:%M -d "$UPDATE_TIME min ago"` if [[ "$TIME_A" > "$TIME_B" ]] then echo "OK | All files changed in $UPDATE_TIME minutes" else echo "$FILE_A last update time is $TIME_A" exit 2 fi
原文链接:https://77isp.com/post/8493.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态