# linux_proc_watch **Repository Path**: zgzy1998/linux_proc_watch ## Basic Information - **Project Name**: linux_proc_watch - **Description**: xrkmonitor 监控平台下的 Linux shell 插件, 用于守护 linux 后台进程 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-05-23 - **Last Updated**: 2021-06-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # linux_proc_watch #### 介绍 [xrkmonitor 监控平台](http://xrkmonitor.com) 下的 Linux shell 插件, 用于守护 linux 后台进程 #### 源码介绍 linux_proc_watch.sh 文件为插件脚本逻辑实现文件,其它文件皆由 xrkmonitor 监控平台源码模板自动生成 #### 安装教程 1. 该插件可同时在 xrkmonitor 云版本或者开源版上使用,进入插件市场,一键安装部署即可使用 #### 使用配置说明 默认配置只守护 slog_mtrepotr_client 进程,如需守护其它进程可在监控系统控制台修改 如需添加监控的进程,可按如下修改配置 首先修改 XRK_PROC_COUNT 配置,该配置表示要守护的后台程序数量 然后添加 XRK_NAME_PROC_[n], XRK_COUNT_MAX_PROC_[n], XRK_COUNT_MIN_PROC_[n], 配置项分别表示进程名,进程 正常运行时的最大最小进程数量, 如机器上有同名的不同后台程序或者不能通过程序名识别守护进程,可添加进程的绝对路径 示例:在默认配置上新增 httpd 程序的守护,配置如下: ``` XRK_PROC_COUNT 2 XRK_NAME_PROC_1 slog_mtreport_client XRK_ABS_PATH_PROC_1 /home/mysvn/my_monitor/mtreport_cloud/slog_mtreport_client XRK_COUNT_MAX_PROC_1 2 XRK_COUNT_MIN_PROC_1 2 XRK_NAME_PROC_2 httpd-prefork XRK_COUNT_MAX_PROC_2 10 XRK_COUNT_MIN_PROC_2 12 ``` 最后: 脚本默认只守护进程,进程数目不匹配时告警并记录日志。如需要在异常时重新拉取后台进程,可在插件部署目录下新增重启脚本, 脚本命名为:restart_[name].sh, [name] 为进程名 示例后台进程 httpd-prefork 重启脚本可如下编写:脚本文件名:restart_httpd-prefork.sh restart_httpd-prefork.sh 的内容可能如下: ``` #!/bin/bash apachectl restart ```