{"id":481736,"date":"2026-05-31T07:00:23","date_gmt":"2026-05-31T07:00:23","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=481736"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=481736","title":{"rendered":"(\u041d\u0435)\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 eBPF: \u0447\u0442\u043e \u043c\u0430\u0440\u043a\u0435\u0442\u043e\u043b\u043e\u0433\u0438 \u0437\u0430\u0431\u044b\u043b\u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043e\u0431 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044f\u0445"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<details class=\"spoiler\">\n<summary>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440 1<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u043e\u0441\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440. \u041c\u043e\u044f \u0446\u0435\u043b\u044c &#8212; \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b eBPF \u0432 Linux. <\/p>\n<p>\u0412\u0435\u0434\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440 2<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430\u0434\u043e \u0443\u0436\u0435 \u0431\u044b\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u043c \u0441 Linux \u0438 eBPF. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0442\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u0443\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u043e, <a href=\"https:\/\/ebpf.io\/what-is-ebpf\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u044d\u0442\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f<\/a>. <\/p>\n<\/div>\n<\/details>\n<h3>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442?<\/h3>\n<p>\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0441\u0435 \u0447\u0430\u0449\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0418\u0411 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 Linux \u0441\u0438\u0441\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f\u0442 \u0441 kernel modules \u043d\u0430 eBPF. <\/p>\n<p>\u041e\u043d\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. <\/p>\n<p><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 \u0434\u043b\u044f Linux &#8212; \u0437\u0430\u043d\u044f\u0442\u0438\u0435 \u043a\u0440\u0430\u0439\u043d\u0435 \u0442\u044f\u0436\u0435\u043b\u043e\u0435.<\/strong> \u041a\u043e\u043c\u043c\u044c\u044e\u043d\u0438\u0442\u0438 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 API \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432 \u043d\u0430 \u0440\u044b\u043d\u043a\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u0432\u0441\u0435 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0442\u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u0432\u043e\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0410 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u0430\u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430, \u043d\u043e \u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0434\u0440\u0430. <\/p>\n<p>Linux \u0434\u0430\u0432\u043d\u043e \u0441\u0442\u0430\u043b \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u0421\u0435\u0433\u043c\u0435\u043d\u0442 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u044f\u0434\u0440\u0435 Linux. \u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0442\u0435\u0442, \u0430 \u0441 \u043d\u0435\u0439 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0418\u0422 \u0438 \u0418\u0411 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445. <\/p>\n<p>\u0418 \u0442\u0443\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0433\u043b\u0443 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043a\u0440\u0438\u0447\u0430\u0442\u044c <strong>\u043e eBPF, \u043a\u0430\u043a \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0435, \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/strong> \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0442\u0434.<\/p>\n<h4>\u041c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433 \u043a\u0440\u0438\u0447\u0438\u0442<\/h4>\n<p>eBPF &#8212; \u044d\u0442\u043e: <\/p>\n<ul>\n<li>\n<p>\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u044f\u0434\u0440\u0430 \u0438\u0437-\u0437\u0430 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043b\u0435\u0433\u043a\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e kernel modules;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 C++, Go, Python, Rust \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0440\u043e\u0441\u0441\u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0441\u0447\u0435\u0442 CO-RE (\u043a\u0441\u0442\u0430\u0442\u0438, \u0441 \u043d\u044e\u0430\u043d\u0441\u0430\u043c\u0438: \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 BTF-\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u044f\u0434\u0440\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438 &lt;5.2, \u043e\u0431 \u044d\u0442\u043e\u043c \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432\u044b\u0439\u0434\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f).<\/p>\n<\/li>\n<\/ul>\n<h4>\u0410 \u044f \u0434\u043e\u043f\u043e\u043b\u043d\u044e<\/h4>\n<p>eBPF &#8212; \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435:<\/p>\n<ul>\n<li>\n<p>\u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u044f\u0434\u0440\u0430 \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u2014 \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 eBPF \u0438 Linux;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u0443\u0436\u0435 <strong>\u043d\u0435 \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u043e\u0447\u043d\u043e<\/strong>, \u043f\u0440\u0430\u0432\u0434\u0430?<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c 2 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b: \u043c\u043e\u043d\u0438\u0442\u043e\u0440 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 (eBPF + Go) \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a (\u0442\u043e\u043b\u044c\u043a\u043e Go).<\/p>\n<blockquote>\n<p>\u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e <strong>\u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043d\u0430 \u0421++\/Python\/Rust.<\/strong> \u0412\u043a\u0443\u0441\u043e\u0432\u0449\u0438\u043d\u0430. <\/p>\n<p>Go \u0432\u044b\u0431\u0440\u0430\u043d \u0438\u0437-\u0437\u0430 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439. <\/p>\n<\/blockquote>\n<h3>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430<\/h3>\n<p>\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u0442\u044c Go \u0438 eBPF \u0438\u043d\u0430\u0447\u0435 \u0441\u0442\u0430\u0442\u044c\u044f \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0435\u0442\u0441\u044f. \u041d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <a href=\"https:\/\/ebpf-go.dev\/guides\/getting-started\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0442\u0443\u0442<\/a> \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: <\/p>\n<ul>\n<li>\n<p>eBPF-\u043c\u043e\u0434\u0443\u043b\u044c, \u043f\u043e\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 <code>execve<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 Go, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 eBPF-\u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u044f\u0434\u0440\u043e \u0438 \u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<h4>eBPF-\u043c\u043e\u0434\u0443\u043b\u044c<\/h4>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c eBPF-\u043c\u043e\u0434\u0443\u043b\u044c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043a <em>tracepoint<\/em> \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>execve<\/code>.<\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e <code>\/\/go:build ignore<\/code><strong>  <\/strong>\u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 <code>execve_monitoring.c<\/code> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0431\u043e\u0440\u0449\u0438\u043a Go \u043d\u0435 \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c C \u043a\u043e\u0434.<\/p>\n<pre><code class=\"cpp\">\/\/go:build ignore#include &lt;linux\/bpf.h&gt;#include &lt;bpf\/bpf_helpers.h&gt;#define MAX_PATH  256#define TASK_COMM_LEN 16\/\/ \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043estruct start_ps_event {    __u32 pid;    char cmd[TASK_COMM_LEN];    char filename[MAX_PATH];} __attribute__((packed));\/\/ \u041d\u0430\u0448\u0430 \u043c\u0430\u043f\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044cstruct {    __uint(type, BPF_MAP_TYPE_HASH);    __uint(max_entries, 1024);    __type(key, __u32);    __type(value, struct start_ps_event); } ps_info SEC(\".maps\");\/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445\/\/ \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435\u043c \u043e \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430struct syscalls_enter_execve_args {    unsigned short common_type;    unsigned char common_flags;    unsigned char common_preempt_count;    int common_pid;    int __syscall_nr;    const char *filename;    const char *const *argv;    const char *const *envp;};\/\/ \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430SEC(\"tracepoint\/syscalls\/sys_enter_execve\") int GetStartedPid(struct syscalls_enter_execve_args* ctx) {    struct start_ps_event event = {};        \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c PID \u0438 \u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b    event.pid = bpf_get_current_pid_tgid() &gt;&gt; 32;    bpf_get_current_comm(event.cmd, sizeof(event.cmd));        \/\/ \u0427\u0438\u0442\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443    bpf_probe_read_user_str(event.filename, sizeof(event.filename), ctx-&gt;filename);        \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c PID \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043c\u0430\u043f\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430    __u32 key = event.pid;    bpf_printk(\"BPF PRINT: process %s started\\n\", event.cmd);        \/\/ \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432 \u043c\u0430\u043f\u0443    long res = bpf_map_update_elem(&amp;ps_info, &amp;key, &amp;event, BPF_ANY);    return 0;}char _license[] SEC(\"license\") = \"GPL\";<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>Go-\u0447\u0430\u0441\u0442\u044c<\/h4>\n<p>\u041d\u0430\u0448 <code>main.go<\/code>\u0434\u0435\u043b\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0443\u043c: \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <code>execve_monitoring.c<\/code> \u0432 \u044f\u0434\u0440\u043e. \u041e\u0436\u0438\u0434\u0430\u0435\u0442, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043c\u0430\u043f\u044b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u0445 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b. <\/p>\n<pre><code class=\"go\">package mainimport (\"bytes\"\"fmt\"\"log\"\"os\"\"os\/signal\"\"syscall\"\"time\"\"github.com\/cilium\/ebpf\/link\"\"github.com\/cilium\/ebpf\/rlimit\")\/\/ \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043d\u0430\u0448\u0435\u0439 start_ps_event \u0438\u0437 execve_monitoring.c\/\/ \u0414\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u0438 \u0442\u0438\u043f\u044b, \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044btype StartPSEvent struct {Pid      uint32Cmd      [16]byteFilename [256]byte}func GetStrFromBytes(b []byte) string {if idx := bytes.IndexByte(b, 0); idx != -1 {return string(b[:idx])}return string(b)}func main() {if err := rlimit.RemoveMemlock(); err != nil {log.Fatalf(\"Failed to remove memlock: %v\", err)}\/\/ \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c eBPF \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u044f\u0434\u0440\u043eobjs := ps_start_hashObjects{}if err := loadPs_start_hashObjects(&amp;objs, nil); err != nil {log.Fatalf(\"Failed to load eBPF objects: %v\", err)}defer objs.Close()\/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a tracepointtp, err := link.Tracepoint(\"syscalls\", \"sys_enter_execve\", objs.GetStartedPid, nil)if err != nil {log.Fatalf(\"Failed to attach tracepoint: %v\", err)}defer tp.Close()fmt.Println(\"eBPF program running and polling Hash Map...\")sigChan := make(chan os.Signal, 1)signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)stopChan := make(chan struct{})\/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043c\u0430\u043f\u044bgo func() {for {select {case &lt;-stopChan:returndefault:var (key     uint32nextKey uint32)var keysToProcess []uint32\/\/ \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043a\u043b\u044e\u0447\u0438 \u0438\u0437 \u043c\u0430\u043f\u044berr := objs.PsInfo.NextKey(nil, &amp;nextKey)for err == nil {key = nextKeykeysToProcess = append(keysToProcess, key)err = objs.PsInfo.NextKey(key, &amp;nextKey)}\/\/ \u0415\u0441\u043b\u0438 \u043a\u0430\u0440\u0442\u0430 \u043f\u0443\u0441\u0442\u0430, \u0436\u0434\u0435\u043c 10\u043c\u0441 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043d\u043e\u0432\u0430if len(keysToProcess) == 0 {time.Sleep(10 * time.Millisecond)continue}                \/\/ \u043f\u0443\u0441\u0442\u044c \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430time.Sleep(1 * time.Millisecond)\/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438, \u0447\u0438\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0443\u0434\u0430\u043b\u044f\u0435\u043cvar e StartPSEventfor _, k := range keysToProcess {                  if lookupErr := objs.PsInfo.Lookup(k, &amp;e); lookupErr == nil {log.Printf(\"Execve: PID=%d, Process=%s, File=%s\\n\",e.Pid,GetStrFromBytes(e.Cmd[:]),GetStrFromBytes(e.Filename[:]),)\/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u044f\u0434\u0440\u0430if delErr := objs.PsInfo.Delete(k); delErr != nil {log.Printf(\"Warning: failed to delete key %d: %v\", k, delErr)}}}\/\/ \u041a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u043f\u0430\u0443\u0437\u0430 \u043c\u0435\u0436\u0434\u0443 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438time.Sleep(5 * time.Millisecond)}}}()&lt;-sigChanclose(stopChan)fmt.Println(\"Shutting down...\")}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 <code>execve <\/code>\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, pid \u0438 \u0438\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<pre><code class=\"bash\">just_me@just_me:~\/go_ebpf_ps_start$ go build &amp;&amp; sudo .\/hash[sudo] password for just_me: eBPF program running and polling Hash Map...Execve: PID=256619, Process=code, File=\/bin\/shExecve: PID=256621, Process=code, File=\/bin\/shExecve: PID=256622, Process=sh, File=\/usr\/bin\/psExecve: PID=256620, Process=sh, File=\/usr\/bin\/whichExecve: PID=256627, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256623, Process=code, File=\/bin\/shExecve: PID=256624, Process=sh, File=\/snap\/code\/195\/usr\/share\/code\/resources\/app\/out\/vs\/base\/node\/cpuUsage.shExecve: PID=256629, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256625, Process=cpuUsage.sh, File=\/usr\/bin\/sedExecve: PID=256626, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256628, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256630, Process=cpuUsage.sh, File=\/usr\/bin\/sleepExecve: PID=256632, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256631, Process=cpuUsage.sh, File=\/usr\/bin\/sedExecve: PID=256638, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256634, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256636, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256641, Process=code, File=\/bin\/shExecve: PID=256642, Process=sh, File=\/usr\/bin\/whichExecve: PID=256643, Process=code, File=\/bin\/shExecve: PID=256644, Process=sh, File=\/usr\/bin\/psExecve: PID=256649, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256646, Process=sh, File=\/snap\/code\/195\/usr\/share\/code\/resources\/app\/out\/vs\/base\/node\/cpuUsage.shExecve: PID=256645, Process=code, File=\/bin\/shExecve: PID=256650, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256652, Process=cpuUsage.sh, File=\/usr\/bin\/sleepExecve: PID=256647, Process=cpuUsage.sh, File=\/usr\/bin\/sedExecve: PID=256651, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256648, Process=cpuUsage.sh, File=\/usr\/bin\/cat...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0443\u043f\u0435\u0440, \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0417\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443.<\/p>\n<h3>\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 eBPF map \u0438\u0437 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f?<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 eBPF \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/p>\n<pre><code class=\"bash\">sudo apt updatesudo apt install linux-tools-common linux-tools-generic linux-tools-$(uname -r)sudo apt install bpftool<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u043b\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430 \u043e\u043d \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u0435\u043d, \u043d\u043e \u043c\u043e\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0441 \u043d\u0443\u043b\u044f<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<pre><code class=\"bash\">sudo bpftool map list<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 &#8212; <strong>\u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 eBPF-map<\/strong> \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043d\u0438\u0445.<\/p>\n<pre><code class=\"bash\">just_me@just_me:\/~$ sudo bpftool map list1: hash  flags 0x0key 9B  value 1B  max_entries 500  memlock 46432B2: hash  flags 0x0key 9B  value 1B  max_entries 500  memlock 46432B4: hash  flags 0x0key 9B  value 1B  max_entries 500  memlock 46432B5: hash  name s_libreoffice_h  flags 0x0key 9B  value 1B  max_entries 1000  memlock 90624B133: hash  name s_firmware_upda  flags 0x0key 9B  value 1B  max_entries 1000  memlock 90624B138: hash  name s_mesa_2404_hoo  flags 0x0key 9B  value 1B  max_entries 1000  memlock 90624B139: hash  name s_chromium_hook  flags 0x0key 9B  value 1B  max_entries 1000  memlock 90624B178: array  name .rodata  flags 0x480key 4B  value 31B  max_entries 1  memlock 8192Bbtf_id 437  frozen179: hash  name ps_info  flags 0x0key 4B  value 276B  max_entries 1024  memlock 365856Bbtf_id 438<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a\u0443\u044e \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u0448\u0435\u0439 \u043c\u0430\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430. <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u043d\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>execve_monitor.c<\/code> <\/p>\n<pre><code class=\"cpp\">struct {    __uint(type, BPF_MAP_TYPE_HASH);    __uint(max_entries, 1024);    __type(key, __u32);    __type(value, struct start_ps_event); } ps_info SEC(\".maps\");<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c <strong>\u043f\u0440\u0438\u0433\u043b\u044f\u0434\u0438\u0442\u0435\u0441\u044c \u043a \u0441\u0442\u0440\u043e\u043a\u0435 19<\/strong> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>sudo bpftool map list<\/code><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0427\u0442\u043e \u0432\u0438\u0434\u0438\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435?<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0427\u0442\u043e \u044d\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435?<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>ps_info<em> <\/em><\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0442\u043e\u0447\u043d\u043e\u0435 \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>hash<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043d\u0430\u043c\u0438 \u0442\u0438\u043f \u043c\u0430\u043f\u044b, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432 <code>execve_monitor.c<\/code>  \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 <code>BPF_MAP_TYPE_HASH<\/code>)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>179<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"> \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0430\u0448\u0435\u0439 \u043c\u0430\u043f\u044b, \u0437\u043d\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u043c \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043a \u043d\u0435\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442&#8230;<\/h4>\n<p>\u041e \u043d\u0435\u0442! \u041a\u0430\u043a \u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u0432\u0438\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b? <br \/>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u0442\u0430\u043a \u0441\u043b\u043e\u0436\u043d\u043e. \u0422\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u043e <strong>\u0440\u0435\u0432\u0435\u0440\u0441-\u0438\u043d\u0436\u0438\u043d\u0438\u0440\u0438\u043d\u0433<\/strong>.<\/p>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0444\u043b\u0430\u0433\u043e\u0432 \u0441\u0431\u043e\u0440\u043a\u0438, \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u044f\u0437\u044b\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0435 \u043d\u0430 Go \u0431\u0435\u0437 stripping \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 (Ghidra\/IDA) \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u044b\u0434\u0430\u0451\u0442 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u0435\u0439. <\/p>\n<blockquote>\n<p>\u0412 production-\u0441\u0431\u043e\u0440\u043a\u0430\u0445 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f: \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0431\u0430\u0440\u044c\u0435\u0440 \u0432\u0445\u043e\u0434\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0438\u0436\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0440\u0435\u0432\u0435\u0440\u0441\u0435 kernel modules.<\/p>\n<\/blockquote>\n<h3>\u0423 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0435\u0441\u0442\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a<\/h3>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0447\u0443\u0436\u043e\u0439 eBPF \u043c\u0430\u043f\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0435\u0435 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<p>\u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439<\/p>\n<pre><code class=\"bash\">sudo bpftool map pin id 179 \/sys\/fs\/bpf\/my_shared_map<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f id, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435. <\/p>\n<p>\u041c\u0435\u0441\u0442\u043e \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u043f\u044b \u043d\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e, \u043f\u0440\u043e\u0441\u0442\u043e <em>\u043d\u0430\u0434\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0443\u0442\u044c<\/em>, \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0435 \u043e\u043d \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0434\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430. \u0417\u0430\u043c\u0435\u0442\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <code>cpuUsage.sh<\/code><\/p>\n<p>\u041d\u0430\u0448 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u043c\u0438\u0440\u043e\u043b\u044e\u0431\u0438\u0432\u044b\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <strong>\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0435\u0433\u043e \u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e<\/strong> \u0441\u043f\u0430\u043c\u0430 \u043e\u0442 <code>cpuUsage.sh<\/code><\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430. \u0422\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e Go \u0447\u0430\u0441\u0442\u044c, eBPF \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d.<\/p>\n<pre><code class=\"go\">package mainimport (\"bytes\"\"log\"\"time\"\"github.com\/cilium\/ebpf\")\/\/ \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u0437 Ghidra \u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0439type StartPSEvent struct {Pid      uint32Cmd      [16]byteFilename [256]byte}func GetStrFromBytes(b []byte) string {if idx := bytes.IndexByte(b, 0); idx != -1 {return string(b[:idx])}return string(b)}func main() {    mapPath := \"\/sys\/fs\/bpf\/my_shared_map\"m, err := ebpf.LoadPinnedMap(mapPath, nil)if err != nil {log.Fatalf(\"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043a\u0430\u0440\u0442\u0443: %v\", err)}defer m.Close()log.Println(\"\u0423\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c \u043a \u043c\u0430\u043f\u0435\u044e \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0447\u0442\u0435\u043d\u0438\u0435...\")for {var (key     uint32nextKey uint32)var keysToProcess []uint32err := m.NextKey(nil, &amp;nextKey)for err == nil {key = nextKeykeysToProcess = append(keysToProcess, key)err = m.NextKey(key, &amp;nextKey)}if len(keysToProcess) == 0 {time.Sleep(10 * time.Millisecond)continue}\/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438, \u0447\u0438\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044bvar value StartPSEventfor _, k := range keysToProcess {if lookupErr := m.Lookup(k, &amp;value); lookupErr == nil {filename := GetStrFromBytes(value.Filename[:])cmd := GetStrFromBytes(value.Cmd[:])                              \/\/ \u0424\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043f\u043e \u0438\u043c\u0435\u043d\u0438                if cmd != \"cpuUsage.sh\" {continue}              log.Printf(\"ID \u043a\u043b\u044e\u0447\u0430: %d | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: %d, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: %s, cmd: %s\", k, value.Pid, filename, cmd)                \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u043c\u0430\u043f\u044b \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c cpuUsage.shif delErr := m.Delete(k); delErr != nil {log.Printf(\"\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435: \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043b\u044e\u0447 %d (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d): %v\", k, delErr)}}}\/\/ \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0430\u0443\u0437\u0430 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0430\u0447\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u0442\u044c \u044f\u0434\u0440\u0443 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0430\u043f\u0443time.Sleep(5 * time.Millisecond)}}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0438\u0445 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<h4>\u0412\u044b\u0432\u043e\u0434 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430<\/h4>\n<pre><code>2026\/05\/30 17:58:07 \u0423\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c \u043a \u043c\u0430\u043f\u0435. \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0447\u0442\u0435\u043d\u0438\u0435...2026\/05\/30 17:58:07 ID \u043a\u043b\u044e\u0447\u0430: 258667 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258667, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:07 ID \u043a\u043b\u044e\u0447\u0430: 258666 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258666, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/sed, cmd: cpuUsage.sh2026\/05\/30 17:58:08 ID \u043a\u043b\u044e\u0447\u0430: 258675 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258675, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/sed, cmd: cpuUsage.sh2026\/05\/30 17:58:08 ID \u043a\u043b\u044e\u0447\u0430: 258676 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258676, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:08 ID \u043a\u043b\u044e\u0447\u0430: 258677 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258677, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:08 ID \u043a\u043b\u044e\u0447\u0430: 258678 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258678, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:08 ID \u043a\u043b\u044e\u0447\u0430: 258679 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258679, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:08 ID \u043a\u043b\u044e\u0447\u0430: 258680 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258680, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/sleep, cmd: cpuUsage.sh2026\/05\/30 17:58:09 ID \u043a\u043b\u044e\u0447\u0430: 258681 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258681, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/sed, cmd: cpuUsage.sh2026\/05\/30 17:58:09 ID \u043a\u043b\u044e\u0447\u0430: 258682 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258682, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:09 ID \u043a\u043b\u044e\u0447\u0430: 258684 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258684, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:09 ID \u043a\u043b\u044e\u0447\u0430: 258686 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258686, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:09 ID \u043a\u043b\u044e\u0447\u0430: 258688 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258688, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/cat, cmd: cpuUsage.sh2026\/05\/30 17:58:09 ID \u043a\u043b\u044e\u0447\u0430: 258696 | PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: 258696, \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430: \/usr\/bin\/sed, cmd: cpuUsage.sh<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0443\u0434\u044f \u043f\u043e \u043b\u043e\u0433\u0430\u043c, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0431\u044b\u043b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u043c\u0430\u043f\u0435 <code>2026\/05\/30 17:58:07<\/code>. <\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u0447\u0442\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043d <strong>\u0431\u044b\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e<\/strong> \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>cpuUsage.sh<\/code><\/p>\n<h4>\u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 execve<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043c\u0435\u043d\u044f\u043b\u0441\u044f \u0432\u044b\u0432\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430:<\/p>\n<pre><code class=\"bash\">2026\/05\/30 17:58:05 Execve: PID=258632, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:05 Execve: PID=258627, Process=code, File=\/bin\/sh2026\/05\/30 17:58:05 Execve: PID=258629, Process=cpuUsage.sh, File=\/usr\/bin\/sed2026\/05\/30 17:58:05 Execve: PID=258630, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:05 Execve: PID=258633, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:05 Execve: PID=258634, Process=cpuUsage.sh, File=\/usr\/bin\/sleep2026\/05\/30 17:58:05 Execve: PID=258631, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:05 Execve: PID=258628, Process=sh, File=\/snap\/code\/195\/usr\/share\/code\/resources\/app\/out\/vs\/base\/node\/cpuUsage.sh2026\/05\/30 17:58:06 Execve: PID=258638, Process=cpuUsage.sh, File=\/usr\/bin\/sed2026\/05\/30 17:58:06 Execve: PID=258639, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:06 Execve: PID=258643, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:06 Execve: PID=258645, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:06 Execve: PID=258641, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:06 Execve: PID=258648, Process=code, File=\/bin\/sh2026\/05\/30 17:58:06 Execve: PID=258649, Process=sh, File=\/usr\/bin\/which2026\/05\/30 17:58:06 Execve: PID=258651, Process=sh, File=\/usr\/bin\/ps2026\/05\/30 17:58:06 Execve: PID=258650, Process=code, File=\/bin\/sh2026\/05\/30 17:58:06 Execve: PID=258655, Process=cpuUsage.sh, File=\/usr\/bin\/sed2026\/05\/30 17:58:06 Execve: PID=258654, Process=sh, File=\/snap\/code\/195\/usr\/share\/code\/resources\/app\/out\/vs\/base\/node\/cpuUsage.sh2026\/05\/30 17:58:06 Execve: PID=258653, Process=code, File=\/bin\/sh2026\/05\/30 17:58:06 Execve: PID=258656, Process=cpuUsage.sh, File=\/usr\/bin\/cat2026\/05\/30 17:58:06 Execve: PID=258657, Process=cpuUsage.sh, File=\/usr\/bin\/sleep2026\/05\/30 17:58:07 Execve: PID=258659, Process=bash, File=\/usr\/bin\/sudo2026\/05\/30 17:58:07 Execve: PID=258661, Process=sudo, File=.\/block2026\/05\/30 17:58:08 Execve: PID=258669, Process=code, File=\/bin\/sh2026\/05\/30 17:58:08 Execve: PID=258670, Process=sh, File=\/usr\/bin\/which2026\/05\/30 17:58:08 Execve: PID=258672, Process=sh, File=\/usr\/bin\/ps2026\/05\/30 17:58:08 Execve: PID=258671, Process=code, File=\/bin\/sh2026\/05\/30 17:58:08 Execve: PID=258674, Process=sh, File=\/snap\/code\/195\/usr\/share\/code\/resources\/app\/out\/vs\/base\/node\/cpuUsage.sh2026\/05\/30 17:58:08 Execve: PID=258673, Process=code, File=\/bin\/sh2026\/05\/30 17:58:09 Execve: PID=258690, Process=code, File=\/bin\/sh2026\/05\/30 17:58:09 Execve: PID=258691, Process=sh, File=\/usr\/bin\/which2026\/05\/30 17:58:09 Execve: PID=258693, Process=sh, File=\/usr\/bin\/ps2026\/05\/30 17:58:09 Execve: PID=258692, Process=code, File=\/bin\/sh<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>2026\/05\/30 17:58:05 - 2026\/05\/30 17:58:06<\/code> &#8212; \u043f\u0435\u0440\u0432\u0430\u044f \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 <code>execve<\/code> \u0434\u043b\u044f <code>cpuUsage.sh<\/code><\/p>\n<p><code>2026\/05\/30 17:58:07<\/code>  &#8212; \u0441 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e <code>cpuUsage.sh<\/code> \u0435\u0441\u0442\u044c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u0445 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442, \u043d\u043e \u0432\u0438\u0434\u0438\u043c \u043c\u044b \u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0435. <\/p>\n<p><strong>\u041c\u043e\u043d\u0438\u0442\u043e\u0440 \u044d\u0442\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442.<\/strong><\/p>\n<p>\u0423\u0440\u0430, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0440\u0435\u0432\u0435\u0440\u0441 \u0438\u043d\u0436\u0435\u043d\u0438\u0440\u0438\u043d\u0433, Go \u0438 \u043f\u0430\u0440\u0443 \u043a\u043e\u043c\u0430\u043d\u0434 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430.<\/p>\n<blockquote>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c <strong>\u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0432 1 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/strong> \u043f\u0435\u0440\u0435\u0434 \u0447\u0442\u0435\u043d\u0438\u0435\u043c \u0438\u0437 \u043c\u0430\u043f\u044b. <\/p>\n<\/blockquote>\n<pre><code class=\"go\">\/\/ \u043f\u0443\u0441\u0442\u044c \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430time.Sleep(1 * time.Millisecond)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<blockquote>\n<p>\u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043b\u043e\u0433\u0430\u0445 \u0433\u043e\u043d\u043a\u0443 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430 \u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430. <\/p>\n<p>\u042d\u0442\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u2014 <strong>\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 race condition<\/strong> \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041a\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0441\u043f\u0435\u043b \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u043c\u0430\u043f\u044b, \u0442\u043e\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443\u0431\u0440\u0430\u0442\u044c, \u0442\u043e \u0438 \u0442\u043e\u0442 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043d\u043e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440 \u0438\u043d\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0437\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437 \u043e\u0431\u0449\u0435\u0439 \u043c\u0430\u043f\u044b, \u0447\u0442\u043e \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0432 \u043b\u043e\u0433\u0430\u0445, \u043a\u0430\u043a \u043e\u0448\u0438\u0431\u043a\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<\/blockquote>\n<p><em>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u0440\u0430\u043d\u0430 \u043d\u0430: Linux 6.11.0-26-generic, Go <\/em>go1.23.4 linux\/amd64<em>, libbpf\/cilium-ebpf \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/em><\/p>\n<p><em>\u041d\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 (&lt;5.8) \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f.<\/em><\/p>\n<h3>\u0427\u0442\u043e \u043c\u044b \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c?<\/h3>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u043f\u0440\u044f\u043c\u043e\u0435 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 eBPF-\u043c\u0430\u043f\u0430\u043c\u0438. \u0412 \u043c\u043e\u0434\u0435\u043b\u0438 Linux, \u0433\u0434\u0435 <code>root<\/code> \u0435\u0434\u0438\u043d, \u043b\u044e\u0431\u043e\u0439 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u044f\u0434\u0440\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043a\u0430\u043d\u0430\u043b\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/p>\n<h3>\u041a\u0430\u043a \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c\u044e map? <\/h3>\n<p>\u0421\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0432 production-\u0441\u0440\u0435\u0434\u0430\u0445 \u043d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u043b\u043e\u0445\u043e, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435<\/p>\n<blockquote>\n<p><em>\u0422\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0eBPF. <\/em>\u0423\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u0438\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u044d\u0442\u043e\u0439 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u00a0\u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445 \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<\/blockquote>\n<p>\u041d\u043e <strong>\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0435\u0441\u0442\u044c<\/strong> \u0438 \u043e\u043d\u0430 \u044f\u0432\u043d\u043e \u043d\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0430 \u0434\u043e \u043a\u043e\u043d\u0446\u0430.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441 \u0437\u0430\u0449\u0438\u0442\u044b \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0439 \u0438, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e, \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u0430\u043c. \u0413\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e\u00a0\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u044f \u043f\u043e\u043a\u0430 \u043d\u0435\u00a0\u043d\u0430\u0448\u043b\u0430 (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c, \u043f\u0440\u043e\u0448\u0443 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u0432\u00a0\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u00a0\u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u0432\u0438\u0434\u0435\u043d\u0438\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<h4>\u041d\u0443\u043b\u0435\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h4>\n<p>\u0412\u00a0\u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u0430\u043f\u044b \u0442\u0438\u043f\u0430 hash, \u0443\u00a0\u043d\u0435\u0435 \u0441\u0432\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u00a0array, ring buffer \u0438 \u0442\u0434, \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f, \u0433\u0434\u0435\u2011\u0442\u043e \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u0433\u0434\u0435\u2011\u0442\u043e \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442 \u0434\u0443\u0431\u043b\u044f\u0436\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. <\/p>\n<p><strong>\u041e\u0442\u00a0\u0442\u0438\u043f\u0430 \u043c\u0430\u043f\u044b \u043c\u043d\u043e\u0433\u043e\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442,<\/strong> \u0438 \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u00a0\u043d\u0443\u0436\u0434\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412\u043e\u0442 <a href=\"https:\/\/docs.ebpf.io\/linux\/map-type\/\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a> \u043f\u043e\u00a0\u043c\u0430\u043f\u0430\u043c.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432\u00a0\u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435\u00a0\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u00a0\u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0412\u00a0eBPF \u0435<strong>\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0437\u0430\u0449\u0438\u0442\u044b \u0434\u043b\u044f\u00a0map<\/strong> \u2011, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u043b\u0430\u0433 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 <code>BPF_F_RDONLY_PROG<\/code>. \u041d\u043e\u00a0\u043e\u043d \u043c\u043e\u0436\u0435\u0442\u00a0\u043b\u0438\u0448\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0443. \u0414\u043b\u044f\u00a0\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0438 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c sysctl \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430\u00a0\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 eBPF \u043a\u043e\u0434\u0430 \u0432\u00a0\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442\u00a0\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439. \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u00a0\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"bash\"> sysctl kernel.unprivileged_bpf_disabled<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 = 1 \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 = 0 \u2014 (\u0434\u0435\u0444\u043e\u043b\u0442 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430\u0445) \u2014 \u043d\u0435 root \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 = 2 \u2014 \u0442\u043e\u0436\u0435, \u0447\u0442\u043e \u0438 1, \u043d\u043e <strong>\u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/strong> \u043d\u0435-\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u044f\u0432\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (<code>BPF_F_RDONLY_PROG<\/code>) \u0438 \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442 <code>pinning<\/code>, \u043e\u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043b\u044e\u0431\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 root \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<h4>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/h4>\n<p>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c eBPF \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445. \u041d\u043e \u044d\u0442\u043e \u043f\u043b\u043e\u0445\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. <\/p>\n<p>\u0425\u043e\u0442\u044c eBPF \u0438 BPF \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044f\u0432\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, <strong>\u0435\u0441\u0442\u044c \u0438 \u044f\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/strong>. \u041e\u043d\u0438 \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438, \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e API, BTF, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u044f\u0434\u0440\u0430 \u043d\u0430\u0442\u0438\u0432\u043d\u043e. \u0410 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432 \u043f\u043e\u043a\u0430 \u043d\u0435\u0442.<\/p>\n<h4>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0441\u044f. \u0414\u0430\u043b\u044c\u0448\u0435 \u043b\u0438\u0448\u044c <em>\u043c\u043e\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/em>.  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e <strong>\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c kernel modules\/LSM \u0441 eBPF<\/strong> \u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u043c\u0430\u043f\u044b. <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u044b\u043c. \u0412 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043f\u043e\u0434 \u044f\u0434\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0434\u0430\u0442\u044c\u0441\u044f (\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e) \u043c\u0430\u043b\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0437\u0430 \u0437\u0430\u0449\u0438\u0442\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043c\u0430\u043f\u0435.<\/p>\n<h3>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <\/h3>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 eBPF \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441, \u043a\u0430\u043a \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0442\u0430\u043a \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439. <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0435\u0439\u0447\u0430\u0441 \u0435\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432 production-\u0441\u0440\u0435\u0434\u0430\u0445, \u0447\u0442\u043e eBPF \u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c SRE\/DevOps\/\u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u0442\u0434, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0433\u043e <strong>\u0436\u0434\u0443\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/strong>. <\/p>\n<p>\u0410 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0438 \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p><em>\u0421\u0442\u0430\u0442\u044c\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043b\u0438\u0447\u043d\u043e\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438. \u041a\u0440\u0438\u0442\u0438\u043a\u0430 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f<\/em><\/p>\n<h3>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.ebpf.io\/linux\/\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043d\u0442\u0440\u043e \u0432 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e <\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/ebpf.io\/what-is-ebpf\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 eBPF<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.ebpf.io\/\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f eBPF<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.ebpf.io\/linux\/map-type\/\" rel=\"noopener noreferrer nofollow\">\u0422\u0438\u043f\u044b eBPF maps<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/ebpf-go.dev\/guides\/getting-started\/\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u0442\u044c Go \u0438 eBPF<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pkg.go.dev\/github.com\/cilium\/ebpf#section-documentation\" rel=\"noopener noreferrer nofollow\">\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 cilium \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Go \u0438 eBPF<\/a> <\/p>\n<\/li>\n<\/ol>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1041618\/\">https:\/\/habr.com\/ru\/articles\/1041618\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440 1\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u043e\u0441\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440. \u041c\u043e\u044f \u0446\u0435\u043b\u044c &#8212; \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b eBPF \u0432 Linux. \u0412\u0435\u0434\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439.\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440 2\u0414\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430\u0434\u043e \u0443\u0436\u0435 \u0431\u044b\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u043c \u0441 Linux \u0438 eBPF. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0442\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u0443\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u044d\u0442\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f. \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442?\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0441\u0435 \u0447\u0430\u0449\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0418\u0411 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 Linux \u0441\u0438\u0441\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f\u0442 \u0441 kernel modules \u043d\u0430 eBPF. \u041e\u043d\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 \u0434\u043b\u044f Linux &#8212; \u0437\u0430\u043d\u044f\u0442\u0438\u0435 \u043a\u0440\u0430\u0439\u043d\u0435 \u0442\u044f\u0436\u0435\u043b\u043e\u0435. \u041a\u043e\u043c\u043c\u044c\u044e\u043d\u0438\u0442\u0438 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 API \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432 \u043d\u0430 \u0440\u044b\u043d\u043a\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u0432\u0441\u0435 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0442\u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u0432\u043e\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0410 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u0430\u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430, \u043d\u043e \u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0434\u0440\u0430. Linux \u0434\u0430\u0432\u043d\u043e \u0441\u0442\u0430\u043b \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u0421\u0435\u0433\u043c\u0435\u043d\u0442 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u044f\u0434\u0440\u0435 Linux. \u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0442\u0435\u0442, \u0430 \u0441 \u043d\u0435\u0439 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0418\u0422 \u0438 \u0418\u0411 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445. \u0418 \u0442\u0443\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0433\u043b\u0443 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043a\u0440\u0438\u0447\u0430\u0442\u044c \u043e eBPF, \u043a\u0430\u043a \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0435, \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0442\u0434.\u041c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433 \u043a\u0440\u0438\u0447\u0438\u0442eBPF &#8212; \u044d\u0442\u043e: \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u044f\u0434\u0440\u0430 \u0438\u0437-\u0437\u0430 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438;\u043b\u0435\u0433\u043a\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e kernel modules;\u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 C++, Go, Python, Rust \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f;\u043a\u0440\u043e\u0441\u0441\u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0441\u0447\u0435\u0442 CO-RE (\u043a\u0441\u0442\u0430\u0442\u0438, \u0441 \u043d\u044e\u0430\u043d\u0441\u0430\u043c\u0438: \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 BTF-\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u044f\u0434\u0440\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438 &lt;5.2, \u043e\u0431 \u044d\u0442\u043e\u043c \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432\u044b\u0439\u0434\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f).\u0410 \u044f \u0434\u043e\u043f\u043e\u043b\u043d\u044eeBPF &#8212; \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435:\u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u044f\u0434\u0440\u0430 \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u2014 \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 eBPF \u0438 Linux;\u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438;\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438.\u0417\u0432\u0443\u0447\u0438\u0442 \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u043e\u0447\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430?\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c 2 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b: \u043c\u043e\u043d\u0438\u0442\u043e\u0440 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 (eBPF + Go) \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a (\u0442\u043e\u043b\u044c\u043a\u043e Go).\u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043d\u0430 \u0421++\/Python\/Rust. \u0412\u043a\u0443\u0441\u043e\u0432\u0449\u0438\u043d\u0430. Go \u0432\u044b\u0431\u0440\u0430\u043d \u0438\u0437-\u0437\u0430 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u0442\u044c Go \u0438 eBPF \u0438\u043d\u0430\u0447\u0435 \u0441\u0442\u0430\u0442\u044c\u044f \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0435\u0442\u0441\u044f. \u041d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0442\u0443\u0442 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: eBPF-\u043c\u043e\u0434\u0443\u043b\u044c, \u043f\u043e\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 execve;\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 Go, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 eBPF-\u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u044f\u0434\u0440\u043e \u0438 \u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.eBPF-\u043c\u043e\u0434\u0443\u043b\u044c\u041d\u0430\u043f\u0438\u0448\u0435\u043c eBPF-\u043c\u043e\u0434\u0443\u043b\u044c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043a tracepoint \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 execve.\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e \/\/go:build ignore  \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 execve_monitoring.c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0431\u043e\u0440\u0449\u0438\u043a Go \u043d\u0435 \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c C \u043a\u043e\u0434.\/\/go:build ignore#include &lt;linux\/bpf.h&gt;#include &lt;bpf\/bpf_helpers.h&gt;#define MAX_PATH  256#define TASK_COMM_LEN 16\/\/ \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043estruct start_ps_event {    __u32 pid;    char cmd[TASK_COMM_LEN];    char filename[MAX_PATH];} __attribute__((packed));\/\/ \u041d\u0430\u0448\u0430 \u043c\u0430\u043f\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044cstruct {    __uint(type, BPF_MAP_TYPE_HASH);    __uint(max_entries, 1024);    __type(key, __u32);    __type(value, struct start_ps_event); } ps_info SEC(&#171;.maps&#187;);\/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445\/\/ \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435\u043c \u043e \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430struct syscalls_enter_execve_args {    unsigned short common_type;    unsigned char common_flags;    unsigned char common_preempt_count;    int common_pid;    int __syscall_nr;    const char *filename;    const char *const *argv;    const char *const *envp;};\/\/ \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430SEC(&#171;tracepoint\/syscalls\/sys_enter_execve&#187;) int GetStartedPid(struct syscalls_enter_execve_args* ctx) {    struct start_ps_event event = {};        \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c PID \u0438 \u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b    event.pid = bpf_get_current_pid_tgid() &gt;&gt; 32;    bpf_get_current_comm(event.cmd, sizeof(event.cmd));        \/\/ \u0427\u0438\u0442\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443    bpf_probe_read_user_str(event.filename, sizeof(event.filename), ctx-&gt;filename);        \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c PID \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043c\u0430\u043f\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430    __u32 key = event.pid;    bpf_printk(&#171;BPF PRINT: process %s started\\n&#187;, event.cmd);        \/\/ \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432 \u043c\u0430\u043f\u0443    long res = bpf_map_update_elem(&amp;ps_info, &amp;key, &amp;event, BPF_ANY);    return 0;}char _license[] SEC(&#171;license&#187;) = &#171;GPL&#187;;Go-\u0447\u0430\u0441\u0442\u044c\u041d\u0430\u0448 main.go\u0434\u0435\u043b\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0443\u043c: \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b execve_monitoring.c \u0432 \u044f\u0434\u0440\u043e. \u041e\u0436\u0438\u0434\u0430\u0435\u0442, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043c\u0430\u043f\u044b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u0445 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b. package mainimport (&#171;bytes&#187;&#187;fmt&#187;&#187;log&#187;&#187;os&#187;&#187;os\/signal&#187;&#187;syscall&#187;&#187;time&#187;&#187;github.com\/cilium\/ebpf\/link&#187;&#187;github.com\/cilium\/ebpf\/rlimit&#187;)\/\/ \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043d\u0430\u0448\u0435\u0439 start_ps_event \u0438\u0437 execve_monitoring.c\/\/ \u0414\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u0438 \u0442\u0438\u043f\u044b, \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044btype StartPSEvent struct {Pid      uint32Cmd      [16]byteFilename [256]byte}func GetStrFromBytes(b []byte) string {if idx := bytes.IndexByte(b, 0); idx != -1 {return string(b[:idx])}return string(b)}func main() {if err := rlimit.RemoveMemlock(); err != nil {log.Fatalf(&#171;Failed to remove memlock: %v&#187;, err)}\/\/ \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c eBPF \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u044f\u0434\u0440\u043eobjs := ps_start_hashObjects{}if err := loadPs_start_hashObjects(&amp;objs, nil); err != nil {log.Fatalf(&#171;Failed to load eBPF objects: %v&#187;, err)}defer objs.Close()\/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a tracepointtp, err := link.Tracepoint(&#171;syscalls&#187;, &#171;sys_enter_execve&#187;, objs.GetStartedPid, nil)if err != nil {log.Fatalf(&#171;Failed to attach tracepoint: %v&#187;, err)}defer tp.Close()fmt.Println(&#171;eBPF program running and polling Hash Map&#8230;&#187;)sigChan := make(chan os.Signal, 1)signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)stopChan := make(chan struct{})\/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043c\u0430\u043f\u044bgo func() {for {select {case &lt;-stopChan:returndefault:var (key     uint32nextKey uint32)var keysToProcess []uint32\/\/ \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043a\u043b\u044e\u0447\u0438 \u0438\u0437 \u043c\u0430\u043f\u044berr := objs.PsInfo.NextKey(nil, &amp;nextKey)for err == nil {key = nextKeykeysToProcess = append(keysToProcess, key)err = objs.PsInfo.NextKey(key, &amp;nextKey)}\/\/ \u0415\u0441\u043b\u0438 \u043a\u0430\u0440\u0442\u0430 \u043f\u0443\u0441\u0442\u0430, \u0436\u0434\u0435\u043c 10\u043c\u0441 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043d\u043e\u0432\u0430if len(keysToProcess) == 0 {time.Sleep(10 * time.Millisecond)continue}                \/\/ \u043f\u0443\u0441\u0442\u044c \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430time.Sleep(1 * time.Millisecond)\/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438, \u0447\u0438\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0443\u0434\u0430\u043b\u044f\u0435\u043cvar e StartPSEventfor _, k := range keysToProcess {                  if lookupErr := objs.PsInfo.Lookup(k, &amp;e); lookupErr == nil {log.Printf(&#171;Execve: PID=%d, Process=%s, File=%s\\n&#187;,e.Pid,GetStrFromBytes(e.Cmd[:]),GetStrFromBytes(e.Filename[:]),)\/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u044f\u0434\u0440\u0430if delErr := objs.PsInfo.Delete(k); delErr != nil {log.Printf(&#171;Warning: failed to delete key %d: %v&#187;, k, delErr)}}}\/\/ \u041a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u043f\u0430\u0443\u0437\u0430 \u043c\u0435\u0436\u0434\u0443 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438time.Sleep(5 * time.Millisecond)}}}()&lt;-sigChanclose(stopChan)fmt.Println(&#171;Shutting down&#8230;&#187;)}\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 execve \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, pid \u0438 \u0438\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.just_me@just_me:~\/go_ebpf_ps_start$ go build &amp;&amp; sudo .\/hash[sudo] password for just_me: eBPF program running and polling Hash Map&#8230;Execve: PID=256619, Process=code, File=\/bin\/shExecve: PID=256621, Process=code, File=\/bin\/shExecve: PID=256622, Process=sh, File=\/usr\/bin\/psExecve: PID=256620, Process=sh, File=\/usr\/bin\/whichExecve: PID=256627, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256623, Process=code, File=\/bin\/shExecve: PID=256624, Process=sh, File=\/snap\/code\/195\/usr\/share\/code\/resources\/app\/out\/vs\/base\/node\/cpuUsage.shExecve: PID=256629, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256625, Process=cpuUsage.sh, File=\/usr\/bin\/sedExecve: PID=256626, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256628, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256630, Process=cpuUsage.sh, File=\/usr\/bin\/sleepExecve: PID=256632, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256631, Process=cpuUsage.sh, File=\/usr\/bin\/sedExecve: PID=256638, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256634, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256636, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256641, Process=code, File=\/bin\/shExecve: PID=256642, Process=sh, File=\/usr\/bin\/whichExecve: PID=256643, Process=code, File=\/bin\/shExecve: PID=256644, Process=sh, File=\/usr\/bin\/psExecve: PID=256649, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256646, Process=sh, File=\/snap\/code\/195\/usr\/share\/code\/resources\/app\/out\/vs\/base\/node\/cpuUsage.shExecve: PID=256645, Process=code, File=\/bin\/shExecve: PID=256650, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256652, Process=cpuUsage.sh, File=\/usr\/bin\/sleepExecve: PID=256647, Process=cpuUsage.sh, File=\/usr\/bin\/sedExecve: PID=256651, Process=cpuUsage.sh, File=\/usr\/bin\/catExecve: PID=256648, Process=cpuUsage.sh, File=\/usr\/bin\/cat&#8230;\u0421\u0443\u043f\u0435\u0440, \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0417\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443.\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 eBPF map \u0438\u0437 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f?\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 eBPF \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439sudo apt updatesudo apt install linux-tools-common linux-tools-generic linux-tools-$(uname -r)sudo apt install bpftool\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435\u0414\u043b\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430 \u043e\u043d \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u0435\u043d, \u043d\u043e \u043c\u043e\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0441 \u043d\u0443\u043b\u044f\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443sudo bpftool map list\u0412\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 eBPF-map \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043d\u0438\u0445.just_me@just_me:\/~$ sudo bpftool map list1: hash  flags 0x0key 9B  value 1B  max_entries 500  memlock 46432B2: hash  flags 0x0key 9B  value 1B  max_entries 500  memlock 46432B4: hash  flags 0x0key 9B  value 1B  max_entries 500  memlock 46432B5: hash  name s_libreoffice_h  flags 0x0key 9B  value 1B  max_entries 1000  memlock 90624B133: hash  name s_firmware_upda  flags 0x0key 9B  value&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-481736","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=481736"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481736\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}