LinuxCommandLibrary

strigger

Trigger system events for debugging and testing

TLDR

Register a new trigger. Execute the specified program when the specified event occurs

$ strigger --set --[primary_database_failure|primary_slurmdbd_failure|primary_slurmctld_acct_buffer_full|primary_slurmctld_failure|...] [[-p|--program]] [path/to/executable]
copy

Execute the specified program when the specified job terminated
$ strigger --set [[-j|--jobid]] [job_id] [[-f|--fini]] [[-p|--program]] "[path/to/executable] [argument1 argument2 ...]"
copy

View active triggers
$ strigger --get
copy

View active triggers regarding the specified job
$ strigger --get [[-j|--jobid]] [job_id]
copy

Clear the specified trigger
$ strigger --clear [trigger_id]
copy

SYNOPSIS

strace [options] command [arguments...]
strace [options] -p PID

PARAMETERS

-c
    Count time, calls, and errors for each system call, and then report a summary.

-f
    Trace child processes as they are forked by the traced process. This is essential for tracing applications that create sub-processes.

-o filename
    Write the trace output to the specified filename instead of standard error. Useful for capturing long traces.

-p PID
    Attach to an already running process specified by its process ID (PID). This allows tracing without restarting the application.

-e expr
    Qualify which events to trace. expr can filter by system call names (e.g., trace=open,close), by signals, or specify a fault injection condition.

-v
    Verbose output. Decodes more structures and displays more information, which can be helpful for in-depth analysis.

-i
    Print the instruction pointer (program counter) at the time of the system call. Aids in debugging assembly-level issues.

-T
    Show the time spent in each system call. Provides insight into performance bottlenecks.

-tt / -ttt
    Prefix each line with the time of day. -ttt adds microsecond precision, useful for highly granular timing analysis.

-s length
    Specify the maximum string size to print. Longer strings are truncated. Default is 32.

-y
    Print the path associated with file descriptor arguments. Makes output much more readable for file operations.

-yy
    Print network protocol information associated with socket file descriptors. Useful for network application debugging.

DESCRIPTION

strace is a powerful diagnostic, debugging, and instructional user-space tool for Linux. It intercepts and records the system calls made by a process and the signals received by it. This provides a detailed look into the low-level interactions a program has with the operating system kernel, including file operations, network communications, memory allocations, and inter-process communications. It is invaluable for understanding program behavior, diagnosing elusive software bugs, and performing security audits by revealing what resources an application accesses.

CAVEATS

Using strace can introduce significant overhead to the traced process, potentially altering its timing and behavior. Tracing privileged processes can reveal sensitive information about system interactions. The volume of output can be extremely large, requiring careful filtering for effective analysis.

NOTE ON 'STRIGGER'

It appears that 'strigger' is not a standard or recognized Linux command. This analysis describes strace, which is a widely used system call tracing tool and is often confused or associated with terms like 'triggering system calls'. If 'strigger' was intended to refer to a specific, non-standard script or concept, please provide further context.

HOW IT WORKS

strace operates by utilizing the ptrace(2) system call. This kernel interface enables a 'tracer' process (strace) to observe and control the execution of a 'tracee' process. It can intercept system calls before or after they are executed, examine and modify the tracee's memory and registers, and handle signals directed to the tracee. This mechanism allows strace to log every interaction between the application and the Linux kernel.

COMMON USE CASES

strace is commonly used for:
- Debugging: Pinpointing the exact system call failure that causes an application crash or malfunction.
- Performance Analysis: Identifying I/O bottlenecks or excessive system call overhead.
- Security Auditing: Understanding what files, network connections, or other resources an unknown program accesses.
- Reverse Engineering: Gaining insight into the behavior of closed-source binaries.
- Learning: Observing how standard commands (e.g., ls, cat) interact with the kernel.

HISTORY

strace originated in the early 1990s as a powerful debugging tool for Linux, inspired by similar utilities on other Unix-like systems. Its foundation lies in the ptrace(2) system call, which allows one process to control another. Over decades, it has undergone continuous development, adapting to new kernel features and adding sophisticated filtering and output options, solidifying its role as an indispensable diagnostic utility in the Linux ecosystem.

SEE ALSO

ltrace(1), ptrace(2), gdb(1), perf(1)

Copied to clipboard