章工运维 章工运维
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)

章工运维

业精于勤,荒于嬉
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)
  • python

  • shell

    • 进程pid判断脚本
    • 日志切割脚本
    • 设置跳板机脚本
    • 编写启动、停止、重启的脚本
    • mysql数据库备份的三种方式
    • jenkins编译服务脚本
    • app编译脚本
    • 常用shell脚本
    • 字符串的截取拼接
    • shell基础
    • centos7主机安全检测脚本和初始化脚本
    • 应用服务重启脚本
    • shell重启python程序脚本
    • rancher的证书制作脚本
    • shell常用脚本集合
    • mysql常用的脚本集合
    • shell批量部署安装包并启动
    • 批量添加定时任务
    • mysql备份企业示例
    • shell脚本创建出色用户体验的6种技巧
    • 多系统一键部署zabbix6脚本(已验证)
    • 批量拿取多台服务器的日志文件
    • shell脚本模块集合
  • go

  • 编程
  • shell
章工运维
2022-12-14

进程pid判断脚本

# zabbix监控进程变动

业务需求后端进程宕机以后能在短时间内迅速拉起,业务影响不大,但是开发需要查看coredump,要求能监控到pid变化;在现有构架下zabbix能监控并报警;

在每台服务器/etc/zabbix/zabbix_agentd.conf设置路径:此例只需要piddiff.sh

UserParameter=checkpid,sh /usr/local/script/piddiff.sh

/etc/zabbix/sh下面存放脚本

storage为业务监控的id取值根据业务需求

#!/bin/bash
onl_ok=1
onl_cored=3
dir=/etc/zabbix/sh
if [[ ! -f "$dir/old.txt" ]];then
    ps aux | grep storage | grep -v grep |grep -v probe | grep root | awk '{print $2,$11}' > $dir/old.txt
else
    sleep 1s
fi
    ps aux | grep storage | grep -v grep |grep -v probe | grep root | awk '{print $2,$11}' > $dir/now.txt
if ! diff -q $dir/old.txt $dir/now.txt > /dev/null;then
    echo $onl_cored
    diff -c $dir/old.txt $dir/now.txt > $dir/`date "+%Y%m%d%H%M"`_diff.txt
    cat $dir/now.txt > $dir/old.txt
else
    echo $onl_ok
fi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
微信 支付宝
上次更新: 2022/12/15, 12:14:09

← python引用数据库 日志切割脚本→

最近更新
01
shell脚本模块集合
05-13
02
生活小技巧(认知版)
04-29
03
生活小技巧(防骗版)
04-29
更多文章>
Theme by Vdoing | Copyright © 2019-2025 | 点击查看十年之约 | 鄂ICP备2024072800号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式