Skip to content

Commit 2f6761a

Browse files
Phillip Kuznetsovcopybaranaut
authored andcommitted
Add processes() to pxviews
Summary: Adding a pxviews function that returns all processes in the cluster. Test Plan: Wrote a script that called processes() and compared to results given from px/pod Reviewers: vihang, jamesbartlett, michelle, nserrino Reviewed By: jamesbartlett Signed-off-by: Phillip Kuznetsov <pkuznetsov@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D11971 GitOrigin-RevId: 2a0b28c
1 parent ce5b6bb commit 2f6761a

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/carnot/planner/pxl_lib/pxviews.pxl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,4 +538,30 @@ def connection_throughput_stats(start_time, end_time):
538538

539539
return df[['time_', 'remote_addr', 'pod_id', 'inbound_conn_throughput', 'outbound_conn_throughput']]
540540

541+
542+
def processes(start_time, end_time):
543+
''' Collects all of the processes running on the cluster inside containers.
544+
545+
@start_time Starting time of the data to examine.
546+
@end_time Ending time of the data to examine.
547+
'''
548+
df = px.DataFrame(table='process_stats', start_time=start_time, end_time=end_time)
549+
df.pod_id = df.ctx['pod_id']
550+
df.container_name = df.ctx['container_name']
551+
df.container_id = df.ctx['container_id']
552+
df.cmdline = df.ctx['cmdline']
553+
df.pid = df.ctx['pid']
554+
555+
df = df.groupby(['upid', 'pod_id', 'container_name', 'container_id', 'cmdline', 'pid']).agg(
556+
time_=('time_', px.max),
557+
)
558+
df.pod = px.pod_id_to_pod_name(df.pod_id)
559+
df.service = px.pod_id_to_service_name(df.pod_id)
560+
df.namespace = px.pod_id_to_namespace(df.pod_id)
561+
df.node = px.pod_id_to_node_name(df.pod_id)
562+
df.container_status = px.container_id_to_status(df.container_id)
563+
564+
return df[['time_', 'service', 'namespace', 'node', 'upid', 'pod_id', 'pod',
565+
'container_name', 'container_id', 'cmdline', 'pid', 'container_status']]
566+
541567
)"

0 commit comments

Comments
 (0)