[转帖]linux 上进程被随机kill掉,如何监测和查询;谁杀了我的进程;Who sends a SIGKILL to my process mysteriously on ubuntu server

linux,进程,随机,kill,如何,监测,查询,who,sends,sigkill,to,my,process,mysteriously,on,ubuntu,server · 浏览次数 : 0

小编点评

**Linux 审计系统 auditAudit** * 审计系统用于跟踪系统中重要的安全事件。 * Audit 可以记录各种事件,包括进程创建、 death、文件系统操作等。 * 通过设置预配置规则,Audit 可以发现并记录违反安全政策的行为。 **如何使用 audit 来发现被杀进程?** 1. 使用 `auditctl` 命令启动 `auditd` 服务。 2. 使用 `auditctl` 添加规则,指定要监控的事件。 3. 运行你的进程。 4. 检查 `audit.log` 文件中的日志记录。 **日志记录中可能会看到以下消息:** * `SIGKILL`:杀死进程的信号。 * `proctitle`:杀死进程的程序名称。 * `pid`:杀死进程的进程 ID。 **注意:** * 审计系统只能提供与事件相关的日志记录。 * 为了找出真正导致进程被杀的程序,需要仔细分析日志记录。

正文

https://www.cnblogs.com/xuyaowen/p/linux-audit.html

 

今天跑实验,发现进程被随机kill。咨询了服务器上的其他同学,他们说之前也发生过,一直存在。看来可能有可能不是我自己程序的原因,只能自己动手解决了。

在 Who sends a SIGKILL to my process mysteriously on ubuntu server 中,提到一个简单的方法,使用audit。

Linux 审计系统:audit

Audit does not provide additional security to your system; rather, it can be used to discover violations of security policies used on your system. These violations can further be prevented by additional security measures such as SELinux.

The Linux Audit system provides a way to track security-relevant information on your system. Based on pre-configured rules, Audit generates log entries to record as much information about the events that are happening on your system as possible. This information is crucial for mission-critical environments to determine the violator of the security policy and the actions they performed.

关于系统的更多内容,可参考 redhat 管理员手册。

安装很简单:sudo apt install auditd

启动服务并查看状态: systemctl enable auditd.service; systemctl restart auditd.service

然后通过auditctrl添加规则: auditctl -a exit,always -F arch=b64 -S kill -F a1=9

测试:

启动然后kill掉Python程序; 查看日志,即可发现kill发起的程序和用户;

sudo ausearch -sc kill
time->Thu Feb 24 04:00:08 2022
type=PROCTITLE msg=audit(1645675208.403:201): proctitle="htop"
type=OBJ_PID msg=audit(1645675208.403:201): opid=40099 oauid=1016 ouid=1016 oses=12951 obj==unconfined ocomm="nvtop"
type=SYSCALL msg=audit(1645675208.403:201): arch=c000003e syscall=62 success=yes exit=0 a0=9ca3 a1=9 a2=c1 a3=8 items=0 ppid=45939 pid=40129 auid=1016 uid=1016 gid=1016 euid=1016 suid=1016 fsuid=1016 egid=1016 sgid=1016 fsgid=1016 tty=pts4 ses=18035 comm="htop" exe="/usr/bin/htop" subj==unconfined key=(null)

下面开始守株待兔了, 再跑一下程序,找到被kill的原因;

# 2022年02月24日12:30:12,  被我找到了,应该是一个恶意程序。。

参考链接:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/chap-system_auditing

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/security_hardening/auditing-the-system_security-hardening

https://documentation.suse.com/sles/12-SP4/html/SLES-all/cha-audit-comp.html

https://stackoverflow.com/questions/26285133/who-sends-a-sigkill-to-my-process-mysteriously-on-ubuntu-server

https://www.cnblogs.com/xybaby/p/8098229.html

保持更新;cnblogs.com/xuyaowen; 

与[转帖]linux 上进程被随机kill掉,如何监测和查询;谁杀了我的进程;Who sends a SIGKILL to my process mysteriously on ubuntu server相似的内容:

