3 ܓiq @s2ddlZddlmZmZmZGdddeeZdS)N)PluginIndependentPlugin PluginOptc@sFeZdZdZdZdZdZedded d gZ d d Z d dZ ddZ dS)Ebpfz eBPF toolZebpfsystemkernelnetworkbpftool namespacesNz0Number of namespaces to collect, 0 for unlimited)defaultZval_typeZdesccCstg}ytj|}Wn0tk rB}z|jd||Sd}~XnXx*t|D]\}}d|krN|j|dqNW|S)z! Collect the list of program IDs z"Couldn't parse bpftool prog list: Nid)jsonloads Exception _log_info enumerateappend)selfZ prog_jsonoutZ prog_dataerr_itemr/usr/lib/python3.6/ebpf.pyget_bpftool_prog_idsszEbpf.get_bpftool_prog_idscCstg}ytj|}Wn0tk rB}z|jd||Sd}~XnXx*t|D]\}}d|krN|j|dqNW|S)z Collect the list of mapIDs z"Could not parse bpftool map list: Nr )r rrrrr)rZmap_jsonrZmap_datarrrrrrget_bpftool_map_ids&szEbpf.get_bpftool_map_idsc Cs|jd}x:|j|dD](}x"dD]}|jd|d|q$WqW|jd}x&|j|dD]}|jd|q`W|jd d d d d gd}|jd}x.|j|dD]}||d} |j| d qWdS)Nzbpftool -j prog listoutputxlatedjitedzbpftool prog dump z id zbpftool -j map listzbpftool map dump id zbpftool prog listzbpftool map listzbpftool cgroup treezbpftool net listzbpftool struct_ops dumpzip netns exec r )Zns_max )rr)Zcollect_cmd_outputrZadd_cmd_outputrZ get_optionZget_network_namespaces) rZprogsZprog_idZdumpcmdmapsZmap_idZ cmd_prefixZnsps namespaceZ ns_cmd_prefixrrrsetup3s$     z Ebpf.setup)rrr)r ) __name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZcommandsrintZ option_listrrr"rrrrr s   r)r Zsos.report.pluginsrrrrrrrr s