|
|
Nagios监控Sphinx的indexer日志
以前写过一个监控sphinx的searchd的插件,参见
http://www.chengyongxu.com/blog/nagios监控sphinx/
因为研发要求关注一下sphinx的indexer是不是在要求的时间内更新了,于是写一个简单插件吧
先把更新时间最早的文件和它的改动时间打出来,和规定的时间UPDATE_TIME比较,发现是规定时间之前更新的就报警。
使用方法:
| 01 | #1.登上运行有sphinx的服务器上,下载脚本放到nagios的libexec目录下,例如: |
| 02 | cd /usr/local/nagios/libexec/ |
| 06 | chown nagios:nagios check_indexer_log |
| 07 | chmod 755 check_indexer_log |
| 09 | #3.在nrpe.cfg文件中增加下边一行,参数根据你的需要修改 |
| 10 | #----------------------------增加文字-开始---------------------------- |
| 11 | command[check_indexer_log]=/usr/local/nagios/libexec/check_indexer_log |
| 12 | #----------------------------增加文字-结束---------------------------- |
| 18 | #----------------------------增加文字-开始---------------------------- |
| 21 | service_description check_indexer_log |
| 22 | check_command check_nrpe!check_indexer_log |
| 27 | notification_interval 30 |
| 28 | notification_period 24x7 |
| 29 | notification_options w,u,c |
| 31 | contact_groups sa_groups |
| 33 | #----------------------------增加文字-结束---------------------------- |
插件贴出如下:
| 03 | LOG_DIR=/usr/local/sphinx/var/log |
| 06 | # 上次改动时间最早的文件和其改动时间,格式为03-0317:25 |
| 07 | FILE_A=`ls -t $LOG_DIR/*searchd.log | tail -n 1` |
| 08 | TIME_A=`ls -tl $LOG_DIR/*searchd.log | tail -n 1 | awk '{print $6$7}'` |
| 09 | # 要求的最近更新时间,格式为03-0317:25 |
| 10 | TIME_B=`date +%m-%d%H:%M -d "$UPDATE_TIME min ago"` |
| 12 | if [[ "$TIME_A" > "$TIME_B" ]] |
| 14 | echo "OK | All files changed in $UPDATE_TIME minutes" |
| 16 | echo "$FILE_A last update time is $TIME_A" |
http://www.chengyongxu.com/blog/nagios%E7%9B%91%E6%8E%A7sphinx%E7%9A%84indexer%E6%97%A5%E5%BF%97/
Nagios监控Sphinx的indexer日志
|
|