[转帖]linux 上进程被随机kill掉,如何监测和查询;谁杀了我的进程;Who sends a SIGKILL to my process mysteriously on ubuntu server

https://www.cnblogs.com/xuyaowen/p/linux-audit.html 今天跑实验,发现进程被随机kill。咨询了服务器上的其他同学,他们说之前也发生过,一直存在。看来可能有可能不是我自己程序的原因,只能自己动手解决了。 在 Who sends a SIGKILL t

[转帖]Linux 调优篇 :虚拟化调优(irqbalance 网卡中断绑定)* 贰

一.网络流量上不去二.中断绑定 2.1 关闭中断平衡守护进程 2.2 脱离中断平衡守护进程 2.3 手动设置中断的CPU亲和性三. 总结 一.网络流量上不去 在Linux的网络调优方面,如果你发现网络流量上不去,那么有一个方面需要去查一下: 网卡处理网络请求的中断是否被绑定到单个CPU(或者说跟处理

【转帖】Linux 调优篇 :虚拟化调优(irqbalance 网卡中断绑定)* 贰

一.网络流量上不去二.中断绑定 2.1 关闭中断平衡守护进程 2.2 脱离中断平衡守护进程 2.3 手动设置中断的CPU亲和性三. 总结 一.网络流量上不去 在Linux的网络调优方面,如果你发现网络流量上不去,那么有一个方面需要去查一下: 网卡处理网络请求的中断是否被绑定到单个CPU(或者说跟处理

[转帖]linux进程、线程与cpu的亲和性(affinity)

https://www.cnblogs.com/wenqiang/p/6049978.html 最近的工作中对性能的要求比较高,下面简单做一下总结: 一、什么是cpu亲和性(affinity) CPU的亲和性, 就是进程要在指定的 CPU 上尽量长时间地运行而不被迁移到其他处理器,也称为CPU关联性

[转帖]某游戏海外版本堆外内存泄露排查

https://www.jianshu.com/p/cae00d9c99fe 某游戏海外版本堆外内存泄露排查 现象 线上有部分服务器用top发现Java进程内存占用占比达到99,而且出现了有一个服务器被Linux OOM Kill 排查 选择了110服,该机器的Java进程最大堆内存设置的是9710

[转帖]Linux进程栈空间大小

https://zhuanlan.zhihu.com/p/530357476 内核栈 Linux上进程的相关属性在内核中表示为task_struct,该结构体中stack成员指向进程内核栈的栈底: struct task_struct { ... void *stack; ... } 我们知道Lin

[转帖]Linux 内核内存性能调优的一些笔记

https://my.oschina.net/u/6150560/blog/7759034 一、前言 在工作生活中,我们时常会遇到一些性能问题:比如手机用久了,在滑动窗口或点击 APP 时会出现页面反应慢、卡顿等情况;比如运行在某台服务器上进程的某些性能指标(影响用户体验的 PCT99 指标等)不达

[转帖]通过Shell脚本自动监控JAVA进程中线程cpu使用率

https://gitee.com/jialy/auto-monitor-java-process/tree/master 本文主要介绍在 show-busy-java-threads.sh 脚本的功能基础上,通过 process-cpu-monitor.sh 脚本实现Linux平台上Java进程或

[转帖]线上环境 Linux 系统调用追踪

线上环境 Linux 系统调用追踪 PingCAP 提到如何动态追踪进程中的系统调用,相信大家第一时间都能想到 strace,它的基本用法非常简单,非常适合用来解决 “为什么这个软件无法在这台机器上运行?” 这类问题。但如果需要分析线上服务 (特别是延迟敏感型)的某些系统调用的延迟时,strace

[转帖]《Linux性能优化实战》笔记(二)—— CPU 上下文切换(上)

上一篇的最后一个例子,在多个进程竞争CPU时,我们看到每个进程实际上%usr部分只有20%多,70%多是在wait,但是load远远高于单个进程使用CPU达到100%。 这让我想到之前看的RWP公开课,里面有一篇连接池管理。为什么相同的业务量,起6千个连接(进程)远远要慢于200个连接,因为绝大多数