YPM

@yeet/opensnoop

3

opensnoop is a lightweight, high-performance tool designed to monitor and log all open system calls in real time. It efficiently captures detailed file access data such as file names, process IDs, and user information, all with minimal system overhead. Ideal for security auditing and troubleshooting, opensnoop provides comprehensive visibility into every file opened on the system, enhancing observability and security. It integrates seamlessly into your existing infrastructure.

Installation

Use yeet to install this package

sudo yeet install opensnoop
0.1.0Dual BSD / GPLPublic

img

opensnoop is a lightweight, high-performance tool designed to monitor and log all open system calls in real time. It efficiently captures detailed file access data such as file names, process IDs, and user information, all with minimal system overhead. Ideal for security auditing and troubleshooting, opensnoop provides comprehensive visibility into every file opened on the system, enhancing observability and security. It integrates seamlessly into your existing infrastructure.

Get Started

1. Install yeet

2. Deploy opensnoop

3. Create a collection

4. Monitor events

Data Schema

Each time an open syscall occurs, a new row is added to the collection with the following schema:

FieldTypeDescription
timestampDateThe time when the open syscall occurred.
seq_noIntA sequential number for the open event.
eventOpensnoopEventContains details about the open event.

Opensnoop Event

FieldTypeDescription
pidintThe process ID of the executed command.
tgidintThe thread group ID of the executed command.
ppidintThe parent process ID of the executed command.
cgroup_idstringThe ID of the control group associated with the process.
cgroup_namestringThe name of the control group associated with the process.
uidintThe user who triggered the open.
gidintThe group ID of the user.
latency_nsintHow long the open took to complete in nanoseconds.
fdintThe file descriptor of the opened file.
commstringThe command name of the executed process.
pathstringThe path of the opened file.

Example query:

You can query this collection using the SQL Editor.

SELECT
  timestamp,
  seq_no,
  event->>'$.pid' AS pid,
  event->>'$.tgid' AS tgid,
  event->>'$.ppid' AS ppid,
  event->>'$.cgroup_id' AS cgroup_id,
  event->>'$.cgroup_name' AS cgroup_name,
  event->>'$.uid' AS uid,
  event->>'$.gid' AS gid,
  CAST(event->>'$.latency_ns' AS int) AS latency_ns,
  event->>'$.fd' AS fd,
  event->>'$.comm' AS comm,
  event->>'$.path' AS path
FROM <your_collection_name_here>
ORDER BY seq_no DESC

Key Details:

JSON Path Extraction

  • The syntax event->>'$.property_name' is used to extract properties from the JSON event object without enclosing them in quotes.

CAST Function

  • latency_ns is cast to an integer, as it is initially treated as a string. This conversion ensures it can be correctly visualized or processed numerically.