728x90
===
Doc ID 2192857.1
===
OS가 어떠한 시그널을 프로세스 쪽에 날리는지 확인하기 위한 명령어로 쓰인다.
아래는 dtrace를 활용한 signal.d 스크립트이다.
#!/usr/sbin/dtrace -qs
string CreatedBy[int] ;
proc:::create
{
this->parent = CreatedBy[pid] != 0 ? CreatedBy[pid] : lltostr(ppid) ;
this->parent = strjoin( this->parent , ":" ) ;
this->parent = strjoin( this->parent , execname) ;
this->parent = strjoin( this->parent , "(") ;
this->parent = strjoin( this->parent , lltostr(pid)) ;
this->parent = strjoin( this->parent , ")") ;
this->child = args[0]->pr_pid ;
CreatedBy[this->child] = this->parent ;
}
proc:::signal-send
/ args[2] == SIGKILL || args[2] == SIGTERM /
{
this->sender_pid = pid ;
this->sender_name = execname ;
this->createdby = CreatedBy[pid] != 0 ? CreatedBy[pid] : "Unknown" ;
this->signalsent = args[2] ;
this->target_pid = args[1]->pr_pid ;
this->target_name = stringof(args[1]->pr_fname) ;
printf("%Y process: %s(%d) created by \"%s\" sent signal ( %d ) to process %s(%d)\n",
walltimestamp,this->sender_name,this->sender_pid,this->createdby,this->signalsent,this->target_name,this->target_pid);
proc:::exit
{
CreatedBy[pid] = 0
}
/* end */
이 파일을 실행권한을 주고, root 계정으로 signal.d 파일을 돌리면 된다.
./signal.d > os_signal.log 2>&1 &
2024 Aug 13 14:31:07 process: sshd(6507) created by "1:sshd(22174)" sent signal ( 15 ) to process sshd(6508)
os_signal.log를 확인하면 이렇게 로깅이 남는다.
'OS > LINUX [UNIX]' 카테고리의 다른 글
| TCP DUMP(1) (0) | 2026.01.26 |
|---|---|
| High CPU 현상 시 사용하는 perf 명령어 (2) | 2025.06.30 |
| 시그널 모음 (0) | 2024.05.20 |
| 리소스 분석 시 사용하는 OS 명령어 (0) | 2024.02.22 |
| netstat (0) | 2024.01.10 |