Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing filterchecks #1843

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions userspace/libsinsp/sinsp_filtercheck_fd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static const filtercheck_field_info sinsp_filter_check_fd_fields[] =
{PT_INT64, EPF_NONE, PF_DEC, "fd.ino", "FD Inode Number", "inode number of the referenced file"},
{PT_CHARBUF, EPF_NONE, PF_NA, "fd.nameraw", "FD Name Raw", "FD full name raw. Just like fd.name, but only used if fd is a file path. File path is kept raw with limited sanitization and without deriving the absolute path."},
{PT_CHARBUF, EPF_IS_LIST | EPF_ARG_ALLOWED | EPF_NO_RHS | EPF_NO_TRANSFORMER, PF_DEC, "fd.types", "FD Type", "List of FD types in used. Can be passed an fd number e.g. fd.types[0] to get the type of stdout as a single item list."},
{PT_CHARBUF, EPF_TABLE_ONLY, PF_NA, "fd.containerpidname", "FD Container Pid Name", "chaining of the container ID, the pid and the FD name."},
};

sinsp_filter_check_fd::sinsp_filter_check_fd()
Expand Down Expand Up @@ -301,6 +302,18 @@ uint8_t* sinsp_filter_check_fd::extract_from_null_fd(sinsp_evt *evt, OUT uint32_
return NULL;
}
}
case TYPE_CONTAINERPIDNAME:
{
if(extract_fdname_from_creator(evt, len, sanitize_strings) == true)
{
m_tstr = m_tinfo->m_container_id + ':' + to_string(m_tinfo->m_pid) + ':' + m_tstr;
RETURN_EXTRACT_STRING(m_tstr);
}
else
{
return NULL;
}
}
case TYPE_DIRECTORY:
case TYPE_CONTAINERDIRECTORY:
{
Expand Down Expand Up @@ -483,6 +496,7 @@ uint8_t* sinsp_filter_check_fd::extract_single(sinsp_evt *evt, OUT uint32_t* len
{
case TYPE_FDNAME:
case TYPE_CONTAINERNAME:
case TYPE_CONTAINERPIDNAME:
if(m_fdinfo == NULL)
{
return extract_from_null_fd(evt, len, sanitize_strings);
Expand All @@ -503,6 +517,11 @@ uint8_t* sinsp_filter_check_fd::extract_single(sinsp_evt *evt, OUT uint32_t* len
ASSERT(m_tinfo != NULL);
m_tstr = m_tinfo->m_container_id + ':' + m_fdinfo->m_name;
}
else if(m_field_id == TYPE_CONTAINERPIDNAME)
{
ASSERT(m_tinfo != NULL);
m_tstr = m_tinfo->m_container_id + ':' + to_string(m_tinfo->m_pid) + ':' + m_fdinfo->m_name;
}
else
{
m_tstr = m_fdinfo->m_name;
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/sinsp_filtercheck_fd.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class sinsp_filter_check_fd : public sinsp_filter_check
TYPE_INO = 41,
TYPE_FDNAMERAW = 42,
TYPE_FDTYPES = 43,
TYPE_CONTAINERPIDNAME = 44,
};

sinsp_filter_check_fd();
Expand Down
Loading