a >hq @s2ddlZddlmZmZmZGdddeeZdS)N)PluginIndependentPlugin PluginOptc@sFeZdZdZdZdZdZeddeddgZ d d Z d d Z d dZ dS)Ebpfz eBPF toolZebpf)systemZkernelnetwork)Zbpftool namespacesNz0Number of namespaces to collect, 0 for unlimited)defaultZval_typeZdescc Csxg}zt|}Wn8tyJ}z |d||WYd}~Sd}~00t|D]\}}d|vrT||dqT|S)z! Collect the list of program IDs z"Couldn't parse bpftool prog list: Nidjsonloads ExceptionZ _log_info enumerateappend)selfZ prog_jsonoutZ prog_dataerr_itemr;/usr/lib/python3.9/site-packages/sos/report/plugins/ebpf.pyget_bpftool_prog_idsszEbpf.get_bpftool_prog_idsc Csxg}zt|}Wn8tyJ}z |d||WYd}~Sd}~00t|D]\}}d|vrT||dqT|S)z Collect the list of mapIDs z"Could not parse bpftool map list: Nr r )rZmap_jsonrZmap_datarrrrrrget_bpftool_map_ids&szEbpf.get_bpftool_map_idsc Cs|d}||dD]$}dD]}|d|d|q q|d}||dD]}|d|qV|gdd }|d }|j|d D]}||d } || d qdS)Nzbpftool -j prog listoutput)ZxlatedZjitedzbpftool prog dump z id zbpftool -j map listzbpftool map dump id )zbpftool prog listzbpftool map listzbpftool cgroup treebpftool net listzbpftool struct_ops dumpzip netns exec r)Zns_max r)Zcollect_cmd_outputrZadd_cmd_outputrZ get_optionZget_network_namespaces) rZprogsZprog_idZdumpcmdmapsZmap_idZ cmd_prefixZnsps namespaceZ ns_cmd_prefixrrrsetup3s      z Ebpf.setup) __name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZcommandsrintZ option_listrrrrrrrr s  r)r Zsos.report.pluginsrrrrrrrr s